Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disabled button styles, closes #4840 #4885

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/app/ui/components/button/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ export const Button: Story = {
},
};

export const Disabled: Story = {
parameters: {
controls: { include: ['size', 'variant'] },
},
args: {
disabled: true,
children: 'Button',
size: 'md',
variant: 'solid',
},
};

// TODO: Remove invert code
export const InvertSolid: Story = {
parameters: {
Expand Down
12 changes: 12 additions & 0 deletions src/app/ui/components/link/link.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ export const Link: Story = {
},
};

export const Disabled: Story = {
parameters: {
controls: { include: ['size', 'variant'] },
},
args: {
children: 'Link',
disabled: true,
size: 'md',
variant: 'underlined',
},
};

// TODO: Remove invert code
export const InvertLink: Story = {
parameters: {
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/components/link/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ type LinkProps = Omit<React.ComponentProps<typeof StyledLink>, keyof LinkVariant
LinkVariantProps;

export const Link = forwardRef((props: LinkProps, ref: ForwardedRef<HTMLAnchorElement>) => {
const { children, fullWidth, invert, size, variant, ...rest } = props;
const { children, disabled, fullWidth, invert, size, variant, ...rest } = props;

return (
<StyledLink
ref={ref}
className={linkRecipe({ fullWidth, invert, size, variant })}
className={linkRecipe({ disabled, fullWidth, invert, size, variant })}
cursor="pointer"
{...rest}
>
Expand Down
16 changes: 13 additions & 3 deletions theme/recipes/button-recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ export const buttonRecipe = defineRecipe({
className: 'button',
jsx: ['Button'],
base: {
_disabled: {
cursor: 'not-allowed',
},
position: 'relative',
rounded: 'xs',
textStyle: 'label.02',
Expand All @@ -54,8 +51,10 @@ export const buttonRecipe = defineRecipe({
bg: 'accent.action-primary-default',
},
_disabled: {
_hover: { bg: 'accent.background-secondary' },
bg: 'accent.background-secondary',
color: 'accent.non-interactive',
cursor: 'not-allowed',
},
_focus: {
_before: {
Expand All @@ -74,6 +73,12 @@ export const buttonRecipe = defineRecipe({
_active: {
bg: 'accent.component-background-pressed',
},
_disabled: {
_hover: { bg: 'unset' },
border: '1px solid {colors.accent.non-interactive}',
color: 'accent.non-interactive',
cursor: 'not-allowed',
},
_focus: {
_before: {
border: '3px solid {colors.focus}',
Expand All @@ -90,6 +95,11 @@ export const buttonRecipe = defineRecipe({
_active: {
bg: 'accent.component-background-pressed',
},
_disabled: {
_hover: { bg: 'unset' },
color: 'accent.non-interactive',
cursor: 'not-allowed',
},
_focus: {
_before: {
border: '3px solid {focus}',
Expand Down
60 changes: 40 additions & 20 deletions theme/recipes/link-recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ export const linkRecipe = defineRecipe({
className: 'link',
jsx: ['Link'],
base: {
_disabled: {
cursor: 'not-allowed',
},
appearance: 'none',
color: 'accent.text-primary',
display: 'inline',
mb: 'space.01',
p: 'unset',
Expand Down Expand Up @@ -48,12 +44,6 @@ export const linkRecipe = defineRecipe({
},
color: 'accent.text-primary',
},
_disabled: {
_before: {
background: 'accent.non-interactive',
},
color: 'accent.non-interactive',
},
_focus: {
_before: { background: 'focus' },
color: 'accent.text-primary',
Expand All @@ -64,6 +54,7 @@ export const linkRecipe = defineRecipe({
background: 'accent.action-primary-hover',
},
},
color: 'accent.text-primary',
},

text: {
Expand All @@ -84,13 +75,6 @@ export const linkRecipe = defineRecipe({
color: 'accent.text-primary',
visibility: 'visible',
},
_disabled: {
_before: {
background: 'accent.non-interactive',
visibility: 'visible',
},
color: 'accent.non-interactive',
},
_focus: {
_before: {
background: 'focus',
Expand All @@ -105,12 +89,13 @@ export const linkRecipe = defineRecipe({
visibility: 'visible',
},
},
color: 'accent.text-primary',
},
},

// TODO: Remove invert code
invert: { true: {} },

disabled: { true: {} },
fullWidth: { true: { width: '100%' } },
},

Expand All @@ -122,8 +107,6 @@ export const linkRecipe = defineRecipe({
// TODO: Remove invert code
compoundVariants: [
{
variant: 'underlined',
invert: true,
css: {
_focus: {
_before: {
Expand All @@ -140,6 +123,43 @@ export const linkRecipe = defineRecipe({
},
color: 'accent.background-secondary',
},
invert: true,
variant: 'underlined',
},
{
css: {
_before: {
content: '""',
background: 'accent.non-interactive',
bottom: '-2px',
height: '2px',
left: 0,
position: 'absolute',
right: 0,
},
color: 'accent.non-interactive',
cursor: 'not-allowed',
},
disabled: true,
variant: 'underlined',
},
{
css: {
_before: {
content: '""',
background: 'accent.non-interactive',
bottom: '-2px',
height: '2px',
left: 0,
position: 'absolute',
right: 0,
visibility: 'visible',
},
color: 'accent.non-interactive',
cursor: 'not-allowed',
},
disabled: true,
variant: 'text',
},
],
});
Loading