CSR-241 add radio button functionality. WIP
This commit is contained in:
parent
82a1fd7057
commit
421b544e7f
2 changed files with 51 additions and 10 deletions
|
|
@ -56,15 +56,31 @@
|
|||
<fieldset>
|
||||
<legend class="sr-only">List Card Demo</legend>
|
||||
<listCard
|
||||
isMultiSelect
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText="Windshield"
|
||||
altText=""
|
||||
buttonID="Damage Location"
|
||||
groupID="checkbox-demo-1"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-2">
|
||||
<div class="col">
|
||||
<h6 class="mx-2 my-4">Functioning as Radio Button</h6>
|
||||
<fieldset>
|
||||
<legend class="sr-only">List Card Demo</legend>
|
||||
<listCard
|
||||
buttonImage="windshield-damage.svg"
|
||||
buttonLabel="Windshield"
|
||||
altText=""
|
||||
buttonID="Damage Location Radio Button"
|
||||
groupID="checkbox-demo-2"
|
||||
/>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-4">
|
||||
<div class="col">
|
||||
<h4 class="m-0 p-2 bg-light rounded">List Button - Single-Line</h4>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,18 @@
|
|||
<template>
|
||||
<div 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="[this.invalid]">
|
||||
<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>
|
||||
</label>
|
||||
</div>
|
||||
<div v-else class="list-card w-100 rounded-3 d-flex align-items-center" :class="[this.invalid]">
|
||||
<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>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
@ -14,9 +21,10 @@ export default {
|
|||
props: {
|
||||
buttonImage: String,
|
||||
buttonLabel: String,
|
||||
altText: String,
|
||||
altText: String,//Leave empty. Screen readers read the buttonLabel text. If alt has content, it will repeat unnecessarily.
|
||||
buttonID: String,
|
||||
groupName: String
|
||||
groupName: String,
|
||||
isMultiSelect: Boolean
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -37,12 +45,11 @@ export default {
|
|||
box-shadow: 0px 0px 0px 6px $blue-100;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
input[type='checkbox'] {
|
||||
position: absolute !important;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
overflow: hidden;
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
input[type='checkbox'],
|
||||
input[type="radio"] {
|
||||
opacity: 0;
|
||||
position: fixed;
|
||||
width: 0;
|
||||
+ label {
|
||||
display: block;
|
||||
position: relative;
|
||||
|
|
@ -92,5 +99,23 @@ export default {
|
|||
background: #ddd;
|
||||
}
|
||||
}
|
||||
input[type="radio"] {
|
||||
+ label::before {
|
||||
content: "";
|
||||
display: none;
|
||||
}
|
||||
+ label::after {
|
||||
content: "";
|
||||
display: none;
|
||||
}
|
||||
+ label {
|
||||
img {
|
||||
height: 46px;
|
||||
width: auto;
|
||||
order: 1;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in a new issue