Skip to content

Commit

Permalink
fix: dropdown item padding
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie authored and pete-watters committed Mar 5, 2024
1 parent 95278ac commit f24f0a2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 15 deletions.
13 changes: 8 additions & 5 deletions src/app/ui/components/dowpdown-menu/dropdown-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ const Label: typeof RadixDropdownMenu.Label = forwardRef((props, ref) => (
<RadixDropdownMenu.Label className={dropdownMenuLabelStyles} ref={ref} {...props} />
));

const dropdownItemStyles = css({ p: 'space.03' });
const Item: typeof RadixDropdownMenu.Item = forwardRef((props, ref) => (
<RadixDropdownMenu.Item
className={css(itemBaseStyles, itemInteractiveStyles)}
ref={ref}
{...props}
/>
<styled.div className={dropdownItemStyles}>
<RadixDropdownMenu.Item
ref={ref}
className={css(itemBaseStyles, itemInteractiveStyles)}
{...props}
/>
</styled.div>
));

const dropdownMenuSeparatorStyles = css({
Expand Down
79 changes: 69 additions & 10 deletions src/app/ui/components/item/item-interactive.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meta, StoryObj } from '@storybook/react';
import { styled } from 'leather-styles/jsx';

import { BtcAvatarIcon } from '@app/ui/components/avatar/btc-avatar-icon';
import { CopyIcon } from '@app/ui/icons/copy-icon';
Expand All @@ -21,19 +22,31 @@ const meta: Meta<typeof Component> = {
export default meta;
type Story = StoryObj<typeof Component>;

function ExampleInteractiveItemContent() {
return (
<ItemLayout
showChevron
flagImg={<BtcAvatarIcon />}
titleLeft="Label"
captionLeft="Caption"
titleRight="1,000.00 ABC"
captionRight="$1,000.00"
/>
);
}

export const ItemInteractive: Story = {
parameters: {
docs: {
description: {
story:
'`InteractiveItem` has its hover state applied with a before pseudo element, so the content aligns independently from its hover state background.',
},
},
},
args: {
onClick: () => {},
children: (
<ItemLayout
showChevron
flagImg={<BtcAvatarIcon />}
titleLeft="Label"
captionLeft="Caption"
titleRight="1,000.00 ABC"
captionRight="$1,000.00"
/>
),
children: <ExampleInteractiveItemContent />,
},
};

Expand Down Expand Up @@ -71,3 +84,49 @@ export const WithButtons: Story = {
),
},
};

export const AlignmentExample: Story = {
parameters: {
docs: {
description: {
story: 'Demonstrates the component alignment in combination with its hover state',
},
},
},
decorators: [
Story => (
<styled.div borderLeft="2px solid" borderColor="red.background-secondary" py="space.06">
<styled.h1 textStyle="heading.04" mb="space.04">
Left aligned header
</styled.h1>
<Story />
</styled.div>
),
],
args: {
onClick: () => {},
children: <ExampleInteractiveItemContent />,
},
};

export const WithPadding: Story = {
parameters: {
docs: {
description: {
story:
"In some layouts, it's necessary to contain the bounds of the element's pseudo element hover background. Wrap the component in a div with padding `space.03` to achieve this",
},
},
},
decorators: [
Story => (
<styled.div border="2px solid" borderColor="red.background-secondary" p="space.03">
<Story />
</styled.div>
),
],
args: {
onClick: () => {},
children: <ExampleInteractiveItemContent />,
},
};

0 comments on commit f24f0a2

Please sign in to comment.