From f0ebf8ca3be49c0e1954c2dc857b5071dff04739 Mon Sep 17 00:00:00 2001 From: bmauger Date: Mon, 15 Nov 2021 09:57:59 -0500 Subject: [PATCH] Create radio button that works properly with screen reader Reviewed with Max and Adam for implementation. --- src/layouts/componentTest/componentTest.vue | 29 +++++++++- src/styles/commonRadioStyles.scss | 59 ++++++++++++++++++++ src/uxComponents/radioList/radioList.spec.js | 1 + src/uxComponents/radioList/radioList.vue | 34 +++++++++++ vue.config.js | 1 + vue.release.config.js | 1 + 6 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/styles/commonRadioStyles.scss create mode 100644 src/uxComponents/radioList/radioList.spec.js create mode 100644 src/uxComponents/radioList/radioList.vue diff --git a/src/layouts/componentTest/componentTest.vue b/src/layouts/componentTest/componentTest.vue index 0f3c70aef..905a1b1b7 100644 --- a/src/layouts/componentTest/componentTest.vue +++ b/src/layouts/componentTest/componentTest.vue @@ -45,6 +45,31 @@ /> +
+ +
+ +

Select Vehicle Year

+ + + +
+
Text Link @@ -95,13 +120,15 @@ import buttonPrimary from "@/uxComponents/buttonPrimary/buttonPrimary"; import buttonSecondary from "@/uxComponents/buttonSecondary/buttonSecondary"; import radioCard from "@/uxComponents/radioCard/radioCard"; import listButton from "@/uxComponents/listButton/listButton"; +import radioList from "@/uxComponents/radioList/radioList"; export default { name: "App", components: { buttonPrimary, buttonSecondary, radioCard, - listButton + listButton, + radioList }, }; diff --git a/src/styles/commonRadioStyles.scss b/src/styles/commonRadioStyles.scss new file mode 100644 index 000000000..953a75985 --- /dev/null +++ b/src/styles/commonRadioStyles.scss @@ -0,0 +1,59 @@ +.radiogroup { + &.radio-list-button { + input[type="radio"] { + opacity: 0; + position: fixed; + width: 0; + &:focus-visible + label { + box-shadow: 0 0 0 2px $blue; + } + &:focus + label { + box-shadow: 0 0 0 2px $blue; + } + &:checked + label { + background: $blue-100; + box-shadow: 0 0 0 1px $blue; + } + } + label { + position: relative; + background: $white; + height: 3rem; + transition: all 150ms linear; + border-radius: $border-radius-lg; + border: 1px solid $gray-500; + width: 100%; + &:hover { + box-shadow: 0 0 0 4px $blue-100; + cursor: pointer; + } + + p { + display: none; + } + &.error { + border: 1px solid $danger; + + p { + display: flex; + color: $danger; + } + } + &.button-loader { + padding: 0 40px 0 12px; + &:after { + content: url(../../assets/img/icons/button-spinner-blue.svg); + position: absolute; + right: 14px; + width: 16px; + height: 16px; + margin-left: 12px; + animation: rotation 1s infinite linear; + @keyframes rotation { + 100% { + transform:rotate(360deg); + } + } + } + } + } + } +} diff --git a/src/uxComponents/radioList/radioList.spec.js b/src/uxComponents/radioList/radioList.spec.js new file mode 100644 index 000000000..882a68129 --- /dev/null +++ b/src/uxComponents/radioList/radioList.spec.js @@ -0,0 +1 @@ +test.todo('some test to be written in the future'); \ No newline at end of file diff --git a/src/uxComponents/radioList/radioList.vue b/src/uxComponents/radioList/radioList.vue new file mode 100644 index 000000000..6b59e6f57 --- /dev/null +++ b/src/uxComponents/radioList/radioList.vue @@ -0,0 +1,34 @@ + + + diff --git a/vue.config.js b/vue.config.js index 8027ca62b..bda41b2dd 100644 --- a/vue.config.js +++ b/vue.config.js @@ -24,6 +24,7 @@ module.exports = { @import "./node_modules/bootstrap/scss/bootstrap"; @import "@/styles/commonStyles.scss"; @import "@/styles/commonButtonStyles.scss"; + @import "@/styles/commonRadioStyles.scss"; @import "@/styles/commonTypographyStyles.scss"; @import "@/styles/commonComponentStyles/ymmsCommonStyles.scss"; ` diff --git a/vue.release.config.js b/vue.release.config.js index c6b87f434..5bc60309f 100644 --- a/vue.release.config.js +++ b/vue.release.config.js @@ -14,6 +14,7 @@ module.exports = { @import "./node_modules/bootstrap/scss/bootstrap"; @import "@/styles/commonStyles.scss"; @import "@/styles/commonButtonStyles.scss"; + @import "@/styles/commonRadioStyles.scss"; @import "@/styles/commonTypographyStyles.scss"; @import "@/styles/commonComponentStyles/ymmsCommonStyles.scss"; `