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
5 changes: 5 additions & 0 deletions .changeset/actionmenu-button-caret-spacing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

ActionMenu.Button: Fix spacing between text and caret
28 changes: 21 additions & 7 deletions src/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Divider} from './ActionList/Divider'
import {ActionListContainerContext} from './ActionList/ActionListContainerContext'
import {Button, ButtonProps} from './Button'
import {MandateProps} from './utils/types'
import {SxProp, merge} from './sx'

type MenuContextProps = Pick<
AnchoredOverlayProps,
Expand Down Expand Up @@ -73,13 +74,26 @@ const Anchor = React.forwardRef<AnchoredOverlayProps['anchorRef'], ActionMenuAnc

/** this component is syntactical sugar 🍭 */
export type ActionMenuButtonProps = ButtonProps
const MenuButton = React.forwardRef<AnchoredOverlayProps['anchorRef'], ButtonProps>((props, anchorRef) => {
return (
<Anchor ref={anchorRef}>
<Button trailingIcon={TriangleDownIcon} type="button" {...props} />
</Anchor>
)
})
const MenuButton = React.forwardRef<AnchoredOverlayProps['anchorRef'], ButtonProps>(
({sx: sxProp = {}, ...props}, anchorRef) => {
return (
<Anchor ref={anchorRef}>
<Button
type="button"
trailingIcon={TriangleDownIcon}
sx={merge(
{
// override the margin on caret for optical alignment
'[data-component=trailingIcon]': {marginX: -1}
},
sxProp as SxProp
)}
{...props}
/>
</Anchor>
)
}
)

type MenuOverlayProps = Partial<OverlayProps> & {
/**
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/__snapshots__/ActionMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ exports[`ActionMenu renders consistently 1`] = `
box-shadow: inset 0 0.15em 0.3em rgba(27,31,36,0.15);
}

.c1 [data-component=trailingIcon] {
margin-left: -4px;
margin-right: -4px;
}

<div
className="c0"
color="fg.default"
Expand Down