diff --git a/packages/components/src/components/buttons/Button/Button.stories.tsx b/packages/components/src/components/buttons/Button/Button.stories.tsx index a48b24eafb1..4c6bbf91a94 100644 --- a/packages/components/src/components/buttons/Button/Button.stories.tsx +++ b/packages/components/src/components/buttons/Button/Button.stories.tsx @@ -11,7 +11,37 @@ export default meta; export const Button: StoryObj = { args: { children: 'Button label', + variant: 'primary', + size: 'medium', + isDisabled: false, + isLoading: false, + isFullWidth: false, + iconAlignment: 'left', + title: 'Button title', ...framePropsStory.args, }, - argTypes: framePropsStory.argTypes, + argTypes: { + variant: { + control: { + type: 'radio', + }, + options: ['primary', 'secondary', 'tertiary', 'info', 'warning', 'destructive'], + }, + size: { + control: { + type: 'radio', + }, + options: ['large', 'medium', 'small', 'tiny'], + }, + icon: { control: 'text' }, + iconSize: { control: 'number' }, + iconAlignment: { + control: { + type: 'radio', + }, + options: ['left', 'right'], + }, + title: { control: 'text' }, + ...framePropsStory.argTypes, + }, }; diff --git a/packages/components/src/components/buttons/Button/Button.tsx b/packages/components/src/components/buttons/Button/Button.tsx index bae88af4904..f561fa1d5e1 100644 --- a/packages/components/src/components/buttons/Button/Button.tsx +++ b/packages/components/src/components/buttons/Button/Button.tsx @@ -48,8 +48,7 @@ export const ButtonContainer = styled.button` &:disabled { background: ${({ theme }) => theme.BG_GREY}; color: ${({ theme }) => theme.textDisabled}; - pointer-events: none; - cursor: default; + cursor: not-allowed; } ${withFrameProps} @@ -142,6 +141,7 @@ export const Button = ({ $hasIcon={!!icon || isLoading} $elevation={elevation} {...rest} + onClick={isDisabled ? undefined : rest?.onClick} {...makePropsTransient(frameProps)} > {!isLoading && icon && IconComponent} diff --git a/packages/components/src/components/form/Checkbox/Checkbox.stories.tsx b/packages/components/src/components/form/Checkbox/Checkbox.stories.tsx index 174dd163679..2161e6981f4 100644 --- a/packages/components/src/components/form/Checkbox/Checkbox.stories.tsx +++ b/packages/components/src/components/form/Checkbox/Checkbox.stories.tsx @@ -29,8 +29,26 @@ export const Checkbox: StoryObj = { }, args: { children: 'Checkbox', + variant: 'primary', + isChecked: false, + isDisabled: false, + labelAlignment: 'right', ...framePropsStory.args, }, - argTypes: framePropsStory.argTypes, + argTypes: { + variant: { + control: { + type: 'radio', + }, + options: ['primary', 'warning', 'destructive'], + }, + labelAlignment: { + control: { + type: 'radio', + }, + options: ['left', 'right'], + }, + ...framePropsStory.argTypes, + }, }; diff --git a/packages/components/src/components/form/Checkbox/Checkbox.tsx b/packages/components/src/components/form/Checkbox/Checkbox.tsx index 5cf7fe29d6c..7f26373e833 100755 --- a/packages/components/src/components/form/Checkbox/Checkbox.tsx +++ b/packages/components/src/components/form/Checkbox/Checkbox.tsx @@ -92,17 +92,22 @@ export const CheckContainer = styled.div<{ $variant: CheckboxVariant }>` background 0.1s, box-shadow 0.1s ease-out; - input:checked + && { + input:checked + & { background: ${({ theme, $variant }) => theme[variantStyles[$variant].backgroundChecked]}; border-color: ${({ theme, $variant }) => theme[variantStyles[$variant].borderChecked]}; } - input:disabled:not(:checked) + && { + input:disabled + & { + cursor: not-allowed; + pointer-events: auto; + } + + input:disabled:not(:checked) + & { background: ${({ theme, $variant }) => theme[variantStyles[$variant].backgroundDisabled]}; border-color: ${({ theme, $variant }) => theme[variantStyles[$variant].borderDisabled]}; } - input:disabled:checked + && { + input:disabled:checked + & { background: ${({ theme, $variant }) => theme[variantStyles[$variant].backgroundDisabledChecked]}; border-color: ${({ theme, $variant }) => @@ -160,7 +165,7 @@ export type CheckboxProps = { export const Checkbox = ({ variant = 'primary', isChecked, - isDisabled, + isDisabled = false, labelAlignment = 'right', onClick, 'data-test': dataTest, @@ -171,7 +176,10 @@ export const Checkbox = ({ const theme = useTheme(); const handleKeyUp = (event: KeyboardEvent) => { - if (event.code === KEYBOARD_CODE.SPACE || event.code === KEYBOARD_CODE.ENTER) { + if ( + !isDisabled && + (event.code === KEYBOARD_CODE.SPACE || event.code === KEYBOARD_CODE.ENTER) + ) { onClick(event); } }; @@ -184,7 +192,7 @@ export const Checkbox = ({ ` height: ${({ $size }) => `${INPUT_HEIGHTS[$size as InputSize]}px`}; ${baseInputStyle} ${({ $size }) => $size === 'small' && typography.hint}; + + &:disabled { + pointer-events: auto; + cursor: not-allowed; + } `; const InputWrapper = styled.div` diff --git a/packages/components/src/components/form/Radio/Radio.stories.tsx b/packages/components/src/components/form/Radio/Radio.stories.tsx index 77002c6ba3e..2a347118405 100644 --- a/packages/components/src/components/form/Radio/Radio.stories.tsx +++ b/packages/components/src/components/form/Radio/Radio.stories.tsx @@ -32,7 +32,26 @@ export const RadioButton: StoryObj = { ); }, - args: { children: 'RadioButton' }, + args: { + children: 'RadioButton', + variant: 'primary', + isChecked: false, + isDisabled: false, + }, + argTypes: { + variant: { + control: { + type: 'radio', + }, + options: ['primary', 'warning', 'destructive'], + }, + labelAlignment: { + control: { + type: 'radio', + }, + options: [null, 'left', 'right'], + }, + }, }; export const RadioButtonGroup: StoryObj = { diff --git a/packages/components/src/components/form/Radio/Radio.tsx b/packages/components/src/components/form/Radio/Radio.tsx index cce70c1f94f..1108e7010c2 100755 --- a/packages/components/src/components/form/Radio/Radio.tsx +++ b/packages/components/src/components/form/Radio/Radio.tsx @@ -54,7 +54,7 @@ const RadioIcon = styled(CheckContainer)` transition: background 0.1s; } - input:checked + && { + input:checked + & { background: ${({ theme }) => theme.backgroundSurfaceElevation0}; border-color: ${({ theme, $variant }) => theme[radioVariantStyles[$variant].borderChecked]}; @@ -64,7 +64,11 @@ const RadioIcon = styled(CheckContainer)` } } - input:disabled:not(:checked) + && { + input:disabled + & { + cursor: not-allowed; + } + + input:disabled:not(:checked) + & { background: ${({ theme }) => theme.backgroundSurfaceElevation0}; border-color: ${({ theme, $variant }) => theme[variantStyles[$variant].borderDisabled]}; @@ -73,7 +77,7 @@ const RadioIcon = styled(CheckContainer)` } } - input:disabled:checked + && { + input:disabled:checked + & { background: transparent; border-color: ${({ theme, $variant }) => theme[radioVariantStyles[$variant].borderDisabledChecked]}; @@ -84,15 +88,13 @@ const RadioIcon = styled(CheckContainer)` } } - ${/* sc-selector */ Container}:hover input:not(:disabled):not(:checked) + && { + ${/* sc-selector */ Container}:hover input:not(:disabled):not(:checked) + & { &::after { background: ${({ theme, $variant }) => theme[variantStyles[$variant].backgroundHover]}; } } - &&& { - ${getFocusShadowStyle()} - } + ${getFocusShadowStyle()} `; export interface RadioProps { @@ -109,20 +111,23 @@ export const Radio = ({ variant = 'primary', isChecked, labelAlignment, - isDisabled, + isDisabled = false, onClick, 'data-test': dataTest, children, }: RadioProps) => { const handleKeyUp = (event: KeyboardEvent) => { - if (event.code === KEYBOARD_CODE.SPACE || event.code === KEYBOARD_CODE.ENTER) { + if ( + !isDisabled && + (event.code === KEYBOARD_CODE.SPACE || event.code === KEYBOARD_CODE.ENTER) + ) { onClick(event); } }; return (