Merge branch 'develop' into feature/CSR-120_vehicle-banner-2

This commit is contained in:
Adam Caouette 2021-11-29 17:22:50 -05:00
commit 08a6e1e8c3
9 changed files with 147 additions and 110 deletions

View file

@ -19,8 +19,7 @@ describe("radioQuestion.vue", () => {
"Question Text"
);
const radioButtons = wrapper.findAllComponents('[data-test="radio"]');
expect(radioButtons[0].attributes("text")).toEqual("2023");
expect(radioButtons[2].attributes("text")).toEqual("2021");
expect(radioButtons.length).toBe(3);
expect(typeof wrapper.props().chooseAnswer).toBe("function");
});
});

View file

@ -1,18 +1,22 @@
<template>
<div class="radio_question">
<div class="needed_car_info mt-4 mb-3 d-flex">
<div class="needed_car_info mt-4 mb-2 d-flex">
<span class="text-center fs-6 fw-bold w-100 needed_car_info-text">{{
questionText
}}</span>
</div>
<div class="car_list overflow-scroll position-absolute">
<div v-for="answer in answers" :key="answer" class="mb-2">
<radio
:text="answer"
:value="answer"
@click="chooseAnswer(answer)"
data-test="radio"
/>
<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">
<h3 class="visually-hidden" id="select-year-radio-group">*</h3>
<radio v-for="answer in answers" :key="answer" class="mb-2"
:radioID="answer"
@click="chooseAnswer(answer)"
loaderColor="blue"
loaderPosition="right"
sizeInRem="1.5"
data-test="radio"
groupName="radio-list"
/>
</div>
</div>
</div>

View file

@ -48,7 +48,7 @@ export default {
.car_list {
// Height will be determined by overall height of content above list
height: calc(100% - 260px);
height: calc(100% - 255px);
width: calc(100% - 1rem);
}
}

View file

@ -37,8 +37,6 @@
color: $danger;
}
}
//Add spinner. Specify width and height
@include loader();
}
}
}

View file

@ -4,66 +4,3 @@
@mixin blue-gradient {
background: linear-gradient(270deg, $blue-500 0%, $blue-700 100%);
}
//Spinner
//Choose color and position
@mixin loader() {
.loader {
display: flex;
//Open an overlay to prevent page interaction
&:before {
content: '';
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: transparent;
z-index: 9999;
cursor: default;
}
//Spinner basics
&:after {
content: '';
mask: url(../../assets/img/icons/spinner.svg);
mask-size: cover;
position: relative;
width: 100%;
height: 100%;
animation: rotation 1s infinite linear;
@keyframes rotation {
100% {
transform:rotate(360deg);
}
}
}
//Spinner position
&.center {
left: 0;
right: 0;
margin: 0 auto;
}
&.right {
margin: 0 0 0 auto;
}
&.left {
margin: 0 auto 0 0;
}
//Spinner color
&:after { //Default spinner color (blue) if no other color is specified from the options below
background-color: $blue;
}
&.red:after {
background-color: $red;
}
&.green:after {
background-color: $green;
}
&.white:after {
background-color: $white;
}
&.black:after {
background-color: $black;
}
}
}

View file

@ -2,8 +2,8 @@
<div class="alert fade show text-center mb-0" role="alert"
:class="[ isDismissible ? 'alert-dismissible' : '', this.alertClass ]"
>
<p class="m-0 fw-bold alert-heading">{{alertHeadline}}</p>
<p class="m-0 text-body">{{alertCopy}}</p>
<p class="m-0 fw-bold small alert-heading">{{alertHeadline}}</p>
<p class="m-0 text-body small">{{alertCopy}}</p>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23.7 23.7" xml:space="preserve">
<path d="m23.24 2.7-9.15 9.15L23.24 21a1.581 1.581 0 0 1-1.12 2.7c-.42 0-.82-.16-1.12-.46l-9.15-9.15-9.15 9.15c-.3.3-.7.46-1.12.46A1.581 1.581 0 0 1 .46 21l8.47-8.47.68-.68L.46 2.7c-.62-.62-.62-1.62 0-2.24.62-.62 1.62-.62 2.24 0l8.47 8.47.68.68L21 .46a1.57 1.57 0 0 1 2.23 0c.63.62.63 1.62.01 2.24z"/>
@ -46,6 +46,7 @@ export default {
}
}
&.alert-info {
background-color: $blue-100;
.alert-heading {
color: $blue-700;
}
@ -56,26 +57,29 @@ export default {
}
}
&.alert-danger {
background-color: $red-100;
.alert-heading {
color: $red-700;
color: $red-600;
}
svg {
fill: $red-700;
fill: $red-600;
width: 1rem;
height: 1rem;
}
}
&.alert-warning {
background-color: $yellow-100;
.alert-heading {
color: $yellow-700;
color: $yellow-600;
}
svg {
fill: $yellow-700;
fill: $yellow-600;
width: 1rem;
height: 1rem;
}
}
&.alert-success {
background-color: $green-100;
.alert-heading {
color: $green-700;
}

View file

@ -27,5 +27,62 @@ export default {
</script>
<style lang="scss">
@include loader();
.loader {
display: flex;
//Open an overlay to prevent page interaction
&:before {
content: '';
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: transparent;
z-index: 9999;
cursor: default;
}
//Spinner basics
&:after {
content: '';
mask: url(../../assets/img/icons/spinner.svg);
mask-size: cover;
position: relative;
width: 100%;
height: 100%;
animation: rotation 1s infinite linear;
@keyframes rotation {
100% {
transform:rotate(360deg);
}
}
}
//Spinner position
&.center {
left: 0;
right: 0;
margin: 0 auto;
}
&.right {
margin: 0 0 0 auto;
}
&.left {
margin: 0 auto 0 0;
}
//Spinner color
&:after { //Default spinner color (blue) if no other color is specified from the options below
background-color: $blue;
}
&.red:after {
background-color: $red;
}
&.green:after {
background-color: $green;
}
&.white:after {
background-color: $white;
}
&.black:after {
background-color: $black;
}
}
</style>

View file

@ -2,22 +2,46 @@ import { shallowMount } from "@vue/test-utils";
import radio from "./radio";
describe("radio.vue", () => {
it("Should render the 'text' prop value as a span value for the radio button label and add the 'value' prop value as the radio button value and id.", () => {
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: {
value: "2023",
text: "12",
radioID: "2023",
groupName: "TestGroup",
loaderColor: "blue",
loaderPosition: "right",
sizeInRem: "1.5",
errorMessage: 'null'
},
});
// Assert
expect(wrapper.find("span").text()).toEqual("12");
expect(wrapper.find("input").attributes()).toEqual({
class: "position-absolute opacity-0",
const input = wrapper.find("input");
const label = wrapper.find("label");
const paragraph = wrapper.find("p");
await label.trigger('click');
expect(input.attributes()).toEqual({
id: "2023",
type: "radio",
value: "2023",
name: "TestGroup",
});
expect(label.attributes()).toEqual({
role: "radio",
tabindex: "0",
for: "2023",
class: "d-flex align-items-center justify-content-between p-2",
"aria-checked": "false"
});
expect(label.text()).toEqual('2023');
expect(paragraph.text()).toEqual('null');
expect(wrapper.vm.display).toBe(true);
});
});

View file

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