Skip to content
Open
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
15 changes: 15 additions & 0 deletions src/ActionRow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ in a row in a control bar or nav.

ActionRow assumes that its last child is the primary action and lays out actions so that the last item is in a primary location. If horizontal, the primary action sits on the right. If stacked, the primary action sits at the top of the stack (this is done via `flex-direction: column-reverse;`).

## Accessibility

When ActionRow groups interactive controls (buttons, links), add `role="group"` and `aria-label`
so assistive technology users can identify the group's purpose and distinguish multiple ActionRows
on the same page:

```jsx live
<ActionRow role="group" aria-label="Form actions">
<Button variant="tertiary">Cancel</Button>
<Button variant="primary">Submit</Button>
</ActionRow>
```

Both attributes are passed through to the underlying element via the standard HTML attributes spread.

## Basic Usage

```jsx live
Expand Down
19 changes: 18 additions & 1 deletion src/ActionRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import React from 'react';
import classNames from 'classnames';

/**
* Layout utility that arranges action controls in a horizontal row or vertical stack.
*
* When ActionRow groups interactive controls (buttons, links), add `role="toolbar"`
* and `aria-label` so assistive technology users can identify the group and
* distinguish multiple ActionRows on the same page:
*
* ```jsx
* <ActionRow role="toolbar" aria-label="Form actions">
* <Button variant="tertiary">Cancel</Button>
* <Button variant="primary">Submit</Button>
* </ActionRow>
* ```
*
* Both props are accepted via the standard HTML attributes spread; no extra
* prop definitions are required.
*/
interface ActionRowProps extends React.HTMLAttributes<HTMLElement> {
/** Specifies the base element */
as?: React.ElementType;
Expand Down Expand Up @@ -32,7 +49,7 @@ function ActionRow({
}

function ActionRowSpacer() {
return <span className="pgn__action-row-spacer" />;
return <span className="pgn__action-row-spacer" aria-hidden="true" />;
}

ActionRow.Spacer = ActionRowSpacer;
Expand Down
4 changes: 4 additions & 0 deletions src/Alert/__snapshots__/Alert.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports[`<Alert /> renders with button and dismissible props 1`] = `
className="pgn__alert-actions pgn__action-row"
>
<span
aria-hidden="true"
className="pgn__action-row-spacer"
/>
<button
Expand Down Expand Up @@ -56,6 +57,7 @@ exports[`<Alert /> renders with button prop 1`] = `
className="pgn__alert-actions pgn__action-row"
>
<span
aria-hidden="true"
className="pgn__action-row-spacer"
/>
<button
Expand Down Expand Up @@ -87,6 +89,7 @@ exports[`<Alert /> renders with dismissible prop 1`] = `
className="pgn__alert-actions pgn__action-row"
>
<span
aria-hidden="true"
className="pgn__action-row-spacer"
/>
<button
Expand Down Expand Up @@ -155,6 +158,7 @@ exports[`<Alert /> renders with stacked prop 1`] = `
className="pgn__alert-actions pgn__action-row"
>
<span
aria-hidden="true"
className="pgn__action-row-spacer"
/>
<button
Expand Down