Skip to content
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
2 changes: 1 addition & 1 deletion .changeset/deprecate-actionlistv1-promote-actionlistv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ See full list of props and examples: https://primer.style/react/ActionList

<ActionList.Group title="Layout">
<ActionList.Item>Table</ActionList.Item>
<ActionList.Item>Board Description></ActionList.Item>
<ActionList.Item>Board Description</ActionList.Item>
</ActionList.Group>
<ActionList.Divider />

Expand Down
2 changes: 1 addition & 1 deletion .changeset/empty-pillows-hunt.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ See full list of props and examples: https://primer.style/react/ActionList

<ActionList.Group title="Layout">
<ActionList.Item>Table</ActionList.Item>
<ActionList.Item>Board Description></ActionList.Item>
<ActionList.Item>Board Description</ActionList.Item>
</ActionList.Group>
<ActionList.Divider />

Expand Down
73 changes: 39 additions & 34 deletions .changeset/smooth-cameras-prove.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,47 +67,52 @@ See [https://primer.style/react/ActionMenu](https://primer.style/react/ActionMen
```jsx
const fieldTypes = [
{leadingVisual: TypographyIcon, text: 'Text'},
{leadingVisual: NumberIcon, text: 'Number'},
];

const [selectedItem, setSelectedItem] = React.useState()

<DropdownMenu
renderAnchor={({children, ...anchorProps}) => (
<ButtonInvisible {...anchorProps}>
{children}
</ButtonInvisible>
)}
placeholder="Select a field type"
items={fieldTypes}
selectedItem={selectedItem}
onChange={() => setSelectedIndex(index)}
/>
{leadingVisual: NumberIcon, text: 'Number'}
]

const Example = () => {
const [selectedItem, setSelectedItem] = React.useState()

return (
<DropdownMenu
renderAnchor={({children, ...anchorProps}) => <ButtonInvisible {...anchorProps}>{children}</ButtonInvisible>}
placeholder="Select a field type"
items={fieldTypes}
selectedItem={selectedItem}
onChange={() => setSelectedIndex(index)}
/>
)
}
```

</td>
<td valign="top">

```jsx
const fieldTypes = [
{icon: <TypographyIcon/>, name: 'Text'},
{icon: <NumberIcon/>, name: 'Number'},
];

const [selectedItem, setSelectedItem] = React.useState()

<ActionMenu>
<ActionMenu.Button>{selectedItem ? selectedItem.name : 'Select a field type'}</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList selectionVariant="single">
{fieldTypes.map(field => (
<ActionList.Item onSelect={() => setSelectedItem(field)} key={field.name}>
<ActionList.LeadingVisual>{field.icon}</ActionList.LeadingVisual>
{field.name}
</ActionList.Item>
<ActionList>
</ActionMenu.Overlay>
<ActionMenu>
{icon: <TypographyIcon />, name: 'Text'},
{icon: <NumberIcon />, name: 'Number'}
]

const Example = () => {
const [selectedItem, setSelectedItem] = React.useState()

return (
<ActionMenu>
<ActionMenu.Button>{selectedItem ? selectedItem.name : 'Select a field type'}</ActionMenu.Button>
<ActionMenu.Overlay>
<ActionList selectionVariant="single">
{fieldTypes.map(field => (
<ActionList.Item onSelect={() => setSelectedItem(field)} key={field.name}>
<ActionList.LeadingVisual>{field.icon}</ActionList.LeadingVisual>
{field.name}
</ActionList.Item>
))}
</ActionList>
</ActionMenu.Overlay>
</ActionMenu>
)
}
```

</td>
Expand Down