176 lines
5.8 KiB
Vue
176 lines
5.8 KiB
Vue
<template>
|
|
<!-- Heavily documented below -->
|
|
<div v-if="isMultiSelect" class="list-card w-100 rounded-3 d-flex align-items-center h-100">
|
|
<input type="checkbox" :id="buttonID" :name="groupName" :value="buttonLabel" :aria-required="isRequired" />
|
|
<label :for="buttonID" class="d-flex flex-column w-100 align-items-center pt-4 pb-2 px-2 h-100" tabindex="1">
|
|
<img class="order-1" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
|
<p class="small m-0 order-3">{{buttonLabel}}</p>
|
|
<p v-if="buttonLabelSubCopy" class="fs-7 m-0 order-4">{{buttonLabelSubCopy}}</p>
|
|
</label>
|
|
</div>
|
|
<div v-else-if="isRadio" class="list-card w-100 rounded-3 d-flex align-items-center h-100">
|
|
<input type="radio" :id="buttonID" :name="groupName" :value="buttonID" :aria-required="isRequired" />
|
|
<label :for="buttonID" class="d-flex flex-column w-100 align-items-center pt-4 pb-2 px-2 h-100" tabindex="1">
|
|
<img class="order-1" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
|
<p class="small mt-2 mb-0 order-2">{{buttonLabel}}</p>
|
|
<p v-if="buttonLabelSubCopy" class="fs-7 m-0 order-3">{{buttonLabelSubCopy}}</p>
|
|
</label>
|
|
</div>
|
|
<div v-else-if="isMultiSelectHorizontal" class="list-card horizontal w-100 rounded-3 d-flex align-items-center h-100">
|
|
<input type="checkbox" :id="buttonID" :name="groupName" :value="buttonLabel" :aria-required="isRequired" />
|
|
<label :for="buttonID" class="d-flex flex-row w-100 align-items-center py-r ps-3 pe-8 px-2 h-100" tabindex="1" :class="{'checkboxTop': buttonLabelSubCopy}">
|
|
<img class="ms-auto order-3" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
|
<div class="order-2">
|
|
<p class="m-0 small">{{buttonLabel}}</p>
|
|
<p v-if="buttonLabelSubCopy" class="m-0 fs-7">{{buttonLabelSubCopy}}</p>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
<div v-else-if="isRadioHorizontal" class="list-card horizontal w-100 rounded-3 d-flex align-items-center h-100">
|
|
<input type="radio" :id="buttonID" :name="groupName" :value="buttonLabel" :aria-required="isRequired" />
|
|
<label :for="buttonID" class="d-flex flex-row w-100 align-items-center py-r ps-3 pe-8 px-2 h-100" tabindex="1" :class="{'checkboxTop': buttonLabelSubCopy}">
|
|
<img class="ms-auto order-3" v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
|
<div class="order-2">
|
|
<p class="m-0 small">{{buttonLabel}}</p>
|
|
<p v-if="buttonLabelSubCopy" class="m-0 fs-7">{{buttonLabelSubCopy}}</p>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "listCard",
|
|
props: {
|
|
//Must choose one of the following four options
|
|
isMultiSelect: Boolean, //Defines use as checkbox
|
|
isRadio: Boolean, //Defines use as radio button
|
|
isMultiSelectHorizontal: Boolean, //Defines use as horizontal checkbox
|
|
isRadioHorizontal: Boolean, //Defines use as horizontal radio button
|
|
//end must choose
|
|
buttonImage: String,//Required: File name of image
|
|
buttonLabel: String,//Required: Label text
|
|
isRequired: Boolean, //Required: is aria-required required or not?
|
|
altText: String,//Leave empty. Screen readers read the buttonLabel text. If alt has content, it will repeat unnecessarily.
|
|
buttonID: String,//Required: Unique
|
|
groupName: String,//Required: Unique
|
|
buttonLabelSubCopy: String,//Optional: sub tex
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.list-card {
|
|
border: 1px solid $gray-500;
|
|
&.invalid { //Red border if invalid
|
|
border: 1px solid $red;
|
|
}
|
|
img {// svg's should be constructed on the same canvas size/viewbox to ensure they occupy the same space in the DOM. This will allow easy/proper alignment of elements. See exisitng svg's for examples.
|
|
height: auto;
|
|
width: 6.5rem;
|
|
margin-bottom: 3rem;
|
|
}
|
|
&:hover {
|
|
box-shadow: 0px 0px 0px 6px $blue-100;
|
|
border: 1px solid transparent;
|
|
}
|
|
input[type='checkbox'],
|
|
input[type="radio"] {
|
|
opacity: 0;
|
|
position: fixed;
|
|
width: 0;
|
|
+ label {
|
|
display: block;
|
|
position: relative;
|
|
&:hover {
|
|
cursor: pointer;
|
|
}
|
|
p {
|
|
text-align: center;
|
|
}
|
|
}
|
|
&:focus + label {
|
|
box-shadow: 0 0 0 2.5px $blue;
|
|
border-radius: .5rem;
|
|
}
|
|
&:checked + label {
|
|
background: $blue-100;
|
|
box-shadow: 0 0 0 1px $blue;
|
|
border-radius: .5rem;
|
|
}
|
|
+ label::before {
|
|
content: "";
|
|
position: absolute;
|
|
display: flex;
|
|
margin: 0 auto;
|
|
width: 1rem;
|
|
height: 1rem;
|
|
margin: 3rem 0 0 0;
|
|
background: white;
|
|
border: 1px solid $gray-500;
|
|
border-radius: 2px;
|
|
order: 2;
|
|
}
|
|
+ label.checkboxTop::before {
|
|
margin: -1.25rem 0.5rem 0 0 !important;
|
|
}
|
|
+ label.checkboxTop::after {
|
|
margin: -1.5rem 0.5rem 0 0 !important;
|
|
}
|
|
&:checked + label::before {
|
|
background: $blue;
|
|
}
|
|
&:checked + label::after {
|
|
content: '';
|
|
position: absolute;
|
|
margin: 3.2rem 0 0 0;
|
|
border-left: 2px solid $white;
|
|
border-bottom: 2px solid $white;
|
|
height: 6px;
|
|
width: 11px;
|
|
transform: rotate(-45deg);
|
|
}
|
|
}
|
|
input[type="radio"] {
|
|
+ label::before {
|
|
content: "";
|
|
display: none;
|
|
}
|
|
+ label::after {
|
|
content: "";
|
|
display: none;
|
|
}
|
|
+ label {
|
|
img {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
}
|
|
&.horizontal {
|
|
img {
|
|
margin-bottom: 0;
|
|
width: 5.5rem;
|
|
}
|
|
input[type='checkbox'],
|
|
input[type="radio"] {
|
|
+ label::before {
|
|
content: "";
|
|
position: relative;
|
|
margin: 0 .5rem 0 0;
|
|
order: 1;
|
|
}
|
|
&:checked + label::after {
|
|
content: '';
|
|
margin: -0.25rem 0 0 0;
|
|
left: .875rem;
|
|
}
|
|
+ label {
|
|
min-height: 48px;
|
|
img {
|
|
margin-bottom: 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|