Skip to content

Commit

Permalink
fix(button): font and image sizes are incorrect and non responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Jan 3, 2025
1 parent 860f554 commit ee54493
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 61 deletions.
6 changes: 0 additions & 6 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ const meta = {
component: Button,

argTypes: {
size: {
options: ['sm', 'md', 'lg'],
control: {
type: 'select',
},
},
variant: {
options: Object.values(ButtonVariants),
control: {
Expand Down
4 changes: 1 addition & 3 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,18 @@ describe('Button', () => {
render(<Button>Submit</Button>);
const buttonElement = screen.getByText('Submit');
expect(buttonElement).toHaveClass(`${px}-button`);
expect(buttonElement).toHaveClass(`${px}-button--md`);
expect(buttonElement).toHaveClass(`${px}-button--primary`);
expect(buttonElement).not.toHaveClass(`${px}-button--icon-last`);
});

it('renders with type and size classnames', () => {
render(
<Button variant={ButtonVariants.secondary} size="lg" isIconLast>
<Button variant={ButtonVariants.secondary} isIconLast>
Cancel
</Button>,
);
const buttonElement = screen.getByText('Cancel');
expect(buttonElement).toHaveClass(`${px}-button`);
expect(buttonElement).toHaveClass(`${px}-button--lg`);
expect(buttonElement).toHaveClass(`${px}-button--secondary`);
expect(buttonElement).toHaveClass(`${px}-button--icon-last`);
});
Expand Down
7 changes: 0 additions & 7 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement | HT
* Is this the principal call to action on the page?
*/
variant?: ButtonVariants;
/**
* How large should the button be?
*/
size?: 'sm' | 'md' | 'lg';
/**
* The type of the button.
*/
Expand Down Expand Up @@ -57,7 +53,6 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
(
{
variant = ButtonVariants.primary,
size = 'md',
children,
className,
isIconLast: iconLast = false,
Expand All @@ -78,7 +73,6 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
href={href}
className={classnames(
`${baseClassName}`,
`${baseClassName}--${size}`,
`${baseClassName}--${variant}`,
{
[`${baseClassName}--icon-last`]: iconLast,
Expand All @@ -99,7 +93,6 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
type={type}
className={classnames(
`${baseClassName}`,
`${baseClassName}--${size}`,
`${baseClassName}--${variant}`,
{
[`${baseClassName}--icon-last`]: iconLast,
Expand Down
27 changes: 5 additions & 22 deletions src/components/Button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.#{$px}-button {
@include bodyText;
@include labelText($button);

align-items: center;
background-color: $pure-black;
Expand All @@ -12,6 +13,7 @@
display: inline-flex;
font-variation-settings: 'wght' 600;
gap: $margin-xsm;
height: $spacing-lg;
justify-content: center;
padding: 0 $padding-md;
position: relative;
Expand All @@ -21,6 +23,8 @@

svg {
fill: $pure-white;
height: $button-label-line-height;
width: $button-label-line-height;

path {
fill: $pure-white;
Expand All @@ -45,27 +49,6 @@
}
}

&--sm {
font-size: 0.75rem;
height: 44px;

svg {
height: 1rem;
width: 1rem;
}
}

&--md,
&--lg {
font-size: 1rem;
height: 48px;

svg {
height: 1.25rem;
width: 1.25rem;
}
}

&--link {
background-color: transparent;
border: 0;
Expand Down Expand Up @@ -146,7 +129,7 @@
background-color: transparent;
border: 0;
color: $pure-black;
height: 28px;
height: $spacing-md;
padding: 0;

svg {
Expand Down
2 changes: 1 addition & 1 deletion src/patterns/ViewingsList/ViewingsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const ViewingsList = ({
onSave={handleOnSave}
/>
))}
<Button id={`viewings-list-add-btn-${props.id || getRandomNum()}`} size="sm" onClick={handleOnAdd}>
<Button id={`viewings-list-add-btn-${props.id || getRandomNum()}`} onClick={handleOnAdd}>
{addViewingsBtnLabel}
</Button>
</div>
Expand Down
25 changes: 3 additions & 22 deletions src/patterns/ViewingsList/ViewingsListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,41 +273,22 @@ const ViewingsListCard = ({
<div className={`${baseClass}__btn-group ${px}-button__group`}>
{editState ? (
<>
<Button
id={`vlc-save-btn-${id}`}
variant={ButtonVariants.ghost}
type="submit"
size="sm"
onClick={handleOnSave}
>
<Button id={`vlc-save-btn-${id}`} variant={ButtonVariants.ghost} type="submit" onClick={handleOnSave}>
{saveBtnLabel}
</Button>
<Button
id={`vlc-cancel-btn-${id}`}
variant={ButtonVariants.ghost}
type="button"
size="sm"
onClick={handleOnCancel}
>
<Button id={`vlc-cancel-btn-${id}`} variant={ButtonVariants.ghost} type="button" onClick={handleOnCancel}>
{cancelBtnLabel}
</Button>
</>
) : (
<>
<Button
id={`vlc-edit-btn-${id}`}
variant={ButtonVariants.ghost}
type="button"
size="sm"
onClick={handleOnEdit}
>
<Button id={`vlc-edit-btn-${id}`} variant={ButtonVariants.ghost} type="button" onClick={handleOnEdit}>
{editBtnLabel}
</Button>
<Button
id={`vlc-delete-btn-${id}`}
variant={ButtonVariants.ghost}
type="button"
size="sm"
onClick={() => typeof onDelete === 'function' && onDelete(id)}
>
{deleteBtnLabel}
Expand Down

0 comments on commit ee54493

Please sign in to comment.