Skip to content

Commit

Permalink
fix: button compound variants
Browse files Browse the repository at this point in the history
  • Loading branch information
gndz07 authored Aug 5, 2024
1 parent 916f30d commit ea60ab3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions components/Button/Button.themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export namespace Theme {

export const getLight: Factory = (primaryColor) => ({
buttonPrimaryBg: '$primary',
buttonPrimaryFocusBg: tinycolor(primaryColor.value).lighten(10).toHslString(),
buttonPrimaryText: 'white',
buttonPrimaryFocusBorder: primaryColor.helpers.pickScale(6, { alpha: true }),
buttonPrimaryGhostHoverText: '$deepBlue9',
Expand All @@ -42,6 +43,7 @@ export namespace Theme {

export const getDark: Factory = (primaryColor) => ({
buttonPrimaryBg: '$primary',
buttonPrimaryFocusBg: tinycolor(primaryColor.value).lighten(10).toHslString(),
buttonPrimaryText: '$deepBlue2',
buttonPrimaryFocusBorder: primaryColor.helpers.pickScale(12, { alpha: true }),
buttonPrimaryGhostHoverText: tinycolor(primaryColor.value).lighten(10).toHslString(),
Expand Down
26 changes: 22 additions & 4 deletions components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ export const StyledButton = styled('button', BUTTON_BASE_STYLES, {
},
},
},
{
variant: 'primary',
state: 'active',
css: {
backgroundColor: '$buttonPrimaryFocusBg',
color: '$buttonPrimaryText',
boxShadow: 'inset 0 0 0 2px white',
},
},
{
variant: 'secondary',
state: 'waiting',
Expand All @@ -226,10 +235,10 @@ export const StyledButton = styled('button', BUTTON_BASE_STYLES, {
},
{
variant: 'secondary',
state: 'active',
ghost: true,
css: {
backgroundColor: '$buttonPrimaryBg',
color: '$buttonPrimaryText',
backgroundColor: 'transparent',
color: '$buttonSecondaryText',
},
},
{
Expand All @@ -240,6 +249,15 @@ export const StyledButton = styled('button', BUTTON_BASE_STYLES, {
color: 'transparent',
},
},
{
variant: 'red',
state: 'active',
css: {
backgroundColor: '$buttonRedFocusBg',
color: '$buttonRedText',
boxShadow: 'inset 0 0 0 2px white',
},
},
{
variant: 'red',
ghost: 'true',
Expand Down Expand Up @@ -291,7 +309,7 @@ export const Button = React.forwardRef<React.ElementRef<typeof StyledButton>, Bu
{children}
</Component>
);
}
},
);

const BaseButton = (props: ButtonProps): JSX.Element => <Button {...props} />;
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

export default defineConfig({
optimizeDeps: {
exclude: ['storybook'],
},
plugins: [react()],
});

0 comments on commit ea60ab3

Please sign in to comment.