CSR-341 WIP nested radio demo

This commit is contained in:
bmauger 2022-02-18 08:50:45 -05:00
parent ec2b033cfe
commit ab23fe5fe7
3 changed files with 129 additions and 58 deletions

View file

@ -1,27 +1,89 @@
<template> <template>
<h5>POC</h5>
<div class="container-fluid nested-radio">
<div class="row mb-1 demo-animate"><!-- demo-animate for demo only -->
<div class="col">
<listCard
groupName="listcard1"
isWide="true"
buttonImage="https://digitalconsumercms-dev.safelite.com/images/default-source/damage-options/car.svg?sfvrsn=1468d7f1_3"
buttonLabel="Green Tint, Blue Shade"
buttonID="radio1"
/>
</div>
</div>
<div class="row mb-1 show-hide"><!-- show-hide for demo only -->
<div class="col">
<p class="mb-0 fw-bold">Ok, select the features</p>
<radio ref="radio"
groupName="group1"
buttonLabel="rain sensor, solar, 3rd visor band"
buttonID="button1"
isRequired
value="test button"
screenReaderOnlyText="rain sensor, solar, 3rd visor band"
/>
<radio ref="radio"
groupName="group1"
buttonLabel="rain sensor, heated glass, solar, 3rd visor band"
buttonID="button2"
isRequired
value="test button"
screenReaderOnlyText="rain sensor, heated glass, solar, 3rd visor band"
/>
</div>
</div>
<div class="row mb-2">
<div class="col">
<listCard
groupName="listcard1"
isWide="true"
buttonImage="https://digitalconsumercms-dev.safelite.com/images/default-source/damage-options/car.svg?sfvrsn=1468d7f1_3"
buttonLabel="Green Tint"
buttonID="radio2"
/>
</div>
</div>
</div>
</template> </template>
<script> <script>
import listCard from "@/ux-components/list-card/list-card"; import listCard from "@/ux-components/list-card/list-card";
import radio from "@/ux-components/radio/radio"; import radio from "@/ux-components/radio/radio";
export default { export default {
name: "nestedRadio", name: "nestedRadio",
props: { components: {
groupName: String, radio,
buttonLabel: String, listCard,
buttonID: String, }
isRequired: Boolean,
value: {
type: [String, Number],
default: "",
},
screenReaderOnlyText: String,
hasError: Boolean,
},
}; };
</script> </script>
<style lang="scss">
.nested-radio {
padding: 20px; // For demo only
.ui-radio {
margin: .25rem 0;
}
p {
font-size: .875rem;
}
// For demo only
.show-hide {
max-height: 0;
transition: max-height 0.35s ease-out;
overflow: hidden;
}
.demo-animate {
&:hover {
+ .show-hide {
max-height: 100px;
transition: max-height 0.35s ease-in;
}
}
}
// END for demo only
}
</style>

View file

@ -173,6 +173,7 @@ export default {
&:checked + label { &:checked + label {
p { p {
color: $black; color: $black;
font-weight: 500;
} }
.sub-copy { .sub-copy {
color: $gray-600; color: $gray-600;

View file

@ -11,7 +11,7 @@
:v-model="checkValue" :v-model="checkValue"
@change="handleCheckChanged" @change="handleCheckChanged"
/> />
<label class="d-flex align-items-center" :for="buttonID"> <label class="d-flex align-items-center radio-label" :for="buttonID">
<p v-if="buttonLabel" class="m-0">{{ buttonLabel }}</p> <p v-if="buttonLabel" class="m-0">{{ buttonLabel }}</p>
<span v-if="screenReaderOnlyText" class="sr-only">{{ <span v-if="screenReaderOnlyText" class="sr-only">{{
screenReaderOnlyText screenReaderOnlyText
@ -81,58 +81,66 @@ export default {
.ui-radio { .ui-radio {
position: relative; position: relative;
input[type="radio"] { input[type="radio"] {
position: absolute !important; position: absolute!important;
height: 1px; height: 1px;
width: 1px; width: 1px;
overflow: hidden; overflow: hidden;
clip: rect(1px, 1px, 1px, 1px); clip: rect(1px,1px,1px,1px);
+ label { + .radio-label {
display: block; &:before {
position: relative; content: '';
&:hover { background: $white;
border-radius: 100%;
border: 1px solid $gray-500;
display: inline-block;
width: 16px;
height: 16px;
position: relative;
margin-right: .5rem;
vertical-align: top;
cursor: pointer; cursor: pointer;
transition: all 250ms ease;
flex-shrink: 0;
} }
} }
+ label::before { &:checked {
content: ""; + .radio-label {
position: relative; &:before {
display: inline-block; background-color: $blue;
margin-right: 8px; box-shadow: inset 0 0 0 2px $white;
width: 16px; }
height: 16px; }
background: white;
border: 1px solid $gray-500;
border-radius: 50%;
} }
&:checked + label::before { &:hover {
background: $white; + label {
border: 1px solid $blue; cursor: pointer;
&:before {
box-shadow: 0 0 0 4px #9fcee6;
}
}
} }
&:checked + label::after { &:focus {
content: ""; + label {
position: absolute; &:before {
top: 8px; box-shadow: 0 0 0 2px #1574a1;
left: 3px; }
height: 6px; }
width: 6px;
transform: rotate(-45deg);
border: 5px solid $blue;
border-radius: 50%;
} }
&:hover + label::before { &:disabled {
box-shadow: 0 0 0 4px $blue-300; + .radio-label {
&:before {
box-shadow: inset 0 0 0 4px $gray-550;
border-color: $gray-550;
background: $gray-550;
}
}
} }
&:focus + label::before { + .radio-label {
box-shadow: 0 0 0 2px $blue; &:empty {
} &:before {
&:focus:checked + label::before { margin-right: 0;
box-shadow: 0 0 0 2px transparent; }
} }
&:disabled + label {
color: $gray-200;
}
&:disabled + label::before {
background: $gray-200;
} }
} }
} }