Skip to content

Commit 9dfc130

Browse files
committed
New sizes for Overlay and Dialog
1 parent 909ada5 commit 9dfc130

File tree

8 files changed

+39
-35
lines changed

8 files changed

+39
-35
lines changed

docs/content/Dialog2.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ By default, the Dialog component implements the design and interactions defined
8989
| footerButtons | `DialogButtonProps[]` | | Optional. Specify buttons that will be rendered in the footer of the dialog. |
9090
| onClose | `(gesture: 'close-button' │ 'escape') => void` | | Required. This method is invoked when a gesture to close the dialog is used (either an Escape key press or clicking the "X" in the top-right corner). The gesture argument indicates the gesture that was used to close the dialog (either 'close-button' or 'escape'). |
9191
| role | `"dialog" │ "alertdialog"` | `"dialog"` | The ARIA role given to the dialog element. More info: [dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal), [alertdialog](https://www.w3.org/TR/wai-aria-practices-1.1/#alertdialog) |
92-
| width | `"sm" │ "md" │ "lg" │ "xl"` | `"xl"` | The fixed width of the dialog. |
93-
| height | `"sm" │ "lg" │ "auto"` | `"auto"` | The fixed height of the dialog, or, auto to adjust the height based on its contents. |
92+
| width | `"small" │ "medium" │ "large" │ "xLarge"` | `"xLarge"` | The fixed width of the dialog. |
93+
| height | `"small" │ "large" │ "auto"` | `"auto"` | The fixed height of the dialog, or, auto to adjust the height based on its contents. |
9494

9595
### DialogHeaderProps
9696

docs/content/Overlay.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ render(<Demo />)
7575
| returnFocusRef | `React.RefObject<HTMLElement>` | `undefined` | Required. Ref for the element to focus when the `Overlay` is closed. |
7676
| onClickOutside | `function` | `undefined` | Required. Function to call when clicking outside of the `Overlay`. Typically this function sets the `Overlay` visibility state to `false`. |
7777
| onEscape | `function` | `undefined` | Required. Function to call when user presses `Escape`. Typically this function sets the `Overlay` visibility state to `false`. |
78-
| width | `'sm', 'md', 'lg', 'xl', 'auto'` | `auto` | Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `sm` corresponds to `256px`, `md` corresponds to `320px`, `lg` corresponds to `480px`, and `xl` corresponds to `640px`. |
79-
| height | `'sm', 'md', 'auto'` | `auto` | Sets the height of the `Overlay`, pick from our set list of heights, or pass `auto` to automatically set the height based on the content of the `Overlay`. `sm` corresponds to `480px` and `md` corresponds to `640px`. |
78+
| width | `'small' │ 'medium' │ 'large' │ 'xLarge' │ 'xxLarge' │ 'auto'` | `auto` | Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `480px`, `xLarge` corresponds to `640px`, `xxLarge` corresponds to `960px`. |
79+
| height | `'xSmall', 'small', 'medium', 'large', 'xLarge', 'auto'` | `auto` | Sets the height of the `Overlay`, pick from our set list of heights, or pass `auto` to automatically set the height based on the content of the `Overlay`. `xSmall` corresponds to `192px`, `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `432px`, `xLarge` corresponds to `600px`. |
8080
| visibility | `'visible', 'hidden'` | `visible` | Sets the visibility of the `Overlay`. |

src/Dialog/ConfirmationDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const ConfirmationDialog: React.FC<ConfirmationDialogProps> = props => {
163163
title={title}
164164
footerButtons={footerButtons}
165165
role="alertdialog"
166-
width="md"
166+
width="medium"
167167
renderHeader={ConfirmationHeader}
168168
renderBody={ConfirmationBody}
169169
renderFooter={ConfirmationFooter}

src/Dialog/Dialog.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,17 @@ export interface DialogProps {
104104

105105
/**
106106
* The width of the dialog.
107-
* sm: 296px
108-
* md: 320px
109-
* lg: 480px
110-
* xl: 640px
107+
* small: 296px
108+
* medium: 320px
109+
* large: 480px
110+
* xLarge: 640px
111111
*/
112112
width?: DialogWidth
113113

114114
/**
115115
* The height of the dialog.
116-
* sm: 296x480
117-
* lg: 480x640
116+
* small: 296x480
117+
* large: 480x640
118118
* auto: variable based on contents
119119
*/
120120
height?: DialogHeight
@@ -160,16 +160,16 @@ const Backdrop = styled('div')`
160160
`
161161

162162
const heightMap = {
163-
sm: '480px',
164-
lg: '640px',
163+
small: '480px',
164+
large: '640px',
165165
auto: 'auto'
166166
} as const
167167

168168
const widthMap = {
169-
sm: '296px',
170-
md: '320px',
171-
lg: '480px',
172-
xl: '640px'
169+
small: '296px',
170+
medium: '320px',
171+
large: '480px',
172+
xLarge: '640px'
173173
} as const
174174

175175
export type DialogWidth = keyof typeof widthMap
@@ -188,7 +188,7 @@ const StyledDialog = styled.div<StyledDialogProps & SystemCommonProps & SystemPo
188188
min-width: 296px;
189189
max-width: calc(100vw - 64px);
190190
max-height: calc(100vh - 64px);
191-
width: ${props => widthMap[props.width ?? ('xl' as const)]};
191+
width: ${props => widthMap[props.width ?? ('xLarge' as const)]};
192192
height: ${props => heightMap[props.height ?? ('auto' as const)]};
193193
border-radius: 12px;
194194
opacity: 1;
@@ -250,7 +250,7 @@ const _Dialog = React.forwardRef<HTMLDivElement, React.PropsWithChildren<DialogP
250250
renderFooter,
251251
onClose,
252252
role = 'dialog',
253-
width = 'xl',
253+
width = 'xLarge',
254254
height = 'auto'
255255
} = props
256256
const dialogLabelId = uniqueId()

src/Overlay.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ type StyledOverlayProps = {
1414
}
1515

1616
const heightMap = {
17-
sm: '480px',
18-
md: '640px',
17+
xSmall: '192px',
18+
small: '256px',
19+
medium: '320px',
20+
large: '432px',
21+
xLarge: '600px',
1922
auto: 'auto'
2023
}
2124

2225
const widthMap = {
23-
sm: '256px',
24-
md: '320px',
25-
lg: '480px',
26-
xl: '640px',
26+
small: '256px',
27+
medium: '320px',
28+
large: '480px',
29+
xLarge: '640px',
30+
xxLarge: '960px',
2731
auto: 'auto'
2832
}
2933

@@ -71,8 +75,8 @@ export type OverlayProps = {
7175
* @param returnFocusRef Required. Ref for the element to focus when the `Overlay` is closed.
7276
* @param onClickOutside Required. Function to call when clicking outside of the `Overlay`. Typically this function sets the `Overlay` visibility state to `false`.
7377
* @param onEscape Required. Function to call when user presses `Escape`. Typically this function sets the `Overlay` visibility state to `false`.
74-
* @param width Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `sm` corresponds to `256px`, `md` corresponds to `320px`, `lg` corresponds to `480px`, and `xl` corresponds to `640px`.
75-
* @param height Sets the height of the `Overlay`, pick from our set list of heights, or pass `auto` to automatically set the height based on the content of the `Overlay`. `sm` corresponds to `480px` and `md` corresponds to `640px`.
78+
* @param width Sets the width of the `Overlay`, pick from our set list of widths, or pass `auto` to automatically set the width based on the content of the `Overlay`. `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `480px`, `xLarge` corresponds to `640px`, `xxLarge` corresponds to `960px`.
79+
* @param height Sets the height of the `Overlay`, pick from our set list of heights, or pass `auto` to automatically set the height based on the content of the `Overlay`. `xSmall` corresponds to `192px`, `small` corresponds to `256px`, `medium` corresponds to `320px`, `large` corresponds to `432px`, `xLarge` corresponds to `600px`.
7680
* @param visibility Sets the visibility of the `Overlay`
7781
*/
7882
const Overlay = React.forwardRef<HTMLDivElement, OverlayProps>(

src/__tests__/Overlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const TestComponent = ({initialFocus, callback}: TestComponentSettings) => {
3434
ignoreClickRefs={[buttonRef]}
3535
onEscape={closeOverlay}
3636
onClickOutside={closeOverlay}
37-
width="sm"
37+
width="small"
3838
>
3939
<Flex flexDirection="column" p={2}>
4040
<Text>Are you sure?</Text>

src/stories/Dialog.stories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ export default {
2222
],
2323
argTypes: {
2424
width: {
25-
defaultValue: 'xl',
25+
defaultValue: 'xLarge',
2626
control: {
2727
type: 'radio',
28-
options: ['sm', 'md', 'lg', 'xl']
28+
options: ['small', 'medium', 'large', 'xLarge']
2929
}
3030
},
3131
height: {
3232
defaultValue: 'auto',
3333
control: {
3434
type: 'radio',
35-
options: ['sm', 'lg', 'auto']
35+
options: ['small', 'large', 'auto']
3636
}
3737
},
3838
subtitle: {
@@ -128,7 +128,7 @@ export const BasicDialog = ({width, height, subtitle}: DialogStoryProps) => {
128128
>
129129
{lipsum}
130130
{secondOpen && (
131-
<Dialog title="Inner dialog!" onClose={onSecondDialogClose} width="sm">
131+
<Dialog title="Inner dialog!" onClose={onSecondDialogClose} width="small">
132132
Hello world
133133
</Dialog>
134134
)}
@@ -229,7 +229,7 @@ export const StressTest = ({width, height, subtitle}: DialogStoryProps) => {
229229
>
230230
{lipsum}
231231
{secondOpen && (
232-
<Dialog title="Inner dialog!" onClose={onSecondDialogClose} width="sm">
232+
<Dialog title="Inner dialog!" onClose={onSecondDialogClose} width="small">
233233
Hello world
234234
</Dialog>
235235
)}

src/stories/Overlay.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const DropdownOverlay = () => {
5151
<Overlay
5252
returnFocusRef={buttonRef}
5353
height="auto"
54-
width="sm"
54+
width="small"
5555
ignoreClickRefs={[buttonRef]}
5656
onEscape={() => setIsOpen(false)}
5757
onClickOutside={() => setIsOpen(false)}
@@ -87,7 +87,7 @@ export const DialogOverlay = () => {
8787
ignoreClickRefs={[buttonRef]}
8888
onEscape={closeOverlay}
8989
onClickOutside={closeOverlay}
90-
width="sm"
90+
width="small"
9191
>
9292
<Flex flexDirection="column" p={2}>
9393
<Text>Are you sure?</Text>

0 commit comments

Comments
 (0)