Skip to content

Commit

Permalink
fix(iconbutton): make this responsive correctly based on Figma
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Jan 3, 2025
1 parent ee54493 commit e720515
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
6 changes: 0 additions & 6 deletions src/components/IconButton/IconButton.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ const meta = {
component: IconButton,

argTypes: {
size: {
options: ['sm', 'md', 'lg'],
control: {
type: 'select',
},
},
variant: {
options: Object.values(ButtonVariants),
control: {
Expand Down
7 changes: 1 addition & 6 deletions src/components/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export interface IconButtonProps extends Omit<React.HTMLAttributes<HTMLButtonEle
* Button contents
*/
children?: React.ReactElement<SVGElement>;
/**
* How large should the button be?
*/
size?: 'sm' | 'md' | 'lg';
/**
* Mainly used for styling
*/
Expand All @@ -24,7 +20,6 @@ export interface IconButtonProps extends Omit<React.HTMLAttributes<HTMLButtonEle

const IconButton = ({
children,
size = 'md',
variant = ButtonVariants.primary,
isDisabled = false,
className,
Expand All @@ -35,7 +30,7 @@ const IconButton = ({
<Button
{...commonProps}
variant={variant}
className={classnames(baseClass, `${baseClass}--${size}`, `${baseClass}--${variant}`, className)}
className={classnames(baseClass, `${baseClass}--${variant}`, className)}
isDisabled={isDisabled}
{...props}
>
Expand Down
38 changes: 28 additions & 10 deletions src/components/IconButton/_iconButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
.#{$px}-icon-button {
align-items: center;
display: flex;
height: $spacing-md;
justify-content: center;
padding: 0;
width: $spacing-md;

& > svg {
height: $button-label-line-height;
width: $button-label-line-height;
}

&:focus-visible {
&:focus-visible {
Expand All @@ -21,14 +28,12 @@
&--ghost {
background: $pure-white;
color: $pure-black;
height: 44px;
width: 44px;

& > svg {
fill: $pure-black;
height: 1.5rem;
height: calc($button-label-line-height * 1.5); // design-cheats-for-button-large
margin-inline-end: unset;
width: 1.5rem;
width: calc($button-label-line-height * 1.5); // design-cheats-for-button-large

path {
fill: $pure-black;
Expand Down Expand Up @@ -58,22 +63,21 @@
}
}

&--secondary {
height: $spacing-lg;
width: $spacing-lg;
}

&--secondary,
&--tertiary.#{$px}-icon-button {
height: 28px;
padding: $spacing-xsm;
width: 28px;

&:focus-visible {
border-radius: 100px;
}

& > svg {
fill: $pure-black;
height: 1.25rem;
margin-inline-end: unset;
position: absolute;
width: 1.25rem;

path {
fill: $pure-black;
Expand All @@ -85,6 +89,20 @@
&:focus-visible {
border-radius: 100px;
}

&:hover {
background-color: $button-hover;

& > svg {
fill: $pure-white;
margin-inline-end: unset;
position: absolute;

path {
fill: $pure-white;
}
}
}
}

&:disabled {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tags/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const Tag = ({ id, className, onRemove, label }: TagProps) => {
<div className={classnames(`${px}-tag`, `${px}-button`, className)} aria-label="Close Tag">
<div className={`${px}-tag__label`}>{label}</div>
<div onClick={() => onRemove(label)} className={`${px}-tag__button`} data-testid={`${id}-item-close-button`}>
<IconButton className={`${px}-tag__button--close`} size="sm">
<IconButton className={`${px}-tag__button--close`}>
<CloseIcon />
</IconButton>
</div>
Expand Down

0 comments on commit e720515

Please sign in to comment.