@navinc/base-react-components
Version:
Nav's Pattern Library
66 lines (65 loc) • 2.34 kB
JavaScript
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;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext } from 'react';
import styled, { ThemeContext } from 'styled-components';
import { Button } from './button';
import { Icon } from './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 = styled(Icon).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.div.withConfig({ displayName: "brc-sc-ButtonActionWrapper", componentId: "brc-sc-1pwnf0v" }) `
display: flex;
align-items: center;
`;
export const ButtonAction = (props) => {
const theme = useContext(ThemeContext);
const { position } = props, buttonProps = __rest(props, ["position"]);
const { children } = props, iconProps = __rest(props, ["children"]);
return (_jsxs(ButtonActionWrapper, { children: [_jsx(Button, Object.assign({}, buttonProps, { variation: "buttonAction" })), _jsx(StyledIcon, Object.assign({}, iconProps, { color: theme.navNeutral400, name: "actions/carrot-up" }))] }));
};
//# sourceMappingURL=button-action.js.map