Merge pull request #117 from Safelite/CSR-241-horizontal-list-card
Csr 241 horizontal list card
This commit is contained in:
commit
9bcbd90f82
5 changed files with 170 additions and 68 deletions
|
|
@ -54,14 +54,15 @@
|
|||
<div class="row g-2">
|
||||
<div class="col">
|
||||
<fieldset>
|
||||
<legend class="sr-only">List Card Demo</legend>
|
||||
<legend class="sr-only">Functioning as Checkbox</legend>
|
||||
<listCard
|
||||
isMultiSelect
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="Damage Location"
|
||||
buttonID="List Card Checkbox"
|
||||
groupID="checkbox-demo-1"
|
||||
buttonLabelSubCopy="Description"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
|
@ -70,13 +71,66 @@
|
|||
<div class="col">
|
||||
<h6 class="mx-2 my-4">Functioning as Radio Button</h6>
|
||||
<fieldset>
|
||||
<legend class="sr-only">List Card Demo</legend>
|
||||
<legend class="sr-only">Functioning as Radio Button</legend>
|
||||
<listCard
|
||||
isRadio
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="Damage Location Radio Button"
|
||||
groupID="checkbox-demo-2"
|
||||
buttonID="List Card Radio Button"
|
||||
groupID="radio-demo-2"
|
||||
buttonLabelSubCopy="Description"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col">
|
||||
<h6 class="mx-2 my-4">Horizontal as Checkbox</h6>
|
||||
<fieldset>
|
||||
<legend class="sr-only">Horizontal Checkbox</legend>
|
||||
<listCard
|
||||
isMultiSelectHorizontal
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="List Card Horizontal Checkbox"
|
||||
groupID="checkbox-demo-3"
|
||||
buttonLabelSubCopy="Description"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col">
|
||||
<h6 class="mx-2 my-4">Horizontal as Radio Button</h6>
|
||||
<fieldset>
|
||||
<legend class="sr-only">Horizontal Radio Button</legend>
|
||||
<listCard
|
||||
isRadioHorizontal
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="List Card Horizontal Radio Button"
|
||||
groupID="radio-demo-4"
|
||||
buttonLabelSubCopy="Description"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col">
|
||||
<h6 class="mx-2 my-4">With error</h6>
|
||||
<fieldset>
|
||||
<legend class="sr-only">Radio button with error state</legend>
|
||||
<listCard
|
||||
isRadioHorizontal
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="Horizontal Radio Button Error State"
|
||||
groupID="radio-demo-5"
|
||||
buttonLabelSubCopy="Description"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
|
@ -105,6 +159,8 @@
|
|||
loaderPosition="right"
|
||||
sizeInRem="1"
|
||||
screenReaderOnlyText="(opens new window)"
|
||||
hasError
|
||||
errorMessage="Error"
|
||||
/>
|
||||
<listButton
|
||||
isMultiSelect
|
||||
|
|
|
|||
|
|
@ -33,13 +33,6 @@
|
|||
+ p {
|
||||
display: none;
|
||||
}
|
||||
&.error {
|
||||
border: 1px solid $danger;
|
||||
+ p {
|
||||
display: flex;
|
||||
color: $danger;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,12 @@ $font-family-base: $font-family-sans-serif;
|
|||
$font-family-code: $font-family-monospace;
|
||||
$font-size-base: 1rem; // Assumes the browser default, typically `16px`
|
||||
|
||||
//Custom Font size (extra small)
|
||||
$font-size-xsm: $font-size-base * .75;
|
||||
$font-sizes: (
|
||||
7: $font-size-xsm
|
||||
);
|
||||
|
||||
//Font weight
|
||||
$font-weight-lighter: lighter;
|
||||
$font-weight-light: 300;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
<span v-if="buttonLabelSubCopy" class="m-0 small" :class="[this.textPosition]">{{buttonLabelSubCopy}}</span>
|
||||
<span v-if="screenReaderOnlyText" class="sr-only">{{screenReaderOnlyText}}</span>
|
||||
</label>
|
||||
<p class="small">{{errorMessage}}</p>
|
||||
</div>
|
||||
<div v-else class="list-group list-button d-flex flex-column w-100 mb-2">
|
||||
<input type="radio" :id="buttonID" :name="groupName" :value="buttonID" :aria-required="isRequired" @keyup.space="displayLoader()">
|
||||
|
|
@ -17,7 +16,6 @@
|
|||
<span v-if="screenReaderOnlyText" class="sr-only">{{screenReaderOnlyText}}</span>
|
||||
<loader v-if="isLoaderDisplayed" :style="{width: `${sizeInRem}rem`, height: `${sizeInRem}rem`}" :class="[this.loaderColor, this.loaderPosition]" />
|
||||
</label>
|
||||
<p class="small">{{errorMessage}}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -40,7 +38,6 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
isError: false,
|
||||
isLoaderDisplayed: false,
|
||||
};
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,16 +1,38 @@
|
|||
<template>
|
||||
<div v-if="isMultiSelect" class="list-card w-100 rounded-3 d-flex align-items-center" :class="[this.invalid]">
|
||||
<div v-if="isMultiSelect" class="list-card w-100 rounded-3 d-flex align-items-center" :class="{'error': hasError}">
|
||||
<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" tabindex="1">
|
||||
<img v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
||||
<p class="m-0 order-3">{{buttonLabel}}</p>
|
||||
<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 class="fs-7 m-0 order-4">{{buttonLabelSubCopy}}</p>
|
||||
</label>
|
||||
</div>
|
||||
<div v-else class="list-card w-100 rounded-3 d-flex align-items-center" :class="[this.invalid]">
|
||||
<div v-else-if="isRadio" class="list-card w-100 rounded-3 d-flex align-items-center" :class="{'error': hasError}">
|
||||
<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" tabindex="1">
|
||||
<img v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
||||
<p class="m-0 order-3">{{buttonLabel}}</p>
|
||||
<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 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" :class="{'error': hasError}">
|
||||
<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-3 ps-3 pe-8" 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 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" :class="{'error': hasError}">
|
||||
<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-3 ps-3 pe-8" 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 class="m-0 fs-7">{{buttonLabelSubCopy}}</p>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -24,21 +46,28 @@ export default {
|
|||
altText: String,//Leave empty. Screen readers read the buttonLabel text. If alt has content, it will repeat unnecessarily.
|
||||
buttonID: String,
|
||||
groupName: String,
|
||||
isMultiSelect: Boolean
|
||||
isMultiSelect: Boolean,
|
||||
isRadio: Boolean,
|
||||
isMultiSelectHorizontal: Boolean,
|
||||
isRadioHorizontal: Boolean,
|
||||
buttonLabelSubCopy: String,
|
||||
hasError: Boolean
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.list-card {
|
||||
&.error {
|
||||
border: 1px solid $red !important;
|
||||
}
|
||||
border: 1px solid $gray-500;
|
||||
&.invalid { //Red border if invalid
|
||||
border: 1px solid $red;
|
||||
}
|
||||
img {
|
||||
height: 46px;
|
||||
width: auto;
|
||||
order: 1;
|
||||
height: auto;
|
||||
width: 2.875rem;
|
||||
margin-bottom: 3rem;
|
||||
}
|
||||
&:hover {
|
||||
|
|
@ -51,69 +80,90 @@ export default {
|
|||
position: fixed;
|
||||
width: 0;
|
||||
+ label {
|
||||
display: block;
|
||||
position: relative;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
&: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: "";
|
||||
display: block;
|
||||
position: relative;
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
&: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: 4rem 0 0 0;
|
||||
margin: 3rem 0 0 0;
|
||||
background: white;
|
||||
border: 1px solid $gray-500;
|
||||
border-radius: 2px;
|
||||
order: 2;
|
||||
}
|
||||
&:checked + label::before {
|
||||
background: $blue;
|
||||
}
|
||||
&:checked + label::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
margin: 4.2rem 0 0 0;
|
||||
border-left: 2px solid $white;
|
||||
border-bottom: 2px solid $white;
|
||||
height: 6px;
|
||||
width: 11px;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
&:disabled + label {
|
||||
color: #575757;
|
||||
}
|
||||
&:disabled + label::before {
|
||||
background: #ddd;
|
||||
}
|
||||
}
|
||||
+ 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;
|
||||
display: none;
|
||||
}
|
||||
+ label::after {
|
||||
content: "";
|
||||
display: none;
|
||||
display: none;
|
||||
}
|
||||
+ label {
|
||||
img {
|
||||
height: 46px;
|
||||
width: auto;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
&.horizontal {
|
||||
img {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
input[type='checkbox'],
|
||||
input[type="radio"] {
|
||||
+ label::before {
|
||||
content: "";
|
||||
position: relative;
|
||||
margin: 0 .5rem 0 0;
|
||||
order: 1;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
&:checked + label::after {
|
||||
content: '';
|
||||
margin: -0.25rem 0 0 0;
|
||||
left: .875rem;
|
||||
}
|
||||
+ label {
|
||||
img {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue