UNPKG

@zohodesk/components

Version:

Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development

58 lines 1.95 kB
import { compileClassNames } from '@zohodesk/utils'; export default function cssJSLogic(_ref) { let { props, style } = _ref; let { customClass, needAppearance, isBold, rounded, size, children, palette, status, disabled, shouldStrikeThroughDisabled } = props; let { customButton = '', customStatus = '', customStatusSize = '' } = customClass; const strikeExcludedPalettes = ['plainprimary', 'plainsecondary', 'plainDanger', 'plainSuccess']; let paletteLower = palette.toLowerCase(); let statusLower = status.toLowerCase(); let canStrikeThrough = !strikeExcludedPalettes.includes(paletteLower); let buttonClass = compileClassNames({ [customButton]: !!customButton, [style.bold]: isBold, [style.default]: !needAppearance, [style[paletteLower]]: needAppearance, [style.rounded]: needAppearance && rounded, [style[size.toLowerCase()]]: needAppearance && !children, [style[`${size}Btn`]]: needAppearance && children, [style[`${size}Btn${paletteLower}`]]: needAppearance && children && rounded, [`${style[`${paletteLower}Strike`]} ${style.strike}`]: disabled && canStrikeThrough && shouldStrikeThroughDisabled, [style.loader]: !!needAppearance && statusLower !== 'none' }); let loaderParentClass = compileClassNames({ [customStatusSize]: !!customStatusSize, [style.loading]: statusLower === 'loading', [style[`${size}loading`]]: statusLower === 'loading', [style.successstate]: statusLower != 'loading' }); let loaderChildClass = compileClassNames({ [customStatus]: !!customStatus, [style.loadingelement]: statusLower === 'loading', [style[`${paletteLower}element`]]: statusLower === 'loading', [style.successelement]: statusLower != 'loading', [style[`${paletteLower}success`]]: statusLower != 'loading' }); return { buttonClass, loaderParentClass, loaderChildClass }; }