Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dialog example #2083

Merged
merged 9 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/funny-hats-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@primer/react": patch
---

Export new Dialog component from the `@primer/react/drafts` bundle:

```diff
- import {Dialog} from '@primer/react/lib-esm/Dialog/Dialog'
+ import {Dialog} from '@primer/react/drafts'
```
44 changes: 4 additions & 40 deletions docs/content/deprecated/Dialog.md → docs/content/Dialog.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,8 @@
---
title: Dialog (legacy)
status: Deprecated
title: Dialog
status: Alpha
---

## Deprecation

Use the [new version of Dialog](/Dialog) instead.

**Before**

```jsx deprecated
<Dialog isOpen={open} onDismiss={() => setOpen(false)} aria-labelledby="header-id">
<Dialog.Header id="header-id">Title</Dialog.Header>
<Box p={3}>
<Text fontFamily="sans-serif">Some content</Text>
</Box>
</Dialog>
```

**After**

```jsx deprecated
{
open && (
<Dialog
title="Dialog example"
subtitle={
<>
This is a <b>description</b> of the dialog.
</>
}
footerButtons={[{content: 'Ok', onClick: () => setOpen(false)}]}
onClose={() => setOpen(false)}
>
<Text fontFamily="sans-serif">Some content</Text>
</Dialog>
)
}
```

The dialog component is used for all modals. It renders on top of the rest of the app with an overlay.

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.
Expand All @@ -57,7 +21,7 @@ If you're running into z-index issues or are rendering the component inside of a

### Examples

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

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

```jsx deprecated live
```jsx live
<State default={false}>
{([isOpen, setIsOpen]) => {
const returnFocusRef = React.useRef(null)
Expand Down
12 changes: 8 additions & 4 deletions docs/content/Dialog.mdx → docs/content/drafts/Dialog.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
title: Dialog
title: Dialog v2
componentId: dialog
status: Alpha
status: Draft
---

import State from '../components/State'
```js
import {Dialog} from '@primer/react/drafts'
```

import State from '../../components/State'

The dialog component 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.

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

### Example

```jsx live
```jsx live drafts
<State default={false}>
{([isOpen, setIsOpen]) => {
const openDialog = React.useCallback(() => setIsOpen(true), [setIsOpen])
Expand Down
8 changes: 4 additions & 4 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@
url: /Truncate
- title: UnderlineNav
url: /UnderlineNav
# - title: Drafts
# children:
- title: Drafts
children:
- title: Dialog v2
url: /drafts/Dialog
- title: Deprecated
children:
- title: ActionList (legacy)
Expand All @@ -163,8 +165,6 @@
url: /deprecated/ChoiceFieldset
- title: ChoiceInputField
url: /deprecated/ChoiceInputField
- title: Dialog (legacy)
url: /deprecated/Dialog
- title: Dropdown
url: /deprecated/Dropdown
- title: DropdownMenu
Expand Down
1 change: 1 addition & 0 deletions src/drafts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* example: import {ActionList} from '@primer/react/drafts
*/
export * from '../NavList'
export * from '../Dialog/Dialog'