@workday/canvas-kit-labs-react
Version:
Canvas Kit Labs is an incubator for new and experimental components. Since we have a rather rigorous process for getting components in at a production level, it can be valuable to make them available earlier while we continuously iterate on the API/functi
36 lines (35 loc) • 2.13 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpandableIcon = void 0;
const react_1 = __importDefault(require("react"));
const common_1 = require("@workday/canvas-kit-react/common");
const canvas_system_icons_web_1 = require("@workday/canvas-system-icons-web");
const useExpandableIcon_1 = require("./hooks/useExpandableIcon");
const icon_1 = require("@workday/canvas-kit-react/icon");
const tokens_1 = require("@workday/canvas-kit-react/tokens");
const useExpandableModel_1 = require("./hooks/useExpandableModel");
const StyledEndIcon = (0, common_1.styled)(icon_1.SystemIcon, {
shouldForwardProp: (0, common_1.filterOutProps)(['visible']),
})({
marginLeft: 'auto',
}, ({ visible }) => ({
transform: !visible ? 'rotate(-180deg)' : undefined,
padding: !visible
? `${tokens_1.space.xxxs} ${tokens_1.space.xs} ${tokens_1.space.xxxs} ${tokens_1.space.xxxs}`
: `${tokens_1.space.xxxs} ${tokens_1.space.xxxs} ${tokens_1.space.xxxs} ${tokens_1.space.xs}`,
}));
const StyledStartIcon = (0, common_1.styled)(icon_1.SystemIcon, {
shouldForwardProp: (0, common_1.filterOutProps)(['visible']),
})({
margin: `0 ${tokens_1.space.xxs} 0 0`,
padding: tokens_1.space.xxxs,
}, ({ visible }) => ({
transform: !visible ? 'rotate(-90deg)' : undefined,
}));
exports.ExpandableIcon = (0, common_1.createSubcomponent)('span')({
modelHook: useExpandableModel_1.useExpandableModel,
elemPropsHook: useExpandableIcon_1.useExpandableIcon,
})(({ icon, visible, iconPosition = 'start', ...elementProps }, Element) => iconPosition === 'end' ? (react_1.default.createElement(StyledEndIcon, { as: Element, fill: tokens_1.colors.licorice200, icon: icon || canvas_system_icons_web_1.chevronUpIcon, visible: visible, ...elementProps })) : (react_1.default.createElement(StyledStartIcon, { as: Element, fill: tokens_1.colors.licorice200, icon: icon || canvas_system_icons_web_1.chevronDownIcon, visible: visible, ...elementProps })));
;