Skip to content

Commit

Permalink
Removed support for dividers in Listbox as this is not accessible (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
fraincs authored Sep 18, 2024
2 parents 6e7f2f0 + 90945f7 commit 528a132
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changeset/rude-buckets-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hopper-ui/components": patch
---

Removed support for dividers in Listbox as this is not accessible
4 changes: 2 additions & 2 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withHopperProvider, viewport } from "@hopper-ui/storybook-addon";
import { viewport, withHopperProvider } from "@hopper-ui/storybook-addon";
import {
Description,
Stories,
Expand All @@ -7,8 +7,8 @@ import {
} from "@storybook/blocks";
import type { Preview } from "@storybook/react";

import "./stories.css";
import "@hopper-ui/tokens/fonts.css";
import "./stories.css";

const preview: Preview = {
parameters: {
Expand Down
7 changes: 0 additions & 7 deletions apps/docs/content/components/collections/Listbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ The Section component represents a `section` within a Hopper container.

- [Header](./Listbox#header)
- [Section](./Listbox#section)
- [Divider](./Divider)
- [ListBoxItem](./Listbox#listboxitem)


Expand Down Expand Up @@ -90,12 +89,6 @@ A fluid list box will take up the full width of its container.

<Example src="ListBox/docs/fluid" />

### Divider

Dividers can be added to a list box.

<Example src="ListBox/docs/divider" />

### Section

A list box can have sections and section headers.
Expand Down
44 changes: 9 additions & 35 deletions packages/components/src/ListBox/docs/ListBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { type Selection, Collection } from "react-aria-components";
import { useAsyncList } from "react-stately";

import { Badge } from "../../Badge/index.ts";
import { Divider } from "../../Divider/index.ts";
import { Header } from "../../Header/index.ts";
import { IconList } from "../../IconList/index.ts";
import { Inline } from "../../layout/index.ts";
Expand All @@ -14,8 +13,8 @@ import { Text } from "../../typography/Text/index.ts";
import { ListBox, ListBoxItem } from "../src/index.ts";

/**
* A ListBox is a disclosure component that appears with a set of actions relevant to a specific control, interface area, data element or application view.
* Typically, this context is determined by the user’s current selection prior to invoking the menu.
* A ListBox is a disclosure component that appears with a set of actions relevant to a specific control, interface area, data element or application view.
* Typically, this context is determined by the user’s current selection prior to invoking the menu.
* Listbox can be opened from components such as Selects or Buttons.
*
* [View repository](https://github.com/gsoft-inc/wl-hopper/tree/main/packages/components/src/ListBox/src)
Expand Down Expand Up @@ -130,7 +129,7 @@ export const SingleSelection = {
}
} satisfies Story;

/**
/**
* A ListBox can have a different selection indicator for single select.
* By default, disallowEmptySelection is set to true when the selection indicator is a radio button.
*/
Expand All @@ -150,7 +149,7 @@ export const MultipleSelection = {
const [selectedKeys, setSelectedKeys] = useState<Selection>(new Set(["1"]));

return (
<ListBox {...args}
<ListBox {...args}
aria-label="list of options"
selectedKeys={selectedKeys}
onSelectionChange={setSelectedKeys}
Expand All @@ -175,7 +174,7 @@ export const MultipleSelection = {
}
} satisfies Story;

/**
/**
* A ListBox can have a different selection indicator for multiple select .
*/
export const MultipleSelectionIndicator = {
Expand Down Expand Up @@ -358,7 +357,7 @@ export const Sections = {
<ListBoxItem>Item 3</ListBoxItem>
<ListBoxItem>Item 4</ListBoxItem>
<ListBoxItem>Item 5</ListBoxItem>
<Section>
<Section >
<Header>More Items</Header>
<ListBoxItem>Item 6</ListBoxItem>
<ListBoxItem>Item 7</ListBoxItem>
Expand All @@ -383,33 +382,8 @@ export const Sections = {
}
} satisfies Story;

/**
* Dividers can be added to a ListBox
*/
export const Dividers = {
render: args => {
return (
<ListBox {...args} aria-label="list of options">
<ListBoxItem>Item 1</ListBoxItem>
<ListBoxItem>Item 2</ListBoxItem>
<ListBoxItem>Item 3</ListBoxItem>
<ListBoxItem>Item 4</ListBoxItem>
<ListBoxItem>Item 5</ListBoxItem>
<Divider />
<ListBoxItem>Item 7</ListBoxItem>
<ListBoxItem>Item 8</ListBoxItem>
<ListBoxItem>Item 9</ListBoxItem>
<ListBoxItem>Item 10</ListBoxItem>
</ListBox>
);
},
args: {
selectionMode: "single"
}
} satisfies Story;

/**
* Items and sections can be populated from a hierarchial data structure.
* Items and sections can be populated from a hierarchial data structure.
* If a section has a header, the `Collection` component can be used to render the child items.
*/
export const DynamicLists = {
Expand Down Expand Up @@ -445,7 +419,7 @@ export const DynamicLists = {
>
{item => {
const listItem = item as ListItemProps;

return <ListBoxItem id={listItem.name}>{listItem.name}</ListBoxItem>;
}}
</ListBox>
Expand Down Expand Up @@ -549,4 +523,4 @@ export const Empty = {
</ListBox>
);
}
} satisfies Story;
} satisfies Story;
13 changes: 2 additions & 11 deletions packages/components/src/ListBox/src/ListBox.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
--hop-ListBox-section-margin-block: var(--hop-space-stack-sm);
--hop-ListBox-section-margin-inline: calc(-1 * var(--hop-ListBox-padding-inline));
--hop-ListBox-section-border-size: var(--hop-ListBox-border-size);
--hop-ListBox-section-border-color: var(--hop-ListBox-border-color);
--hop-ListBox-section-border-color: var(--hop-ListBox-border-color);

/* Section Header */
--hop-ListBox-section-header-color: var(--hop-neutral-text-weak);
Expand All @@ -34,10 +34,6 @@
--hop-ListBox-section-header-top-offset: var(--hop-overline-top-offset);
--hop-ListBox-section-header-bottom-offset: var(--hop-overline-bottom-offset);

/* Divider */
--hop-ListBox-divider-margin-block: var(--hop-space-stack-sm);
--hop-ListBox-divider-margin-inline: calc(-1 * var(--hop-ListBox-padding-inline));

/* Internal Variables */
--max-width: var(--hop-ListBox-max-width);
--width: var(--hop-ListBox-width);
Expand Down Expand Up @@ -80,7 +76,7 @@
/* Select section that follows an item */
.hop-ListBox__item + .hop-ListBox__section {
--section-margin-block-start: var(--hop-ListBox-section-margin-block);
--section-border-block-start: var(--hop-ListBox-section-border-size) solid var(--hop-ListBox-section-border-color);
--section-border-block-start: var(--hop-ListBox-section-border-size) solid var(--hop-ListBox-section-border-color);
}

/* Select section that has an item right after */
Expand Down Expand Up @@ -130,8 +126,3 @@
/* -0.25rem */
margin-block-start: var(--hop-ListBox-section-header-top-offset);
}

.hop-ListBox__divider {
margin-block: var(--hop-ListBox-divider-margin-block);
margin-inline: var(--hop-ListBox-divider-margin-inline);
}

0 comments on commit 528a132

Please sign in to comment.