386 lines
15 KiB
Vue
386 lines
15 KiB
Vue
<template>
|
|
<div id="app">
|
|
<fieldset>
|
|
<legend class=" sr-only">Date Picker</legend>
|
|
<div class="calendar-grid-container">
|
|
<div class="month-year body-small d-flex align-items-center ps-3 small">{{currentMonth}} {{currentYear}}</div>
|
|
<div class="legend caption d-flex align-items-center justify-content-end"><span class="legend-circle me-1"></span> = Available</div>
|
|
<div class="nav-back ps-3"><button></button></div>
|
|
<div class="nav-forward pe-3"><button></button></div>
|
|
<!-- Do the days of the weeek need to be read? -->
|
|
<div class="grid-item caption"><span class="sr-only">Sunday</span>S</div>
|
|
<div class="grid-item caption"><span class="sr-only">Monday</span>M</div>
|
|
<div class="grid-item caption"><span class="sr-only">Tuesday</span>T</div>
|
|
<div class="grid-item caption"><span class="sr-only">Wednesday</span>W</div>
|
|
<div class="grid-item caption"><span class="sr-only">Thursday</span>T</div>
|
|
<div class="grid-item caption"><span class="sr-only">Friday</span>F</div>
|
|
<div class="grid-item caption"><span class="sr-only">Saturday</span>S</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="-2" hidden type="radio" name="day-of-month" id="sep-30" />
|
|
<label class="past-day" for="sep-30"><span>30</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="-2" hidden type="radio" name="day-of-month" id="sep-31" />
|
|
<label class="past-day" for="sep-31"><span>31</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-1" />
|
|
<label class="highlighted-day selectable-day" for="oct-1"><span class="sr-only">{{dayOfWeek}} {{pastMonth}} {{dayOfMonth}}</span><span>1</span></label>
|
|
<div v-if="isFirstDayOfMonth" class="current-month first-of-month">OCT</div>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-2" />
|
|
<label class="highlighted-day selectable-day" :class="[isCurrentDay ? 'current-day' : '']" for="oct-2"><span>2</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-3" />
|
|
<label class="highlighted-day selectable-day" for="oct-3"><span>3</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-4" />
|
|
<label class="highlighted-day selectable-day" for="oct-4"><span>4</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-5" />
|
|
<label class="highlighted-day selectable-day" for="oct-5"><span>5</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-6" />
|
|
<label class="highlighted-day selectable-day" for="oct-6"><span>6</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-7" />
|
|
<label class="highlighted-day selectable-day" for="oct-7"><span>7</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-8" />
|
|
<label class="highlighted-day selectable-day" for="oct-8"><span>8</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-9" />
|
|
<label class="highlighted-day selectable-day" for="oct-9"><span>9</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-10" />
|
|
<label class="highlighted-day selectable-day" for="oct-10"><span>10</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-11" />
|
|
<label class="highlighted-day selectable-day" for="oct-11"><span>11</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-12" />
|
|
<label class="highlighted-day selectable-day" for="oct-12"><span>12</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-13" />
|
|
<label class="highlighted-day selectable-day" for="oct-13"><span>13</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-14" />
|
|
<label class="highlighted-day selectable-day" for="oct-14"><span>17</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-15" />
|
|
<label class="highlighted-day selectable-day" for="oct-15"><span>15</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-16" />
|
|
<label class="highlighted-day selectable-day" for="oct-16"><span>16</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-17" />
|
|
<label class="highlighted-day selectable-day" for="oct-17"><span>17</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-18" />
|
|
<label class="highlighted-day selectable-day" for="oct-18"><span>18</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-19" />
|
|
<label class="highlighted-day selectable-day" for="oct-19"><span>19</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-20" />
|
|
<label class="highlighted-day selectable-day" for="oct-20"><span>20</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-21" />
|
|
<label class="highlighted-day selectable-day" for="oct-21"><span>21</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-22" />
|
|
<label class="highlighted-day selectable-day" for="oct-22"><span>22</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-23" />
|
|
<label class="highlighted-day selectable-day" for="oct-23"><span>23</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-24" />
|
|
<label class="highlighted-day selectable-day" for="oct-24"><span>24</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-25" />
|
|
<label class="highlighted-day selectable-day" for="oct-25"><span>25</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-26" />
|
|
<label class="highlighted-day selectable-day" for="oct-26"><span>26</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-27" />
|
|
<label class="highlighted-day selectable-day" for="oct-27"><span>27</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-28" />
|
|
<label class="highlighted-day selectable-day" for="oct-28"><span>28</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-29" />
|
|
<label class="highlighted-day selectable-day" for="oct-29"><span>29</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-30" />
|
|
<label class="highlighted-day selectable-day" for="oct-30"><span>30</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="oct-31" />
|
|
<label class="highlighted-day selectable-day" for="oct-31"><span>31</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper future-day">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="nov-1" />
|
|
<label class="future-day selectable-day" for="nov-1"><span>1</span></label>
|
|
</div>
|
|
<div class="grid-item radio-wrapper future-day">
|
|
<input tabindex="0" type="radio" name="day-of-month" id="nov-2" />
|
|
<label class="future-day selectable-day" for="nov-2"><span>2</span></label>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: "datePicker",
|
|
data() {
|
|
return {
|
|
dayOfWeek: "Tuesday",
|
|
dayOfMonth: "1st",
|
|
pastMonth: "October",
|
|
currentMonth: "October",
|
|
currentYear: "2022",
|
|
isFirstDayOfMonth: true,
|
|
isCurrentDay: true,
|
|
isCurrentDayDot: true,
|
|
isPastDay: true,
|
|
};
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.calendar-grid-container {
|
|
margin: 0 auto;
|
|
max-width: 414px;
|
|
display: grid;
|
|
//grid-template-columns: auto auto auto auto auto auto auto;
|
|
grid-template-columns: repeat(7, 1fr);
|
|
justify-content: center;
|
|
align-items: center;
|
|
padding: 4px;
|
|
|
|
.grid-item {
|
|
text-align: center;
|
|
margin: 10%;
|
|
}
|
|
|
|
.month-year {
|
|
grid-area: 1 / 1 / 2 / 4;
|
|
text-transform: uppercase;
|
|
}
|
|
.legend {
|
|
grid-area: 1 / 4 / 2 / 6;
|
|
.legend-circle {
|
|
border-radius: 50%;
|
|
width: 16px;
|
|
height: 16px;
|
|
background-color: $blue-100;
|
|
border: 1px solid $blue;
|
|
}
|
|
}
|
|
.nav-back {
|
|
grid-area: 1 / 6 / 2 / 7;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
button {
|
|
&:after {
|
|
content: "";
|
|
position: absolute;
|
|
width: 7px;
|
|
height: 12px;
|
|
background-image: url("data:image/svg+xml,%3Csvg width='7' height='12' viewBox='0 0 7 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0.331685 6.00121C0.330445 5.82446 0.399256 5.65442 0.523053 5.52832L5.84499 0.198256C5.97188 0.0713149 6.14397 -8.63821e-08 6.32341 -6.72174e-08C6.50285 -4.80527e-08 6.67495 0.071315 6.80183 0.198256C6.92872 0.325198 7 0.497368 7 0.67689C7 0.856412 6.92872 1.02858 6.80183 1.15552L1.94874 6.00121L6.80183 10.8526C6.92745 10.9796 6.99751 11.1512 6.99662 11.3299C6.99572 11.5085 6.92393 11.6794 6.79705 11.8051C6.67016 11.9308 6.49857 12.0009 6.32003 12C6.14148 11.9991 5.97061 11.9273 5.84499 11.8003L0.526881 6.47601C0.401568 6.34983 0.331375 6.17908 0.331685 6.00121Z' fill='%231574A1'/%3E%3C/svg%3E%0A");
|
|
}
|
|
}
|
|
}
|
|
.nav-forward {
|
|
grid-area: 1 / 7 / 2 / 8;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
button {
|
|
&:after {
|
|
content: "";
|
|
position: absolute;
|
|
width: 7px;
|
|
height: 12px;
|
|
background-image: url("data:image/svg+xml,%3Csvg width='7' height='12' viewBox='0 0 7 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.66831 5.99879C6.66955 6.17554 6.60074 6.34558 6.47695 6.47168L1.15501 11.8017C1.02812 11.9287 0.85603 12 0.676587 12C0.497145 12 0.325053 11.9287 0.198168 11.8017C0.0712831 11.6748 7.268e-09 11.5026 8.07183e-09 11.3231C8.87567e-09 11.1436 0.0712831 10.9714 0.198168 10.8445L5.05126 5.99879L0.198168 1.14736C0.0725521 1.02042 0.00248585 0.848755 0.00338306 0.670131C0.00428028 0.491506 0.0760674 0.320554 0.202952 0.194881C0.329837 0.0692091 0.501426 -0.000888818 0.679971 9.54485e-06C0.858515 0.000906955 1.02939 0.0727263 1.15501 0.199668L6.47312 5.52399C6.59843 5.65017 6.66862 5.82092 6.66831 5.99879Z' fill='%231574A1'/%3E%3C/svg%3E%0A");
|
|
}
|
|
}
|
|
}
|
|
|
|
.nav-back,
|
|
.nav-forward {
|
|
button {
|
|
position: relative;
|
|
border-radius: 50%;
|
|
width: 28px;
|
|
height: 28px;
|
|
background-color: $blue-100;
|
|
border: 1px solid $blue;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
&:focus {
|
|
box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px #1574a1;
|
|
background-color: $blue;
|
|
color: $white;
|
|
}
|
|
}
|
|
}
|
|
|
|
.radio-wrapper {
|
|
position: relative;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
outline: none;
|
|
|
|
input[type="radio"] {
|
|
position: absolute;; //override bootstrap
|
|
height: 0;
|
|
opacity: 0;
|
|
|
|
&:focus-visible + label {
|
|
box-shadow: 0 0 0 2.5px $blue;
|
|
}
|
|
&:focus + label,
|
|
&:checked:focus + label {
|
|
box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px #1574a1;
|
|
background-color: $blue;
|
|
color: $white;
|
|
&.past-day {
|
|
box-shadow: none;
|
|
background-color: transparent;
|
|
color: $gray-500;
|
|
font-weight: normal;
|
|
}
|
|
&.current-day {
|
|
&:after {
|
|
background-color: $white;
|
|
}
|
|
}
|
|
+ .first-of-month {
|
|
color: $white;
|
|
}
|
|
}
|
|
&:checked + label {
|
|
color: $blue;
|
|
//font-weight: 500;
|
|
box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px #1574a1;
|
|
background-color: $blue;
|
|
color: $white;
|
|
}
|
|
&:checked + label p,
|
|
&:checked + label span {
|
|
//font-weight: 500;
|
|
}
|
|
}
|
|
|
|
.first-of-month {
|
|
position: absolute;
|
|
font-size: 9px;
|
|
color: $blue;
|
|
top: 0;
|
|
z-index: 1;
|
|
}
|
|
|
|
label {
|
|
position: relative;
|
|
cursor: pointer;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
width: 40px;
|
|
height: 40px;
|
|
min-width: 40px;
|
|
border-radius: 50%;
|
|
|
|
&.past-day {
|
|
color: $gray-500;
|
|
background-color: transparent;
|
|
border: 1px solid transparent;
|
|
pointer-events: none;
|
|
}
|
|
|
|
&.highlighted-day {
|
|
color: $blue;
|
|
background-color: $blue-100;
|
|
border: 1px solid $blue;
|
|
}
|
|
|
|
&.current-day {
|
|
&:after {
|
|
content: '';
|
|
width: .25rem;
|
|
height: .25rem;
|
|
border-radius: 50%;
|
|
background-color: $blue;
|
|
position: absolute;
|
|
top: 28px;
|
|
}
|
|
}
|
|
|
|
&.future-day {
|
|
|
|
}
|
|
|
|
&.selectable-day {
|
|
&:hover {
|
|
cursor: pointer;
|
|
}
|
|
}
|
|
|
|
span {
|
|
&.small {
|
|
font-size: .75rem;
|
|
color: $gray-550;
|
|
}
|
|
}
|
|
|
|
&:hover {
|
|
@include media-breakpoint-up(sm) {
|
|
box-shadow: 0 0 0 4px transparent;
|
|
background-color: $blue;
|
|
color: $white;
|
|
}
|
|
cursor: pointer;
|
|
}
|
|
+ p {
|
|
display: none;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
</style>
|