Skip to content

Commit d6f4467

Browse files
authored
Migrate docs for deprecated React components (#710)
1 parent afb4833 commit d6f4467

22 files changed

+1102
-68
lines changed

.markdownlint-cli2.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const options = githubMarkdownOpinions.init({
1212
'ul-indent': false,
1313
'no-hard-tabs': false,
1414
'first-line-heading': false,
15+
'no-space-in-code': false
1516
})
1617

1718
module.exports = {

content/components/action-bar.mdx

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ railsIds:
1010
import {Box, Text} from '@primer/react'
1111
import ComponentLayout from '~/src/layouts/component-layout'
1212
export default ComponentLayout
13+
import {AccessibilityLink} from '~/src/components/accessibility-link'
1314

1415
## Usage
1516

@@ -247,3 +248,6 @@ An action bar has an ARIA role of [`toolbar`](https://developer.mozilla.org/en-U
247248
/>
248249
</Box>
249250

251+
### Known accessibility issues (GitHub staff only)
252+
253+
<AccessibilityLink label="ActionBar"/>

content/components/action-list.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ railsIds:
55
- Primer::Alpha::ActionList
66
figmaId: action_list
77
description:
8-
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent.
8+
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent,
99
single-column format, with room for icons, descriptions, side information, and other rich visuals.
1010
---
1111

@@ -339,4 +339,4 @@ The tooltip and optional dialog should be triggered by a button element that wra
339339

340340
### Known accessibility issues (GitHub staff only)
341341

342-
<AccessibilityLink label="ActionList"/>
342+
<AccessibilityLink label="ActionList"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
title: Action list
3+
reactId: action_list
4+
reactStatus: deprecated
5+
description:
6+
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent,
7+
single-column format, with room for icons, descriptions, side information, and other rich visuals.
8+
---
9+
10+
import {ComponentPageNav} from '~/src/components/component-page-nav'
11+
import StatusMenu from '~/src/components/status-menu'
12+
import {AccessibilityLabel, StatusLabel} from '@primer/gatsby-theme-doctocat'
13+
import {Label} from '@primer/react'
14+
import { graphql } from "gatsby"
15+
16+
export const query = graphql`
17+
query {
18+
primerReactVersion {
19+
version
20+
}
21+
allReactComponent(filter: {componentId: {eq: "action_list"}}) {
22+
nodes {
23+
status
24+
}
25+
}
26+
}
27+
`
28+
29+
<Box style={{marginBottom: "24px"}}>
30+
<ComponentPageNav
31+
basePath="/components/action-list"
32+
includeReact={true}
33+
includeRails={true}
34+
includeFigma={true}
35+
current="react"
36+
/>
37+
</Box>
38+
39+
<Box style={{display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "25px"}}>
40+
<Box style={{display: "flex", gap: "5px"}}>
41+
<Label size="large">@primer/react@v{props.data.primerReactVersion.version}</Label>
42+
<StatusLabel status="Deprecated" />
43+
<AccessibilityLabel a11yReviewed={false} short={false} />
44+
</Box>
45+
<Box>
46+
<StatusMenu currentStatus="deprecated" statuses={[...props.data.allReactComponent.nodes.map((reactComponent) => reactComponent.status), "deprecated"]} parentPath="/components/action-list/react" />
47+
</Box>
48+
</Box>
49+
50+
An `ActionList` is a list of items which can be activated or selected. `ActionList` is the base component for many of our menu-type components, including and `ActionMenu`.
51+
52+
## Deprecation
53+
54+
Use the [new version of ActionList](/components/action-list/react) with composable API, design updates and accessibility fixes.
55+
56+
### Before
57+
58+
```jsx
59+
<ActionList
60+
items={[
61+
{text: 'New file'},
62+
{text: 'Copy link'},
63+
{text: 'Edit file'},
64+
ActionList.Divider,
65+
{text: 'Delete file', variant: 'danger'},
66+
]}
67+
/>
68+
```
69+
70+
### After
71+
72+
```jsx
73+
<ActionList>
74+
<ActionList.Item>New file</ActionList.Item>
75+
<ActionList.Item>Copy link</ActionList.Item>
76+
<ActionList.Item>Edit file</ActionList.Item>
77+
<ActionList.Divider />
78+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
79+
</ActionList>
80+
```
81+
82+
Or continue using deprecated API:
83+
84+
```js
85+
import {ActionList} from '@primer/react/deprecated'
86+
```
87+
88+
## Minimal example
89+
90+
```jsx live deprecated
91+
<ActionList
92+
items={[
93+
{text: 'New file'},
94+
ActionList.Divider,
95+
{text: 'Copy link'},
96+
{text: 'Edit file'},
97+
{text: 'Delete file', variant: 'danger'},
98+
]}
99+
/>
100+
```
101+
102+
## Example with grouped items
103+
104+
```jsx live deprecated
105+
<ActionList
106+
groupMetadata={[
107+
{groupId: '0'},
108+
{groupId: '1', header: {title: 'Live query', variant: 'subtle'}},
109+
{groupId: '2', header: {title: 'Layout', variant: 'subtle'}},
110+
{groupId: '3'},
111+
{groupId: '4'},
112+
]}
113+
items={[
114+
{key: '1', leadingVisual: TypographyIcon, text: 'Rename', groupId: '0', trailingVisual: '⌘R'},
115+
{key: '2', leadingVisual: VersionsIcon, text: 'Duplicate', groupId: '0'},
116+
{key: '3', leadingVisual: SearchIcon, text: 'repo:github/github', groupId: '1'},
117+
{
118+
key: '4',
119+
leadingVisual: NoteIcon,
120+
text: 'Table',
121+
description: 'Information-dense table optimized for operations across teams',
122+
descriptionVariant: 'block',
123+
groupId: '2',
124+
},
125+
{
126+
key: '5',
127+
leadingVisual: ProjectIcon,
128+
text: 'Board',
129+
description: 'Kanban-style board focused on visual states',
130+
descriptionVariant: 'block',
131+
groupId: '2',
132+
},
133+
{
134+
key: '6',
135+
leadingVisual: FilterIcon,
136+
text: 'Save sort and filters to current view',
137+
disabled: true,
138+
groupId: '3',
139+
},
140+
{key: '7', leadingVisual: FilterIcon, text: 'Save sort and filters to new view', groupId: '3'},
141+
{key: '8', leadingVisual: GearIcon, text: 'View settings', groupId: '4'},
142+
]}
143+
/>
144+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
---
2+
title: ActionMenu
3+
reactId: action_menu
4+
reactStatus: deprecated
5+
description: Action menu is composed of action list and overlay patterns used for quick actions and selections.
6+
---
7+
8+
import {ComponentPageNav} from '~/src/components/component-page-nav'
9+
import StatusMenu from '~/src/components/status-menu'
10+
import {AccessibilityLabel, StatusLabel} from '@primer/gatsby-theme-doctocat'
11+
import {Label} from '@primer/react'
12+
import { graphql } from "gatsby"
13+
14+
export const query = graphql`
15+
query {
16+
primerReactVersion {
17+
version
18+
}
19+
allReactComponent(filter: {componentId: {eq: "action_menu"}}) {
20+
nodes {
21+
status
22+
}
23+
}
24+
}
25+
`
26+
27+
<Box style={{marginBottom: "24px"}}>
28+
<ComponentPageNav
29+
basePath="/components/action-menu"
30+
includeReact={true}
31+
includeRails={true}
32+
includeFigma={true}
33+
current="react"
34+
/>
35+
</Box>
36+
37+
<Box style={{display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "25px"}}>
38+
<Box style={{display: "flex", gap: "5px"}}>
39+
<Label size="large">@primer/react@v{props.data.primerReactVersion.version}</Label>
40+
<StatusLabel status="Deprecated" />
41+
<AccessibilityLabel a11yReviewed={false} short={false} />
42+
</Box>
43+
<Box>
44+
<StatusMenu currentStatus="deprecated" statuses={[...props.data.allReactComponent.nodes.map((reactComponent) => reactComponent.status), "deprecated"]} parentPath="/components/action-menu/react" />
45+
</Box>
46+
</Box>
47+
48+
An `ActionMenu` is an ActionList-based component for creating a menu of actions that expands through a trigger button.
49+
50+
## Deprecation
51+
52+
Use [new version of ActionMenu](/components/action-menu/react) with composable API, design updates and accessibility fixes.
53+
54+
### Before
55+
56+
```jsx
57+
<ActionMenu
58+
anchorContent="Menu"
59+
onAction={fn}
60+
items={[
61+
{text: 'New file'},
62+
{text: 'Copy link'},
63+
{text: 'Edit file'},
64+
ActionMenu.Divider,
65+
{text: 'Delete file', variant: 'danger'},
66+
]}
67+
overlayProps={{width: 'small'}}
68+
/>
69+
```
70+
71+
### After
72+
73+
```jsx
74+
<ActionMenu>
75+
<ActionMenu.Button>Menu</ActionMenu.Button>
76+
<ActionMenu.Overlay width="small">
77+
<ActionList>
78+
<ActionList.Item onSelect={fn}>New file</ActionList.Item>
79+
<ActionList.Item>Copy link</ActionList.Item>
80+
<ActionList.Item>Edit file</ActionList.Item>
81+
<ActionList.Divider />
82+
<ActionList.Item variant="danger">Delete file</ActionList.Item>
83+
</ActionList>
84+
</ActionMenu.Overlay>
85+
</ActionMenu>
86+
```
87+
88+
Or continue using deprecated API:
89+
90+
```js
91+
import {ActionMenu} from '@primer/react/deprecated'
92+
```
93+
94+
## Default example
95+
96+
```jsx live deprecated
97+
<ActionMenu
98+
anchorContent="Menu"
99+
onAction={({text}) => console.log(text)}
100+
items={[
101+
{text: 'New file', key: 'new-file'},
102+
ActionMenu.Divider,
103+
{text: 'Copy link', key: 'copy-link'},
104+
{text: 'Edit file', key: 'edit-file'},
105+
{text: 'Delete file', variant: 'danger', key: 'delete-file'},
106+
]}
107+
/>
108+
```
109+
110+
## Example with grouped items
111+
112+
```jsx live deprecated
113+
<ActionMenu
114+
anchorContent="Menu"
115+
onAction={({text}) => console.log(text)}
116+
groupMetadata={[
117+
{groupId: '0'},
118+
{groupId: '1', header: {title: 'Live query', variant: 'subtle'}},
119+
{groupId: '2', header: {title: 'Layout', variant: 'subtle'}},
120+
{groupId: '3'},
121+
{groupId: '4'},
122+
]}
123+
items={[
124+
{key: '1', leadingVisual: TypographyIcon, text: 'Rename', groupId: '0'},
125+
{key: '2', leadingVisual: VersionsIcon, text: 'Duplicate', groupId: '0'},
126+
{key: '3', leadingVisual: SearchIcon, text: 'repo:github/github', groupId: '1'},
127+
{
128+
key: '4',
129+
leadingVisual: NoteIcon,
130+
text: 'Table',
131+
description: 'Information-dense table optimized for operations across teams',
132+
descriptionVariant: 'block',
133+
groupId: '2',
134+
},
135+
{
136+
key: '5',
137+
leadingVisual: ProjectIcon,
138+
text: 'Board',
139+
description: 'Kanban-style board focused on visual states',
140+
descriptionVariant: 'block',
141+
groupId: '2',
142+
},
143+
{
144+
key: '6',
145+
leadingVisual: FilterIcon,
146+
text: 'Save sort and filters to current view',
147+
disabled: true,
148+
groupId: '3',
149+
},
150+
{key: '7', leadingVisual: FilterIcon, text: 'Save sort and filters to new view', groupId: '3'},
151+
{key: '8', leadingVisual: GearIcon, text: 'View settings', groupId: '4'},
152+
]}
153+
/>
154+
```
155+
156+
## Component props
157+
158+
| Name | Type | Default | Description |
159+
| :------------ | :------------------------------------ | :---------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
160+
| items | `ItemProps[]` | `undefined` | Required. A list of item objects conforming to the `ActionList.Item` props interface. |
161+
| renderItem | `(props: ItemProps) => JSX.Element` | `ActionList.Item` | Optional. If defined, each item in `items` will be passed to this function, allowing for `ActionList`-wide custom item rendering. |
162+
| groupMetadata | `GroupProps[]` | `undefined` | Optional. If defined, `ActionList` will group `items` into `ActionList.Group`s separated by `ActionList.Divider` according to their `groupId` property. |
163+
| renderAnchor | `(props: ButtonProps) => JSX.Element` | `Button` | Optional. If defined, provided component will be used to render the menu anchor. Will receive the selected `Item` text as `children` prop when an item is activated. |
164+
| anchorContent | React.ReactNode | `undefined` | Optional. If defined, it will be passed to the trigger as the elements child. |
165+
| onAction | (props: ItemProps) => void | `undefined` | Optional. If defined, this function will be called when a menu item is activated either by a click or a keyboard press. |
166+
| open | boolean | `undefined` | Optional. If defined, ActionMenu will use this to control the open/closed state of the Overlay instead of controlling the state internally. Should be used in conjunction with the `setOpen` prop. |
167+
| setOpen | (state: boolean) => void | `undefined` | Optional. If defined, ActionMenu will use this to control the open/closed state of the Overlay instead of controlling the state internally. Should be used in conjunction with the `open` prop. |

0 commit comments

Comments
 (0)