Skip to content

Commit

Permalink
feat(dialog): additional props for rendering children at the top and …
Browse files Browse the repository at this point in the history
…bottom of dialog
  • Loading branch information
TimMikeladze committed Sep 1, 2022
1 parent 469d9ab commit 6629d1b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ export type AuthDialogProps = PropsWithChildren<{
* Defaults to `xs`.
*/
breakpoint?: Breakpoint,
/**
* Content to render at the bottom of the dialog.
*/
childrenBottom?: React.ReactNode;
/**
* Content to render at the top of the dialog. Alias for `children` to keep backwards compatibility.
*/
childrenTop?: React.ReactNode;
/**
* Disable autofocus of email field.
*/
Expand Down
11 changes: 10 additions & 1 deletion src/AuthDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ export type AuthDialogProps = PropsWithChildren<{
* Defaults to `xs`.
*/
breakpoint?: Breakpoint,
/**
* Content to render at the bottom of the dialog.
*/
childrenBottom?: React.ReactNode;
/**
* Content to render at the top of the dialog. Alias for `children` to keep backwards compatibility.
*/
childrenTop?: React.ReactNode;
/**
* Disable autofocus of email field.
*/
Expand Down Expand Up @@ -310,7 +318,7 @@ export function AuthDialog(props: AuthDialogProps) {
{props.error || props.DialogContentProps?.children}
</DialogContentText>
<Stack spacing={2}>
{props.children}
{props.children || props.childrenTop}
{(emailProviderConfig || props.alwaysShowEmailField) && (
<EmailField
onSubmitEmail={handleSubmitEmail}
Expand Down Expand Up @@ -369,6 +377,7 @@ export function AuthDialog(props: AuthDialogProps) {
</Typography>
</Button>
))}
{props.childrenBottom}
</Stack>
</>
)}
Expand Down
7 changes: 6 additions & 1 deletion src/stories/NextAuthDialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,16 @@ Custom.args = {
children: (
<>
<Typography>
Some custom fields
Some custom fields at the top
</Typography>
<TextField type="text" placeholder="Email" fullWidth />
<TextField type="password" placeholder="Password" fullWidth />
</>),
childrenBottom: (
<Typography>
Some custom fields at the bottom
</Typography>
),
};

Custom.parameters = {
Expand Down

0 comments on commit 6629d1b

Please sign in to comment.