UNPKG

@navinc/base-react-components

Version:
96 lines (95 loc) 3.82 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ButtonAction = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const styled_components_1 = __importStar(require("styled-components")); const button_1 = require("./button"); const icon_1 = __importDefault(require("./icon")); const getSize = (size) => { const carrotSizes = { small: { width: '23px', height: '23px', }, medium: { width: '26px', height: '26px', }, large: { width: '28px', height: '28px', }, extraLarge: { width: '32px', height: '32px', }, }; return size ? carrotSizes[size] : carrotSizes.medium; }; const StyledIcon = (0, styled_components_1.default)(icon_1.default).withConfig({ displayName: "brc-sc-StyledIcon", componentId: "brc-sc-1gxm255" }) ` overflow: hidden; transition: all 0.3s ease-out; transform: ${({ position }) => { const rotations = { collapsed: 'rotate(0.75turn) !important', navigate: 'rotate(0.50turn) !important', expanded: '', }; return rotations[position]; }}; padding: 5px; cursor: pointer; & { ${({ size }) => getSize(size)} } `; const ButtonActionWrapper = styled_components_1.default.div.withConfig({ displayName: "brc-sc-ButtonActionWrapper", componentId: "brc-sc-1pwnf0v" }) ` display: flex; align-items: center; `; const ButtonAction = (props) => { const theme = (0, react_1.useContext)(styled_components_1.ThemeContext); const { position } = props, buttonProps = __rest(props, ["position"]); const { children } = props, iconProps = __rest(props, ["children"]); return ((0, jsx_runtime_1.jsxs)(ButtonActionWrapper, { children: [(0, jsx_runtime_1.jsx)(button_1.Button, Object.assign({}, buttonProps, { variation: "buttonAction" })), (0, jsx_runtime_1.jsx)(StyledIcon, Object.assign({}, iconProps, { color: theme.navNeutral400, name: "actions/carrot-up" }))] })); }; exports.ButtonAction = ButtonAction; //# sourceMappingURL=button-action.js.map