Skip to content

Commit

Permalink
Rename closeButtonLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
dlnr committed May 10, 2024
1 parent 3c4e936 commit 4cd305b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('Alert', () => {
})

it('renders the close button with a label', () => {
const { container } = render(<Alert closeable={true} closeLabel="Close" />)
const { container } = render(<Alert closeable={true} closeButtonLabel="Close" />)

const component = container.querySelector(':only-child')
const closeButton = component?.querySelector('.ams-icon-button')
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type AlertProps = {
/** Whether the alert can be dismissed by the user. Adds a button to the top right. */
closeable?: boolean
/** The label for the button that dismisses the Alert. */
closeLabel?: string
closeButtonLabel?: string
/**
* The hierarchical level of the alert title within the document.
* @default 2
Expand All @@ -43,7 +43,7 @@ export const Alert = forwardRef(
children,
className,
closeable,
closeLabel = 'Sluiten',
closeButtonLabel = 'Sluiten',
headingLevel = 2,
onClose,
severity = 'warning',
Expand All @@ -68,7 +68,7 @@ export const Alert = forwardRef(
)}
{children}
</div>
{closeable && <IconButton label={closeLabel} size={alertSize} onClick={onClose} />}
{closeable && <IconButton label={closeButtonLabel} size={alertSize} onClick={onClose} />}
</Tag>
)
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Dialog/Dialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('Dialog', () => {
})

it('renders a custom close label', () => {
render(<Dialog open closeLabel="Close" />)
render(<Dialog open closeButtonLabel="Close" />)

const closeButton = screen.getByText('Close')

Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ export type DialogProps = {
/** Children for the footer of the dialog, like a save or close button. */
actions?: ReactNode
/** The label for the button that dismisses the Dialog. */
closeLabel?: string
closeButtonLabel?: string
} & PropsWithChildren<DialogHTMLAttributes<HTMLDialogElement>>

export const Dialog = forwardRef(
(
{ actions, children, className, closeLabel = 'Sluiten', title, ...restProps }: DialogProps,
{ actions, children, className, closeButtonLabel = 'Sluiten', title, ...restProps }: DialogProps,
ref: ForwardedRef<HTMLDialogElement>,
) => (
<dialog {...restProps} ref={ref} className={clsx('ams-dialog', className)}>
<form method="dialog" className="ams-dialog__form">
<header className="ams-dialog__header">
<Heading size="level-4">{title}</Heading>
<IconButton formNoValidate label={closeLabel} size="level-4" />
<IconButton formNoValidate label={closeButtonLabel} size="level-4" />
</header>
<article className="ams-dialog__article">{children}</article>
{actions && <footer className="ams-dialog__footer">{actions}</footer>}
Expand Down
7 changes: 5 additions & 2 deletions packages/react/src/Pagination/Pagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ describe('Pagination', () => {

it('render custom labels for the "previous" and "next" buttons', () => {
render(<Pagination totalPages={10} previousLabel="previous" nextLabel="next" />)
expect(screen.getByText('previous')).toBeInTheDocument()
expect(screen.getByText('next')).toBeInTheDocument()
const previousButton = screen.getByRole('button', { name: 'previous' })
const nextButton = screen.getByRole('button', { name: 'next' })

expect(previousButton).toBeInTheDocument()
expect(nextButton).toBeInTheDocument()
})

it('render custom aria-labels for the "previous" and "next" buttons', () => {
Expand Down

0 comments on commit 4cd305b

Please sign in to comment.