-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
100 lines (93 loc) · 2.6 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module">
import { AC } from './src/ayr.js';
AC({
root: '#comp1',
state: {
counter: 1,
},
effects: function() {
return {
updateCounter: () => {
this.state.counter = this.state.counter + 1;
}
}
},
dependants: function() {
return {
doubledCounter: (e) => {
return this.state.counter * 2
},
tripledCounter: () => {
return this.state.counter * 3
}
}
}
})
// AC({
// root: '#comp2',
// state: {
// input: '',
// secret: 'this is public value'
// },
// effects: function() {
// return {
// mirrorInput: (e) => {
// console.log('in calback: ', e)
// this.state.input = e.target.value;
// },
// revealSecret: () => {
// this.state.secret = 'SSHHHHHH! SECRET!'
// },
// hideSecret: () => [
// this.state.secret = 'this is public value'
// ]
// }
// }
// })
// AC({
// root: '#comp3',
// state: {
// showingValue: false,
// vals: [ 'first value', 'second value', 'third super ocol value' ]
// },
// effects: function() {
// return {
// flipShowingValue: () => {
// this.state.showingValue = !this.state.showingValue;
// },
// addFourthVal: () => {
// this.state.vals = [ ...this.state.vals, 'fourth added value' ]
// }
// }
// }
// })
</script>
</head>
<body id="body">
<div id='comp1'>
<button id="btn" y-click="{updateCounter}">Increment Value</button>
<p>
Counter value:
<span id="test" y-data="{counter}"></span>
</p>
</div>
<!-- <div id="comp3">
<p y-click="{flipShowingValue}">Flip Value</p>
<input type="checkbox" id="flipper" y-change="{flipShowingValue}"/>
<p>
Is Showing Value?
</p>
<span y-if="{showingValue}">Yes!</span>
<button y-click="{addFourthVal}">add fourth</button>
<div y-for="{v in vals}" style="display: flex;flex-direction: column;">
<span y-data="{v}">te</span>
</div>
</div> -->
</body>
</html>