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>
|
<fieldset>
|
||||||
<legend class="sr-only">List Card Demo</legend>
|
<legend class="sr-only">List Card Demo</legend>
|
||||||
<listCard
|
<listCard
|
||||||
|
isMultiSelect
|
||||||
buttonImage="windshield-damage.svg"
|
buttonImage="windshield-damage.svg"
|
||||||
buttonLabel="Windshield"
|
buttonLabel="Windshield"
|
||||||
altText="Windshield"
|
altText=""
|
||||||
buttonID="Damage Location"
|
buttonID="Damage Location"
|
||||||
groupID="checkbox-demo-1"
|
groupID="checkbox-demo-1"
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</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="row my-4">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h4 class="m-0 p-2 bg-light rounded">List Button - Single-Line</h4>
|
<h4 class="m-0 p-2 bg-light rounded">List Button - Single-Line</h4>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
<template>
|
<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" />
|
<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">
|
<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" />
|
<img v-bind:src="require(`@/assets/img/icons/${buttonImage}`)" v-bind:alt="altText" />
|
||||||
<p class="m-0 order-3">{{buttonLabel}}</p>
|
<p class="m-0 order-3">{{buttonLabel}}</p>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</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>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -14,9 +21,10 @@ export default {
|
||||||
props: {
|
props: {
|
||||||
buttonImage: String,
|
buttonImage: String,
|
||||||
buttonLabel: 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,
|
buttonID: String,
|
||||||
groupName: String
|
groupName: String,
|
||||||
|
isMultiSelect: Boolean
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -37,12 +45,11 @@ export default {
|
||||||
box-shadow: 0px 0px 0px 6px $blue-100;
|
box-shadow: 0px 0px 0px 6px $blue-100;
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
}
|
}
|
||||||
input[type='checkbox'] {
|
input[type='checkbox'],
|
||||||
position: absolute !important;
|
input[type="radio"] {
|
||||||
height: 1px;
|
opacity: 0;
|
||||||
width: 1px;
|
position: fixed;
|
||||||
overflow: hidden;
|
width: 0;
|
||||||
clip: rect(1px, 1px, 1px, 1px);
|
|
||||||
+ label {
|
+ label {
|
||||||
display: block;
|
display: block;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
@ -92,5 +99,23 @@ export default {
|
||||||
background: #ddd;
|
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>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue