Skip to content

Commit

Permalink
Add suffix to checkbox / radio items
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed May 9, 2023
1 parent bf73a7c commit 52e1152
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/components/src/ui/radix-dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ export const DropdownMenuItem = forwardRef(
export const DropdownMenuCheckboxItem = ( {
children,
checked = false,
suffix,
...props
}: DropdownMenuPrimitive.DropdownMenuCheckboxItemProps ) => {
}: DropdownMenuCheckboxItemProps ) => {
return (
<DropdownMenuStyled.CheckboxItem { ...props } checked={ checked }>
<DropdownMenuStyled.ItemPrefixWrapper>
Expand All @@ -183,6 +184,11 @@ export const DropdownMenuCheckboxItem = ( {
</DropdownMenuPrimitive.ItemIndicator>
</DropdownMenuStyled.ItemPrefixWrapper>
{ children }
{ suffix && (
<DropdownMenuStyled.ItemSuffixWrapper>
{ suffix }
</DropdownMenuStyled.ItemSuffixWrapper>
) }
</DropdownMenuStyled.CheckboxItem>
);
};
Expand All @@ -199,6 +205,7 @@ const radioDot = (

export const DropdownMenuRadioItem = ( {
children,
suffix,
...props
}: DropdownMenuRadioItemProps ) => {
return (
Expand All @@ -213,6 +220,11 @@ export const DropdownMenuRadioItem = ( {
</DropdownMenuPrimitive.ItemIndicator>
</DropdownMenuStyled.ItemPrefixWrapper>
{ children }
{ suffix && (
<DropdownMenuStyled.ItemSuffixWrapper>
{ suffix }
</DropdownMenuStyled.ItemSuffixWrapper>
) }
</DropdownMenuStyled.RadioItem>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const CheckboxItemsGroup = () => {
<DropdownMenuCheckboxItem
checked={ bookmarksChecked }
onCheckedChange={ setBookmarksChecked }
suffix={ <KeyboardShortcut>⌘+B</KeyboardShortcut> }
>
Show Bookmarks
</DropdownMenuCheckboxItem>
Expand Down

0 comments on commit 52e1152

Please sign in to comment.