Merge branch 'develop' into feautre/CSR-224
This commit is contained in:
commit
b1a765fd1c
28 changed files with 700 additions and 703 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import radioQuestion from "@/common-components/radio-question/radio-question";
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
|
|
||||||
describe("radioQuestion.vue", () => {
|
describe("buttonQuestion.vue", () => {
|
||||||
it("Should render the 'questionText' prop value as a span value for the radio question and the 'answer' values should render as text values for radio components.", async () => {
|
it("Should render the 'questionText' prop value as a span value for the button question and the 'answer' values should render as text values for button components.", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(radioQuestion);
|
const wrapper = shallowMount(buttonQuestion);
|
||||||
await wrapper.setProps({
|
await wrapper.setProps({
|
||||||
questionText: "Question Text",
|
questionText: "Question Text",
|
||||||
answers: ["2023", "2022", "2021"],
|
answers: ["2023", "2022", "2021"],
|
||||||
|
|
@ -16,8 +16,8 @@ describe("radioQuestion.vue", () => {
|
||||||
expect(wrapper.find(".needed_car_info-text").text()).toEqual(
|
expect(wrapper.find(".needed_car_info-text").text()).toEqual(
|
||||||
"Question Text"
|
"Question Text"
|
||||||
);
|
);
|
||||||
const radioButtons = wrapper.findAllComponents('[data-test="radio"]');
|
const buttonButtons = wrapper.findAllComponents('[data-test="button"]');
|
||||||
expect(radioButtons.length).toBe(3);
|
expect(buttonButtons.length).toBe(3);
|
||||||
expect(wrapper.props().modelValue).toBe("2020");
|
expect(wrapper.props().modelValue).toBe("2020");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
48
src/common-components/button-question/button-question.vue
Normal file
48
src/common-components/button-question/button-question.vue
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
<template>
|
||||||
|
<div class="button_question">
|
||||||
|
<div class="needed_car_info mt-6 mb-4 d-flex">
|
||||||
|
<span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{
|
||||||
|
questionText
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="w-100 d-flex justify-content-center">
|
||||||
|
<fieldset class="car_list overflow-scroll position-absolute container-fluid w-100 pt-1 px-5 py-0" role="radiogroup">
|
||||||
|
<legend class="sr-only">{{groupName}}</legend>
|
||||||
|
<listButton v-for="answer in answers" :key="answer"
|
||||||
|
:buttonID="answer"
|
||||||
|
@click="chooseAnswer(answer)"
|
||||||
|
loaderColor="blue"
|
||||||
|
loaderPosition="right"
|
||||||
|
sizeInRem="1.5"
|
||||||
|
data-test="button"
|
||||||
|
:groupName="groupName"
|
||||||
|
textPosition="text-start"
|
||||||
|
isRequired=true
|
||||||
|
:value="modelValue"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import listButton from "@/ux-components/list-button/list-button";
|
||||||
|
export default {
|
||||||
|
name: "buttonQuestion",
|
||||||
|
props: {
|
||||||
|
questionText: String,
|
||||||
|
answers: Array,
|
||||||
|
modelValue: String,
|
||||||
|
groupName: String
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
chooseAnswer(answer) {
|
||||||
|
this.$emit("update:modelValue", answer);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
listButton,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="radio_question">
|
|
||||||
<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">{{
|
|
||||||
questionText
|
|
||||||
}}</span>
|
|
||||||
</div>
|
|
||||||
<div class="w-100 d-flex justify-content-center">
|
|
||||||
<div
|
|
||||||
class="
|
|
||||||
car_list
|
|
||||||
overflow-scroll
|
|
||||||
position-absolute
|
|
||||||
container-fluid
|
|
||||||
w-100
|
|
||||||
pt-1
|
|
||||||
"
|
|
||||||
role="radiogroup"
|
|
||||||
aria-labelledby="select-year-radio-group"
|
|
||||||
>
|
|
||||||
<h3 class="visually-hidden" id="select-year-radio-group">*</h3>
|
|
||||||
<radio
|
|
||||||
v-for="answer in answers"
|
|
||||||
:key="answer"
|
|
||||||
:radioID="answer"
|
|
||||||
@click="chooseAnswer(answer)"
|
|
||||||
loaderColor="blue"
|
|
||||||
loaderPosition="right"
|
|
||||||
sizeInRem="1.5"
|
|
||||||
data-test="radio"
|
|
||||||
groupName="radio-list"
|
|
||||||
textPosition="text-start"
|
|
||||||
:value="modelValue"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import radio from "@/ux-components/radio/radio";
|
|
||||||
export default {
|
|
||||||
name: "radio-question",
|
|
||||||
props: {
|
|
||||||
questionText: String,
|
|
||||||
answers: Array,
|
|
||||||
modelValue: String,
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
chooseAnswer(answer) {
|
|
||||||
this.$emit("update:modelValue", answer);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
radio,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="vehicle_banner mb-3 text-center">
|
<div class="vehicle_banner mb-4 text-center">
|
||||||
<img
|
<img
|
||||||
class="vehicle-image img-fluid blurrycar"
|
class="vehicle-image img-fluid blurrycar"
|
||||||
:src="vehicleImageSrc"
|
:src="vehicleImageSrc"
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,30 @@
|
||||||
<div class="container-fluid container-shadow p-2 rounded-3">
|
<div class="container-fluid container-shadow p-2 rounded-3">
|
||||||
<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 Card</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Card</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row g-2">
|
<div class="row g-2">
|
||||||
<radioCard
|
<listCard
|
||||||
radioLabel="Windshield"
|
buttonLabel="Windshield"
|
||||||
radioImage="windshield-damage.svg"
|
buttonImage="windshield-damage.svg"
|
||||||
altText="Windshield"
|
altText="Windshield"
|
||||||
groupName="damageKey"
|
groupName="damageKey"
|
||||||
radioID="windshield"
|
buttonID="windshield"
|
||||||
/>
|
/>
|
||||||
<radioCard
|
<listCard
|
||||||
radioLabel="Side Window"
|
buttonLabel="Side Window"
|
||||||
radioImage="side-window-damage.svg"
|
buttonImage="side-window-damage.svg"
|
||||||
altText="Side Window"
|
altText="Side Window"
|
||||||
groupName="damageKey"
|
groupName="damageKey"
|
||||||
radioID="sidewindow"
|
buttonID="sidewindow"
|
||||||
/>
|
/>
|
||||||
<radioCard
|
<listCard
|
||||||
radioLabel="Back Glass"
|
buttonLabel="Back Glass"
|
||||||
radioImage="back-glass-damage.svg"
|
buttonImage="back-glass-damage.svg"
|
||||||
altText="Back Glass"
|
altText="Back Glass"
|
||||||
groupName="damageKey"
|
groupName="damageKey"
|
||||||
radioID="backglass"
|
buttonID="backglass"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-4">
|
<div class="row my-4">
|
||||||
|
|
@ -35,7 +35,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col my-3 d-flex align-items-center">
|
<div class="col my-3 d-flex align-items-center">
|
||||||
<buttonPrimary buttonText="Primary" loaderColor="white" sizeInRem="1" />
|
<buttonPrimary
|
||||||
|
buttonText="Primary"
|
||||||
|
loaderColor="white"
|
||||||
|
sizeInRem="1" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
@ -47,214 +50,218 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row my-4">
|
|
||||||
<div class="col">
|
|
||||||
<h4 class="m-0 p-2 bg-light rounded">List Button</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col my-3 d-flex align-items-center">
|
<div class="col my-3 d-flex align-items-center">
|
||||||
<listButton
|
<buttonBack/>
|
||||||
buttonText="List Button"
|
|
||||||
errorText="Test error message"
|
|
||||||
loaderColor="blue"
|
|
||||||
loaderPosition="right"
|
|
||||||
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 - Single-Line</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Button - 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 group -->
|
||||||
<div
|
<div
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-labelledby="demo-1-radio-group"
|
aria-labelledby="demo-1-radio-group"
|
||||||
class="col my-3 d-flex align-items-center flex-column"
|
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="demo-1-radio-group">
|
<h3 class="sr-only" id="demo-1-radio-group">
|
||||||
Select Vehicle Year
|
Select Vehicle Year
|
||||||
</h3>
|
</h3>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-1"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2021"
|
buttonID="2021"
|
||||||
textPosition="text-start"
|
isRequired=true
|
||||||
loaderColor="blue"
|
textPosition="text-start"
|
||||||
loaderPosition="right"
|
loaderColor="blue"
|
||||||
sizeInRem="1"
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-1"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2020"
|
buttonID="2020"
|
||||||
textPosition="text-start"
|
isRequired=true
|
||||||
loaderColor="blue"
|
textPosition="text-start"
|
||||||
loaderPosition="right"
|
loaderColor="blue"
|
||||||
sizeInRem="1"
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-1"
|
groupName="demo-1"
|
||||||
ariaLabelBy="vehicle-year"
|
ariaLabelBy="vehicle-year"
|
||||||
radioID="2019"
|
buttonID="2019"
|
||||||
textPosition="text-start"
|
isRequired=true
|
||||||
loaderColor="blue"
|
textPosition="text-start"
|
||||||
loaderPosition="right"
|
loaderColor="blue"
|
||||||
sizeInRem="1"
|
loaderPosition="right"
|
||||||
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
</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 - Multi-Line</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Button - Multi-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 group -->
|
||||||
<div
|
<div
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-labelledby="demo-2-radio-group"
|
aria-labelledby="demo-2-radio-group"
|
||||||
class="col my-3 d-flex align-items-center flex-column"
|
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="demo-2-radio-group">
|
<h3 class="sr-only" id="demo-2-radio-group">
|
||||||
Select Vehicle Year
|
Select Vehicle Year
|
||||||
</h3>
|
</h3>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-2"
|
groupName="demo-2"
|
||||||
ariaLabelBy="vehicle-make"
|
ariaLabelBy="vehicle-make"
|
||||||
radioID="Chevrolet"
|
buttonID="Chevrolet"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-2"
|
groupName="demo-2"
|
||||||
ariaLabelBy="vehicle-make"
|
ariaLabelBy="vehicle-make"
|
||||||
radioID="Dodge"
|
buttonID="Dodge"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-2"
|
groupName="demo-2"
|
||||||
ariaLabelBy="vehicle-make"
|
ariaLabelBy="vehicle-make"
|
||||||
radioID="Ford"
|
buttonID="Ford"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
</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 - Multi-Line Centered</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Button - Multi-Line Centered</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 group -->
|
||||||
<div
|
<div
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-labelledby="demo-3-radio-group"
|
aria-labelledby="demo-3-radio-group"
|
||||||
class="col my-3 d-flex align-items-center flex-column"
|
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="demo-3-radio-group">
|
<h3 class="sr-only" id="demo-3-radio-group">
|
||||||
Multi-Line Centered
|
Multi-Line Centered
|
||||||
</h3>
|
</h3>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-3"
|
groupName="demo-3"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="Corvette"
|
buttonID="Corvette"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-3"
|
groupName="demo-3"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="Testarosa"
|
buttonID="Testarosa"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radio
|
<listButton
|
||||||
groupName="demo-3"
|
groupName="demo-3"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="S600"
|
buttonID="S600"
|
||||||
radioLabelSubCopy="Test sub-headline"
|
buttonLabelSubCopy="Test sub-headline"
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
</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 Horizontal</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Button Horizontal</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row px-3">
|
<div class="row px-3">
|
||||||
<!-- 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 group -->
|
||||||
<div
|
<div
|
||||||
role="radiogroup"
|
role="radiogroup"
|
||||||
aria-labelledby="demo-4-radio-group"
|
aria-labelledby="demo-4-radio-group"
|
||||||
class="d-flex flex-row p-0"
|
class="d-flex flex-row p-0"
|
||||||
>
|
>
|
||||||
<!-- 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="demo-4-radio-group">
|
<h3 class="sr-only" id="demo-4-radio-group">
|
||||||
Select Vehicle Year
|
Select Vehicle Year
|
||||||
</h3>
|
</h3>
|
||||||
<radioHorizontal
|
<listButtonHorizontal
|
||||||
groupName="demo-4"
|
groupName="demo-4"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="1"
|
buttonID="1"
|
||||||
radioLabelSubCopy=""
|
buttonLabelSubCopy=""
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
v-bind:totalInGroup="3"
|
v-bind:totalInGroup="3"
|
||||||
v-bind:positionInGroup="1"
|
v-bind:positionInGroup="1"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radioHorizontal
|
<listButtonHorizontal
|
||||||
groupName="demo-4"
|
groupName="demo-4"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="2"
|
buttonID="2"
|
||||||
radioLabelSubCopy=""
|
buttonLabelSubCopy=""
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
v-bind:totalInGroup="3"
|
v-bind:totalInGroup="3"
|
||||||
v-bind:positionInGroup="2"
|
v-bind:positionInGroup="2"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
<radioHorizontal
|
<listButtonHorizontal
|
||||||
groupName="demo-4"
|
groupName="demo-4"
|
||||||
ariaLabelBy="vehicle-model"
|
ariaLabelBy="vehicle-model"
|
||||||
radioID="3"
|
buttonID="3"
|
||||||
radioLabelSubCopy=""
|
buttonLabelSubCopy=""
|
||||||
textPosition="text-center"
|
textPosition="text-center"
|
||||||
loaderColor="blue"
|
loaderColor="blue"
|
||||||
loaderPosition="right"
|
loaderPosition="right"
|
||||||
sizeInRem="1"
|
sizeInRem="1"
|
||||||
v-bind:totalInGroup="3"
|
v-bind:totalInGroup="3"
|
||||||
v-bind:positionInGroup="3"
|
v-bind:positionInGroup="3"
|
||||||
|
screenReaderOnlyText="(opens new window)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -414,24 +421,24 @@
|
||||||
<script>
|
<script>
|
||||||
import buttonPrimary from "@/ux-components/button-primary/button-primary";
|
import buttonPrimary from "@/ux-components/button-primary/button-primary";
|
||||||
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 buttonBack from "@/ux-components/button-back/button-back";
|
||||||
|
import listCard from "@/ux-components/list-card/list-card";
|
||||||
import listButton from "@/ux-components/list-button/list-button";
|
import listButton from "@/ux-components/list-button/list-button";
|
||||||
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";
|
||||||
import siteHeader from "@/common-components/site-header/site-header";
|
import siteHeader from "@/common-components/site-header/site-header";
|
||||||
import radioHorizontal from "@/ux-components/radio-horizontal/radio-horizontal";
|
import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-button-horizontal";
|
||||||
export default {
|
export default {
|
||||||
name: "App",
|
name: "App",
|
||||||
components: {
|
components: {
|
||||||
buttonPrimary,
|
buttonPrimary,
|
||||||
buttonSecondary,
|
buttonSecondary,
|
||||||
radioCard,
|
buttonBack,
|
||||||
|
listCard,
|
||||||
listButton,
|
listButton,
|
||||||
radio,
|
|
||||||
alert,
|
alert,
|
||||||
vehicleBanner,
|
vehicleBanner,
|
||||||
radioHorizontal,
|
listButtonHorizontal,
|
||||||
siteHeader,
|
siteHeader,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
import { shallowMount, flushPromises } from "@vue/test-utils";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue";
|
import vehicleYear from "@/layouts/vehicle-year/vehicle-year.vue";
|
||||||
|
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
import { nextTick } from "vue";
|
import { nextTick } from "vue";
|
||||||
|
|
||||||
|
|
@ -10,72 +11,84 @@ jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("vehicle-year.vue", () => {
|
describe("vehicle-year.vue", () => {
|
||||||
test("vehicle-year.vue should render data from CMS", async () => {
|
test("Year question component is initized with api data", async (done) => {
|
||||||
// Arrange
|
|
||||||
|
|
||||||
// Our mock data for our call to settleAllPromises
|
//Arange
|
||||||
const mockData = {
|
const radioQuestionCmsContent = { QuestionText: "What year is your vehicle?" };
|
||||||
getPageContent: {
|
const yearQuestionInitialData = ["2023", "2022", "2021"];
|
||||||
PageHeaderWidget: [{ HeaderText: "Select a year to get started" }],
|
const { wrapper, apiPromise } = setupMocks( {
|
||||||
RadioQuestionWidget: [{ QuestionText: "What year is your vehicle?" }],
|
radioQuestionCmsContent: radioQuestionCmsContent,
|
||||||
VehicleBannerWidget: [
|
yearQuestionInitialData: yearQuestionInitialData,
|
||||||
{
|
} );
|
||||||
GenericVehicleImage:
|
|
||||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
SiteHeaderWidget: [
|
|
||||||
{
|
|
||||||
LogoImage:
|
|
||||||
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
isCmsContentReady: true,
|
|
||||||
},
|
|
||||||
getVehicleYear: [2023, 2022, 2021],
|
|
||||||
store: {
|
|
||||||
commit: jest.fn(),
|
|
||||||
year: null,
|
|
||||||
},
|
|
||||||
router: {
|
|
||||||
push: jest.fn(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// our router information needed.
|
//Act
|
||||||
const to = {
|
vehicleYear.beforeRouteEnter.call(wrapper.vm, { query: { fmgPage: "vehicle-year" } }, undefined, (c) => c(wrapper.vm));
|
||||||
query: {
|
|
||||||
fmgPage: "vehicle-year",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const mountOptions = getMountOptions(mockData);
|
//Assert
|
||||||
|
apiPromise.finally(() => {
|
||||||
// our mock implementation of settleAllPromises
|
expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith(radioQuestionCmsContent, yearQuestionInitialData);
|
||||||
settleAllPromises.mockImplementation(() => {
|
done();
|
||||||
return Promise.resolve(mockData);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
|
||||||
const wrapper = shallowMount(vehicleYear, mountOptions);
|
|
||||||
wrapper.vm.$options.watch.selectedYear.call(wrapper.vm);
|
|
||||||
|
|
||||||
// Call our beforeRouteEnter on the component.
|
|
||||||
// This passes (c) => c(wrapper.vm) so that next can be called and our
|
|
||||||
// data can be set.
|
|
||||||
vehicleYear.beforeRouteEnter.call(wrapper.vm, to, undefined, (c) =>
|
|
||||||
c(wrapper.vm)
|
|
||||||
);
|
|
||||||
|
|
||||||
await nextTick(); // Wait for the DOM to update.
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
const header = await wrapper.find(".Header");
|
|
||||||
expect(header.attributes("text")).toEqual("Select a year to get started");
|
|
||||||
|
|
||||||
const yearQuestion = wrapper.findComponent({ name: "year-question" });
|
|
||||||
expect(yearQuestion.attributes("questiontext")).toEqual(
|
|
||||||
"What year is your vehicle?"
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("vehicle-year.vue", () => {
|
||||||
|
test("Page header is passed data from CMS", async (done) => {
|
||||||
|
|
||||||
|
//Arange
|
||||||
|
const { wrapper, apiPromise } = setupMocks( { pageHeaderWidgetHeaderText: "Select a year to get started" });
|
||||||
|
|
||||||
|
//Act
|
||||||
|
vehicleYear.beforeRouteEnter.call(wrapper.vm, { query: { fmgPage: "vehicle-year" } }, undefined, (c) => c(wrapper.vm));
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
const header = await wrapper.find(".Header");
|
||||||
|
apiPromise.finally(() => {
|
||||||
|
expect(header.attributes("text")).toEqual("Select a year to get started");
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
radioQuestionCmsContent = {},
|
||||||
|
yearQuestionInitialData = {},
|
||||||
|
pageHeaderWidgetHeaderText = {},
|
||||||
|
}) {
|
||||||
|
|
||||||
|
//Mock api responses
|
||||||
|
const apiResponses = {
|
||||||
|
cmsContent: {
|
||||||
|
PageHeaderWidget: [{ HeaderText: pageHeaderWidgetHeaderText }],
|
||||||
|
RadioQuestionWidget: [radioQuestionCmsContent],
|
||||||
|
VehicleBannerWidget: [
|
||||||
|
{
|
||||||
|
GenericVehicleImage:
|
||||||
|
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/blurred-image.jpg?sfvrsn=a6ce3034_3",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
SiteHeaderWidget: [
|
||||||
|
{
|
||||||
|
LogoImage:
|
||||||
|
"https://digitalconsumercms-dev.safelite.com/images/default-source/default-album/safelite-logo.svg?sfvrsn=45e7ed06_3",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
isCmsContentReady: true,
|
||||||
|
},
|
||||||
|
yearQuestionInitialData: yearQuestionInitialData,
|
||||||
|
};
|
||||||
|
const apiPromise = Promise.resolve(apiResponses);
|
||||||
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
|
|
||||||
|
//Mock year question methods
|
||||||
|
yearQuestion.methods = {
|
||||||
|
loadInitialData: jest.fn(),
|
||||||
|
initializeComponent: jest.fn(),
|
||||||
|
};
|
||||||
|
const mountOptions = getMountOptions({ });
|
||||||
|
const wrapper = shallowMount(vehicleYear, mountOptions);
|
||||||
|
const yearQuestionWrapper = wrapper.findComponent({ name: "yearQuestion" });
|
||||||
|
yearQuestionWrapper.vm.initializeComponent = yearQuestion.methods.initializeComponent;
|
||||||
|
|
||||||
|
return { wrapper, apiPromise };
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
<template>
|
<template v-if="isCmsContentReady">
|
||||||
<siteHeader :imageSrc="siteHeaderWidget.LogoImage" />
|
<div class="container-fluid shadow rounded-3 p-0">
|
||||||
<div class="select-car">
|
<siteHeader :imageSrc="siteHeaderWidget.LogoImage" />
|
||||||
<div class="select-car-form rounded text-center">
|
<div class="select-car">
|
||||||
<vehicleBanner
|
<div class="select-car-form rounded text-center">
|
||||||
:vehicleImageSrc="vehicleBannerWidget.GenericVehicleImage"
|
<vehicleBanner :vehicleImageSrc="vehicleBannerWidget.GenericVehicleImage" />
|
||||||
/>
|
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
||||||
<pageHeader :text="pageHeaderWidgets.HeaderText" class="Header" />
|
<yearQuestion v-model="selectedYear" ref="yearQuestion" />
|
||||||
<yearQuestion
|
</div>
|
||||||
:questionText="radioQuestionWidgets.QuestionText"
|
|
||||||
:years="vehicleYears"
|
|
||||||
v-model="selectedYear"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -24,15 +20,11 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
|
||||||
export default {
|
export default {
|
||||||
name: "vehicle-year",
|
name: "vehicle-year",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
pageHeaderWidgets: {},
|
pageHeaderWidgets: {},
|
||||||
radioQuestionWidgets: {},
|
|
||||||
vehicleYears: [],
|
|
||||||
siteHeaderWidget: {},
|
siteHeaderWidget: {},
|
||||||
vehicleBannerWidget: {},
|
vehicleBannerWidget: {},
|
||||||
selectedYear: null,
|
selectedYear: null,
|
||||||
|
|
@ -41,34 +33,30 @@ export default {
|
||||||
computed: {},
|
computed: {},
|
||||||
|
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
|
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const contentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
const getVehicleYearPromise = store.dispatch(
|
const yearQuestionInitialDataPromise = yearQuestion.methods.loadInitialData();
|
||||||
storeActions.GET_VEHICLE_YEARS,
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
|
|
||||||
// Settle promises and get results
|
// Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "getPageContent",
|
resultKey: "cmsContent",
|
||||||
promise: contentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
resultKey: "getVehicleYear",
|
resultKey: "yearQuestionInitialData",
|
||||||
promise: getVehicleYearPromise,
|
promise: yearQuestionInitialDataPromise,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
settleAllPromises(promiseResultMap).then((resultMap) => {
|
settleAllPromises(promiseResultMap).then((resultMap) => {
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.pageHeaderWidgets = resultMap.getPageContent.PageHeaderWidget[0];
|
vm.pageHeaderWidgets = resultMap.cmsContent.PageHeaderWidget[0];
|
||||||
vm.siteHeaderWidget = resultMap.getPageContent.SiteHeaderWidget[0];
|
vm.siteHeaderWidget = resultMap.cmsContent.SiteHeaderWidget[0];
|
||||||
vm.radioQuestionWidgets =
|
vm.vehicleBannerWidget = resultMap.cmsContent.VehicleBannerWidget[0];
|
||||||
resultMap.getPageContent.RadioQuestionWidget[0];
|
vm.$refs.yearQuestion.initializeComponent(resultMap.cmsContent.RadioQuestionWidget[0], resultMap.yearQuestionInitialData);
|
||||||
vm.vehicleBannerWidget =
|
|
||||||
resultMap.getPageContent.VehicleBannerWidget[0];
|
|
||||||
vm.vehicleYears = resultMap.getVehicleYear;
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -76,8 +64,8 @@ export default {
|
||||||
watch: {
|
watch: {
|
||||||
selectedYear(year) {
|
selectedYear(year) {
|
||||||
this.$store.commit(this.storeMutations.UPDATE_YEAR, year);
|
this.$store.commit(this.storeMutations.UPDATE_YEAR, year);
|
||||||
this.$router.push("?fmgPage=vehicle-make");
|
this.$router.push('?fmgPage=vehicle-make');
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
@ -92,12 +80,10 @@ export default {
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.select-car {
|
.select-car {
|
||||||
height: calc(100vh - 56px);
|
height: calc(100vh - 56px);
|
||||||
padding: 0 1.5rem;
|
|
||||||
|
|
||||||
.car_list {
|
.car_list {
|
||||||
// Height will be determined by overall height of content above list
|
// Height will be determined by overall height of content above list
|
||||||
height: calc(100% - 300px);
|
height: calc(100% - 300px);
|
||||||
padding: 0 1.5rem;
|
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,80 @@
|
||||||
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
import yearQuestion from "@/layouts/vehicle-year/year-question/year-question";
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||||
|
import store from "@/store";
|
||||||
|
jest.mock("@/store", () => { return {}; }, {virtual: true});
|
||||||
|
|
||||||
describe("year-question.vue", () => {
|
describe("year-question.vue", () => {
|
||||||
test("year-question should take a prop for years and questionText, and trigger a selectYear function when an option is clicked.", async () => {
|
test("Selected year is emitted upon selection.", async () => {
|
||||||
// Act
|
|
||||||
const wrapper = shallowMount(yearQuestion);
|
|
||||||
await wrapper.setProps({
|
|
||||||
questionText: "What year is your vehicle?",
|
|
||||||
years: ["2023", "2022", "2021"],
|
|
||||||
modelValue: "2020",
|
|
||||||
});
|
|
||||||
wrapper.vm.$options.watch.selectedYear.call(wrapper.vm);
|
|
||||||
|
|
||||||
// Assert
|
//Arrange
|
||||||
const radioQuestion = await wrapper.findComponent({
|
const { wrapper } = setupMocks({ modelValueProp: "2020" });
|
||||||
name: "radioQuestion",
|
const yearToSelect = "2021";
|
||||||
});
|
|
||||||
expect(radioQuestion.attributes("questiontext")).toBe(
|
//Act
|
||||||
"What year is your vehicle?"
|
wrapper.setData({ selectedYear: yearToSelect });
|
||||||
);
|
await wrapper.vm.$nextTick();
|
||||||
expect(radioQuestion.attributes("answers")).toBe("2023,2022,2021");
|
|
||||||
expect(wrapper.componentVM.modelValue).toBe("2020");
|
//Assert
|
||||||
|
expect(wrapper.emitted()["update:modelValue"][0]).toEqual(["2021"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("year-question.vue", () => {
|
||||||
|
test("CMS question text is used as radio question text.", async () => {
|
||||||
|
|
||||||
|
//Arrange
|
||||||
|
const { wrapper, cmsContent } = setupMocks({ cmsQuestionText: "What year is your vehicle?" });
|
||||||
|
|
||||||
|
//Act
|
||||||
|
yearQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, null);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
const buttonQuestionComponent = await wrapper.findComponent({ name: "buttonQuestion" });
|
||||||
|
expect(buttonQuestionComponent.attributes("questiontext")).toBe("What year is your vehicle?");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("year-question.vue", () => {
|
||||||
|
test("Data from store api are used as radio question answers.", async () => {
|
||||||
|
|
||||||
|
//Arrange
|
||||||
|
const { wrapper, cmsContent } = setupMocks({ dataFromStoreApi: ["2023", "2022", "2021"] });
|
||||||
|
|
||||||
|
//Act
|
||||||
|
const initialData = yearQuestion.methods.loadInitialData.call(wrapper.vm);
|
||||||
|
yearQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, initialData);
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
const buttonQuestionComponent = await wrapper.findComponent({ name: "buttonQuestion" });
|
||||||
|
expect(buttonQuestionComponent.attributes("answers")).toBe("2023,2022,2021");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function setupMocks({
|
||||||
|
modelValueProp = "1900",
|
||||||
|
cmsQuestionText = "CMS text goes here",
|
||||||
|
dataFromStoreApi = [],
|
||||||
|
}) {
|
||||||
|
|
||||||
|
//Mock store
|
||||||
|
store.dispatch = jest.fn(() => dataFromStoreApi);
|
||||||
|
const mountOptions = getMountOptions({
|
||||||
|
store: {
|
||||||
|
dispatch: store.dispatch,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
//Mock props
|
||||||
|
mountOptions.propsData = {
|
||||||
|
modelValue: modelValueProp,
|
||||||
|
};
|
||||||
|
const wrapper = shallowMount(yearQuestion, mountOptions);
|
||||||
|
|
||||||
|
//Mock CMS content
|
||||||
|
const cmsContent = {
|
||||||
|
QuestionText: cmsQuestionText
|
||||||
|
};
|
||||||
|
return { wrapper, cmsContent };
|
||||||
|
}
|
||||||
|
|
@ -1,34 +1,46 @@
|
||||||
<template>
|
<template>
|
||||||
<radioQuestion
|
<buttonQuestion class="radioQuestion"
|
||||||
class="radioQuestion"
|
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
:answers="years"
|
:answers="years"
|
||||||
|
groupName="Choose Vehicle Year"
|
||||||
v-model="selectedYear"
|
v-model="selectedYear"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import radioQuestion from "@/common-components/radio-question/radio-question";
|
import buttonQuestion from "@/common-components/button-question/button-question";
|
||||||
|
// Supporting files
|
||||||
|
import store from "@/store";
|
||||||
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "year-question",
|
name: "year-question",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
questionText: null,
|
||||||
selectedYear: null,
|
selectedYear: null,
|
||||||
};
|
years: Array,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
questionText: String,
|
|
||||||
years: Array,
|
|
||||||
modelValue: String,
|
modelValue: String,
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
radioQuestion,
|
buttonQuestion,
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadInitialData() {
|
||||||
|
return store.dispatch(storeActions.GET_VEHICLE_YEARS, {});
|
||||||
|
},
|
||||||
|
initializeComponent(cmsContent, initialData) {
|
||||||
|
this.questionText = cmsContent.QuestionText;
|
||||||
|
this.years = initialData;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
selectedYear(val) {
|
selectedYear(val) {
|
||||||
this.$emit("update:modelValue", val);
|
this.$emit("update:modelValue", val);
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -53,33 +53,4 @@
|
||||||
border-radius: $border-radius-lg;
|
border-radius: $border-radius-lg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&.list-button {
|
|
||||||
position: relative;
|
|
||||||
background: $white;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
&:focus, // Mouse, touch, stylus focus
|
|
||||||
&:focus-visible { // Keyboard focus for accessibility
|
|
||||||
box-shadow: 0 0 0 2px $blue;
|
|
||||||
}
|
|
||||||
&:active {
|
|
||||||
background: $blue-100;
|
|
||||||
border: 1px solid $blue;
|
|
||||||
}
|
|
||||||
+ label {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
&.error {
|
|
||||||
border: 1px solid $danger;
|
|
||||||
~ label {
|
|
||||||
display: flex;
|
|
||||||
color: $danger;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
.radiogroup {
|
.list-group {
|
||||||
&.radio-list-button {
|
&.list-button {
|
||||||
input[type="radio"] {
|
input[type="radio"] {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|
@ -25,5 +25,14 @@ body {
|
||||||
.container-fluid {
|
.container-fluid {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sr-only {
|
||||||
|
position: absolute;
|
||||||
|
left: -10000px;
|
||||||
|
top: auto;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Hide horizontal scrollbar
|
// Hide horizontal scrollbar
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ $gray-200: #E3E4E4;// Used in theme
|
||||||
$gray-300: #D2D4D4;
|
$gray-300: #D2D4D4;
|
||||||
$gray: #B0B3B3;// Default Gray
|
$gray: #B0B3B3;// Default Gray
|
||||||
$gray-500: #8E9292;// Used in theme
|
$gray-500: #8E9292;// Used in theme
|
||||||
|
$gray-550: #727676;// Used in theme
|
||||||
$gray-600: #4D5151;// Used in theme
|
$gray-600: #4D5151;// Used in theme
|
||||||
$gray-700: #303333;// Used in theme
|
$gray-700: #303333;// Used in theme
|
||||||
$gray-800: #222424;// Used in theme
|
$gray-800: #222424;// Used in theme
|
||||||
|
|
@ -130,6 +131,7 @@ $h5-font-size: $font-size-base * 1.25;
|
||||||
$h6-font-size: $font-size-base * .875;
|
$h6-font-size: $font-size-base * .875;
|
||||||
|
|
||||||
//Border Radius
|
//Border Radius
|
||||||
|
// Helper classes are rounded, rounded-1, rounded-2, rounded-3
|
||||||
$border-radius: .25rem;
|
$border-radius: .25rem;
|
||||||
$border-radius-sm: .2rem;
|
$border-radius-sm: .2rem;
|
||||||
$border-radius-lg: .5rem;//Used for buttons. Can be used for other things, of course.
|
$border-radius-lg: .5rem;//Used for buttons. Can be used for other things, of course.
|
||||||
|
|
|
||||||
65
src/ux-components/button-back/button-back.vue
Normal file
65
src/ux-components/button-back/button-back.vue
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
<template>
|
||||||
|
<button class="back-button-wrapper d-flex p-0">
|
||||||
|
<div class="button-back">
|
||||||
|
<div class="arrow-left"></div>
|
||||||
|
<div class="box"></div>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "buttonBack"
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.back-button-wrapper {
|
||||||
|
border: none;
|
||||||
|
background: transparent;
|
||||||
|
.button-back {
|
||||||
|
display: inline-flex;
|
||||||
|
position: relative;
|
||||||
|
height: 18px;
|
||||||
|
width: 23px;
|
||||||
|
overflow: hidden;
|
||||||
|
.arrow-left {
|
||||||
|
position: absolute;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
left: 4px;
|
||||||
|
background-color: $gray-550;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
.box {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
background: $gray-550;
|
||||||
|
height: 100%;
|
||||||
|
width: 11px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
left: 12px;
|
||||||
|
border-radius: 5px;
|
||||||
|
&:before, &:after {
|
||||||
|
position: absolute;
|
||||||
|
left: 1px;
|
||||||
|
top: 3px;
|
||||||
|
content: " ";
|
||||||
|
height: 12px;
|
||||||
|
width: 2px;
|
||||||
|
background-color: $white;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
&:before {
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
&:after {
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="current_car_info-text">
|
<div class="current_car_info-text">
|
||||||
<div class="d-flex align-items-center justify-content-center">
|
<div class="d-flex align-items-center justify-content-center">
|
||||||
<h2 class="text-center text-dark fs-5 d-block fw-normal mb-0">
|
<h2 class="text-center fs-5 d-block fw-normal mb-0">{{ text }}</h2>
|
||||||
{{ text }}
|
|
||||||
</h2>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -16,3 +14,9 @@ export default {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
h2 {
|
||||||
|
color: $gray-550;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
import { shallowMount } from "@vue/test-utils";
|
||||||
import radioHorizontal from "./radio-horizontal";
|
import listButtonHorizontal from "./list-button-horizontal";
|
||||||
|
|
||||||
describe("radio.vue", () => {
|
describe("list-button.vue", () => {
|
||||||
it("Should render the 'radioID' prop value as the label and id value as well as the radio button value, groupName as the name value, and fire a click even that sets the display data attribute to true.", async () => {
|
it("Should render the 'buttonID' prop value as the label and id value as well as the button value, groupName as the name value, and fire a click even that sets the display data attribute to true.", async () => {
|
||||||
// Act
|
// Act
|
||||||
const wrapper = shallowMount(radioHorizontal, {
|
const wrapper = shallowMount(listButtonHorizontal, {
|
||||||
propsData: {
|
propsData: {
|
||||||
radioID: "2023",
|
buttonID: "2023",
|
||||||
groupName: "TestGroup",
|
groupName: "TestGroup",
|
||||||
loaderColor: "blue",
|
loaderColor: "blue",
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
<!-- See the component-test.vue page for example implementation -->
|
||||||
|
<template>
|
||||||
|
<!-- IMPORTANT: Refrain from using more than 4 horizontal buttons on desktop, 3 on mobile. -->
|
||||||
|
<div class="col list-group list-button-horizontal d-flex flex-column mb-2">
|
||||||
|
<input type="radio" :id="buttonID" :name="groupName" :value="buttonID" aria-required="true" @keyup.space="displayComponent"/>
|
||||||
|
<label role="radio" tabindex="-1" aria-checked="false" :for="buttonID" class="d-flex flex-column justify-content-center py-3 px-4" :class="isFirstOrLastButton" @click='displayComponent'>
|
||||||
|
<span class="m-0" :class="[this.textPosition]">{{buttonID}}</span>
|
||||||
|
<span v-if="buttonLabelSubCopy" class="m-0 small" :class="[this.textPosition]">{{buttonLabelSubCopy}}</span>
|
||||||
|
<span v-if="screenReaderOnlyText" class="sr-only">{{screenReaderOnlyText}}</span>
|
||||||
|
<loader v-if="display" :style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" :class="[this.loaderColor, this.loaderPosition]" />
|
||||||
|
</label>
|
||||||
|
<p class="small">{{ errorMessage }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import loader from "@/ux-components/loader/loader";
|
||||||
|
export default {
|
||||||
|
name: "listButtonHorizontal",
|
||||||
|
props: {
|
||||||
|
groupName: String, /* Required, unique for each button GROUP */
|
||||||
|
buttonID: String, /* Required, unique for each button. Used for button id, label and <label for> */
|
||||||
|
buttonLabelSubCopy: String, /* Optional, used for multi-line buttons */
|
||||||
|
screenReaderOnlyText: String, /* Optional, copy to be read by screenreader */
|
||||||
|
textPosition: String, /* Optional, use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */
|
||||||
|
errorMessage: String, /* Optional, if there is an error message to be displayed */
|
||||||
|
loaderColor: String, /* Specify color of loader/spinner. Options are blue, red, green, white, black. Default is blue */
|
||||||
|
loaderPosition: String, /* Specify horizontal position of loader/spinner. Options are center, right, left */
|
||||||
|
sizeInRem: [Number,String], /* Specify size of loader/spinner in rem. Example: 1.5 (equals 24px (16x1.5)) */
|
||||||
|
totalInGroup: Number, /* Required, total number of buttons in group. Used to tell first and last in group to apply border radius. */
|
||||||
|
positionInGroup: Number /* Rquired, position of button in group. Example, 1,2,3 */
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
isError: false,
|
||||||
|
display: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
displayComponent() {
|
||||||
|
this.display = true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
loader,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isFirstOrLastButton() {
|
||||||
|
let className = "";
|
||||||
|
if (this.positionInGroup == this.totalInGroup) {
|
||||||
|
className = "last-item";
|
||||||
|
} else if (this.positionInGroup == 1) {
|
||||||
|
className = "first-item";
|
||||||
|
}
|
||||||
|
return className;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.list-button-horizontal {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
&:checked + label p:first-child {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
label {
|
||||||
|
position: relative;
|
||||||
|
background: $white;
|
||||||
|
transition: all 150ms linear;
|
||||||
|
border: 1px solid $gray-500;
|
||||||
|
width: 100%;
|
||||||
|
&:hover {
|
||||||
|
box-shadow: 0 0 0 4px $blue-100;
|
||||||
|
cursor: pointer;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
+ p {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
&.error {
|
||||||
|
border: 1px solid $danger;
|
||||||
|
+ p {
|
||||||
|
display: flex;
|
||||||
|
color: $danger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&.first-item {
|
||||||
|
border-bottom-left-radius: 0.5rem;
|
||||||
|
border-top-left-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
&.last-item {
|
||||||
|
border-bottom-right-radius: 0.5rem;
|
||||||
|
border-top-right-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1 +1,47 @@
|
||||||
test.todo("some test to be written in the future");
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import listButton from "./list-button";
|
||||||
|
|
||||||
|
describe("list-button.vue", () => {
|
||||||
|
it("Should render the 'buttonID' prop value as the label and id value as well as the button value, groupName as the name value, and fire a click even that sets the display data attribute to true.", async () => {
|
||||||
|
// Act
|
||||||
|
const wrapper = shallowMount(listButton, {
|
||||||
|
propsData: {
|
||||||
|
buttonID: "2023",
|
||||||
|
groupName: "TestGroup",
|
||||||
|
loaderColor: "blue",
|
||||||
|
loaderPosition: "right",
|
||||||
|
sizeInRem: "1.5",
|
||||||
|
errorMessage: "null",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
const input = wrapper.find("input");
|
||||||
|
const label = wrapper.find("label");
|
||||||
|
const paragraph = wrapper.find("span");
|
||||||
|
|
||||||
|
await label.trigger("click");
|
||||||
|
|
||||||
|
expect(input.attributes()).toEqual({
|
||||||
|
id: "2023",
|
||||||
|
type: "radio",
|
||||||
|
value: "2023",
|
||||||
|
name: "TestGroup",
|
||||||
|
"aria-required": "false",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(label.attributes()).toEqual({
|
||||||
|
role: "radio",
|
||||||
|
tabindex: "-1",
|
||||||
|
for: "2023",
|
||||||
|
class: "d-flex flex-column justify-content-center py-3 px-4",
|
||||||
|
"aria-checked": "false",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(label.text()).toEqual("2023");
|
||||||
|
|
||||||
|
expect(paragraph.text()).toEqual("2023");
|
||||||
|
|
||||||
|
expect(wrapper.vm.display).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="d-flex flex-column w-100">
|
<!-- See the component-test.vue page for example implementation -->
|
||||||
<button
|
<div class="list-group list-button d-flex flex-column w-100 mb-2">
|
||||||
class="
|
<input type="radio" :id="buttonID" :name="groupName" :value="buttonID" :aria-required="isRequired" @keyup.space="displayComponent()">
|
||||||
btn
|
<label role="radio" tabindex="-1" aria-checked="false" :for="buttonID" class="d-flex flex-column justify-content-center py-3 px-4" @click='displayComponent()'>
|
||||||
list-button
|
<span class="m-0" :class="[this.textPosition]">{{buttonID}}</span>
|
||||||
d-flex
|
<span v-if="buttonLabelSubCopy" class="m-0 small" :class="[this.textPosition]">{{buttonLabelSubCopy}}</span>
|
||||||
align-items-center
|
<span v-if="screenReaderOnlyText" class="sr-only">{{screenReaderOnlyText}}</span>
|
||||||
justify-content-between
|
<loader v-if="display" :style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" :class="[this.loaderColor, this.loaderPosition]" />
|
||||||
py-3
|
</label>
|
||||||
px-4
|
<p class="small">{{errorMessage}}</p>
|
||||||
"
|
</div>
|
||||||
@click="displayComponent"
|
|
||||||
v-bind:class="[this.isError ? 'error' : '']"
|
|
||||||
>
|
|
||||||
<span class="m-0">{{ this.buttonText }}</span>
|
|
||||||
<loader
|
|
||||||
v-if="display"
|
|
||||||
v-bind:style="{ width: `${sizeInRem}rem`, height: `${sizeInRem}rem` }"
|
|
||||||
v-bind:class="[this.loaderColor, this.loaderPosition]"
|
|
||||||
/>
|
|
||||||
</button>
|
|
||||||
<label class="small mt-1">{{ this.errorText }}</label>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -29,16 +17,21 @@ import loader from "@/ux-components/loader/loader";
|
||||||
export default {
|
export default {
|
||||||
name: "listButton",
|
name: "listButton",
|
||||||
props: {
|
props: {
|
||||||
buttonText: String,
|
groupName: String, /* Required, unique for each button GROUP */
|
||||||
errorText: String,
|
buttonID: String, /* Required, unique for each button. Used for button id, label and <label for> */
|
||||||
loaderColor: String,
|
isRequired: Boolean, /* Optional, default is false */
|
||||||
loaderPosition: String,
|
screenReaderOnlyText: String, /* Optional, copy to be read by screenreader */
|
||||||
sizeInRem: [Number, String],
|
buttonLabelSubCopy: String, /* Optional, used for multi-line buttons */
|
||||||
|
textPosition: String, /* Optional, use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */
|
||||||
|
errorMessage: String, /* Optional, if there is an error message to be displayed */
|
||||||
|
loaderColor: String, /* Specify color of loader/spinner. Options are blue, red, green, white, black. Default is blue */
|
||||||
|
loaderPosition: String, /* Specify horizontal position of loader/spinner. Options are center, right, left */
|
||||||
|
sizeInRem: [Number,String], /* Specify size of loader/spinner in rem. Example: 1.5 (equals 24px (16x1.5)) */
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
display: false,
|
|
||||||
isError: false,
|
isError: false,
|
||||||
|
display: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -48,6 +41,6 @@ export default {
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
loader,
|
loader,
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
1
src/ux-components/list-card/list-card.spec.js
Normal file
1
src/ux-components/list-card/list-card.spec.js
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
test.todo("some test to be written in the future");
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="col mb-3 d-flex radio-card">
|
<div class="col mb-3 d-flex list-card">
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
class="position-absolute opacity-0"
|
class="position-absolute opacity-0"
|
||||||
:class="className"
|
:class="className"
|
||||||
:id="radioID"
|
:id="buttonID"
|
||||||
:name="groupName"
|
:name="groupName"
|
||||||
:value="radioLabel"
|
:value="buttonLabel"
|
||||||
v-model="picked"
|
v-model="picked"
|
||||||
:tabindex="tabIndex"
|
:tabindex="tabIndex"
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
v-bind:for="radioID"
|
v-bind:for="buttonID"
|
||||||
class="rounded-3 d-flex flex-column align-items-center w-100"
|
class="rounded-3 d-flex flex-column align-items-center w-100"
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
class="px-3 pt-3 pb-2 mt-auto"
|
class="px-3 pt-3 pb-2 mt-auto"
|
||||||
v-bind:src="require(`@/assets/img/icons/${radioImage}`)"
|
v-bind:src="require(`@/assets/img/icons/${buttonImage}`)"
|
||||||
v-bind:alt="altText"
|
v-bind:alt="altText"
|
||||||
/>
|
/>
|
||||||
<span class="mt-auto mb-2 text-center lh-1">{{ radioLabel }}</span>
|
<span class="mt-auto mb-2 text-center lh-1">{{ buttonLabel }}</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -28,13 +28,13 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "radioCard",
|
name: "listCard",
|
||||||
props: [
|
props: [
|
||||||
"groupName",
|
"groupName",
|
||||||
"radioLabel",
|
"buttonLabel",
|
||||||
"radioImage",
|
"buttonImage",
|
||||||
"altText",
|
"altText",
|
||||||
"radioID",
|
"buttonID",
|
||||||
"tabIndex",
|
"tabIndex",
|
||||||
"className",
|
"className",
|
||||||
],
|
],
|
||||||
|
|
@ -46,7 +46,7 @@ export default {
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.radio-card {
|
.list-card {
|
||||||
input[type="radio"] {
|
input[type="radio"] {
|
||||||
&:focus + label {
|
&:focus + label {
|
||||||
background-color: $white;
|
background-color: $white;
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div class="loader"
|
||||||
class="loader"
|
role="alert"
|
||||||
v-bind:style="{ width: `${sizeInRem}rem`, height: `${sizeInRem}rem` }"
|
aria-label="Loading new page"
|
||||||
v-bind:class="[this.loaderColor, this.loaderPosition]"
|
v-bind:style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}"
|
||||||
|
v-bind:class="[this.loaderColor, this.loaderPosition]"
|
||||||
></div>
|
></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -61,6 +62,7 @@ export default {
|
||||||
&.center {
|
&.center {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 50%;
|
right: 50%;
|
||||||
|
transform: translateX(50%);
|
||||||
}
|
}
|
||||||
&.right {
|
&.right {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
||||||
<!-- See the component-test.vue page for example implementation -->
|
|
||||||
<!-- role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <div role="radiogroup" aria-labelledby="demo-radio-group" class="col my-3 d-flex align-items-center flex-column"> -->
|
|
||||||
<!-- An h3 with id must be included just before the opening radio button group. ***The id must match the aria-labelledby of the parent div.*** -->
|
|
||||||
<!-- Example -->
|
|
||||||
<!-- <h3 class="visually-hidden" id="demo-radio-group">Select Vehicle Year</h3> -->
|
|
||||||
<template>
|
|
||||||
<!-- IMPORTANT: Refrain from using more than 4 horizontal radio buttons on desktop, 3 on mobile. -->
|
|
||||||
<div class="col radiogroup radio-horizontal d-flex flex-column mb-2">
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
:id="radioID"
|
|
||||||
:name="groupName"
|
|
||||||
:value="radioID"
|
|
||||||
aria-required="true"
|
|
||||||
@keyup.space="displayComponent"
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
role="radio"
|
|
||||||
tabindex="-1"
|
|
||||||
aria-checked="false"
|
|
||||||
:for="radioID"
|
|
||||||
class="d-flex flex-column justify-content-center py-3 px-4"
|
|
||||||
:class="isFirstOrLastButton"
|
|
||||||
@click="displayComponent"
|
|
||||||
>
|
|
||||||
<span class="m-0" :class="[this.textPosition]">{{ radioID }}</span>
|
|
||||||
<span class="m-0 small" :class="[this.textPosition]">{{
|
|
||||||
radioLabelSubCopy
|
|
||||||
}}</span>
|
|
||||||
<loader
|
|
||||||
v-if="display"
|
|
||||||
:style="{ width: `${sizeInRem}rem`, height: `${sizeInRem}rem` }"
|
|
||||||
:class="[this.loaderColor, this.loaderPosition]"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
<p class="small">{{ errorMessage }}</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import loader from "@/ux-components/loader/loader";
|
|
||||||
export default {
|
|
||||||
name: "radioHorizontal",
|
|
||||||
props: {
|
|
||||||
groupName: String /* Required, unique for each radio button GROUP */,
|
|
||||||
radioID:
|
|
||||||
String /* Required, unique for each radio button. Used for button id, label and <label for> */,
|
|
||||||
radioLabelSubCopy: String /* Optional, used for multi-line radio buttons */,
|
|
||||||
textPosition:
|
|
||||||
String /* Optional, use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */,
|
|
||||||
errorMessage:
|
|
||||||
String /* Optional, if there is an error message to be displayed */,
|
|
||||||
loaderColor:
|
|
||||||
String /* Specify color of loader/spinner. Options are blue, red, green, white, black. Default is blue */,
|
|
||||||
loaderPosition:
|
|
||||||
String /* Specify horizontal position of loader/spinner. Options are center, right, left */,
|
|
||||||
sizeInRem: [
|
|
||||||
Number,
|
|
||||||
String,
|
|
||||||
] /* Specify size of loader/spinner in rem. Example: 1.5 (equals 24px (16x1.5)) */,
|
|
||||||
totalInGroup:
|
|
||||||
Number /* Required, total number of radio buttons in group. Used to tell first and last in group to apply border radius. */,
|
|
||||||
positionInGroup:
|
|
||||||
Number /* Rquired, position of radio button in group. Example, 1,2,3 */,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
isError: false,
|
|
||||||
display: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
displayComponent() {
|
|
||||||
this.display = true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
loader,
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
isFirstOrLastButton() {
|
|
||||||
let className = "";
|
|
||||||
if (this.positionInGroup == this.totalInGroup) {
|
|
||||||
className = "last-item";
|
|
||||||
} else if (this.positionInGroup == 1) {
|
|
||||||
className = "first-item";
|
|
||||||
}
|
|
||||||
return className;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<style lang="scss">
|
|
||||||
.radio-horizontal {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
&:checked + label p:first-child {
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
label {
|
|
||||||
position: relative;
|
|
||||||
background: $white;
|
|
||||||
transition: all 150ms linear;
|
|
||||||
border: 1px solid $gray-500;
|
|
||||||
width: 100%;
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 0 0 4px $blue-100;
|
|
||||||
cursor: pointer;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
+ p {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
&.error {
|
|
||||||
border: 1px solid $danger;
|
|
||||||
+ p {
|
|
||||||
display: flex;
|
|
||||||
color: $danger;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&.first-item {
|
|
||||||
border-bottom-left-radius: 0.5rem;
|
|
||||||
border-top-left-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
&.last-item {
|
|
||||||
border-bottom-right-radius: 0.5rem;
|
|
||||||
border-top-right-radius: 0.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
import { shallowMount } from "@vue/test-utils";
|
|
||||||
import radio from "./radio";
|
|
||||||
|
|
||||||
describe("radio.vue", () => {
|
|
||||||
it("Should render the 'radioID' prop value as the label and id value as well as the radio button value, groupName as the name value, and fire a click even that sets the display data attribute to true.", async () => {
|
|
||||||
// Act
|
|
||||||
const wrapper = shallowMount(radio, {
|
|
||||||
propsData: {
|
|
||||||
radioID: "2023",
|
|
||||||
groupName: "TestGroup",
|
|
||||||
loaderColor: "blue",
|
|
||||||
loaderPosition: "right",
|
|
||||||
sizeInRem: "1.5",
|
|
||||||
errorMessage: "null",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
const input = wrapper.find("input");
|
|
||||||
const label = wrapper.find("label");
|
|
||||||
const paragraph = wrapper.find("span");
|
|
||||||
|
|
||||||
await label.trigger("click");
|
|
||||||
|
|
||||||
expect(input.attributes()).toEqual({
|
|
||||||
id: "2023",
|
|
||||||
type: "radio",
|
|
||||||
value: "2023",
|
|
||||||
name: "TestGroup",
|
|
||||||
"aria-required": "true",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(label.attributes()).toEqual({
|
|
||||||
role: "radio",
|
|
||||||
tabindex: "-1",
|
|
||||||
for: "2023",
|
|
||||||
class: "d-flex flex-column justify-content-center py-3 px-4",
|
|
||||||
"aria-checked": "false",
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(label.text()).toEqual("2023");
|
|
||||||
|
|
||||||
expect(paragraph.text()).toEqual("2023");
|
|
||||||
|
|
||||||
expect(wrapper.vm.display).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
<template>
|
|
||||||
<!-- See the component-test.vue page for example implementation -->
|
|
||||||
<!-- role="radiogroup" and aria-labelledby must be included in the parent component for the radio group -->
|
|
||||||
<!-- Example: -->
|
|
||||||
<!-- <div role="radiogroup" aria-labelledby="demo-radio-group" class="col my-3 d-flex align-items-center flex-column"> -->
|
|
||||||
<!-- An h3 with id must be included just before the opening radio button group. ***The id must match the aria-labelledby of the parent div.*** -->
|
|
||||||
<!-- Example -->
|
|
||||||
<!-- <h3 class="visually-hidden" id="demo-radio-group">Select Vehicle Year</h3> -->
|
|
||||||
<div class="radiogroup radio-list-button d-flex flex-column w-100 mb-2">
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
:id="radioID"
|
|
||||||
:name="groupName"
|
|
||||||
:value="radioID"
|
|
||||||
aria-required="true"
|
|
||||||
@keyup.space="displayComponent"
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
role="radio"
|
|
||||||
tabindex="-1"
|
|
||||||
aria-checked="false"
|
|
||||||
:for="radioID"
|
|
||||||
class="d-flex flex-column justify-content-center py-3 px-4"
|
|
||||||
@click="displayComponent"
|
|
||||||
>
|
|
||||||
<span class="m-0" :class="[this.textPosition]">{{ radioID }}</span>
|
|
||||||
<span class="m-0 small" :class="[this.textPosition]">{{
|
|
||||||
radioLabelSubCopy
|
|
||||||
}}</span>
|
|
||||||
<loader
|
|
||||||
v-if="display"
|
|
||||||
:style="{ width: `${sizeInRem}rem`, height: `${sizeInRem}rem` }"
|
|
||||||
: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: String /* Required, unique for each radio button GROUP */,
|
|
||||||
radioID:
|
|
||||||
String /* Required, unique for each radio button. Used for button id, label and <label for> */,
|
|
||||||
radioLabelSubCopy: String /* Optional, used for multi-line radio buttons */,
|
|
||||||
textPosition:
|
|
||||||
String /* Optional, use Bootstrap classes: text-start, text-center, text-end. Default (empty) is text-start */,
|
|
||||||
errorMessage:
|
|
||||||
String /* Optional, if there is an error message to be displayed */,
|
|
||||||
loaderColor:
|
|
||||||
String /* Specify color of loader/spinner. Options are blue, red, green, white, black. Default is blue */,
|
|
||||||
loaderPosition:
|
|
||||||
String /* Specify horizontal position of loader/spinner. Options are center, right, left */,
|
|
||||||
sizeInRem: [
|
|
||||||
Number,
|
|
||||||
String,
|
|
||||||
] /* Specify size of loader/spinner in rem. Example: 1.5 (equals 24px (16x1.5)) */,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
isError: false,
|
|
||||||
display: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
displayComponent() {
|
|
||||||
this.display = true;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
loader,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
@ -17,7 +17,7 @@ module.exports = {
|
||||||
@import "./node_modules/bootstrap/scss/bootstrap";
|
@import "./node_modules/bootstrap/scss/bootstrap";
|
||||||
@import "@/styles/common-styles.scss";
|
@import "@/styles/common-styles.scss";
|
||||||
@import "@/styles/common-button-styles.scss";
|
@import "@/styles/common-button-styles.scss";
|
||||||
@import "@/styles/common-radio-styles.scss";
|
@import "@/styles/common-list-styles.scss";
|
||||||
@import "@/styles/common-typography-styles.scss";
|
@import "@/styles/common-typography-styles.scss";
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ module.exports = {
|
||||||
@import "./node_modules/bootstrap/scss/bootstrap";
|
@import "./node_modules/bootstrap/scss/bootstrap";
|
||||||
@import "@/styles/common-styles.scss";
|
@import "@/styles/common-styles.scss";
|
||||||
@import "@/styles/common-button-styles.scss";
|
@import "@/styles/common-button-styles.scss";
|
||||||
@import "@/styles/common-radio-styles.scss";
|
@import "@/styles/common-list-styles.scss";
|
||||||
@import "@/styles/common-typography-styles.scss";
|
@import "@/styles/common-typography-styles.scss";
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue