Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/lemon-seals-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@launchpad-ui/components": patch
---

align popover padding for filtered collections
17 changes: 13 additions & 4 deletions packages/components/src/styles/Popover.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@

&[data-trigger='DialogTrigger'],
&[data-trigger='ComboBoxDialog'],
&[data-trigger='SubmenuTrigger'] {
padding: var(--lp-spacing-300);
&[data-trigger='DatePicker'],
&[data-trigger='DateRangePicker'] {
Comment on lines +41 to +42
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These missing bits meant the buttons sat flush against the popover's edges

padding: var(--lp-spacing-200);
}

&:has(input[type='search']):is(
[data-trigger='Select'],
[data-trigger='MenuTrigger'],
[data-trigger='SubmenuTrigger']
) {
padding: var(--lp-spacing-200);
}

&:is([data-trigger='DatePicker'], [data-trigger='DateRangePicker']) {
padding: var(--lp-spacing-300);
&[data-trigger='SubmenuTrigger']:has(div[role='application']) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one ensures a date(range)-picker in a submenu also has breathing room, consistent with the rest.

Calendars/date pickers / etc… don't have a direct WAI-ARIA role, and RAC uses role='application' for them. Based on what I read about that role, this felt reasonable: a widget with the "application" role is meant to be its own little UI, which makes me think that's a reasonable signal/differentiator in this context.

padding: var(--lp-spacing-200);
}

&[data-placement='top'] {
Expand Down
62 changes: 62 additions & 0 deletions packages/components/stories/Menu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import type { Selection as AriaSelection } from 'react-aria-components';

import { Icon } from '@launchpad-ui/icons';
import { useState } from 'react';
import { useFilter } from 'react-aria-components';
import { expect, fireEvent, userEvent, waitFor, within } from 'storybook/test';

import { Autocomplete as AutocompleteComponent } from '../src/Autocomplete';
import { Button } from '../src/Button';
import { Group } from '../src/Group';
import { Header } from '../src/Header';
import { IconButton } from '../src/IconButton';
import { Input } from '../src/Input';
import { Keyboard } from '../src/Keyboard';
import { Menu, MenuItem, MenuTrigger, SubmenuTrigger } from '../src/Menu';
import { Popover } from '../src/Popover';
import { Pressable } from '../src/Pressable';
import { SearchField } from '../src/SearchField';
import { MenuSection } from '../src/Section';
import { Separator } from '../src/Separator';
import { Text } from '../src/Text';
Expand Down Expand Up @@ -336,3 +342,59 @@ export const CustomTrigger: Story = {
},
...open,
};

export const Autocomplete: Story = {
render: (args) => {
const { contains } = useFilter({ sensitivity: 'base' });

return (
<MenuTrigger>
<Button>Trigger</Button>
<Popover>
<AutocompleteComponent filter={contains}>
<SearchField aria-label="search" autoFocus>
<Group>
<Icon name="search" size="small" />
<Input placeholder="Search" />
<IconButton
icon="cancel-circle-outline"
aria-label="clear"
size="small"
variant="minimal"
/>
</Group>
</SearchField>
<Menu {...args}>
<MenuItem>Item one</MenuItem>
<MenuItem>Item two</MenuItem>
<MenuItem>Item three</MenuItem>
<SubmenuTrigger>
<MenuItem>Item four</MenuItem>
<Popover>
<AutocompleteComponent filter={contains}>
<SearchField aria-label="search" autoFocus>
<Group>
<Icon name="search" size="small" />
<Input placeholder="Search" />
<IconButton
icon="cancel-circle-outline"
aria-label="clear"
size="small"
variant="minimal"
/>
</Group>
</SearchField>
<Menu {...args}>
<MenuItem>Item five</MenuItem>
<MenuItem>Item six</MenuItem>
</Menu>
</AutocompleteComponent>
</Popover>
</SubmenuTrigger>
</Menu>
</AutocompleteComponent>
</Popover>
</MenuTrigger>
);
},
};
44 changes: 44 additions & 0 deletions packages/components/stories/Select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import type { ComponentType } from 'react';

import { Icon } from '@launchpad-ui/icons';
import { vars } from '@launchpad-ui/vars';
import { useFilter } from 'react-aria-components';
import { expect, userEvent, within } from 'storybook/test';

import { Autocomplete as AutocompleteComponent } from '../src/Autocomplete';
import { Button } from '../src/Button';
import { Group } from '../src/Group';
import { IconButton } from '../src/IconButton';
import { Input } from '../src/Input';
import { Label } from '../src/Label';
import { ListBox, ListBoxItem } from '../src/ListBox';
import { Popover } from '../src/Popover';
import { SearchField } from '../src/SearchField';
import { Select, SelectValue } from '../src/Select';
import { Text } from '../src/Text';

Expand Down Expand Up @@ -158,3 +164,41 @@ export const States: Story = {
await userEvent.tab();
},
};

export const Autocomplete: Story = {
render: (args) => {
const { contains } = useFilter({ sensitivity: 'base' });

return (
<Select {...args}>
<Label>Label</Label>
<Button>
<SelectValue />
<Icon name="chevron-down" size="small" />
</Button>
<Text slot="description">Description</Text>
<Popover>
<AutocompleteComponent filter={contains}>
<SearchField aria-label="search" autoFocus>
<Group>
<Icon name="search" size="small" />
<Input placeholder="Search" />
<IconButton
icon="cancel-circle-outline"
aria-label="clear"
size="small"
variant="minimal"
/>
</Group>
</SearchField>
<ListBox>
<ListBoxItem>Item one</ListBoxItem>
<ListBoxItem>Item two</ListBoxItem>
<ListBoxItem>Item three</ListBoxItem>
</ListBox>
</AutocompleteComponent>
</Popover>
</Select>
);
},
};
Loading