Skip to content

Commit 5bc624b

Browse files
ty-v1colebemis
authored andcommitted
Fix Dialog example (primer#2083)
* import Dialog v2 instead of old Dialog * Revert "import Dialog v1 instead of old Dialog" This reverts commit 8ac1080. * move the new Dialog to drafts * undeprecate the legacy dialog * Update docs/content/drafts/Dialog.mdx Co-authored-by: Cole Bemis <colebemis@github.com> * update navigation menu * Create funny-hats-sing.md Co-authored-by: Cole Bemis <colebemis@github.com>
1 parent 47d9a25 commit 5bc624b

File tree

5 files changed

+27
-48
lines changed

5 files changed

+27
-48
lines changed

.changeset/funny-hats-sing.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@primer/react": patch
3+
---
4+
5+
Export new Dialog component from the `@primer/react/drafts` bundle:
6+
7+
```diff
8+
- import {Dialog} from '@primer/react/lib-esm/Dialog/Dialog'
9+
+ import {Dialog} from '@primer/react/drafts'
10+
```

docs/content/deprecated/Dialog.md renamed to docs/content/Dialog.md

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,8 @@
11
---
2-
title: Dialog (legacy)
3-
status: Deprecated
2+
title: Dialog
3+
status: Alpha
44
---
55

6-
## Deprecation
7-
8-
Use the [new version of Dialog](/Dialog) instead.
9-
10-
**Before**
11-
12-
```jsx deprecated
13-
<Dialog isOpen={open} onDismiss={() => setOpen(false)} aria-labelledby="header-id">
14-
<Dialog.Header id="header-id">Title</Dialog.Header>
15-
<Box p={3}>
16-
<Text fontFamily="sans-serif">Some content</Text>
17-
</Box>
18-
</Dialog>
19-
```
20-
21-
**After**
22-
23-
```jsx deprecated
24-
{
25-
open && (
26-
<Dialog
27-
title="Dialog example"
28-
subtitle={
29-
<>
30-
This is a <b>description</b> of the dialog.
31-
</>
32-
}
33-
footerButtons={[{content: 'Ok', onClick: () => setOpen(false)}]}
34-
onClose={() => setOpen(false)}
35-
>
36-
<Text fontFamily="sans-serif">Some content</Text>
37-
</Dialog>
38-
)
39-
}
40-
```
41-
426
The dialog component is used for all modals. It renders on top of the rest of the app with an overlay.
437

448
You'll need to manage the `isOpen` state in a wrapper component of your own and pass in a function to be used to close the Dialog. For documentation purposes only we've created a mock `State` to handle this, but you should handle the state in the component you consume `Dialog` in or in a wrapper component.
@@ -57,7 +21,7 @@ If you're running into z-index issues or are rendering the component inside of a
5721

5822
### Examples
5923

60-
```jsx deprecated live
24+
```jsx live
6125
<State default={false}>
6226
{([isOpen, setIsOpen]) => {
6327
const returnFocusRef = React.useRef(null)
@@ -85,7 +49,7 @@ If you're running into z-index issues or are rendering the component inside of a
8549

8650
You can also pass any non-text content into the header:
8751

88-
```jsx deprecated live
52+
```jsx live
8953
<State default={false}>
9054
{([isOpen, setIsOpen]) => {
9155
const returnFocusRef = React.useRef(null)

docs/content/Dialog.mdx renamed to docs/content/drafts/Dialog.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
---
2-
title: Dialog
2+
title: Dialog v2
33
componentId: dialog
4-
status: Alpha
4+
status: Draft
55
---
66

7-
import State from '../components/State'
7+
```js
8+
import {Dialog} from '@primer/react/drafts'
9+
```
10+
11+
import State from '../../components/State'
812

913
The dialog component is the Primer implementation of the ARIA design pattern [Dialog](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal). A dialog is a type of overlay that can be used for confirming actions, asking for disambiguation, and presenting small forms. They generally allow the user to focus on a quick task without having to navigate to a different page.
1014

@@ -45,7 +49,7 @@ By default, the Dialog component implements the design and interactions defined
4549

4650
### Example
4751

48-
```jsx live
52+
```jsx live drafts
4953
<State default={false}>
5054
{([isOpen, setIsOpen]) => {
5155
const openDialog = React.useCallback(() => setIsOpen(true), [setIsOpen])

docs/src/@primer/gatsby-theme-doctocat/nav.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,10 @@
146146
url: /Truncate
147147
- title: UnderlineNav
148148
url: /UnderlineNav
149-
# - title: Drafts
150-
# children:
149+
- title: Drafts
150+
children:
151+
- title: Dialog v2
152+
url: /drafts/Dialog
151153
- title: Deprecated
152154
children:
153155
- title: ActionList (legacy)
@@ -162,8 +164,6 @@
162164
url: /deprecated/ChoiceFieldset
163165
- title: ChoiceInputField
164166
url: /deprecated/ChoiceInputField
165-
- title: Dialog (legacy)
166-
url: /deprecated/Dialog
167167
- title: Dropdown
168168
url: /deprecated/Dropdown
169169
- title: DropdownMenu

src/drafts/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
* example: import {ActionList} from '@primer/react/drafts
66
*/
77
export * from '../NavList'
8+
export * from '../Dialog/Dialog'

0 commit comments

Comments
 (0)