This repository has been archived by the owner on Jun 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
972 lines (686 loc) · 28.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
<html>
<style>.bottom-100 { bottom: 100%; }</style>
<script src="/packages/intersect/dist/cdn.js" defer></script>
<script src="/packages/morph/dist/cdn.js" defer></script>
<script src="/packages/history/dist/cdn.js"></script>
<script src="/packages/persist/dist/cdn.js"></script>
<script src="/packages/trap/dist/cdn.js"></script>
<script src="/packages/alpinejs/dist/cdn.js" defer></script>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script> -->
<!-- A -->
<!-- <div x-data="{ step: 1 }" x-history="step">
<button x-text="step" @click="step++"></button>
</div> -->
<div x-data="{ count: 0 }">
<button @click="count++">increment</button>
<span x-text="count"></span>
</div>
<!-- <div x-data="{ count: 0, open: true }">
<span x-text="count" :class="open && 'foo'"></span>
<div x-intersect="count++" style="margin-top: 100vh;">hi</div>
</div> -->
<!-- <div x-data="test">
<button x-text="foo.step" @click="foo.step++"></button>
</div>
<div x-data="{ foo: 'bar' }"></div> -->
<!-- Now let's say you want the URL bar to say ?foo=bar -->
<!-- (and change when "foo" changes, etc...): -->
<script>
let old = Element.prototype.setAttribute
Element.prototype.setAttribute = function (name, value) {
if (! name.includes('@')) {
old.bind(this)(name, value)
} else {
let el = document.createRange().createContextualFragment(
`<div ${name}="${value}"></div>`
).firstElementChild
let attr = el.getAttributeNode(name)
el.removeAttributeNode(attr)
this.setAttributeNode(attr)
delete el
}
}
// benchmark(5000, {
// first: () => {
// let div = document.createElement('div')
// div.setAttribute('foo', 'bar')
// },
// second: () => {
// let div = document.createElement('div')
// div.setAttribute('@foo', 'bar')
// },
// })
function benchmark(times, callbacks) {
if (typeof callbacks === 'function') {
callbacks = { function: callbacks }
}
let result = {}
Object.entries(callbacks).forEach(([key, value]) => {
let thing = {}
let start = performance.now()
for (let index = 0; index < times; index++) {
value()
}
let end = performance.now() - start
result[key] = {
time: end,
}
})
console.table(result)
}
</script>
<article>
<nav>
<h1></h1>
<h2></h2>
</nav>
<main>
<h3></h3>
<h4></h4>
</main>
</article>
<!-- Initialization Strategies: -->
<!-- Crawl Everything -->
<!-- Is there a way to render partials of page -->
<!-- Find Roots And Crawl Them -->
<script>
// let cally = (el, skip ) => { if (el.tagName === 'NAV') { skip() }; let attrs = el.attributes }
// // benchmark(250, {
// // recursive() {
// // walk(document.querySelector('article'), cally)
// // },
// // tree() {
// // treeWalk(document.querySelector('article'), cally)
// // },
// // })
// // walk3(document.querySelector('article'), el => console.log(el))
// walk3(document.querySelector('article'), (el, next) => {
// console.log(el);
// requestAnimationFrame(() => {
// console.log("nextFrame");
// next()
// })
// }).then(() => {
// console.log('finished');
// })
// function walk3(el, callback) {
// callback(el, () => {
// let node = el.firstElementChild
// node && walk3(node, (el, next) => {
// callback(el, next)
// })
// // while (node) {
// // walk3(node, callback)
// // node = node.nextElementSibling
// // }
// })
// }
// function walker2(el, callback) {
// callback(el, () => {
// let node = el.firstElementChild
// while (node) {
// walker2(node, callback)
// let children = node.children
// for (let index = 0; index < children.length; index++) {
// const element = children[index];
// walker2(element, callback)
// }
// node = node.firstElementChild
// }
// })
// }
// function walker(el, callback, after) {
// return new Promise(resolve => {
// callback(el, () => {
// let promises = []
// let node = el.firstElementChild
// while (node) {
// promises.push(walker(node, callback, () => {}))
// node = node.nextElementSibling
// }
// Promise.all(promises).then(() => {
// resolve()
// })
// })
// })
// }
// function walk(el, callback) {
// // if (el instanceof ShadowRoot) {
// // Array.from(el.children).forEach(el => walk(el, callback))
// // return
// // }
// let skip = false
// callback(el, () => skip = true)
// if (skip) return
// let node = el.firstElementChild
// while (node) {
// walk(node, callback, false)
// node = node.nextElementSibling
// }
// }
// function treeWalk(el, callback) {
// var treeWalker = document.createTreeWalker(
// el,
// NodeFilter.SHOW_ELEMENT,
// {acceptNode(node) {
// let skip
// callback(node, () => skip = true)
// if (skip) return NodeFilter.FILTER_REJECT
// return NodeFilter.FILTER_ACCEPT
// }}
// );
// while(treeWalker.nextNode() !== null) {}
// }
</script>
<!-- <div x-data="{ word: $uppercase('hey') }">
<button x-text="word"></button>
<input type="text" x-model="word">
</div> -->
<!-- <div x-data="{ items: $fetch(url, []).loading() }">
<button @click="count++" x-text="count"></button>
</div> -->
<script>
document.addEventListener('alpine:initializing', () => {
Alpine.magic('uppercase', () => Alpine.interceptor((key, path) => {
console.log(key, path);
return {
init(value, setter) {
setter(value.toUpperCase())
},
set(value, setter) {
setter(value.toUpperCase())
}
}
}))
})
</script>
<!-- <div x-data="{ foo: 'bar' }" x-query-string="foo"></div> -->
<!-- Or maybe you want to persist the value of "foo" to -->
<!-- localStorage so it persists between page refreshes:-->
<!-- <div x-data="{ foo: $queryString('bar') }"></div> -->
<script>
document.addEventListener('alpine:initializing', () => {
Alpine.data('test', function () {
return {
foo: { step: this.$persist(1) }
}
})
})
</script>
<!-- B -->
<!-- <div x-data="{ step: $history(1) }">...</div> -->
<!-- <div x-data="{ foo: 'bar' }">
<button @click="foo = 'baz'">Change Foo</button>
<span x-text="foo"></span>
</div>
<button onclick="morph()">morph</button>
<script>
let div = document.querySelector('div')
let html = div.outerHTML
function morph() {
morphit(div, html)
}
</script> -->
<!-- Use Cases: -->
<!-- Animating in -->
<!-- only animate once -->
<!-- only animate from one direction -->
<!-- Popper type functionality -->
<!-- Animating based on position in viewport -->
<!-- Infinite Scroll -->
<!-- Lazzy loading -->
<!-- Show some dirty modal to sign up if the person read the whole blog post -->
<!-- When any portion of an element comes into the viewport -->
<!-- <div x-intersect=""></div>
<div x-intersect.once=""></div> -->
<!-- <script src="https://unpkg.com/[email protected]/dist/inert.min.js" defer></script> -->
<!-- <div class="h-64"></div>
<div class="h-64"></div>
<div class="h-64" x-data x-effect="console.log($bound($el))">yoyoyo</div> -->
<!-- <div x-data @scroll.window="$el.style['margin-left'] = $el.getBoundingClientRect().top + 'px'">hey</div> -->
<!-- <div x-data :style="{ transform: 'translateX('+$bound($el).top+'px)' }" style="transition: all 1s">hey</div>
<div class="h-64"></div>
<div class="h-64"></div> -->
<script>
function $bound(el) {
let data = Alpine.reactive({
top: el.getBoundingClientRect().top,
})
window.addEventListener('scroll', () => {
data.top = el.getBoundingClientRect().top
}, { passive: true })
return data
}
</script>
<!-- <div x-data="{ count: 1 }">
<button @click="count++">inc</button>
<span x-text></span>
</div>
<div x-data="{ county: 1 }" x-history="county">
<button @click="county++">inc</button>
<span x-text="county"></span>
</div> -->
<!-- <div x-data="{ search: '', html: '' }" x-history="search" x-effect="html = '<h1>'+search+'</h1>'">
<input type="text" x-model="search">
<div x-morph="html"></div>
</div> -->
<!-- <div x-data="{ foo: 'bar' }">
<button @click="$el.remove()" x-destroy="foo = 'baz'">Remove Me</button>
<span x-text="foo"></span>
</div> -->
<!-- <div x-data="{ foo: 1 }" x-history="foo">
<button @click="foo++">inc</button>
foo: <span x-text="foo"></span>
</div>
<div x-data="{ bar: 1 }" x-history="bar">
<button @click="bar++">inc</button>
bar: <span x-text="bar"></span>
<template x-if="bar > 1">
<div x-data="{ baz: 1 }" x-history="baz">
<button @click="baz++">inc</button>
baz: <span x-text="baz"></span>
</div>
</template>
</div> -->
<script>
window.historyStateManager = {
replaceState(url, response, component) {
this.updateState('replaceState', url, response, component)
},
pushState(url, response, component) {
this.updateState('pushState', url, response, component)
},
updateState(method, url, response, component) {
let state = this.currentState()
state.storeResponse(response, component)
let stateArray = state.toStateArray()
// Copy over existing history state if it's an object, so we don't overwrite it.
let fullstateObject = Object.assign(history.state || {}, { livewire: stateArray })
let capitalize = subject => subject.charAt(0).toUpperCase() + subject.slice(1)
store.callHook('before'+capitalize(method), fullstateObject, url, component)
try {
history[method](fullstateObject, '', url)
} catch (error) {
// Firefox has a 160kb limit to history state entries.
// If that limit is reached, we'll instead put it in
// sessionStorage and store a reference to it.
if (error.name === 'NS_ERROR_ILLEGAL_VALUE') {
let key = this.storeInSession(stateArray)
fullstateObject.livewire = key
history[method](fullstateObject, '', url)
}
}
},
replayResponses(event, callback) {
if (! event.state.livewire) return
let state = typeof event.state.livewire === 'string'
? new LivewireState(this.getFromSession(event.state.livewire))
: new LivewireState(event.state.livewire)
state.replayResponses(callback)
},
currentState() {
if (! history.state) return new LivewireState
if (! history.state.livewire) return new LivewireState
let state = typeof history.state.livewire === 'string'
? new LivewireState(this.getFromSession(history.state.livewire))
: new LivewireState(history.state.livewire)
return state
},
missingState(event) {
return ! (event.state && event.state.livewire)
},
clearState() {
// This is to prevent exponentially increasing the size of our state on page refresh.
if (window.history.state) window.history.state.livewire = (new LivewireState).toStateArray();
},
storeInSession(value) {
let key = 'livewire:'+(new Date).getTime()
let stringifiedValue = JSON.stringify(value)
this.tryToStoreInSession(key, stringifiedValue)
return key
},
tryToStoreInSession(key, value) {
// sessionStorage has a max storage limit (usally 5MB).
// If we meet that limit, we'll start removing entries
// (oldest first), until there's enough space to store
// the new one.
try {
sessionStorage.setItem(key, value)
} catch (error) {
// 22 is Chrome, 1-14 is other browsers.
if (! [22, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14].includes(error.code)) return
let oldestTimestamp = Object.keys(sessionStorage)
.map(key => Number(key.replace('livewire:', '')))
.sort()
.shift()
if (! oldestTimestamp) return
sessionStorage.removeItem('livewire:'+oldestTimestamp)
this.tryToStoreInSession(key, value)
}
},
getFromSession(key) {
let item = sessionStorage.getItem(key)
if (! item) return
return JSON.parse(item)
},
}
</script>
<div class="h-64"></div>
<!-- <h1 x-data x-intersect="console.log('yoyo')">yoyo</h1> --> -->
<script>
window.eventStack = []
let playing = false;
['click', 'mouseenter', 'mouseleave', 'scroll'].forEach(key => {
window.addEventListener(key, event => {
if (playing) return
window.eventStack.push(event)
});
});
function play() {
playing = true
let recurse = (stack, end) => setTimeout(() => {
if (stack.length === 0) return end()
let event = stack.pop()
event.target.dispatchEvent(event)
recurse(stack, end)
}, 5)
recurse(window.eventStack, () => playing = false)
}
</script>
<!-- <br>
<br>
<br>
<div x-data="{ search: '' }" x-effect="console.log(search)">
<input x-model="search" placeholder="Search...">
</div>
<script>
document.addEventListener('alpine:initializing', () => {
Alpine.component('component', () => ({
init() {
window.addEventListener('click', () => {
this.foo = 'baz'
})
},
foo: 'bar'
}))
})
</script>
<div x-data="component">
<span x-text="foo"></span>
<button>click me</button>
</div>
<div x-data="{ show: false }">
<button @click="show = true">Show</button>
<h1 x-show="show" @click.away="show = false">h1</h1>
<h2>h2</h2>
</div>
<div x-data x-init="$refs.blab.textContent = 'bar'">
<div x-data>
<span @click="$refs"></span>
<span @click="$refs.blab"></span>
<span x-ref="blab">foo</span>
</div>
<span x-ref="blab">foo</span>
</div> -->
<!-- <div x-data="{ show: false }">
<button @click="show = true">Show</button>
<h1 x-show="show" @click.away="show = false">h1</h1>
<h2>h2</h2>
</div> -->
<div class="h-64"></div>
<!-- <div x-data="dropdown" x-init="load()" x-on:keydown.window.escape="open = false"
x-on:click.away="open = false" class="relative inline-block text-left z-0">
<div>
<span class="rounded-md shadow-sm">
<button x-ref="button" x-on:click="toggle()" type="button"
class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-sm leading-5 font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:bg-gray-50 active:text-gray-800 transition ease-in-out duration-150"
id="options-menu" aria-haspopup="true" x-bind:aria-expanded="open" aria-expanded="true">
Actions
<svg class="h-5 w-5" x-description="Heroicon name: chevron-down" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
</button>
</span>
</div>
<div x-ref="dropdown" x-show="open" style="display: none;"
// Popper dropdowns
// Enter on scroll animations (leave on scroll away)
x-intersect:out.bottom="$entry up = true"
x-intersect:out.top="up = false"
x-intersect:leave:bottom-edge="up = true"
x-intersect:leave:top-edge="up = false"
x-intersect="doSomething"
x-intersect:enter="console.log('in'); up = true;"
x-intersect:leave="console.log('out'); up = false;"
x-description="Dropdown panel, show/hide based on dropdown state."
x-transition:enter="transition ease-out duration-100"
x-transition:enter-start="transform opacity-0 scale-95"
x-transition:enter-end="transform opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="transform opacity-100 scale-100"
x-transition:leave-end="transform opacity-0 scale-95"
class="origin-top-right absolute block w-56 rounded-md shadow-lg border border-gray-300"
x-bind:class="{'bottom-100 mb-2' : !up, 'mt-2' : up}" x-on:toggle-direction.document="up = !up">
<div class="rounded-md bg-white shadow-xs">
<div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="options-menu">
<a href="#" x-on:click.prevent="$dispatch('toggle-modal-quote-copy-search'); open = false"
class="px-4 py-2 flex items-center space-x-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900"
role="menuitem">
Copy Items
</a>
<a href="#" x-on:click.prevent="$dispatch('toggle-modal-add-existing-drawing-to-quote'); open = false"
class="px-4 py-2 flex items-center space-x-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900"
role="menuitem">
Add Existing Item
</a>
</div>
</div>
</div>
</div>
<div class="h-64"></div>
<script>
document.addEventListener('alpine:initializing', () => {
Alpine.component('dropdown', () => ({
open: false,
up: true,
dropdownEl: null,
load() {
// let el = document.querySelector('[x-ref="dropdown"]')
// var observer = new IntersectionObserver((entries) => {
// if (entries[0].boundingClientRect.bottom > entries[0].intersectionRect.bottom && this.up) {
// this.up = false;
// } else if (entries[0].boundingClientRect.top < entries[0].intersectionRect.top && !this.up) {
// this.up = true;
// }
// }, { threshold: [0, 1] }
// );
// observer.observe(el);
},
toggle() {
this.open = !this.open;
}
}))
})
</script> -->
</html>
<!--
Solutions:
- No batching
- Batch effects
-->
<!--
// Light-dom story:
// add "x-element" to all custom elements
// walk through and initialize
// when you hit x-element, process element bindings
// on the side:
// initialize template element with props
// get bindings on slot
// attach bindings as scope on x-scope to element
// continue rendering tree
// when all is over, replace x-element with real elements
// attach scope to slotted element roots
// replace slots with slotted elements
// Shadow-dom story:
// Should be same except handling of slot replacement and element replacement
// Just attach shadow instead
// Stand-alone story
// Upgrade elements, but don't wait for Alpine to hit "x-element" directive.
// Just initialize element tree -->
<!--
<div x-data="{ foo: 'baz' }">
<the-outer class="bg-gray-100" :foo="foo + '-nested'">
<div>
<span x-text="foo"></span>
</div>
</the-outer>
</div>
<template x-element="the-outer" x-props="{ foo: 'fiiii' }">
<div class="border-b-8" x-data="{ hey: 'there' }" x-provide="hey">
<h1 x-text="foo"></h1>
<the-inner :foo="foo + '-nested-deep'">
<span x-text="foo"></span>
</the-inner>
<slot></slot>
</div>
</template>
<template x-element="the-inner" x-props="{ foo: '' }" x-inject="hey">
<div class="border-b-8">
<h1 x-text="hey"></h1>
<slot></slot>
</div>
</template> -->
<!--
Problems:
- Shadow DOM styling
- Root element?
- Attribute/event forwarding
- Attribute/event attaching to root from component
- x-scope?
- Spruce? $store?
-->
<!--
Homework:
- inject styles cost
- compare to x-spread
-->
<!-- <body class="bg-gray-100 text-gray-900 font-sans antialiased">
<div class="flex items-center justify-center p-12" x-data="{ checked: false }">
<div class="w-full max-w-xs mx-auto">
<div x-spread="window.headlessUI.switchGroup">
<label x-spread="window.headlessUI.switchLabel">Thing Here</label>
<button x-spread="window.headlessUI.switchButton">
<span :class="checked && 'bg-blue-500'">Hey Hey</span>
</button>
</div>
<switch-group class="flex items-center space-x-4">
<switch-label>Enable notifications</switch-label>
<the-switch x-model="checked" x-scope="{ props }">
<button
x-spread="{ props }"
class="relative inline-flex flex-shrink-0 h-6 transition-colors duration-200 ease-in-out border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:ring"
:class="checked ? 'bg-indigo-600' : 'bg-gray-200'"
>
<span
class="inline-block w-5 h-5 transition duration-200 ease-in-out transform bg-white rounded-full"
:class="{ 'translate-x-5': checked, 'translate-x-0': ! checked }"
></span>
</button>
</the-switch>
</switch-group>
</div>
</div>
<template x-element="switch-group">
<slot :foo="'bar'" x-data="{ api: { labelEl: null, switchEl: null} }" x-provide="api"></slot>
</template>
<template x-element="switch-label" x-inject="api">
<label
x-data="{ id: Math.random().toString(36).substring(7) }"
x-init="api.labelEl = $el"
:id="'headlessui-switch-label-' + id"
@pointerup="api.switchEl.click() && api.switchEl.focus({ preventScroll: true })"
>
<slot></slot>
</label>
</template>
<template x-element="the-switch" x-props="{ value: false }" x-inject="api" x-as="label">
<slot
x-init="if(api) api.switchEl = $el"
@click.prevent="$dispatch('input', ! value)"
@keyup.space.prevent="$dispatch('input', ! value)"
@keypress.prevent
role="switch"
tabindex="0"
:aria-checked="!! value"
:aria-labelledby="api && api.labelEl.id"
></slot>
</template>
</body> -->
</html>
<!-- Todo: work with "value" props and models -->
<!--
Alpine Portage || x-element?
Alpine Evolve || x-morph?
Alpine Evolve
Alpine Erode
Alpenglow
Glacier
Groves
Guide
Alpa
Altitude
Slide
Biome
Lake
Lodge
Tundra
Yak
Yodle
Cairn
Soar
Frost -->
<!-- <div class="space-x-4">
<slot>
<span>first</span>
<span>second</span>
</slot>
<slot>
<span>first</span>
<span>second</span>
</slot>
<span>third</span>
<slot>
<span>fourth</span>
</slot>
</div> -->
<!-- <div class="space-x-4">
<div style="display: contents" invisible>
<span>first</span>
<span>second</span>
</div>
<div style="display: contents" invisible>
<span>first</span>
<span>second</span>
</div>
<span>third</span>
<div style="display: contents" invisible>
<span>fourth</span>
</div>
</div> -->
<!-- <style>
.space-x-4>slot>:not([hidden])~:not([hidden]),
.space-x-4>[invisible]>:not([hidden])~:not([hidden]),
.space-x-4>:not([hidden])~slot>:not([hidden]),
.space-x-4>:not([hidden])~[invisible]>:not([hidden]),
.space-x-4>:not([hidden])~:not([hidden]) {
background: blue;
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}
</style> -->