From aa1388964484e58159096037656897c0448413d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Connor=20B=C3=A4r?= Date: Fri, 3 Apr 2020 10:46:00 +0200 Subject: [PATCH] feat(components): rewrite Selector components (#560) * feat(components): rewrite the Selector as radio/checkbox This makes the Selector component accessible (it wasn't before). It also brings the API inline with the Checkbox and RadioButton components. Furthermore, it allows for multiple options to be selected. BREAKING CHANGE: The Selector component now accepts the onChange, value, name, and checked props. The onClick and selected props have been removed. ISSUES CLOSED: #544 * feat(components): increase color contrast on Selector ISSUES CLOSED: #544 * feat(components): add SelectorGroup component The SelectorGroup is a convenience component to display multiple, related Selector components in an accessible way. The component API is modelled after the RadioButtonGroup component, so they can be used interchangeably. * fix(components): remove unnecessary attributes from Checkbox and RadioButton labels The value and name attributes are not valid HTML attributes on the label element. * feat(components): rename label prop for RadioButtonGroup options The options that are passed to a RadioButtonGroup should include a children prop instead of a label prop. This brings it in line with the RadioButton and SelectorGroup components. BREAKING CHANGE: The label property of the options prop of the RadioButtonGroup component has been renamed to children. * test(components): update storyshots * refactor(docs): don't persist event unnecessarily --- .../__fixtures__/functional-component.js | 2 +- src/__snapshots__/storyshots.spec.js.snap | 747 ++++++++++++------ src/components/Checkbox/Checkbox.js | 23 +- src/components/Checkbox/Checkbox.spec.js | 27 +- .../__snapshots__/Checkbox.spec.js.snap | 10 - src/components/RadioButton/RadioButton.js | 60 +- .../__snapshots__/RadioButton.spec.js.snap | 59 +- .../RadioButtonGroup/RadioButtonGroup.js | 26 +- .../RadioButtonGroup/RadioButtonGroup.spec.js | 38 +- .../RadioButtonGroup.story.js | 22 +- .../RadioButtonGroup.spec.js.snap | 165 +--- src/components/Selector/Selector.docs.mdx | 18 +- src/components/Selector/Selector.js | 163 +++- src/components/Selector/Selector.spec.js | 82 +- src/components/Selector/Selector.story.js | 36 +- .../__snapshots__/Selector.spec.js.snap | 250 +++++- src/components/SelectorGroup/SelectorGroup.js | 99 +++ .../SelectorGroup/SelectorGroup.spec.js | 82 ++ .../SelectorGroup/SelectorGroup.story.js | 74 ++ .../__snapshots__/SelectorGroup.spec.js.snap | 122 +++ src/components/SelectorGroup/index.js | 18 + 21 files changed, 1555 insertions(+), 568 deletions(-) create mode 100644 src/components/SelectorGroup/SelectorGroup.js create mode 100644 src/components/SelectorGroup/SelectorGroup.spec.js create mode 100644 src/components/SelectorGroup/SelectorGroup.story.js create mode 100644 src/components/SelectorGroup/__snapshots__/SelectorGroup.spec.js.snap create mode 100644 src/components/SelectorGroup/index.js diff --git a/scripts/static-styles/__fixtures__/functional-component.js b/scripts/static-styles/__fixtures__/functional-component.js index 9c6b7c575e..d72c737558 100644 --- a/scripts/static-styles/__fixtures__/functional-component.js +++ b/scripts/static-styles/__fixtures__/functional-component.js @@ -37,7 +37,7 @@ function FunctionalComponent({ label, value }) { const id = 'id'; return ( - + ); diff --git a/src/__snapshots__/storyshots.spec.js.snap b/src/__snapshots__/storyshots.spec.js.snap index 99ef18db8b..78e3f69c72 100644 --- a/src/__snapshots__/storyshots.spec.js.snap +++ b/src/__snapshots__/storyshots.spec.js.snap @@ -11118,7 +11118,7 @@ label + .circuit-14 { class="circuit-6 circuit-7" >
@@ -14285,8 +14285,6 @@ exports[`Storyshots Forms/Checkbox Base 1`] = `