From d26067b648e23402fbfefdd9110b3cde0671ed0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Marohni=C4=87?= Date: Thu, 15 Oct 2020 15:55:30 +0200 Subject: [PATCH] feat(ButtonPrimitive): add support for aria-current --- .../orbit-components/src/primitives/ButtonPrimitive/README.md | 1 + .../orbit-components/src/primitives/ButtonPrimitive/index.d.ts | 1 + .../orbit-components/src/primitives/ButtonPrimitive/index.js | 2 ++ .../src/primitives/ButtonPrimitive/index.js.flow | 1 + 4 files changed, 5 insertions(+) diff --git a/packages/orbit-components/src/primitives/ButtonPrimitive/README.md b/packages/orbit-components/src/primitives/ButtonPrimitive/README.md index 7f0d984c7e..925def9e6f 100644 --- a/packages/orbit-components/src/primitives/ButtonPrimitive/README.md +++ b/packages/orbit-components/src/primitives/ButtonPrimitive/README.md @@ -21,6 +21,7 @@ Table below contains all types of the props available in ButtonPrimitive compone | asComponent | `string \| React.Element` | `"button"` | The component used for the root node. | | ariaControls | `string` | | Id of the element the button controls. | | ariaExpanded | `boolean` | | Tells screen reader the controlled element from `ariaControls` is expanded. | +| arialCurrent | `string` | | Indicates whether the element represents the current item within within a container or set of related elements. | | background | `string` | | The background of the ButtonPrimitive on initial state. | | backgroundHover | `string` | | The background of the ButtonPrimitive on hover state. | | backgroundActive | `string` | | The background of the ButtonPrimitive on active state. | diff --git a/packages/orbit-components/src/primitives/ButtonPrimitive/index.d.ts b/packages/orbit-components/src/primitives/ButtonPrimitive/index.d.ts index 7d9b71ddf1..75f98ab813 100644 --- a/packages/orbit-components/src/primitives/ButtonPrimitive/index.d.ts +++ b/packages/orbit-components/src/primitives/ButtonPrimitive/index.d.ts @@ -9,6 +9,7 @@ type functionReturningString = () => string; export interface ButtonCommonProps extends Common.Global, Common.Ref, Common.SpaceAfter { readonly asComponent?: Common.Component; readonly ariaControls?: string; + readonly ariaCurrent?: string; readonly ariaExpanded?: boolean; readonly ariaLabelledby?: string; readonly children?: React.ReactNode; diff --git a/packages/orbit-components/src/primitives/ButtonPrimitive/index.js b/packages/orbit-components/src/primitives/ButtonPrimitive/index.js index e890e5da2b..5030c8871d 100644 --- a/packages/orbit-components/src/primitives/ButtonPrimitive/index.js +++ b/packages/orbit-components/src/primitives/ButtonPrimitive/index.js @@ -30,6 +30,7 @@ export const StyledButtonPrimitive = styled( ariaControls, ariaExpanded, ariaLabelledby, + ariaCurrent, title, className, rel, @@ -60,6 +61,7 @@ export const StyledButtonPrimitive = styled( ref={forwardedRef} data-test={dataTest} aria-controls={ariaControls} + aria-current={ariaCurrent} aria-expanded={ariaExpanded} aria-label={title} aria-labelledby={ariaLabelledby} diff --git a/packages/orbit-components/src/primitives/ButtonPrimitive/index.js.flow b/packages/orbit-components/src/primitives/ButtonPrimitive/index.js.flow index ae70f9fa6c..b7fdc8b2a0 100644 --- a/packages/orbit-components/src/primitives/ButtonPrimitive/index.js.flow +++ b/packages/orbit-components/src/primitives/ButtonPrimitive/index.js.flow @@ -16,6 +16,7 @@ export type Size = "small" | "normal" | "large"; export type ButtonCommonProps = {| +asComponent?: Component, +ariaControls?: string, + +ariaCurrent?: string, +ariaExpanded?: boolean, +ariaLabelledby?: string, +children?: React.Node,