-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
2118 lines (2006 loc) · 89.4 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MiniJS</title>
<script src="/dist/minijs.umd.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/base16/google-light.min.css"
/>
<script>
hljs.highlightAll()
MiniJS.debug = false
</script>
</head>
<body class="pb-64">
<header class="flex items-center justify-center p-10">
<div>
<h1 class="text-3xl text-black font-mono font-bold">MiniJS</h1>
<nav class="mt-4">
<ul class="flex justify-center text-xs">
<li>
<a
href="./demo/observer.html"
class="text-blue-900 font-medium hover:underline focus:underline"
>
DOM Observer
</a>
</li>
</ul>
</nav>
</div>
</header>
<section class="p-5 bg-gray-100 mt-10">
<div class="max-w-5xl mx-auto">
<div class="flex items-center justify-between mb-5">
<h3 class="font-bold font-mono">AirBnB Search Bar:</h3>
</div>
<div :clickout="showSearch = false">
<script>
showSearch = false
selectedTab = 'Where'
destination = ''
totalMonths = 12
checkIn = ''
checkOut = ''
// Where Tab
regions = [
{
name: "I'm flexible",
image:
'https://a0.muscache.com/pictures/f9ec8a23-ed44-420b-83e5-10ff1f071a13.jpg',
alt: 'Map of whole world',
value: '',
},
{
name: 'Europe',
image:
'https://a0.muscache.com/im/pictures/7b5cf816-6c16-49f8-99e5-cbc4adfd97e2.jpg',
alt: 'Map of Europe',
value: 'Europe',
},
{
name: 'Japan',
image:
'https://a0.muscache.com/im/pictures/26891a81-b9db-4a9c-8aab-63486b7e627c.jpg?im_w=320',
alt: 'Map of Japan',
value: 'Japan',
},
{
name: 'United States',
image:
'https://a0.muscache.com/im/pictures/4e762891-75a3-4fe1-b73a-cd7e673ba915.jpg',
alt: 'Map of United States',
value: 'United States',
},
{
name: 'South Korea',
image:
'https://a0.muscache.com/im/pictures/c193e77c-0b2b-4f76-8101-b869348d8fc4.jpg',
alt: 'Map of South Korea',
value: 'South Korea',
},
{
name: 'Australia',
image:
'https://a0.muscache.com/im/pictures/42a1fb0f-214c-41ec-b9d7-135fbbdb8316.jpg',
alt: 'Map of Australia',
value: 'Australia',
},
]
destinations = [
'Boracay, Philippines',
'Kyoto, Japan',
'Barcelona, Spain',
'Santorini, Greece',
'Paris, France',
'London, United Kingdom',
'New York, United States',
'Cape Town, South Africa',
'Rio de Janeiro, Brazil',
'Sydney, Australia',
]
filteredDestinations = []
selectedDestination = ''
// When Tab
months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
]
whenSelectedTab = 'Flexible'
whenHowLong = 'Week'
selectedMonths = []
scrollPosition = 'middle'
SCROLL_OFFSET = 128
function getStartAndEndMonth(totalMonths) {
const today = new Date()
const startMonth = today.getMonth() + 1
const endMonth = today.getMonth() + 1 + totalMonths
const startDate = new Date(today.getFullYear(), startMonth, 1)
const endDate = new Date(today.getFullYear(), endMonth, 1)
return [startDate, endDate]
}
function getSliderValue(position) {
const rect = document
.querySelector('.slider')
.getBoundingClientRect()
const dx = position.x - rect.left - rect.width / 2
const dy = position.y - rect.top - rect.height / 2
const theta = Math.atan2(dy, dx)
const left = 50 + 50 * Math.cos(theta)
const top = 50 + 50 * Math.sin(theta)
let percentage = ((theta + Math.PI / 2) / (2 * Math.PI)) * 100
if (percentage < 0) percentage += 100
return { left, top, percentage }
}
</script>
<div class="flex items-center justify-center">
<div
id="search-bar"
role="search"
class="inline-block p-3 rounded-full bg-white text-gray-900 border border-gray-300 cursor-pointer shadow"
aria-labelledby="airbnb-search"
:class="showSearch ? 'hidden' : ''"
:click="showSearch = true"
>
<span id="airbnb-search" class="sr-only">Start your search</span>
<div class="flex justify-between divide-x divide-gray-300">
<div
type="button"
class="w-full py-0.5 px-4 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap"
>
<span class="sr-only">Location</span>
Anywhere
</div>
<div
type="button"
class="w-full py-0.5 px-4 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap"
>
<span class="sr-only">Check In / Check Out</span>
Any week
</div>
<button
type="button"
class="w-full py-0.5 px-4 flex items-center justify-center text-sm text-gray-500 font-normal whitespace-nowrap"
>
<span class="sr-only">Guests</span>
Add guests
<span
class="ml-4 -mr-5 -my-3 inline-block p-2 bg-red-500 text-white rounded-full"
aria-hidden="true"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
class="w-4 h-4"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"
/>
</svg>
</span>
</button>
</div>
</div>
</div>
<div
class="z-10 w-full flex flex-col gap-8 duration-300 transition-all opacity-0 h-0"
:class="showSearch ? 'h-auto opacity-100 translate-y-0 pointer-events-auto' : 'h-0 translate-y-4 opacity-0 pointer-events-none'"
>
<div class="mx-auto w-max flex gap-8">
<button
type="button"
class="text-base text-gray-900 underline decoration-2 underline-offset-8 decoration-gray-900"
>
Stays
</button>
<button type="button" class="text-base text-gray-900">
Experiences
</button>
<button type="button" class="text-base text-gray-900">
Online Experiences
</button>
</div>
<div
role="search"
class="relative w-full rounded-full bg-gray-200 text-gray-900 border border-gray-300 shadow"
>
<div class="flex justify-between divide-x divide-gray-300">
<div
class="relative w-full py-4 px-6 flex flex-col gap-1 text-sm text-gray-900 font-medium whitespace-nowrap rounded-full border-none cursor-pointer transition-colors duration-100"
tabindex="0"
:class="selectedTab === 'Where' ? 'bg-white shadow-lg' : 'hover:bg-gray-300'"
:press="selectedTab = 'Where';
$('#destination').focus();"
>
<label
htmlFor="destination"
class="font-bold text-xs pointer-events-none"
>
Where
</label>
<input
id="destination"
type="text"
:value="destination"
:change="destination = this.value;
filteredDestinations = destinations.search(destination)
const region = regions.find((region) => region.name === destination)
if (region)
selectedDestination = region.name
else if (filteredDestinations.length)
selectedDestination = filteredDestinations.first
else
selectedDestination = null"
:keyup.up="selectedDestination = filteredDestinations.previousItem(selectedDestination)"
:keyup.down="selectedDestination = filteredDestinations.nextItem(selectedDestination)"
placeholder="Search destinations"
class="bg-transparent font-normal placeholder:text-gray-400 focus:outline-none"
:keyup.enter="if (selectedDestination == null) return
destination = selectedDestination;
selectedTab = whenSelectedTab === 'Dates' ? 'Check In' : 'When'
this.blur();"
/>
<button
class="absolute top-1/2 right-4 -translate-y-1/2 p-1 text-gray-900 rounded-full hover:bg-gray-300 focus:bg-gray-100"
:class="destination.length && selectedTab === 'Where' ? '' : 'hidden'"
:click="destination = ''"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
class="w-4 h-4"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
<span class="sr-only">Close</span>
</button>
</div>
<div
class="relative w-full py-4 px-6 flex flex-col gap-1 text-sm text-gray-900 font-medium whitespace-nowrap rounded-full border-none cursor-pointer transition-colors duration-100"
tabindex="0"
:class="(selectedTab === 'Check In' ? 'bg-white shadow-lg' : 'hover:bg-gray-300')
+ (whenSelectedTab !== 'Dates' ? ' hidden' : '')"
:press="selectedTab = 'Check In'"
>
<label
htmlFor="check-in"
class="font-bold text-xs pointer-events-none"
>
Check In
</label>
<input
id="check-in"
type="text"
:value="checkIn"
placeholder="Add dates"
class="bg-transparent font-normal placeholder:text-gray-400 focus:outline-none pointer-events-none"
disabled
/>
</div>
<div
class="relative w-full py-4 px-6 flex flex-col gap-1 text-sm text-gray-900 font-medium whitespace-nowrap rounded-full border-none cursor-pointer transition-colors duration-100"
tabindex="0"
:class="(selectedTab === 'Check Out' ? 'bg-white shadow-lg' : 'hover:bg-gray-300')
+ (whenSelectedTab !== 'Dates' ? ' hidden' : '')"
:press="selectedTab = 'Check Out'"
>
<label
htmlFor="check-out"
class="font-bold text-xs pointer-events-none"
>
Check Out
</label>
<input
id="check-out"
type="text"
:value="checkOut"
placeholder="Add dates"
class="bg-transparent font-normal placeholder:text-gray-400 focus:outline-none pointer-events-none"
disabled
/>
</div>
<div
class="relative w-full py-4 px-6 flex flex-col gap-1 text-sm text-gray-900 font-medium whitespace-nowrap rounded-full border-none cursor-pointer transition-colors duration-100"
tabindex="0"
:class="(selectedTab === 'When' ? 'bg-white shadow-lg' : 'hover:bg-gray-300')
(whenSelectedTab === 'Dates' ? 'hidden' : '')"
:press="selectedTab = 'When'"
>
<span class="sr-only">Check In / Check Out</span>
<label
htmlFor="time"
class="font-bold text-xs pointer-events-none"
>
When
</label>
<input
id="time"
type="text"
:value="if (whenSelectedTab === 'Flexible') {
return selectedMonths.length
? `${whenHowLong} in ${selectedMonths.join(', ')}`
: `Any ${whenHowLong.toLowerCase()}`
}
if (whenSelectedTab === 'Months') {
const [startDate, endDate] = getStartAndEndMonth(totalMonths);
let date = startDate.toLocaleString('default', {
month: 'short',
year: 'numeric',
day: 'numeric',
})
date += ' - '
date += endDate.toLocaleString('default', {
month: 'short',
year: 'numeric',
day: 'numeric',
})
return date
}
return ''"
class="bg-transparent pointer-events-none text-ellipsis"
disabled
/>
</div>
<div
class="relative w-full py-4 px-6 flex flex-col gap-1 text-sm text-gray-900 font-medium whitespace-nowrap rounded-full border-none cursor-pointer transition-colors duration-100"
tabindex="0"
:class="selectedTab === 'Who' ? 'bg-white shadow-lg' : 'hover:bg-gray-300'"
:press="selectedTab = 'Who'"
>
<span class="sr-only">Guests</span>
Add guests
</div>
</div>
</div>
<div id="search-flyout" class="-mt-6">
<!-- Where: Search by Region -->
<div
class="w-max p-6 bg-white rounded-3xl border border-gray-300 shadow"
:class="selectedTab === 'Where' && (regions.some((region) => region.name === destination) || !destination.length) ? '' : 'hidden'"
>
<div class="text-xs font-bold text-gray-900">
Search by region
</div>
<div
class="my-6 grid grid-cols-3 gap-x-3 gap-y-6"
:each="region in regions"
>
<div class="flex flex-col gap-2">
<button
type="button"
class="h-32 w-32 border border-gray-300 rounded-lg overflow-hidden hover:border-gray-900 focus:border-gray-900"
:click="destination = region.value;
selectedTab = whenSelectedTab === 'Dates' ? 'Check In' : 'When'"
:class="region.name === destination ? 'border-gray-900' : ''"
>
<img
class="touch-none h-full w-full"
:src="region.image"
:alt="region.alt"
/>
</button>
<div
class="text-sm text-gray-600"
:text="region.name"
></div>
</div>
</div>
</div>
<!-- Where: Search Results -->
<div
class="w-max py-6 bg-white rounded-3xl border border-gray-300 shadow"
:class="selectedTab === 'Where' && destination.length && !regions.some((region) => region.name === destination) ? '' : 'hidden'"
>
<ul :each="place in filteredDestinations">
<li
class="px-6"
:class="selectedDestination == place ? 'bg-gray-100' : ''"
>
<button
type="button"
class="py-2 flex items-center gap-2"
:click="destination = place;
selectedTab = whenSelectedTab === 'Dates' ? 'Check In' : 'When'"
:mouseover="selectedDestination = place"
>
<div class="p-3 bg-gray-200 rounded-lg">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-6 h-6"
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M15 10.5a3 3 0 11-6 0 3 3 0 016 0z"
/>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z"
/>
</svg>
</div>
<div class="text-base text-gray-700" :text="place"></div>
</button>
</li>
</ul>
<p
class="px-6 text-sm text-gray-700"
:class="filteredDestinations.length ? 'sr-only' : ''"
>
There are no results matching your search.
</p>
</div>
<!-- When -->
<div
class="w-full py-6 bg-white text-center rounded-3xl border border-gray-300 shadow overflow-hidden"
:class="['When', 'Check In', 'Check Out'].includes(selectedTab) ? '' : 'hidden'"
>
<div
class="mx-auto p-1 w-max flex gap-1 bg-gray-200 rounded-full"
>
<button
type="button"
class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100"
:class="whenSelectedTab === 'Dates' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'"
:click="whenSelectedTab = 'Dates'; selectedTab = 'Check In';"
>
Dates
</button>
<button
type="button"
class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100"
:class="whenSelectedTab === 'Months' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'"
:click="whenSelectedTab = 'Months'; selectedTab = 'When';"
>
Months
</button>
<button
type="button"
class="py-2 px-6 flex items-center justify-center text-sm text-gray-900 font-medium whitespace-nowrap rounded-full cursor-pointer transition-colors duration-100"
:class="whenSelectedTab === 'Flexible' ? 'bg-white ring-1 ring-gray-300' : 'hover:bg-gray-300'"
:click="whenSelectedTab = 'Flexible'; selectedTab = 'When';"
>
Flexible
</button>
</div>
<!-- When - Flexible -->
<div
class="mt-8 flex flex-col items-center justify-center gap-8"
:class="whenSelectedTab === 'Flexible' ? '' : 'hidden'"
>
<div class="flex flex-col gap-3">
<div class="text-lg font-medium text-gray-900">
How long would you like to stay?
</div>
<div class="flex gap-2">
<button
type="button"
class="py-2 px-4 text-base text-gray-900 rounded-full"
:class="whenHowLong === 'Weekend' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'"
:click="whenHowLong = 'Weekend';"
>
Weekend
</button>
<button
type="button"
class="py-2 px-4 text-base text-gray-900 rounded-full"
:class="whenHowLong === 'Week' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'"
:click="whenHowLong = 'Week';"
>
Week
</button>
<button
type="button"
class="py-2 px-4 text-base text-gray-900 rounded-full"
:class="whenHowLong === 'Month' ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'"
:click="whenHowLong = 'Month';"
>
Month
</button>
</div>
</div>
<div class="flex flex-col gap-3">
<div class="text-lg font-medium text-gray-900">
When do you want to go?
</div>
<style>
.scrollbar-hidden::-webkit-scrollbar {
display: none;
}
.scrollbar-hidden {
-ms-overflow-style: none;
scrollbar-width: none;
}
</style>
<div class="max-w-4xl relative">
<button
type="button"
:class="scrollPosition === 'left' ? 'hidden' : ''"
class="absolute top-1/2 -translate-y-1/2 -left-4 h-8 w-8 flex items-center justify-center bg-white text-gray-900 rounded-full border border-gray-300 shadow-lg"
:click="$('#months').scrollBy({ top: 0, left: -SCROLL_OFFSET, behavior: 'smooth' });
scrollPosition = $('#months').scrollLeft <= SCROLL_OFFSET
? 'left'
: 'middle';"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z"
clip-rule="evenodd"
/>
</svg>
<span class="sr-only">Previous Months</span>
</button>
<ul
id="months"
class="p-1 flex gap-2 overflow-y-auto scrollbar-hidden"
:each="month in months"
>
<li>
<button
type="button"
class="h-36 w-28 flex flex-col items-center justify-center gap-1 text-center text-gray-900 rounded-2xl"
:class="selectedMonths.includes(month) ? 'ring-2 ring-gray-900' : 'ring-1 ring-gray-200'"
:click="selectedMonths.toggle(month);"
>
<span
:class="selectedMonths.includes(month) ? 'text-gray-900' : 'text-gray-600'"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-10 h-10"
:
aria-hidden="true"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5"
/>
</svg>
</span>
<span
class="text-base text-gray-900"
:text="month"
></span>
</button>
</li>
</ul>
<button
type="button"
:class="scrollPosition === 'right' ? 'hidden' : ''"
class="absolute top-1/2 -translate-y-1/2 -right-4 h-8 w-8 flex items-center justify-center bg-white text-gray-900 rounded-full border border-gray-300 shadow-lg"
:click="$('#months').scrollBy({ top: 0, left: SCROLL_OFFSET, behavior: 'smooth' });
scrollPosition = $('#months').scrollLeftMax - $('#months').scrollLeft - SCROLL_OFFSET <= 0
? 'right'
: 'middle';"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
fill="currentColor"
class="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z"
clip-rule="evenodd"
/>
</svg>
<span class="sr-only">Next Months</span>
</button>
</div>
</div>
</div>
<!-- When - Months -->
<div
class="mt-8 flex flex-col items-center justify-center gap-8"
:class="whenSelectedTab === 'Months' ? '' : 'hidden'"
>
<div class="text-lg font-medium text-gray-900">
When's your trip?
</div>
<style>
.slider-fill:before {
background: conic-gradient(
var(--fill-color) calc(var(--percentage) * 1%),
#0000 0
);
}
</style>
<!-- Slider -->
<div
class="slider-container relative shadow-inset rounded-full"
style="width: 230px; height: 230px"
>
<!-- Slider Fill -->
<div
class="slider-fill absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-full aspect-square inline-grid place-content-center bg-gray-200 rounded-full before:content-[''] before:absolute before:rounded-full before:inset-0"
style="--percentage: 100; --fill-color: #e11d48"
aria-hidden="true"
></div>
<!-- Slider with Handle -->
<div
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
>
<div
class="slider relative"
style="width: 200px; height: 200px"
:mousedown="mousedown = true"
:mouseup="mousedown = false"
:mousemove="if (mousedown) {
const { percentage, left, top } = getSliderValue({
x: event.clientX,
y: event.clientY,
});
totalMonths = Math.round(percentage / 100 * 12) === 0
? 12
: Math.round(percentage / 100 * 12);
$('.slider-fill').style.setProperty('--percentage', percentage);
$('.slider-handle').style.left = `${left}%`;
$('.slider-handle').style.top = `${top}%`;
}"
>
<div
class="slider-circle relative w-full h-full rounded-full"
>
<div
class="slider-handle absolute top-0 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-white rounded-full ring-2 ring-rose-500"
style="width: 25px; height: 25px"
></div>
</div>
</div>
</div>
<!-- Slider Label -->
<div
class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 h-3/4 w-3/4 flex flex-col items-center justify-center bg-white rounded-full shadow-lg pointer-events-none"
>
<span
class="slider-label text-6xl font-bold"
:text="totalMonths"
></span>
<span class="text-base font-bold">months</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="p-5 bg-gray-100 mt-10">
<div class="max-w-5xl mx-auto">
<div class="flex items-center justify-between mb-5">
<h3 class="font-bold font-mono">Active State Example:</h3>
<button
:click="showCode1 = !showCode1"
class="flex items-center bg-white border shadow rounded-full px-5 py-2 text-xs font-bold font-mono hover:bg-blue-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-4 h-4 mr-2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
/>
</svg>
SHOW CODE
</button>
</div>
<script>
activeTab = 'Company'
</script>
<div>
<div class="hidden sm:block">
<nav
class="isolate flex divide-x divide-gray-200 rounded-lg shadow"
aria-label="Tabs"
>
<!-- Current: "text-gray-900", Default: "text-gray-500 hover:text-gray-700" -->
<a
:class="activeTab == 'My Account' ? 'text-gray-900' : 'text-gray-500' "
:click="activeTab = 'My Account'"
class="rounded-l-lg group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10"
aria-current="page"
>
<span>My Account</span>
<span
:class="activeTab == 'My Account' ? 'bg-indigo-500' : 'bg-transparent'"
aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.5"
></span>
</a>
<a
:class="activeTab == 'Company' ? 'text-gray-900' : 'text-gray-500' "
:click="activeTab = 'Company'"
class="hover:text-gray-700 group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10"
>
<span>Company</span>
<span
class="bg-indigo-500 absolute inset-x-0 bottom-0 h-0.5"
:class="activeTab == 'Company' ? 'bg-indigo-500' : 'bg-transparent'"
aria-hidden="true"
></span>
</a>
<a
:class="activeTab == 'Team Members' ? 'text-gray-900' : 'text-gray-500'"
:click="activeTab = 'Team Members'"
class="hover:text-gray-700 group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10"
>
<span>Team Members</span>
<span
class="absolute inset-x-0 bottom-0 h-0.5"
:class="activeTab == 'Team Members' ? 'bg-indigo-500' : 'bg-transparent'"
aria-hidden="true"
></span>
</a>
<a
:class="activeTab == 'Billing' ? 'text-gray-900' : 'text-gray-500' "
:click="activeTab = 'Billing'"
class="hover:text-gray-700 rounded-r-lg group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10"
>
<span>Billing</span>
<span
class="absolute inset-x-0 bottom-0 h-0.5"
:class="activeTab == 'Billing' ? 'bg-indigo-500' : 'bg-transparent'"
aria-hidden="true"
></span>
</a>
</nav>
</div>
<div class="hidden" :class="showCode1 ? 'block' : 'hidden'">
<p
class="mt-4 -mb-4 text-gray-500 font-medium font-mono text-xs text-right"
>
With TailwindCSS classes
</p>
<pre>
<code class="language-html text-xs overflow-hidden rounded-lg">
<script>
activeTab = 'Company';
</script>
<nav class="isolate flex divide-x divide-gray-200 rounded-lg shadow" aria-label="Tabs">
<a :class="activeTab == 'My Account' ? 'text-gray-900' : 'text-gray-500' " :click="activeTab = 'My Account'"
class=" rounded-l-lg group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10"
aria-current="page">
<span>My Account</span>
<span :class="activeTab == 'My Account' ? 'bg-indigo-500' : 'bg-transparent'" aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.5"></span>
</a>
<a :class="activeTab == 'Company' ? 'text-gray-900' : 'text-gray-500' " :click="activeTab = 'Company'"
class="hover:text-gray-700 group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10">
<span>Company</span>
<span :class="activeTab == 'Company' ? 'bg-indigo-500' : 'bg-transparent'" aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.5"></span>
</a>
<a :class="activeTab == 'Team Members' ? 'text-gray-900' : 'text-gray-500' "
:click="activeTab = 'Team Members'"
class="hover:text-gray-700 group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10">
<span>Team Members</span>
<span :class="activeTab == 'Team Members' ? 'bg-indigo-500' : 'bg-transparent'" aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.5"></span>
</a>
<a :class="activeTab == 'Billing' ? 'text-gray-900' : 'text-gray-500' " :click="activeTab = 'Billing'"
class="hover:text-gray-700 rounded-r-lg group relative min-w-0 flex-1 overflow-hidden bg-white py-4 px-4 text-center text-sm font-medium hover:bg-gray-50 focus:z-10">
<span>Billing</span>
<span :class="activeTab == 'Billing' ? 'bg-indigo-500' : 'bg-transparent'" aria-hidden="true"
class="absolute inset-x-0 bottom-0 h-0.5"></span>
</a>
</nav>
</code>
</pre>
</div>
</div>
</div>
</section>
<section class="p-5 bg-gray-100 mt-10">
<div class="max-w-5xl mx-auto">
<div class="flex items-center justify-between mb-5">
<h3 class="font-bold font-mono">On Change Example:</h3>
<button
:click="showCode2 = !showCode2"
class="flex items-center bg-white border shadow rounded-full px-5 py-2 text-xs font-bold font-mono hover:bg-blue-50"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-4 h-4 mr-2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"
/>
</svg>
SHOW CODE
</button>
</div>
<div>
<div class="p-4 border border-dashed border-black rounded">
<div class="flex items-end">
<div class="flex flex-col">
<p class="font-bold font-mono text-sm">Input:</p>
<input
:change="inputValue = this.value;"
:value="inputValue"
value="Hello World"
type="text"
name="text"
class="px-3 max-w-sm block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
<h2
class="ml-3 mt-2 text-lg font-medium font-mono"
:text="inputValue"
>
Hello World
</h2>
</div>
<div class="hidden" :class="showCode2 ? 'block' : 'hidden' ">
<pre>
<code class="language-html text-xs overflow-hidden rounded-lg">
<div>
<div class="flex flex-col">
<p class="font-bold font-mono text-sm">Input:</p>
<input :change="inputValue = this.value" :value="inputValue" value="Hello World" type="text" name="text" class="px-3 max-w-sm block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
</div>
<h2 class="ml-3 mt-2 text-lg font-medium font-mono" :text="inputValue">Hello World</h2>
</div>
</code>
</pre>
</div>
</div>
<div class="p-4 border border-dashed border-black rounded mt-2">
<div class="flex items-end">
<div class="flex flex-col">
<p class="font-bold font-mono text-sm">Checkbox:</p>
<div class="flex items-center mt-3">
<input
:change="checkboxValue = this.checked"
:checked="checkboxValue"
type="checkbox"
class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600"
/>
<h2
class="ml-2 text-sm font-semibold font-mono"
:text="checkboxValue ? 'ON' : 'OFF' "
>
OFF
</h2>
</div>
</div>
</div>
<div class="hidden" :class="showCode2 ? 'block' : 'hidden'">
<pre>
<code class="language-html text-xs overflow-hidden rounded-lg">
<div>
<input :change="checkboxValue = this.checked" :checked="checkboxValue" type="checkbox" class="h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600">
<h2 class="ml-2 text-sm font-semibold font-mono" :text="checkboxValue ? 'ON' : 'OFF' "></h2>
</div>
</code>
</pre>
</div>
</div>
<div class="p-4 border border-dashed border-black rounded mt-2">
<div class="flex items-end">
<div class="flex flex-col">
<p class="font-bold font-mono text-sm">Select:</p>
<select
:value="selectedCountry ||= 'Canada' "
:change="selectedCountry = this.value"
name="location"
class="w-full rounded-md border-0 py-2 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
>