-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(APP-3912): Update Dialog and DialogAlert implementations (#396)
- Loading branch information
Showing
40 changed files
with
898 additions
and
608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 15 additions & 3 deletions
18
src/core/components/dialogs/dialog/dialogContent/dialogContent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,30 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { DialogRoot } from '../dialogRoot'; | ||
import { DialogContent, type IDialogContentProps } from './dialogContent'; | ||
|
||
describe('<Dialog.Content/> component', () => { | ||
const createTestComponent = (props?: Partial<IDialogContentProps>) => { | ||
const completeProps: IDialogContentProps = { ...props }; | ||
|
||
return <DialogContent {...completeProps} />; | ||
const hiddenDescription = props?.description ? undefined : 'description'; | ||
|
||
return ( | ||
<DialogRoot hiddenTitle="title" hiddenDescription={hiddenDescription} open={true}> | ||
<DialogContent {...completeProps} /> | ||
</DialogRoot> | ||
); | ||
}; | ||
|
||
it('renders the given content', () => { | ||
const content = 'Test content'; | ||
|
||
render(createTestComponent({ children: content })); | ||
|
||
expect(screen.getByText(content)).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders the dialog description when specified', () => { | ||
const description = 'test-description'; | ||
render(createTestComponent({ description })); | ||
expect(screen.getByText(description)).toBeInTheDocument(); | ||
expect(screen.getByRole('dialog')).toHaveAccessibleDescription(description); | ||
}); | ||
}); |
31 changes: 25 additions & 6 deletions
31
src/core/components/dialogs/dialog/dialogContent/dialogContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
import { Description } from '@radix-ui/react-dialog'; | ||
import classNames from 'classnames'; | ||
import type React from 'react'; | ||
import { type ComponentPropsWithoutRef } from 'react'; | ||
|
||
export interface IDialogContentProps extends ComponentPropsWithoutRef<'div'> {} | ||
export interface IDialogContentProps extends ComponentPropsWithoutRef<'div'> { | ||
/** | ||
* Optional description of the dialog. | ||
*/ | ||
description?: string; | ||
/** | ||
* Removes the default paddings when set to true. | ||
* @default false | ||
*/ | ||
noInset?: boolean; | ||
} | ||
|
||
/** | ||
* `Dialog.Content` component. | ||
*/ | ||
export const DialogContent: React.FC<IDialogContentProps> = ({ className, ...otherProps }) => { | ||
return <div className={classNames('overflow-auto px-4 md:px-6', className)} {...otherProps} />; | ||
export const DialogContent: React.FC<IDialogContentProps> = (props) => { | ||
const { description, noInset = false, className, children, ...otherProps } = props; | ||
|
||
return ( | ||
<div className={classNames('overflow-auto', { 'px-4 md:px-6': !noInset }, className)} {...otherProps}> | ||
{description && ( | ||
<Description className="pb-3 text-sm leading-normal text-neutral-500 md:pb-4"> | ||
{description} | ||
</Description> | ||
)} | ||
{children} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 40 additions & 47 deletions
87
src/core/components/dialogs/dialog/dialogFooter/dialogFooter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.