@wix/design-system
Version:
@wix/design-system
36 lines • 1.96 kB
JavaScript
import React from 'react';
import { CaretDown, CaretRight } from '@wix/wix-ui-icons-common/system';
import Button from '../../../Button';
import TextButton from '../../../TextButton';
import { buttonTypes, dataHooks, skins } from '../../constants';
import { useIcons } from '../../../WixDesignSystemIconThemeProvider';
import { st, classes } from './AccordionItemCaret.st.css.js';
const AccordionItemCaret = ({ showLabel, buttonType, skin, open, disabled, hover, collapseLabel, expandLabel, }) => {
const icons = useIcons('AccordionItemCaret', {
CaretDown,
CaretRight,
});
const skinProp = skin === skins.neutral ? 'dark' : 'standard';
const isLabelShown = showLabel === 'always' || hover;
const label = open ? collapseLabel : expandLabel;
if (buttonType === buttonTypes.node && isLabelShown && label) {
return React.createElement("div", { "data-hook": dataHooks.toggleButton }, label);
}
if (buttonType === buttonTypes.button &&
label &&
// For this buttonType, showLabel default is 'always' if undefined.
(showLabel === 'hover' ? hover : true)) {
return (React.createElement(Button, { skin: skinProp, size: "small", priority: open ? 'secondary' : 'primary', disabled: disabled, dataHook: dataHooks.toggleButton, children: label }));
}
if (buttonType === buttonTypes.textButton) {
const suffixIcon = open ? React.createElement(icons.CaretDown, null) : React.createElement(icons.CaretRight, null);
return (React.createElement(TextButton, { className: st(classes.textButton, {
withLabel: !!(isLabelShown && label),
isHovered: hover,
disabled,
}), skin: skinProp, suffixIcon: suffixIcon, disabled: disabled, dataHook: dataHooks.toggleButton, children: isLabelShown && label }));
}
return null;
};
export default AccordionItemCaret;
//# sourceMappingURL=AccordionItemCaret.js.map