Cleaning up props for radio question component
This commit is contained in:
parent
882667c8f7
commit
4ca5d09def
7 changed files with 66 additions and 54 deletions
|
|
@ -1,36 +1,35 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="isVehicleQuestion ? 'button_question' : ''">
|
<div :class="isOverflowScrollable ? 'button_question' : ''">
|
||||||
<div v-if="questionText" class="mt-6 mb-4 d-flex">
|
<div v-if="questionText" class="mt-6 mb-4 d-flex">
|
||||||
<span class="text-center fs-6 fw-bold w-100">{{
|
<span class="text-center fs-6 fw-bold w-100">{{
|
||||||
questionText
|
questionText
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="w-100 d-flex justify-content-center">
|
<div class="w-100 d-flex justify-content-center">
|
||||||
<fieldset class="w-100" :class="isVehicleQuestion ? vehicleQuestionClasses : ''" role="radiogroup" :aria-labelledby="groupName ? groupName + '-radio-group' : ''">
|
<fieldset class="w-100" :class="getFieldSetClasses" role="radiogroup" :aria-labelledby="groupName ? groupName + '-radio-group' : ''">
|
||||||
<legend class="sr-only">{{groupName}}</legend>
|
<legend class="sr-only">{{groupName}}</legend>
|
||||||
<div :class="isRow ? 'row g-2' : isColumn ? columnClasses : 'w-100'">
|
<div :class="getComponentWrapperClasses">
|
||||||
<component :is="buttonType" v-for="answer in answers" :key="answer"
|
<component :is="buttonType" v-for="answer in answers" :key="answer"
|
||||||
:buttonID="answer.Name ? answer.Name : answer"
|
|
||||||
@mouseup="chooseAnswer(answer.Name ? answer.Name : answer)"
|
@mouseup="chooseAnswer(answer.Name ? answer.Name : answer)"
|
||||||
@keyup.space="chooseAnswer(answer.Name ? answer.Name : answer)"
|
@keyup.space="chooseAnswer(answer.Name ? answer.Name : answer)"
|
||||||
|
:buttonID="answer.Name ? answer.Name : answer"
|
||||||
|
:buttonLabel="answer.Text ? answer.Text : answer"
|
||||||
|
:buttonLabelSubCopy="answer.SubText"
|
||||||
|
:textPosition="textPosition"
|
||||||
|
:isMultiSelect="isMultiSelect"
|
||||||
|
:groupName="groupName"
|
||||||
:loaderEnabled="loaderEnabled"
|
:loaderEnabled="loaderEnabled"
|
||||||
:loaderColor="loaderColor"
|
:loaderColor="loaderColor"
|
||||||
:loaderPosition="loaderPosition"
|
:loaderPosition="loaderPosition"
|
||||||
:sizeInRem="sizeInRem"
|
:sizeInRem="sizeInRem"
|
||||||
data-test="button"
|
:isWide="isWide"
|
||||||
:groupName="groupName"
|
|
||||||
:textPosition="textPosition"
|
|
||||||
screenReaderOnlyText="(opens new window)"
|
|
||||||
:isMultiSelect="isMultiSelect"
|
|
||||||
:isHorizontal="isHorizontal"
|
|
||||||
:ariaLabelBy="ariaLabelBy"
|
|
||||||
:isRequired="isRequired"
|
:isRequired="isRequired"
|
||||||
:buttonImage="answer.AnswerImageUrl"
|
:buttonImage="answer.AnswerImageUrl"
|
||||||
:buttonImageId="answer.ImageId"
|
:buttonImageId="answer.ImageId"
|
||||||
:buttonLabel="answer.Text ? answer.Text : answer"
|
:altText="answer.Name ? answer.Name : answer"
|
||||||
:altText="altText"
|
screenReaderOnlyText="(opens new window)"
|
||||||
:buttonLabelSubCopy="answer.SubText"
|
|
||||||
:value="modelValue"
|
:value="modelValue"
|
||||||
|
data-test="button"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
@ -51,6 +50,7 @@ export default {
|
||||||
default: 'listButton'
|
default: 'listButton'
|
||||||
},
|
},
|
||||||
isMultiSelect: Boolean,
|
isMultiSelect: Boolean,
|
||||||
|
groupName: String,
|
||||||
questionText: String,
|
questionText: String,
|
||||||
answers: Array,
|
answers: Array,
|
||||||
textPosition: {
|
textPosition: {
|
||||||
|
|
@ -70,25 +70,30 @@ export default {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
default: 1.5
|
default: 1.5
|
||||||
},
|
},
|
||||||
modelValue: String,
|
|
||||||
groupName: String,
|
|
||||||
ariaLabelBy: String,
|
|
||||||
isRequired: Boolean,
|
isRequired: Boolean,
|
||||||
isVehicleQuestion: Boolean,
|
isOverflowScrollable: Boolean,
|
||||||
isHorizontal: Boolean,
|
isWide: Boolean,
|
||||||
isColumn: Boolean,
|
modelValue: String,
|
||||||
isRow: Boolean,
|
|
||||||
buttonImage: String,
|
|
||||||
buttonImageId: String,
|
|
||||||
buttonLabel: String,
|
|
||||||
altText: String,
|
|
||||||
buttonLabelSubCopy: String,
|
|
||||||
},
|
},
|
||||||
data() {
|
computed: {
|
||||||
return {
|
getFieldSetClasses(){
|
||||||
vehicleQuestionClasses: 'container-fluid overflow-scroll position-absolute px-5 pt-1 py-0',
|
return this.isOverflowScrollable ? 'container-fluid overflow-scroll position-absolute px-5 pt-1 py-0' : '';
|
||||||
columnClasses: 'd-flex flex-row p-0'
|
},
|
||||||
};
|
getComponentWrapperClasses() {
|
||||||
|
let classes;
|
||||||
|
switch(this.buttonType) {
|
||||||
|
case 'listButton':
|
||||||
|
classes = 'w-100'
|
||||||
|
break;
|
||||||
|
case 'listButtonHorizontal':
|
||||||
|
classes = 'd-flex flex-row p-0'
|
||||||
|
break;
|
||||||
|
case 'listCard':
|
||||||
|
classes = 'row g-2'
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return classes;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
chooseAnswer(answer) {
|
chooseAnswer(answer) {
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@
|
||||||
<legend class="sr-only">Horizontal Checkbox</legend>
|
<legend class="sr-only">Horizontal Checkbox</legend>
|
||||||
<listCard
|
<listCard
|
||||||
isMultiSelect
|
isMultiSelect
|
||||||
isHorizontal
|
isWide
|
||||||
buttonImage="windshield-damage.svg"
|
buttonImage="windshield-damage.svg"
|
||||||
buttonLabel="Windshield"
|
buttonLabel="Windshield"
|
||||||
altText=""
|
altText=""
|
||||||
|
|
@ -180,7 +180,7 @@
|
||||||
<legend class="sr-only">Checkbox no Description</legend>
|
<legend class="sr-only">Checkbox no Description</legend>
|
||||||
<listCard
|
<listCard
|
||||||
isMultiSelect
|
isMultiSelect
|
||||||
isHorizontal
|
isWide
|
||||||
buttonImage="side-window-damage-right-all.svg"
|
buttonImage="side-window-damage-right-all.svg"
|
||||||
buttonLabel="Side Window"
|
buttonLabel="Side Window"
|
||||||
altText=""
|
altText=""
|
||||||
|
|
@ -197,7 +197,7 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend class="sr-only">Horizontal Radio Button</legend>
|
<legend class="sr-only">Horizontal Radio Button</legend>
|
||||||
<listCard
|
<listCard
|
||||||
isHorizontal
|
isWide
|
||||||
buttonImage="back-glass-damage.svg"
|
buttonImage="back-glass-damage.svg"
|
||||||
buttonLabel="Rear Window"
|
buttonLabel="Rear Window"
|
||||||
altText=""
|
altText=""
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend class="sr-only">Radio Button no Description</legend>
|
<legend class="sr-only">Radio Button no Description</legend>
|
||||||
<listCard
|
<listCard
|
||||||
isHorizontal
|
isWide
|
||||||
buttonImage="windshield-damage.svg"
|
buttonImage="windshield-damage.svg"
|
||||||
buttonLabel="Windshield"
|
buttonLabel="Windshield"
|
||||||
altText=""
|
altText=""
|
||||||
|
|
@ -833,7 +833,7 @@
|
||||||
/>
|
/>
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
isMultiSelect
|
isMultiSelect
|
||||||
isHorizontal
|
isWide
|
||||||
:answers="listCardCheckBoxHorizontal"
|
:answers="listCardCheckBoxHorizontal"
|
||||||
buttonType="listCard"
|
buttonType="listCard"
|
||||||
ariaLabelBy="horizontal_check_card"
|
ariaLabelBy="horizontal_check_card"
|
||||||
|
|
@ -842,7 +842,7 @@
|
||||||
/>
|
/>
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
isMultiSelect
|
isMultiSelect
|
||||||
isHorizontal
|
isWide
|
||||||
:answers="listCardCheckBoxHorizontalSubText"
|
:answers="listCardCheckBoxHorizontalSubText"
|
||||||
buttonType="listCard"
|
buttonType="listCard"
|
||||||
ariaLabelBy="horizontal_check_card-st"
|
ariaLabelBy="horizontal_check_card-st"
|
||||||
|
|
@ -850,7 +850,7 @@
|
||||||
questionText="With Subtext"
|
questionText="With Subtext"
|
||||||
/>
|
/>
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
isHorizontal
|
isWide
|
||||||
:answers="listRadioHorizontal"
|
:answers="listRadioHorizontal"
|
||||||
buttonType="listCard"
|
buttonType="listCard"
|
||||||
ariaLabelBy="horizontal_radio_card"
|
ariaLabelBy="horizontal_radio_card"
|
||||||
|
|
@ -858,7 +858,7 @@
|
||||||
questionText="List Card Horizontal as radio"
|
questionText="List Card Horizontal as radio"
|
||||||
/>
|
/>
|
||||||
<buttonQuestion
|
<buttonQuestion
|
||||||
isHorizontal
|
isWide
|
||||||
:answers="listRadioHorizontalSubText"
|
:answers="listRadioHorizontalSubText"
|
||||||
buttonType="listCard"
|
buttonType="listCard"
|
||||||
ariaLabelBy="horizontal_radio_card-st"
|
ariaLabelBy="horizontal_radio_card-st"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<buttonQuestion class="radioQuestion"
|
<buttonQuestion class="radioQuestion"
|
||||||
|
isOverflowScrollable
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
:answers="makes"
|
:answers="makes"
|
||||||
groupName="Choose Vehicle Make"
|
groupName="Choose Vehicle Make"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
:isVehicleQuestion="true"
|
|
||||||
:loaderEnabled="true"
|
:loaderEnabled="true"
|
||||||
v-model="modelValue"
|
v-model="modelValue"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<buttonQuestion class="radioQuestion"
|
<buttonQuestion class="radioQuestion"
|
||||||
|
isOverflowScrollable
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
:answers="models"
|
:answers="models"
|
||||||
groupName="Choose Vehicle Model"
|
groupName="Choose Vehicle Model"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
:isVehicleQuestion="true"
|
|
||||||
:loaderEnabled="true"
|
:loaderEnabled="true"
|
||||||
v-model="modelValue"
|
v-model="modelValue"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<buttonQuestion class="radioQuestion"
|
<buttonQuestion class="radioQuestion"
|
||||||
|
isOverflowScrollable
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
:answers="styles"
|
:answers="styles"
|
||||||
groupName="Choose Vehicle Style"
|
groupName="Choose Vehicle Style"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
:isVehicleQuestion="true"
|
|
||||||
:loaderEnabled="true"
|
:loaderEnabled="true"
|
||||||
v-model="modelValue"
|
v-model="modelValue"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<buttonQuestion class="radioQuestion"
|
<buttonQuestion class="radioQuestion"
|
||||||
|
isOverflowScrollable
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
:answers="years"
|
:answers="years"
|
||||||
groupName="Choose Vehicle Year"
|
groupName="Choose Vehicle Year"
|
||||||
:isVehicleQuestion="true"
|
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
:loaderEnabled="true"
|
:loaderEnabled="true"
|
||||||
v-model="modelValue"
|
v-model="modelValue"
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- Heavily documented below -->
|
<!-- Heavily documented below -->
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="list-card w-100 rounded-3 d-flex align-items-center h-100" :class="isHorizontal ? 'horizontal' : ''">
|
<div class="list-card w-100 rounded-3 d-flex align-items-center h-100" :class="isWide ? 'horizontal' : ''">
|
||||||
<input :type="isMultiSelect ? 'checkbox' : 'radio'" :id="buttonID" :name="groupName" :value="buttonID" :aria-required="isRequired" @click="handleChange(value)" :data-focus-target="groupName" />
|
<input :type="isMultiSelect ? 'checkbox' : 'radio'" :id="buttonID" :name="groupName" :value="buttonID" :aria-required="isRequired" @click="handleChange(value)" :data-focus-target="groupName" />
|
||||||
<label :for="buttonID" class="d-flex w-100 align-items-center px-2 h-100" :class="[isHorizontal ? rowClasses : columnClasses,isHorizontal && buttonLabelSubCopy ? 'checkboxTop' : '']" tabindex="-1">
|
<label :for="buttonID" class="d-flex w-100 align-items-center px-2 h-100" :class="getLabelClasses" tabindex="-1">
|
||||||
<img :id="buttonImageId" :class="!isHorizontal ? 'order-1' : 'ms-auto order-3'" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" :alt="altText" />
|
<img :id="buttonImageId" :class="!isWide ? 'order-1' : 'ms-auto order-3'" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" :alt="altText" />
|
||||||
<p v-if="!isHorizontal" class="small order-3" :class="isMultiSelect ? 'm-0' : 'mt-2 mb-0'">{{buttonLabel}}</p>
|
<p v-if="!isWide" class="small order-3" :class="isMultiSelect ? 'm-0' : 'mt-2 mb-0'">{{buttonLabel}}</p>
|
||||||
<p v-if="buttonLabelSubCopy && !isHorizontal" class="fs-7 m-0 order-4">{{buttonLabelSubCopy}}</p>
|
<p v-if="buttonLabelSubCopy && !isWide" class="fs-7 m-0 order-4">{{buttonLabelSubCopy}}</p>
|
||||||
<div v-if="isHorizontal" class="order-2">
|
<div v-if="isWide" class="order-2">
|
||||||
<p class="m-0 small">{{buttonLabel}}</p>
|
<p class="m-0 small">{{buttonLabel}}</p>
|
||||||
<p v-if="buttonLabelSubCopy" class="m-0 fs-7">{{buttonLabelSubCopy}}</p>
|
<p v-if="buttonLabelSubCopy" class="m-0 fs-7">{{buttonLabelSubCopy}}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -25,7 +25,7 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
//Must choose one of the following four options
|
//Must choose one of the following four options
|
||||||
isMultiSelect: Boolean, //Defines use as checkbox
|
isMultiSelect: Boolean, //Defines use as checkbox
|
||||||
isHorizontal: Boolean,
|
isWide: Boolean,
|
||||||
//end must choose
|
//end must choose
|
||||||
buttonImage: String,//Required: File name of image
|
buttonImage: String,//Required: File name of image
|
||||||
buttonImageId: String,
|
buttonImageId: String,
|
||||||
|
|
@ -40,10 +40,17 @@ export default {
|
||||||
default: ""
|
default: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data(){
|
computed: {
|
||||||
return {
|
getLabelClasses(){
|
||||||
columnClasses: "flex-column pt-4 pb-2",
|
if(this.isWide) {
|
||||||
rowClasses: "flex-row py-r ps-3 pe-8"
|
let classes = "flex-row py-r ps-3 pe-8";
|
||||||
|
if(this.buttonLabelSubCopy) {
|
||||||
|
classes += " checkboxTop"
|
||||||
|
}
|
||||||
|
return classes
|
||||||
|
} else {
|
||||||
|
return "flex-column pt-4 pb-2";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue