-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
69 lines (61 loc) · 2.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Alpine.js Day Picker</title>
<style>
a {
text-decoration: none;
color: black;
}
.is-disabled {
color: red;
}
.is-active {
color: green;
}
</style>
</head>
<body>
<div id="app">
<div x-data="DayPicker($refs.dayInput)">
<button type="button" @click="currentWeek--" :disabled="currentWeek <= minWeeks">
Previous week
</button>
<input type="number" x-model.number="currentWeek" aria-label="Current week" />
<input
type="date"
x-model="value"
x-ref="dayInput"
:min="subWeeks(today, 3).toISOString().split('T')[0]"
:max="addWeeks(today, 2).toISOString().split('T')[0]"
aria-label="Date"
/>
<button type="button" @click="currentWeek++" :disabled="currentWeek >= maxWeeks">
Next week
</button>
<template x-for="day of daysOfTheWeek" :key="day.getTime()">
<a
href="#"
role="button"
@click.prevent="value = day"
:class="{
'is-active': isSameDay(valueAsDate, day),
'is-disabled': !isDayAvailable(day)
}"
x-bind:aria-disabled="!isDayAvailable(day)"
>
<div>
<span x-text="day.getDate()"></span>
<span x-text="day.toLocaleString('en', { month: 'long' })"></span>
<span x-text="day.getFullYear()"></span>
<span x-text="day.toLocaleString('en', { weekday: 'long' })"></span>
</div>
</a>
</template>
</div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>