Skip to content

Commit

Permalink
Prefix component with types exported from ActionList2 and ActionMenu2 (
Browse files Browse the repository at this point in the history
…#1883)

* prefix component name to types

* add changeset

* Update .changeset/actionlist2-actionmenu2-prefix-types.md

Co-authored-by: Cole Bemis <colebemis@github.com>

Co-authored-by: Cole Bemis <colebemis@github.com>
  • Loading branch information
2 people authored and mperrotti committed Feb 25, 2022
1 parent 728410a commit 0c2ca6e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .changeset/actionlist2-actionmenu2-prefix-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@primer/react': major
---

`ActionList2` exported types are now prefixed with `ActionList`:

```
ListProps → ActionListProps
GroupProps → ActionListGroupProps
ItemProps → ActionListItemProps
DescriptionProps → ActionListDescriptionProps
LeadingVisualProps → ActionListLeadingVisualProps,
TrailingVisualProps → ActionListTrailingVisualProps
```

`ActionMenu2` exported types are now prefixed with `ActionMenu`:

```
MenuButtonProps → ActionMenuButtonProps
MenuAnchorProps → ActionMenuAnchorProps
```
11 changes: 7 additions & 4 deletions src/ActionList2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import {Description} from './Description'
import {LeadingVisual, TrailingVisual} from './Visuals'

export type {ListProps as ActionListProps} from './List'
export type {GroupProps} from './Group'
export type {ItemProps} from './Item'
export type {DescriptionProps} from './Description'
export type {LeadingVisualProps, TrailingVisualProps} from './Visuals'
export type {GroupProps as ActionListGroupProps} from './Group'
export type {ItemProps as ActionListItemProps} from './Item'
export type {DescriptionProps as ActionListDescriptionProps} from './Description'
export type {
LeadingVisualProps as ActionListLeadingVisualProps,
TrailingVisualProps as ActionListTrailingVisualProps
} from './Visuals'

/**
* Collection of list-related components.
Expand Down
6 changes: 3 additions & 3 deletions src/ActionMenu2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ const Menu: React.FC<ActionMenuProps> = ({
)
}

export type MenuAnchorProps = {children: React.ReactElement}
const Anchor = React.forwardRef<AnchoredOverlayProps['anchorRef'], MenuAnchorProps>(
export type ActionMenuAnchorProps = {children: React.ReactElement}
const Anchor = React.forwardRef<AnchoredOverlayProps['anchorRef'], ActionMenuAnchorProps>(
({children, ...anchorProps}, anchorRef) => {
return React.cloneElement(children, {...anchorProps, ref: anchorRef})
}
)

/** this component is syntactical sugar 🍭 */
export type MenuButtonProps = ButtonProps
export type ActionMenuButtonProps = ButtonProps
const MenuButton = React.forwardRef<AnchoredOverlayProps['anchorRef'], ButtonProps>((props, anchorRef) => {
return (
<Anchor ref={anchorRef}>
Expand Down

0 comments on commit 0c2ca6e

Please sign in to comment.