Skip to content

Commit

Permalink
Migrate docs for deprecated React components (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron committed Jan 18, 2024
1 parent afb4833 commit d6f4467
Show file tree
Hide file tree
Showing 22 changed files with 1,102 additions and 68 deletions.
1 change: 1 addition & 0 deletions .markdownlint-cli2.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const options = githubMarkdownOpinions.init({
'ul-indent': false,
'no-hard-tabs': false,
'first-line-heading': false,
'no-space-in-code': false
})

module.exports = {
Expand Down
4 changes: 4 additions & 0 deletions content/components/action-bar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ railsIds:
import {Box, Text} from '@primer/react'
import ComponentLayout from '~/src/layouts/component-layout'
export default ComponentLayout
import {AccessibilityLink} from '~/src/components/accessibility-link'

## Usage

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

### Known accessibility issues (GitHub staff only)

<AccessibilityLink label="ActionBar"/>
4 changes: 2 additions & 2 deletions content/components/action-list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ railsIds:
- Primer::Alpha::ActionList
figmaId: action_list
description:
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent.
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent,
single-column format, with room for icons, descriptions, side information, and other rich visuals.
---

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

### Known accessibility issues (GitHub staff only)

<AccessibilityLink label="ActionList"/>
<AccessibilityLink label="ActionList"/>
144 changes: 144 additions & 0 deletions content/components/action-list/react/deprecated.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
title: Action list
reactId: action_list
reactStatus: deprecated
description:
Action list is a vertical list of interactive actions or options. It's composed of items presented in a consistent,
single-column format, with room for icons, descriptions, side information, and other rich visuals.
---

import {ComponentPageNav} from '~/src/components/component-page-nav'
import StatusMenu from '~/src/components/status-menu'
import {AccessibilityLabel, StatusLabel} from '@primer/gatsby-theme-doctocat'
import {Label} from '@primer/react'
import { graphql } from "gatsby"

export const query = graphql`
query {
primerReactVersion {
version
}
allReactComponent(filter: {componentId: {eq: "action_list"}}) {
nodes {
status
}
}
}
`

<Box style={{marginBottom: "24px"}}>
<ComponentPageNav
basePath="/components/action-list"
includeReact={true}
includeRails={true}
includeFigma={true}
current="react"
/>
</Box>

<Box style={{display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "25px"}}>
<Box style={{display: "flex", gap: "5px"}}>
<Label size="large">@primer/react@v{props.data.primerReactVersion.version}</Label>
<StatusLabel status="Deprecated" />
<AccessibilityLabel a11yReviewed={false} short={false} />
</Box>
<Box>
<StatusMenu currentStatus="deprecated" statuses={[...props.data.allReactComponent.nodes.map((reactComponent) => reactComponent.status), "deprecated"]} parentPath="/components/action-list/react" />
</Box>
</Box>

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`.

## Deprecation

Use the [new version of ActionList](/components/action-list/react) with composable API, design updates and accessibility fixes.

### Before

```jsx
<ActionList
items={[
{text: 'New file'},
{text: 'Copy link'},
{text: 'Edit file'},
ActionList.Divider,
{text: 'Delete file', variant: 'danger'},
]}
/>
```

### After

```jsx
<ActionList>
<ActionList.Item>New file</ActionList.Item>
<ActionList.Item>Copy link</ActionList.Item>
<ActionList.Item>Edit file</ActionList.Item>
<ActionList.Divider />
<ActionList.Item variant="danger">Delete file</ActionList.Item>
</ActionList>
```

Or continue using deprecated API:

```js
import {ActionList} from '@primer/react/deprecated'
```

## Minimal example

```jsx live deprecated
<ActionList
items={[
{text: 'New file'},
ActionList.Divider,
{text: 'Copy link'},
{text: 'Edit file'},
{text: 'Delete file', variant: 'danger'},
]}
/>
```

## Example with grouped items

```jsx live deprecated
<ActionList
groupMetadata={[
{groupId: '0'},
{groupId: '1', header: {title: 'Live query', variant: 'subtle'}},
{groupId: '2', header: {title: 'Layout', variant: 'subtle'}},
{groupId: '3'},
{groupId: '4'},
]}
items={[
{key: '1', leadingVisual: TypographyIcon, text: 'Rename', groupId: '0', trailingVisual: '⌘R'},
{key: '2', leadingVisual: VersionsIcon, text: 'Duplicate', groupId: '0'},
{key: '3', leadingVisual: SearchIcon, text: 'repo:github/github', groupId: '1'},
{
key: '4',
leadingVisual: NoteIcon,
text: 'Table',
description: 'Information-dense table optimized for operations across teams',
descriptionVariant: 'block',
groupId: '2',
},
{
key: '5',
leadingVisual: ProjectIcon,
text: 'Board',
description: 'Kanban-style board focused on visual states',
descriptionVariant: 'block',
groupId: '2',
},
{
key: '6',
leadingVisual: FilterIcon,
text: 'Save sort and filters to current view',
disabled: true,
groupId: '3',
},
{key: '7', leadingVisual: FilterIcon, text: 'Save sort and filters to new view', groupId: '3'},
{key: '8', leadingVisual: GearIcon, text: 'View settings', groupId: '4'},
]}
/>
```
167 changes: 167 additions & 0 deletions content/components/action-menu/react/deprecated.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
title: ActionMenu
reactId: action_menu
reactStatus: deprecated
description: Action menu is composed of action list and overlay patterns used for quick actions and selections.
---

import {ComponentPageNav} from '~/src/components/component-page-nav'
import StatusMenu from '~/src/components/status-menu'
import {AccessibilityLabel, StatusLabel} from '@primer/gatsby-theme-doctocat'
import {Label} from '@primer/react'
import { graphql } from "gatsby"

export const query = graphql`
query {
primerReactVersion {
version
}
allReactComponent(filter: {componentId: {eq: "action_menu"}}) {
nodes {
status
}
}
}
`

<Box style={{marginBottom: "24px"}}>
<ComponentPageNav
basePath="/components/action-menu"
includeReact={true}
includeRails={true}
includeFigma={true}
current="react"
/>
</Box>

<Box style={{display: "flex", justifyContent: "space-between", alignItems: "center", marginBottom: "25px"}}>
<Box style={{display: "flex", gap: "5px"}}>
<Label size="large">@primer/react@v{props.data.primerReactVersion.version}</Label>
<StatusLabel status="Deprecated" />
<AccessibilityLabel a11yReviewed={false} short={false} />
</Box>
<Box>
<StatusMenu currentStatus="deprecated" statuses={[...props.data.allReactComponent.nodes.map((reactComponent) => reactComponent.status), "deprecated"]} parentPath="/components/action-menu/react" />
</Box>
</Box>

An `ActionMenu` is an ActionList-based component for creating a menu of actions that expands through a trigger button.

## Deprecation

Use [new version of ActionMenu](/components/action-menu/react) with composable API, design updates and accessibility fixes.

### Before

```jsx
<ActionMenu
anchorContent="Menu"
onAction={fn}
items={[
{text: 'New file'},
{text: 'Copy link'},
{text: 'Edit file'},
ActionMenu.Divider,
{text: 'Delete file', variant: 'danger'},
]}
overlayProps={{width: 'small'}}
/>
```

### After

```jsx
<ActionMenu>
<ActionMenu.Button>Menu</ActionMenu.Button>
<ActionMenu.Overlay width="small">
<ActionList>
<ActionList.Item onSelect={fn}>New file</ActionList.Item>
<ActionList.Item>Copy link</ActionList.Item>
<ActionList.Item>Edit file</ActionList.Item>
<ActionList.Divider />
<ActionList.Item variant="danger">Delete file</ActionList.Item>
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
```

Or continue using deprecated API:

```js
import {ActionMenu} from '@primer/react/deprecated'
```

## Default example

```jsx live deprecated
<ActionMenu
anchorContent="Menu"
onAction={({text}) => console.log(text)}
items={[
{text: 'New file', key: 'new-file'},
ActionMenu.Divider,
{text: 'Copy link', key: 'copy-link'},
{text: 'Edit file', key: 'edit-file'},
{text: 'Delete file', variant: 'danger', key: 'delete-file'},
]}
/>
```

## Example with grouped items

```jsx live deprecated
<ActionMenu
anchorContent="Menu"
onAction={({text}) => console.log(text)}
groupMetadata={[
{groupId: '0'},
{groupId: '1', header: {title: 'Live query', variant: 'subtle'}},
{groupId: '2', header: {title: 'Layout', variant: 'subtle'}},
{groupId: '3'},
{groupId: '4'},
]}
items={[
{key: '1', leadingVisual: TypographyIcon, text: 'Rename', groupId: '0'},
{key: '2', leadingVisual: VersionsIcon, text: 'Duplicate', groupId: '0'},
{key: '3', leadingVisual: SearchIcon, text: 'repo:github/github', groupId: '1'},
{
key: '4',
leadingVisual: NoteIcon,
text: 'Table',
description: 'Information-dense table optimized for operations across teams',
descriptionVariant: 'block',
groupId: '2',
},
{
key: '5',
leadingVisual: ProjectIcon,
text: 'Board',
description: 'Kanban-style board focused on visual states',
descriptionVariant: 'block',
groupId: '2',
},
{
key: '6',
leadingVisual: FilterIcon,
text: 'Save sort and filters to current view',
disabled: true,
groupId: '3',
},
{key: '7', leadingVisual: FilterIcon, text: 'Save sort and filters to new view', groupId: '3'},
{key: '8', leadingVisual: GearIcon, text: 'View settings', groupId: '4'},
]}
/>
```

## Component props

| Name | Type | Default | Description |
| :------------ | :------------------------------------ | :---------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| items | `ItemProps[]` | `undefined` | Required. A list of item objects conforming to the `ActionList.Item` props interface. |
| 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. |
| groupMetadata | `GroupProps[]` | `undefined` | Optional. If defined, `ActionList` will group `items` into `ActionList.Group`s separated by `ActionList.Divider` according to their `groupId` property. |
| 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. |
| anchorContent | React.ReactNode | `undefined` | Optional. If defined, it will be passed to the trigger as the elements child. |
| 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. |
| 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. |
| 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. |
Loading

0 comments on commit d6f4467

Please sign in to comment.