-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
31 lines (24 loc) · 1.1 KB
/
demo.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
<style>
/* Makes the demo code cleaner, but damn writing CSS without Tailwind awful. */
body { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center; } div { display: flex; align-items: center; margin-bottom: 20px; } button { padding: 8px; margin: 24px; } * { font-size: 1.4rem ;}
</style>
<script type="module">
import { reactive } from './src/index.js'
import 'https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js'
window.counter = reactive({
count: 10,
})
</script>
<h2>First counter</h2>
<div x-data="{ counter: $reactive(window.counter) }">
<button @click="counter.count--">-</button>
Click count: <span x-text="counter.count"></span>
<button @click="counter.count++">+</button>
</div>
<h2>Second counter</h2>
<div x-data="{ counter: $reactive(window.counter) }">
<button @click="counter.count--">-</button>
Click count: <span x-text="counter.count"></span>
<button @click="counter.count++">+</button>
</div>
<span>Try using <code>counter.count = 25</code> in the console.</span>