UNPKG

@navinc/base-react-components

Version:
51 lines 2.11 kB
import { jsx as _jsx } from "react/jsx-runtime"; import styled from 'styled-components'; import CarrotLeft from './icons/actions/carrot-left.js'; import PropTypes from 'prop-types'; import isRebrand from './is-rebrand.js'; const setColor = ({ isInvalid, disabled, theme }) => { if (isRebrand(theme)) { if (isInvalid) return theme.navStatusNegative; return disabled ? theme.navNeutral400 : theme.navPrimary; } if (isInvalid) return theme.error; return disabled ? theme.scuttleGray500 : theme.azure; }; const ChevronWrapper = styled.div.withConfig({ displayName: "brc-sc-ChevronWrapper", componentId: "brc-sc-yupxyd" }) ` pointer-events: none; `; const StyledChevron = styled(CarrotLeft).withConfig({ displayName: "brc-sc-StyledChevron", componentId: "brc-sc-15j0i7d" }) ` fill: ${({ isInvalid, disabled, theme }) => setColor({ isInvalid, disabled, theme })}; transform: ${({ $isOpen }) => `rotate(${$isOpen ? '0turn' : '-0.25turn'})}`}; transition: 'transform 0.2s ease-in-out', transitionDelay: '0.1s', willChange: 'transform', `; ChevronWrapper.displayName = 'ChevronWrapper'; /** * * @param {*} props You can not access props directly. | optional | {} * @property {string} className * @property {boolean} disabled * @property {boolean} isInvalid * @property {boolean} $isOpen * @returns React.ReactElement */ export const Chevron = ({ className, disabled, isInvalid, $isOpen }) => (_jsx(ChevronWrapper, Object.assign({ className: className }, { children: _jsx(StyledChevron, { "$isOpen": $isOpen, disabled: disabled, isInvalid: isInvalid }) }))); Chevron.propTypes = { className: PropTypes.string, disabled: PropTypes.bool, isInvalid: PropTypes.bool, /** Shares the isOpen state with styled-components, but does not pass down to the child as a prop */ $isOpen: PropTypes.bool, }; Chevron.defaultProps = { disabled: false, isInvalid: false, $isOpen: false, }; Chevron.displayName = 'Chevron'; export default styled(Chevron).withConfig({ componentId: "brc-sc-1dui8iq" }) ``; //# sourceMappingURL=chevron.js.map