feat: update Button to v2 design

This commit is contained in:
doprz
2024-03-06 12:51:09 -06:00
parent 837fddf804
commit 863521fb3b
10 changed files with 108 additions and 111 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -4,21 +4,21 @@ import React from 'react';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
title: 'Components/Common/Button',
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
args: {
children: 'Button',
},
argTypes: {
children: { control: 'text' },
},
title: 'Components/Common/Button',
component: Button,
parameters: {
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
layout: 'centered',
},
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
// More on argTypes: https://storybook.js.org/docs/api/argtypes
args: {
children: 'Button',
},
argTypes: {
children: { control: 'text' },
},
} satisfies Meta<typeof Button>;
export default meta;
@@ -26,72 +26,55 @@ type Story = StoryObj<typeof meta>;
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
export const Default: Story = {
args: {},
args: {},
};
export const Disabled: Story = {
args: {
disabled: true,
},
args: {
disabled: true,
},
};
export const Grid: Story = {
render: props => (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex' }}>
<Button {...props} type='primary' />
<Button {...props} type='secondary' />
<Button {...props} type='tertiary' />
<Button {...props} type='danger' />
<Button {...props} type='warning' />
<Button {...props} type='success' />
<Button {...props} type='info' />
</div>
<div style={{ display: 'flex' }}>
<Button {...props} type='primary' disabled />
<Button {...props} type='secondary' disabled />
<Button {...props} type='tertiary' disabled />
<Button {...props} type='danger' disabled />
<Button {...props} type='warning' disabled />
<Button {...props} type='success' disabled />
<Button {...props} type='info' disabled />
</div>
</div>
),
render: props => (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex' }}>
<Button {...props} type='filled' />
<Button {...props} type='outline' />
<Button {...props} type='single' />
</div>
<div style={{ display: 'flex' }}>
<Button {...props} type='filled' disabled />
<Button {...props} type='outline' disabled />
<Button {...props} type='single' disabled />
</div>
</div>
),
};
// TODO: Actually show the buttons as they appear in the design
export const CourseButtons: Story = {
args: {
children: 'Add Course',
},
render: props => (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex' }}>
<Button {...props} type='primary' />
<Button {...props} type='secondary' />
<Button {...props} type='tertiary' />
<Button {...props} type='danger' />
<Button {...props} type='warning' />
<Button {...props} type='success' />
<Button {...props} type='info' />
</div>
<div style={{ display: 'flex' }}>
<Button {...props} type='primary' disabled />
<Button {...props} type='secondary' disabled />
<Button {...props} type='tertiary' disabled />
<Button {...props} type='danger' disabled />
<Button {...props} type='warning' disabled />
<Button {...props} type='success' disabled />
<Button {...props} type='info' disabled />
</div>
</div>
),
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/file/8tsCay2FRqctrdcZ3r9Ahw/UTRP?type=design&node-id=324-389&mode=design&t=BoS5xBrpSsjgQXqv-4',
args: {
children: 'Add Course',
},
render: props => (
<div style={{ display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex' }}>
<Button {...props} type='filled' />
<Button {...props} type='outline' />
<Button {...props} type='single' />
</div>
<div style={{ display: 'flex' }}>
<Button {...props} type='filled' disabled />
<Button {...props} type='outline' disabled />
<Button {...props} type='single' disabled />
</div>
</div>
),
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/file/8tsCay2FRqctrdcZ3r9Ahw/UTRP?type=design&node-id=324-389&mode=design&t=BoS5xBrpSsjgQXqv-4',
},
},
},
};

View File

@@ -2,15 +2,18 @@
@use 'src/views/styles/colors.module.scss';
.button {
background-color: #000;
color: #fff;
padding: 10px;
padding: 0px 16px;
height: 40px;
margin: 10px;
border-radius: 8px;
border-radius: 4px;
border: none;
cursor: pointer;
transition: all 0.1s ease-in-out;
font-family: 'Inter';
font-family: 'Roboto';
font-size: 18px;
font-style: normal;
font-weight: 500;
line-height: normal;
display: flex;
align-items: center;
@@ -34,34 +37,19 @@
}
}
@each $color,
$value
in (
primary: colors.$burnt_orange,
secondary: colors.$charcoal,
tertiary: colors.$bluebonnet,
danger: colors.$speedway_brick,
warning: colors.$tangerine,
success: colors.$turtle_pond,
info: colors.$turquoise
)
{
&.#{$color} {
background-color: $value;
color: #fff;
&.filled {
background-color: var(--color-primary);
color: var(--color-secondary);
}
&:hover {
background-color: color.adjust($value, $lightness: 10%);
}
&.outline {
background-color: var(--color-secondary);
color: var(--color-primary);
border: 1px solid var(--color-primary);
}
&:focus-visible,
&:active {
background-color: color.adjust($value, $lightness: -10%);
}
&.disabled {
background-color: $value !important;
}
}
&.single {
background-color: var(--color-secondary);
color: var(--color-primary);
}
}

View File

@@ -5,11 +5,16 @@ import styles from './Button.module.scss';
interface Props {
className?: string;
style?: React.CSSProperties;
type?: 'filled' | 'outline' | 'single';
onClick?: () => void;
type?: 'primary' | 'secondary' | 'tertiary' | 'danger' | 'warning' | 'success' | 'info';
iconOnly?: boolean;
showSymbol?: boolean;
symbol?: React.ReactNode;
disabled?: boolean;
title?: string;
testId?: string;
primaryColor?: string;
secondaryColor?: string;
}
/**
@@ -17,18 +22,29 @@ interface Props {
* @returns
*/
export function Button({
style,
className,
style,
type,
testId,
children,
onClick,
iconOnly,
showSymbol,
symbol,
disabled,
title,
onClick,
testId,
primaryColor,
secondaryColor,
children,
}: React.PropsWithChildren<Props>): JSX.Element {
return (
<button
style={style}
style={
{
...style,
'--color-primary': primaryColor ?? '#333F48',
'--color-secondary': secondaryColor ?? '#FFFFFF',
} as React.CSSProperties
}
data-testid={testId}
className={clsx(styles.button, className, styles[type ?? 'primary'], {
[styles.disabled]: disabled,
@@ -36,7 +52,7 @@ export function Button({
title={title}
onClick={disabled ? undefined : onClick}
>
{children}
{!iconOnly && children}
</button>
);
}

View File

@@ -8,6 +8,16 @@
}
}
@each $weight in '100' '300' '400' '500' '700' '900' {
@font-face {
font-family: 'Roboto';
src: url('@public/fonts/roboto-#{$weight}.woff2') format('woff2');
font-display: auto;
font-style: normal;
font-weight: #{$weight};
}
}
@font-face {
font-family: 'Roboto Flex';
src: url('@public/fonts/roboto-flex.woff2') format('woff2');