Skip to content

Commit

Permalink
Merge pull request #1089 from searchspring/checkbox-size-bugfix
Browse files Browse the repository at this point in the history
fix(checkbox): checkbox size prop now accepts both string and number
  • Loading branch information
korgon authored Jul 1, 2024
2 parents 5a026b2 + 911cffb commit 1a5a0ca
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ import { Icon, IconProps } from '../../Atoms/Icon';
import { useA11y } from '../../../hooks/useA11y';

const CSS = {
checkbox: ({ size, color, theme }: CheckboxProps) =>
css({
checkbox: ({ size, color, theme }: Partial<CheckboxProps>) => {
const pixelSize = isNaN(Number(size)) ? size : `${size}px`;
return css({
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
height: size,
width: size,
height: pixelSize,
width: pixelSize,
border: `1px solid ${color || theme?.colors?.primary || '#333'}`,
'&.ss__checkbox--disabled': {
opacity: 0.7,
},
'& .ss__checkbox__empty': {
display: 'inline-block',
width: `calc(${size} - 30%)`,
height: `calc(${size} - 30%)`,
width: `calc(${pixelSize} - 30%)`,
height: `calc(${pixelSize} - 30%)`,
},
}),
});
},
native: () => css({}),
};

Expand Down Expand Up @@ -140,7 +142,7 @@ export interface CheckboxProps extends ComponentProps {
icon?: string;
iconColor?: string;
onClick?: (e: React.MouseEvent<HTMLInputElement | HTMLSpanElement, MouseEvent>) => void;
size?: string;
size?: string | number;
startChecked?: boolean;
native?: boolean;
disableA11y?: boolean;
Expand Down

0 comments on commit 1a5a0ca

Please sign in to comment.