diff --git a/packages/gamut/src/DataList/Controls/ExpandControl.tsx b/packages/gamut/src/DataList/Controls/ExpandControl.tsx index 657fc45c57e..20123a3d1b4 100644 --- a/packages/gamut/src/DataList/Controls/ExpandControl.tsx +++ b/packages/gamut/src/DataList/Controls/ExpandControl.tsx @@ -34,7 +34,7 @@ export const ExpandControl: React.FC = ({ aria-expanded={expanded} > - + diff --git a/packages/gamut/src/Disclosure/index.tsx b/packages/gamut/src/Disclosure/index.tsx index eae846c22b2..aa2b9a78a38 100644 --- a/packages/gamut/src/Disclosure/index.tsx +++ b/packages/gamut/src/Disclosure/index.tsx @@ -29,36 +29,37 @@ export const Disclosure: React.FC = ({ variant, }) => { const [isExpanded, setIsExpanded] = useState(initiallyExpanded); + return ( onClick?.()} - as={isListItem ? 'li' : undefined} + variant={variant} > {isExpanded && ( )} diff --git a/packages/gamut/src/Drawer/index.tsx b/packages/gamut/src/Drawer/index.tsx index 36796f6078e..44d9d958934 100644 --- a/packages/gamut/src/Drawer/index.tsx +++ b/packages/gamut/src/Drawer/index.tsx @@ -15,7 +15,6 @@ export interface DrawerProps extends Omit { * Whether the drawer should be open. */ expanded?: boolean; - /** * Which edge of the drawer content container is aligned to during the animation. */ @@ -23,9 +22,9 @@ export interface DrawerProps extends Omit { } export const Drawer: React.FC = ({ + alignContentContainer = 'right', children, expanded, - alignContentContainer = 'right', ...props }) => { const drawerRef = useRef(null); @@ -41,7 +40,6 @@ export const Drawer: React.FC = ({ {expanded ? ( = ({ + bg = 'background', children, closeLabel = 'Close', expanded, openFrom = 'left', onClose, title, - bg = 'background', }) => { return ( = ({ > = ({ const tip = ( clickHandler()} diff --git a/packages/styleguide/src/lib/Atoms/Drawer/Drawer.mdx b/packages/styleguide/src/lib/Atoms/Drawer/Drawer.mdx index cb78a1e64be..7c0221cf2c7 100644 --- a/packages/styleguide/src/lib/Atoms/Drawer/Drawer.mdx +++ b/packages/styleguide/src/lib/Atoms/Drawer/Drawer.mdx @@ -34,6 +34,28 @@ An example of a molecule that uses Drawer is the F Our Drawers are [controlled components](https://reactjs.org/docs/forms.html#controlled-components), so their checked value must be controlled by an external state passed in as `expanded`. +The component that toggles the `Drawer` should include the `aria-expanded` attribute. The `aria-expanded` attribute should reflect the value of the `expanded` prop passed to the `Drawer`. In the example below, the `StrokeButton` controls the expansion of the `Drawer`, so the button has the `aria-expanded` attribute. + +```tsx +const ExampleDrawer: React.FC = () => { + const [expanded, setExpanded] = useState(false); + + return ( + + + Example Drawer + + setExpanded((previousExpanded) => !previousExpanded)} + > + Set the proper aria-labels! + + + ); +}; +``` + ## Playground diff --git a/packages/styleguide/src/lib/Atoms/Drawer/Drawer.stories.tsx b/packages/styleguide/src/lib/Atoms/Drawer/Drawer.stories.tsx index acfb94e4bcd..1e189305290 100644 --- a/packages/styleguide/src/lib/Atoms/Drawer/Drawer.stories.tsx +++ b/packages/styleguide/src/lib/Atoms/Drawer/Drawer.stories.tsx @@ -15,6 +15,7 @@ export const Default: React.FC = () => { Drawer content in here! setExpanded((previousExpanded) => !previousExpanded)} > Toggle Drawer diff --git a/packages/styleguide/src/lib/Molecules/Flyout/Flyout.mdx b/packages/styleguide/src/lib/Molecules/Flyout/Flyout.mdx index 81c1bb925bb..89afe953e0d 100644 --- a/packages/styleguide/src/lib/Molecules/Flyout/Flyout.mdx +++ b/packages/styleguide/src/lib/Molecules/Flyout/Flyout.mdx @@ -28,7 +28,29 @@ On button click, a container animates in from the left or right side of the wind Internally, Flyout is a combination of Overlay and Drawer. -Our Flyouts are [controlled components](https://reactjs.org/docs/forms.html#controlled-components), so their checked value must be controlled by an external state passed in as `expanded` and `onChange`: +Our Flyouts are [controlled components](https://reactjs.org/docs/forms.html#controlled-components), so their checked value must be controlled by an external state passed in as `expanded` and `onChange`. + +The component that toggles the `Flyout` should include the `aria-expanded` attribute. The `aria-expanded` attribute should reflect the value of the `expanded` prop passed to the `Flyout`. In the example below, the `StrokeButton` controls the expansion of the `Flyout`, so the button has the `aria-expanded` attribute. + +```tsx +const ExampleFlyout: React.FC = () => { + const [expanded, setExpanded] = useState(false); + + return ( + + + Example Flyout + + setExpanded((previousExpanded) => !previousExpanded)} + > + Set the proper aria-labels! + + + ); +}; +``` ## Playground diff --git a/packages/styleguide/src/lib/Molecules/Flyout/Flyout.stories.tsx b/packages/styleguide/src/lib/Molecules/Flyout/Flyout.stories.tsx index 0d7d229340e..c373b010c93 100644 --- a/packages/styleguide/src/lib/Molecules/Flyout/Flyout.stories.tsx +++ b/packages/styleguide/src/lib/Molecules/Flyout/Flyout.stories.tsx @@ -35,7 +35,10 @@ export const FlyoutExample: Story = { hurricane... - setExpanded(true)}> + setExpanded(true)} + > Tell me more?! diff --git a/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.mdx b/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.mdx index 1740c8606d1..eaf403e57f0 100644 --- a/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.mdx +++ b/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.mdx @@ -216,6 +216,8 @@ You can define collapsible content by passing an `expanded` prop and the `React. #### Expand on button click +The `ListRow` component has access to the `ExpandControl` component which can be used to toggle the expanded state of the row. The `ExpandControl` component will automatically handle the rotation of the icon based on the expanded state. + ```tsx export const ExpandableRow: React.FC<{ header: string; @@ -233,11 +235,11 @@ export const ExpandableRow: React.FC<{ {header} {content} - setExpanded(!isExpanded)}> - - - - + setExpanded(!isExpanded)} + disabled={false} + /> ); @@ -291,15 +293,15 @@ You can combine variants and spacing to your needs. -### Expandable buttom +### Expandable button -Buttons can be configured to expand the row content. +Buttons can be configured to expand the row content. Check over the "Expand on button click" section for more guidance. ### Expanded row -An entire row can be made interactive to expand the row content. +An entire row can be made interactive to expand the row content. Check over the "Expand on row click" section for more guidance. diff --git a/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.stories.tsx b/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.stories.tsx index 8133db2e641..89ed8956993 100644 --- a/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.stories.tsx +++ b/packages/styleguide/src/lib/Organisms/Lists & Tables/List/List.stories.tsx @@ -1,5 +1,6 @@ import { Box, + ExpandControl, FillButton, FlexBox, IconButton, @@ -14,7 +15,6 @@ import { import { ArrowChevronDownIcon, HouseEntranceIcon, - MiniChevronDownIcon, MiniDeleteIcon, MiniKebabMenuIcon, StarIcon, @@ -655,11 +655,11 @@ const ExpandableButtonClickRow: React.FC<{ Hail - setExpanded(!isExpanded)}> - - - - + setExpanded(!isExpanded)} + disabled={false} + /> ); @@ -705,7 +705,7 @@ export const ExpandableRowClick: React.FC = ({ - +