UNPKG

backpack-ui

Version:
138 lines (106 loc) 3.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require("react"); var _react2 = _interopRequireDefault(_react); var _propTypes = require("prop-types"); var _propTypes2 = _interopRequireDefault(_propTypes); var _radium = require("radium"); var _radium2 = _interopRequireDefault(_radium); var _colors = require("../../styles/colors"); var _colors2 = _interopRequireDefault(_colors); var _timing = require("../../styles/timing"); var _timing2 = _interopRequireDefault(_timing); var _color = require("../../utils/color"); var _font = require("../../utils/font"); var _font2 = _interopRequireDefault(_font); var _icon = require("../icon"); var _icon2 = _interopRequireDefault(_icon); var _createQAHook = require("../../utils/createQAHook"); var _createQAHook2 = _interopRequireDefault(_createQAHook); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var baseFontSize = 14; var hoverStyles = { backgroundColor: "rgba(" + (0, _color.rgb)(_colors2.default.bgOverlay) + ", .9)" }; var styles = { container: { base: { backgroundColor: "rgba(" + (0, _color.rgb)(_colors2.default.bgOverlay) + ", .6)", border: 0, borderRadius: 4 / baseFontSize + "em", color: _colors2.default.bgPrimary, cursor: "pointer", display: "block", fontFamily: (0, _font2.default)("benton"), fontSize: baseFontSize + "px", lineHeight: 1, padding: 5 / baseFontSize + "em " + 4 / baseFontSize + "em " + 4 / baseFontSize + "em " + 7 / baseFontSize + "em", transition: "background-color " + _timing2.default.default, verticalAlign: "baseline", width: "auto", ":hover": hoverStyles, ":active": hoverStyles, ":focus": hoverStyles } }, label: { base: { fontSize: 10 / baseFontSize + "em", marginRight: 10 / baseFontSize + "em", verticalAlign: "middle" } } }; /** * ExpandButton component * * @usage * <ExpandButton /> */ function ExpandButton(_ref) { var label = _ref.label, onClick = _ref.onClick, qaHook = _ref.qaHook; return _react2.default.createElement( "button", { className: "ExpandButton", style: styles.container.base, "aria-label": "Expand", onClick: onClick, "data-testid": qaHook ? (0, _createQAHook2.default)(label, "ExpandButton", "btn") : null }, label && _react2.default.createElement( "small", { className: "ExpandButton-label", style: styles.label.base }, label ), _react2.default.createElement(_icon2.default.PopOut, null) ); } ExpandButton.propTypes = { /** * Text to be placed to the right of the icon */ label: _propTypes2.default.string, /** * Perform an action when the button is clicked */ onClick: _propTypes2.default.func, /** * QA Hook */ qaHook: _propTypes2.default.bool }; ExpandButton.defaultProps = { label: "", onClick: null, qaHook: false }; ExpandButton.styles = styles; exports.default = (0, _radium2.default)(ExpandButton);