Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dropdown item padding #5024

Merged
merged 1 commit into from
Mar 5, 2024
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
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 />,
},
};
Loading