Skip to content

Commit

Permalink
fix styles and type of children
Browse files Browse the repository at this point in the history
  • Loading branch information
sirineJ committed Dec 5, 2024
1 parent 7943586 commit ff0ea0e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 4 additions & 5 deletions packages/circuit-ui/components/Dialog/Dialog.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pointer-events: none;
visibility: hidden;
border: none;
border-radius: var(--cui-border-radius-byte);
border-radius: var(--cui-border-radius-mega);
outline: none;
box-shadow: 0 3px 8px 0 rgb(0 0 0 / 20%);
opacity: 0;
Expand All @@ -26,8 +26,8 @@
}

@media (min-width: 480px) {
.dialog {
width: max-content;
.dialog .content {
width: min-content;
min-width: 480px;
max-width: 90vw;
max-height: 90vw;
Expand Down Expand Up @@ -90,7 +90,7 @@
opacity: 1;
}

.close {
.dialog .close {
position: absolute;
top: var(--cui-spacings-byte);
right: var(--cui-spacings-byte);
Expand All @@ -115,7 +115,6 @@
.content {
overflow-y: auto;
background-color: var(--cui-bg-elevated);
border-radius: var(--cui-border-radius-byte);
}

@media (max-width: 479px) {
Expand Down
12 changes: 9 additions & 3 deletions packages/circuit-ui/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ export interface DialogProps
*/
onClose?: () => void;
/**
* a function that returns the content of the dialog.
* a ReactNode or a function that returns the content of the dialog.
*/
children?: ({ onClose }: { onClose?: DialogProps['onClose'] }) => ReactNode;
children?:
| ReactNode
| (({ onClose }: { onClose?: DialogProps['onClose'] }) => ReactNode);
/**
* Text label for the close button for screen readers.
* Important for accessibility.
Expand Down Expand Up @@ -256,7 +258,11 @@ export const Dialog = forwardRef<HTMLDialogElement, DialogProps>(
{closeButtonLabel}
</CloseButton>
{open && (
<div className={classes.content}>{children?.({ onClose })}</div>
<div className={classes.content}>
{typeof children === 'function'
? children?.({ onClose })
: children}
</div>
)}
</dialog>
</>
Expand Down

0 comments on commit ff0ea0e

Please sign in to comment.