Skip to content

Commit

Permalink
fix: v2/SimpleMenu - IconButton trigger style props
Browse files Browse the repository at this point in the history
  • Loading branch information
Udi Silvestre committed Oct 25, 2023
1 parent 8f02ce1 commit e305a0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/strapi-design-system/src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
},
);

IconButton.displayName = 'IconButton';

const IconButtonWrapper = styled(BaseButton)<Required<Pick<IconButtonProps, 'size' | 'variant'>>>`
background-color: ${({ theme, variant }) => {
if (variant === VARIANT_SECONDARY) {
Expand Down Expand Up @@ -210,3 +212,5 @@ export const IconButtonGroup = styled(Flex)`
}
}
`;

IconButtonGroup.displayName = 'IconButtonGroup';
14 changes: 10 additions & 4 deletions packages/strapi-design-system/src/v2/SimpleMenu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,23 @@ interface TriggerProps extends ButtonProps {}

const MenuTrigger = forwardRef<HTMLButtonElement, TriggerProps>(
({ size, endIcon = <CarretDown width={`${6 / 16}rem`} height={`${4 / 16}rem`} aria-hidden />, ...props }, ref) => {
const isSizeS = size === 'S';
const isIconButton = (props.as as any)?.displayName === 'IconButton';
const paddingY = isSizeS ? 1 : 2;
const paddingX = isSizeS ? 3 : 4;

return (
<DropdownMenu.Trigger asChild>
<Button
ref={ref}
type="button"
variant="ghost"
endIcon={endIcon}
paddingTop={size === 'S' ? 1 : 2}
paddingBottom={size === 'S' ? 1 : 2}
paddingLeft={size === 'S' ? 3 : 4}
paddingRight={size === 'S' ? 3 : 4}
paddingTop={isIconButton ? '0' : paddingY}
paddingBottom={isIconButton ? '0' : paddingY}
paddingLeft={isIconButton ? '0' : paddingX}
paddingRight={isIconButton ? '0' : paddingX}
justifyContent={isIconButton ? 'center' : undefined}
{...props}
/>
</DropdownMenu.Trigger>
Expand Down

0 comments on commit e305a0e

Please sign in to comment.