-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
168 lines (148 loc) · 3.22 KB
/
index.html
File metadata and controls
168 lines (148 loc) · 3.22 KB
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
<html>
<body>
<script type="module">
import {
div,
span,
code,
h3,
header,
footer,
button,
input,
flexCol,
flexCenteredRow,
flexRow, ul, form, li, title, meta, flexCenteredCol
} from 'https://cdn.jsdelivr.net/npm/@srfnstack/fntags@0.3.5/src/fnelements.min.mjs'
import { fnstate } from 'https://cdn.jsdelivr.net/npm/@srfnstack/fntags@0.3.5/src/fntags.min.mjs'
// Build the document header
document.head.append(
title('fntags hello world'),
meta({ charset: 'utf-8' }),
meta({
'http-equiv': 'X-UA-Compatible',
content: 'IE=edge'
}),
meta({
name: 'viewport',
content: 'width=device-width, initial-scale=1'
})
)
const content = flexRow({ style: { justifyContent: 'space-evenly', flexWrap: 'wrap' } })
document.body.append(content)
const addContent = (title, newContent) => content.append(
flexCenteredCol({
style: {
padding: '10px',
height: '250px',
width: '250px',
border: 'solid 1px #eee',
borderRadius: '5px'
}
},
h3(title),
flexCenteredCol(
{ style: { justifyContent: 'center', height: '100%' } },
newContent
)
)
)
const element = div(
code('Hello '),
span({
id: 'world',
style: { color: 'green' }
},
'World!'
)
)
element.animate(
[{ transform: 'rotate(360deg)' }],
{
duration: 1000,
iterations: Infinity
}
)
document.body.append(element)
addContent(
'Animated Content',
element
)
const stuffTodo = (stuff, todos) => div(
h3(stuff),
todos.map(todo => div('- ', todo))
)
const frame = (...children) => div(
header('---Header---'),
...children,
footer('---Footer---')
)
frame(
'Hello, Jerry',
stuffTodo(
'Here\'s Stuff to do',
['a', 'b', 'c']
)
)
const enabled = fnstate(true)
addContent(
'Bind Element',
div(
button({
onclick: () => enabled(!enabled())
},
'Toggle'
),
enabled.bindAs(() => enabled()
? div('enabled')
: div('disabled')
)
)
)
const color = fnstate('dodgerblue')
addContent(
'Bind Style and Attributes',
flexCol({
style: 'font-size: 25px; background-color: lavenderblush'
},
input({
oninput: e => color(e.target.value),
value: color.bindAttr()
}),
flexCenteredRow({
style: {
color: color.bindStyle(),
justifyContent: 'center',
'font-size': '20px'
}
},
'Hello World!'
)
)
)
const todos = fnstate([], todo => todo)
const todoInput = input({ placeholder: 'Enter Todo' })
const addTodo = e => {
e.preventDefault()
if (!todoInput.value) return
todos(todos().concat([todoInput.value]))
todoInput.value = ''
}
addContent(
'Bind Array to Children',
flexCol(
form({ onsubmit: addTodo },
flexRow(
todoInput,
button({ onclick: addTodo, type: 'submit' }, 'Submit')
)
),
todos.bindChildren(
ul({ class: 'todos-list' }),
todo => li(todo())
)
)
)
</script>
</body>
</html>