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

Added Button Shortcut Style Enhancements + Additional Storybook Tests #8947

Merged
merged 9 commits into from
Dec 10, 2024
50 changes: 39 additions & 11 deletions packages/twenty-ui/src/input/button/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,45 @@ const StyledSoonPill = styled(Pill)`
margin-left: auto;
`;

const StyledShortcutLabel = styled.div`
color: ${({ theme }) => theme.font.color.light};
font-weight: ${({ theme }) => theme.font.weight.medium};
`;

const StyledSeparator = styled.div<{ buttonSize: ButtonSize }>`
background: ${({ theme }) => theme.border.color.light};
const StyledSeparator = styled.div<{
buttonSize: ButtonSize;
accent: ButtonAccent;
}>`
background: ${({ theme, accent }) => {
switch (accent) {
case 'blue':
return theme.color.blue30;
case 'danger':
return theme.border.color.danger;
default:
return theme.font.color.light;
}
}};
height: ${({ theme, buttonSize }) =>
theme.spacing(buttonSize === 'small' ? 3 : 4)};
margin: 0 ${({ theme }) => theme.spacing(1)};
theme.spacing(buttonSize === 'small' ? 2 : 4)};
margin: 0;
width: 1px;
`;

const StyledShortcutLabel = styled.div<{
variant: ButtonVariant;
accent: ButtonAccent;
}>`
color: ${({ theme, variant, accent }) => {
switch (accent) {
case 'blue':
return theme.color.blue30;
case 'danger':
return variant === 'primary'
? theme.border.color.danger
: theme.color.red40;
default:
return theme.font.color.light;
}
}};
font-weight: ${({ theme }) => theme.font.weight.medium};
`;

export const Button = ({
className,
Icon,
Expand Down Expand Up @@ -416,8 +442,10 @@ export const Button = ({
{title}
{shortcut && (
<>
<StyledSeparator buttonSize={size} />
<StyledShortcutLabel>{shortcut}</StyledShortcutLabel>
<StyledSeparator buttonSize={size} accent={accent} />
<StyledShortcutLabel variant={variant} accent={accent}>
{shortcut}
</StyledShortcutLabel>
</>
)}
{soon && <StyledSoonPill label="Soon" />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Default: Story = {
};

export const Catalog: CatalogStory<Story, typeof Button> = {
args: { title: 'Filter', Icon: IconSearch },
args: { title: 'Filter', Icon: IconSearch, shortcut: '' },
argTypes: {
size: { control: false },
variant: { control: false },
Expand All @@ -55,7 +55,6 @@ export const Catalog: CatalogStory<Story, typeof Button> = {
soon: { control: false },
position: { control: false },
className: { control: false },
shortcut: { control: false },
},
parameters: {
pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
Expand Down Expand Up @@ -277,7 +276,6 @@ export const ShortcutCatalog: CatalogStory<Story, typeof Button> = {
fullWidth: { control: false },
soon: { control: false },
position: { control: false },
shortcut: { control: false },
},
parameters: {
pseudo: { hover: ['.hover'], active: ['.pressed'], focus: ['.focus'] },
Expand All @@ -288,6 +286,20 @@ export const ShortcutCatalog: CatalogStory<Story, typeof Button> = {
values: ['small', 'medium'] satisfies ButtonSize[],
props: (size: ButtonSize) => ({ size }),
},
{
name: 'accents',
values: ['default', 'blue', 'danger'] satisfies ButtonAccent[],
props: (accent: ButtonAccent) => ({ accent }),
},
{
name: 'variants',
values: [
'primary',
'secondary',
'tertiary',
] satisfies ButtonVariant[],
props: (variant: ButtonVariant) => ({ variant }),
},
],
},
},
Expand Down
Loading