Skip to content

Commit

Permalink
fix(dropdown): fix alignment
Browse files Browse the repository at this point in the history
Also fix position of toolbar dropdown
  • Loading branch information
clementprevot committed Mar 26, 2024
1 parent 6179738 commit f11cfcc
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ export const Autocomplete = forwardRef<CombinedRefs, AutocompleteProps>(

<Dropdown
ref={dropdownRef}
align="end"
disabled={disabled}
dropdown={{
align: 'end',
className: cn(
`${PREFIX}-${GROUP_NAME}__dropdown`,
dropdown.className,
Expand Down
2 changes: 1 addition & 1 deletion packages/fractal/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ perfectionist/sort-objects */
{isOpen && (
<RxDropdown.Content
ref={dropdownRef}
align={align ?? withIndicator ? 'end' : 'center'}
align={align || (withIndicator ? 'end' : 'center')}
asChild
className={cn(
`${PREFIX}-${GROUP_NAME}__dropdown`,
Expand Down
2 changes: 1 addition & 1 deletion packages/fractal/src/components/Dropdown/Dropdown.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export interface DropdownProps extends AllHTMLAttributes<HTMLDivElement> {
* option;
* - a number: the width of the dropdown will be the number of pixels
* provided.
* - '*<number>' (a number prefixed with the '*' character): the width of
* - '*number' (a number prefixed with the '*' character): the width of
* the popover will be the provided fraction of the width of the trigger.
* For example '*0.5' will make the popover width half the width of the
* trigger.
Expand Down
2 changes: 1 addition & 1 deletion packages/fractal/src/components/Popover/Popover.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface PopoverProps extends AllHTMLAttributes<HTMLDivElement> {
* - '*<number>': the width of the popover will be the provided fraction of
* the width of the trigger. For example '*0.5' will make the popover
* width half the width of the trigger.
* - '*<number>' (a number prefixed with the '*' character): the width of
* - '*number' (a number prefixed with the '*' character): the width of
* the popover will be the provided fraction of the width of the trigger.
* For example '*0.5' will make the popover width half the width of the
* trigger.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ const mixedMenu = (

const meta: Meta<ToolbarDropdownProps> = {
argTypes: {
align: {
control: 'radio',
mapping: {
Auto: undefined,
Center: 'center',
End: 'end',
Start: 'start',
},
options: ['Auto', 'Start', 'Center', 'End'],
},
children: {
control: 'radio',
mapping: {
Expand Down Expand Up @@ -97,6 +107,17 @@ const meta: Meta<ToolbarDropdownProps> = {
},
options: ['None', 'Cancel', 'Check', 'Error', 'Send', 'Star'],
},
side: {
control: 'radio',
mapping: {
Auto: undefined,
Bottom: 'bottom',
Left: 'left',
Right: 'right',
Top: 'top',
},
options: ['Auto', 'Top', 'Right', 'Bottom', 'Left'],
},
width: {
control: 'radio',
options: [
Expand All @@ -115,6 +136,7 @@ const meta: Meta<ToolbarDropdownProps> = {
},
args: {
active: false,
align: undefined,
children: 'Text',
defaultOpen: false,
disabled: false,
Expand All @@ -125,6 +147,7 @@ const meta: Meta<ToolbarDropdownProps> = {
iconPosition: 'left',
label: 'Star wars characters',
open: false,
side: undefined,
width: 'fit',
withIndicator: true,
},
Expand Down
6 changes: 5 additions & 1 deletion packages/fractal/src/components/Toolbar/ToolbarDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ToolbarDropdown = forwardRef<
aria-label={label}
className={cn(
`${PREFIX}-${GROUP_NAME}__dropdown`,
`group h-3 max-h-3 rounded-xs [&_.fractal-dropdown\\\\_\\\\_trigger\\\\_\\\\_indicator>svg]:size-one-and-half`,
'group h-3 max-h-3 rounded-xs',
// eslint-disable-next-line no-nested-ternary
isOpen && !isDisabled
? 'text-dark'
Expand All @@ -72,6 +72,10 @@ export const ToolbarDropdown = forwardRef<
)}
condensed
disabled={isDisabled}
dropdown={{
className:
'data-[side="bottom"]:mt-2 data-[side="top"]:mb-2 data-[side="right"]:ml-[calc(theme(spacing.2)+theme(spacing.half))] data-[side="left"]:mr-[calc(theme(spacing.2)+theme(spacing.half))]',
}}
elevation={elevation}
title={label}
trigger={
Expand Down

0 comments on commit f11cfcc

Please sign in to comment.