Skip to content

Commit

Permalink
fix: Button fixes (#1122)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlnr authored Mar 11, 2024
1 parent 4acef4e commit b5a9504
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
4 changes: 0 additions & 4 deletions packages/css/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
}
}

.amsterdam-button--busy {
cursor: var(--amsterdam-button-busy-cursor);
}

.amsterdam-button--primary {
background-color: var(--amsterdam-button-primary-background-color);
box-shadow: var(--amsterdam-button-primary-box-shadow);
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/Button/Button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ describe('Button', () => {
expect(button).toBeVisible()
})

it('renders an additional class name', () => {
render(<Button className="extra">Click me!</Button>)

const button = screen.getByRole('button', {
name: 'Click me!',
})

expect(button).toHaveClass('amsterdam-button extra')
})

it('renders a default button with variant primary', () => {
render(<Button>primary</Button>)

Expand Down
7 changes: 2 additions & 5 deletions packages/react/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ import type { ButtonHTMLAttributes, ForwardedRef, PropsWithChildren } from 'reac

export type ButtonProps = {
variant?: 'primary' | 'secondary' | 'tertiary'
/** Render the button in a busy state to indicate something has to finish loading */
busy?: boolean
} & PropsWithChildren<ButtonHTMLAttributes<HTMLButtonElement>>

export const Button = forwardRef(
(
{ children, type, disabled, busy, variant = 'primary', ...restProps }: ButtonProps,
{ children, className, type, disabled, variant = 'primary', ...restProps }: ButtonProps,
ref: ForwardedRef<HTMLButtonElement>,
) => {
return (
<button
{...restProps}
ref={ref}
disabled={disabled}
className={clsx('amsterdam-button', busy === true && 'amsterdam-button--busy', `amsterdam-button--${variant}`)}
className={clsx('amsterdam-button', `amsterdam-button--${variant}`, className)}
type={type || 'button'}
aria-busy={busy || undefined}
>
{children}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"padding-block": { "value": "{amsterdam.space.inside.xs}" },
"padding-inline": { "value": "{amsterdam.space.inside.md}" },
"outline-offset": { "value": "{amsterdam.focus.outline-offset}" },
"busy": {
"cursor": { "value": "{amsterdam.action.busy.cursor}" }
},
"disabled": {
"cursor": { "value": "{amsterdam.action.disabled.cursor}" }
},
Expand Down
1 change: 0 additions & 1 deletion storybook/src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const meta = {
children: 'Button label',
variant: 'primary',
disabled: false,
busy: false,
},
argTypes: {
children: {
Expand Down

0 comments on commit b5a9504

Please sign in to comment.