Merge pull request #66 from Safelite/CSR-186-radio-button-variations

CSR-186 Add multi-line radio variation.
This commit is contained in:
bmauger 2021-12-01 12:58:47 -05:00 committed by GitHub
commit e79afbf9c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 135 additions and 102 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="radio_question"> <div class="radio_question">
<div class="needed_car_info mt-4 mb-2 d-flex"> <div class="needed_car_info mt-5 mb-2 d-flex">
<span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{ <span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{
questionText questionText
}}</span> }}</span>
@ -8,7 +8,7 @@
<div class="w-100 d-flex justify-content-center"> <div class="w-100 d-flex justify-content-center">
<div class="car_list overflow-scroll position-absolute container-fluid pt-1" role="radiogroup" aria-labelledby="select-year-radio-group"> <div class="car_list overflow-scroll position-absolute container-fluid pt-1" role="radiogroup" aria-labelledby="select-year-radio-group">
<h3 class="visually-hidden" id="select-year-radio-group">*</h3> <h3 class="visually-hidden" id="select-year-radio-group">*</h3>
<radio v-for="answer in answers" :key="answer" class="mb-2" <radio v-for="answer in answers" :key="answer"
:radioID="answer" :radioID="answer"
@click="chooseAnswer(answer)" @click="chooseAnswer(answer)"
loaderColor="blue" loaderColor="blue"
@ -35,4 +35,4 @@ export default {
radio, radio,
}, },
}; };
</script> </script>

View file

@ -38,7 +38,6 @@
<buttonPrimary <buttonPrimary
buttonText="Primary" buttonText="Primary"
loaderColor="white" loaderColor="white"
loaderPosition="right"
sizeInRem="1" sizeInRem="1"
/> />
</div> </div>
@ -48,7 +47,6 @@
<buttonSecondary <buttonSecondary
buttonText="Secondary" buttonText="Secondary"
loaderColor="white" loaderColor="white"
loaderPosition="right"
sizeInRem="1" sizeInRem="1"
/> />
</div> </div>
@ -65,43 +63,125 @@
errorText="Test error message" errorText="Test error message"
loaderColor="blue" loaderColor="blue"
loaderPosition="right" loaderPosition="right"
sizeInRem="1.5" sizeInRem="1"
/> />
</div> </div>
</div> </div>
<div class="row my-4"> <div class="row my-4">
<div class="col"> <div class="col">
<h4 class="m-0 p-2 bg-light rounded">Radio Button Group</h4> <h4 class="m-0 p-2 bg-light rounded">Radio Button Group - Single-Line</h4>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group --> <!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
<div role="radiogroup" aria-labelledby="select-year-radio-group" class="col my-3 d-flex align-items-center flex-column"> <div role="radiogroup" aria-labelledby="demo-1-radio-group" class="col my-3 d-flex align-items-center flex-column">
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. --> <!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
<h3 class="visually-hidden" id="select-year-radio-group">Select Vehicle Year</h3> <h3 class="visually-hidden" id="demo-1-radio-group">Select Vehicle Year</h3>
<radioList <radio
groupName="demo" groupName="demo-1"
ariaLabelBy="vehicle-year" ariaLabelBy="vehicle-year"
radioID="2021" radioID="2021"
textPosition="text-start"
loaderColor="blue" loaderColor="blue"
loaderPosition="right" loaderPosition="right"
sizeInRem="1.5" sizeInRem="1"
/> />
<radioList <radio
groupName="demo" groupName="demo-1"
ariaLabelBy="vehicle-year" ariaLabelBy="vehicle-year"
radioID="2020" radioID="2020"
textPosition="text-start"
loaderColor="blue" loaderColor="blue"
loaderPosition="right" loaderPosition="right"
sizeInRem="1.5" sizeInRem="1"
/> />
<radioList <radio
groupName="demo" groupName="demo-1"
ariaLabelBy="vehicle-year" ariaLabelBy="vehicle-year"
radioID="2019" radioID="2019"
textPosition="text-start"
loaderColor="blue" loaderColor="blue"
loaderPosition="right" loaderPosition="right"
sizeInRem="1.5" sizeInRem="1"
/>
</div>
</div>
<div class="row my-4">
<div class="col">
<h4 class="m-0 p-2 bg-light rounded">Radio Button Group - Multi-Line</h4>
</div>
</div>
<div class="row">
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
<div role="radiogroup" aria-labelledby="demo-2-radio-group" class="col my-3 d-flex align-items-center flex-column">
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
<h3 class="visually-hidden" id="demo-2-radio-group">Select Vehicle Year</h3>
<radio
groupName="demo-2"
ariaLabelBy="vehicle-make"
radioID="Chevrolet"
radioSubID="Test sub-headline"
textPosition="text-start"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/>
<radio
groupName="demo-2"
ariaLabelBy="vehicle-make"
radioID="Dodge"
radioSubID="Test sub-headline"
textPosition="text-start"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/>
<radio
groupName="demo-2"
ariaLabelBy="vehicle-make"
radioID="Ford"
radioSubID="Test sub-headline"
textPosition="text-start"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/>
</div>
</div>
<div class="row">
<!-- The role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
<div role="radiogroup" aria-labelledby="demo-3-radio-group" class="col my-3 d-flex align-items-center flex-column">
<!-- The h3 and id must be included. The id must match the aria-labelledby of the parent div. -->
<h3 class="visually-hidden" id="demo-3-radio-group">Select Vehicle Year</h3>
<radio
groupName="demo-3"
ariaLabelBy="vehicle-model"
radioID="Corvette"
radioSubID="Test sub-headline"
textPosition="text-center"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/>
<radio
groupName="demo-3"
ariaLabelBy="vehicle-model"
radioID="Testarosa"
radioSubID="Test sub-headline"
textPosition="text-center"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/>
<radio
groupName="demo-3"
ariaLabelBy="vehicle-model"
radioID="S600"
radioSubID="Test sub-headline"
textPosition="text-center"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1"
/> />
</div> </div>
</div> </div>
@ -250,7 +330,7 @@
import buttonSecondary from "@/ux-components/button-secondary/button-secondary"; import buttonSecondary from "@/ux-components/button-secondary/button-secondary";
import radioCard from "@/ux-components/radio-card/radio-card"; import radioCard from "@/ux-components/radio-card/radio-card";
import listButton from "@/ux-components/list-button/list-button"; import listButton from "@/ux-components/list-button/list-button";
import radioList from "@/ux-components/radio-list/radio-list"; import radio from "@/ux-components/radio/radio";
import alert from "@/ux-components/alert/alert"; import alert from "@/ux-components/alert/alert";
import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner"; import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
export default { export default {
@ -260,7 +340,7 @@
buttonSecondary, buttonSecondary,
radioCard, radioCard,
listButton, listButton,
radioList, radio,
alert, alert,
vehicleBanner vehicleBanner
}, },

View file

@ -6,7 +6,6 @@
@include blue-gradient; @include blue-gradient;
border: none; border: none;
border-radius: $border-radius-lg; border-radius: $border-radius-lg;
height: 48px;
color: $white; color: $white;
transition: all 150ms linear; transition: all 150ms linear;
&:hover { &:hover {
@ -33,7 +32,6 @@
background: transparent; background: transparent;
border: 1px solid $blue; border: 1px solid $blue;
border-radius: $border-radius-lg; border-radius: $border-radius-lg;
height: 48px;
color: $blue; color: $blue;
transition: all 150ms linear; transition: all 150ms linear;
&:hover { &:hover {
@ -58,7 +56,6 @@
&.list-button { &.list-button {
position: relative; position: relative;
background: $white; background: $white;
height: 48px;
transition: all 150ms linear; transition: all 150ms linear;
border-radius: $border-radius-lg; border-radius: $border-radius-lg;
border: 1px solid $gray-500; border: 1px solid $gray-500;

View file

@ -18,7 +18,6 @@
label { label {
position: relative; position: relative;
background: $white; background: $white;
min-height: 3rem;
transition: all 150ms linear; transition: all 150ms linear;
border-radius: $border-radius-lg; border-radius: $border-radius-lg;
border: 1px solid $gray-500; border: 1px solid $gray-500;

View file

@ -136,17 +136,18 @@ $border-radius-lg: .5rem;//Used for buttons. Can be used for other th
$border-radius-pill: 50rem; $border-radius-pill: 50rem;
//Spacing //Spacing
// Seven spacers available instead of the usual 5 // 8 spacers available instead of the usual 5
$spacer: 1rem; $spacer: 1rem;
$spacers: ( $spacers: (
0: 0, 0: 0,
1: $spacer * .25, 1: $spacer * .25, /* 4px */
2: $spacer * .5, 2: $spacer * .5, /* 8px */
3: $spacer, 3: $spacer * .75, /* 12px */
4: $spacer * 1.5, 4: $spacer * 1, /* 16px */
5: $spacer * 2, 5: $spacer * 1.5, /* 24px */
6: $spacer * 2.5, 6: $spacer * 2, /* 32px */
7: $spacer * 3, 7: $spacer * 2.5, /* 40px */
8: $spacer * 3, /* 48px */
); );
//Grid breakpoints //Grid breakpoints

View file

@ -2,10 +2,10 @@
<button <button
:disabled="isDisabled" :disabled="isDisabled"
:aria-disabled="isDisabled" :aria-disabled="isDisabled"
class="btn btn-primary d-flex align-items-center" class="btn btn-primary d-flex align-items-center py-3 px-4"
@click='displayComponent' @click='displayComponent'
> >
{{ this.buttonText }} <p class="m-0">{{ this.buttonText }}</p>
<loader <loader
class="ms-2" class="ms-2"
v-if="display" v-if="display"

View file

@ -2,10 +2,10 @@
<button <button
:disabled="isDisabled" :disabled="isDisabled"
:aria-disabled="isDisabled" :aria-disabled="isDisabled"
class="btn btn-secondary d-flex align-items-center" class="btn btn-secondary d-flex align-items-center py-3 px-4"
@click='displayComponent' @click='displayComponent'
> >
{{ this.buttonText }} <p class="m-0">{{ this.buttonText }}</p>
<loader <loader
class="ms-2" class="ms-2"
v-if="display" v-if="display"

View file

@ -1,14 +1,14 @@
<template> <template>
<div class="d-flex flex-column w-100"> <div class="d-flex flex-column w-100">
<button <button
class="btn list-button d-flex align-items-center justify-content-between" class="btn list-button d-flex align-items-center justify-content-between py-3 px-4"
@click='displayComponent' @click='displayComponent'
v-bind:class="[ v-bind:class="[
this.isLoading ? 'button-loader' : 'not-loading', this.isLoading ? 'button-loader' : 'not-loading',
this.isError ? 'error' : '', this.isError ? 'error' : '',
]" ]"
> >
{{ this.buttonText }} <p class="m-0">{{ this.buttonText }}</p>
<loader <loader
v-if="display" v-if="display"
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"

View file

@ -8,7 +8,7 @@
<script> <script>
export default { export default {
name: "loader", name: "loader",
/* Specify size in number value which translates to rem value. For example, 1.5 = 1.5rem */ /* Specify size in number value which translates to rem value. For example, 1.5 = 1.5rem = 24px */
props: { props: {
sizeInRem: { sizeInRem: {
type: Number, type: Number,
@ -18,7 +18,7 @@ export default {
loaderColor: { loaderColor: {
type: String type: String
}, },
/* Position options: center, right, left (OPTIONAL) */ /* Position options: center, right, left (OPTIONAL, do NOT use on btn-* classes) */
loaderPosition: { loaderPosition: {
type: String type: String
} }
@ -58,15 +58,16 @@ export default {
} }
//Spinner position //Spinner position
&.center { &.center {
left: 0; position: absolute;
right: 0; right: 50%;
margin: 0 auto;
} }
&.right { &.right {
margin: 0 0 0 auto; position: absolute;
right: 1rem;
} }
&.left { &.left {
margin: 0 auto 0 0; position: absolute;
left: 1rem;
} }
//Spinner color //Spinner color
&:after { //Default spinner color (blue) if no other color is specified from the options below &:after { //Default spinner color (blue) if no other color is specified from the options below

View file

@ -1 +0,0 @@
test.todo("some test to be written in the future");

View file

@ -1,51 +0,0 @@
<template>
<div class="radiogroup radio-list-button d-flex flex-column w-100">
<input type="radio"
v-bind:id="radioID"
v-bind:name="groupName"
v-bind:value="radioID">
<label role="radio" tabindex="0" aria-checked="false"
v-bind:for="radioID"
class="mb-2 d-flex align-items-center justify-content-between p-2"
@click='displayComponent'
>{{radioID}}
<loader
v-if="display"
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
v-bind:class="[this.loaderColor, this.loaderPosition]"
/>
</label>
<p class="small">{{errorMessage}}</p>
</div>
</template>
<script>
import loader from "@/ux-components/loader/loader";
export default {
name: "radioList",
props: [
"groupName",
"ariaLabelBy",
"radioID",
"errorMessage",
"loaderColor",
"loaderPosition",
"sizeInRem"
],
data() {
return {
isError: false,
display: false
};
},
methods: {
displayComponent() {
this.display = true;
},
},
components: {
loader,
},
};
</script>

View file

@ -33,13 +33,13 @@ describe("radio.vue", () => {
role: "radio", role: "radio",
tabindex: "0", tabindex: "0",
for: "2023", for: "2023",
class: "d-flex align-items-center justify-content-between p-2", class: "d-flex flex-column justify-content-center py-3 px-4",
"aria-checked": "false" "aria-checked": "false"
}); });
expect(label.text()).toEqual('2023'); expect(label.text()).toEqual('2023');
expect(paragraph.text()).toEqual('null'); expect(paragraph.text()).toEqual('2023');
expect(wrapper.vm.display).toBe(true); expect(wrapper.vm.display).toBe(true);

View file

@ -1,14 +1,19 @@
<template> <template>
<div class="radiogroup radio-list-button d-flex flex-column w-100"> <div class="radiogroup radio-list-button d-flex flex-column w-100 mb-2">
<input type="radio" <input type="radio"
:id="radioID" :id="radioID"
:name="groupName" :name="groupName"
:value="radioID"> :value="radioID">
<label role="radio" tabindex="0" aria-checked="false" <label role="radio" tabindex="0" aria-checked="false"
:for="radioID" :for="radioID"
class="d-flex align-items-center justify-content-between p-2" class="d-flex flex-column justify-content-center py-3 px-4"
@click='displayComponent' @click='displayComponent'
>{{radioID}} ><p class="m-0"
:class="[this.textPosition]"
>{{radioID}}</p>
<p class="m-0 small"
:class="[this.textPosition]"
>{{radioSubID}}</p>
<loader <loader
v-if="display" v-if="display"
:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" :style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
@ -26,6 +31,8 @@ export default {
props: [ props: [
"groupName", "groupName",
"radioID", "radioID",
"radioSubID",
"textPosition", /* Use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */
"errorMessage", "errorMessage",
"loaderColor", "loaderColor",
"loaderPosition", "loaderPosition",