import { Theme } from '@cleartrip/ct-design-theme'; import { TypographyColor } from '@cleartrip/ct-design-typography'; import { ChipSize } from './type'; interface ChipStyleProps { theme: Theme; size: ChipSize; isSelected: boolean; isDisabled: boolean; topIcon?: boolean; } const getDefaultChipStyles = (theme: Theme, size: ChipSize, topIcon = false) => { const baseStyles = { borderRadius: 50, borderStyle: theme.border.style.solid, }; if (topIcon) { return { ...baseStyles, paddingVertical: theme.spacing[2], }; } return { ...baseStyles, height: theme.size[8], }; }; const getBorderStyles = (theme: Theme, isSelected: boolean, isDisabled: boolean) => { if (isDisabled) { return { borderWidth: theme.border.width.none, }; } if (isSelected) { return { borderColor: theme.color.border.primary, borderWidth: theme.border.width.md, }; } return { borderColor: theme.color.border.disabledDark, borderWidth: theme.border.width.sm, }; }; const getBackgroundColorStyles = (theme: Theme, isSelected: boolean, isDisabled: boolean) => { if (isDisabled) { return { backgroundColor: theme.color.background.disabled, }; } if (isSelected) { return { backgroundColor: theme.color.chip.selectedPrimaryBg, }; } return { backgroundColor: theme.color.background.neutral, }; }; const getLabelColor = (isDisabled: boolean): TypographyColor => { return isDisabled ? TypographyColor.DISABLED : TypographyColor.PRIMARY; }; export const getChipStyles = ({ theme, size, isDisabled, isSelected, topIcon = false }: ChipStyleProps) => ({ ...getDefaultChipStyles(theme, size, topIcon), ...getBorderStyles(theme, isSelected, isDisabled), ...getBackgroundColorStyles(theme, isSelected, isDisabled), }); export { getLabelColor };