-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.html
231 lines (197 loc) · 6.77 KB
/
sample.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mtsgi/kitstrap/d/0.5/kitstrap.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mtsgi/kitstrap/d/0.5/kitstrap-font.css">
<title>kaf.js sample</title>
</head>
<body>
<main id="kaf">
<div class="kit-pane p-l p-b-xl kit-bgclr-limegreen">
<h3 kit-i>{{ h.observe }}</h3>
<div class="kit-notice -black m-0" kit:observe="today"></div>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-crimson">
<h3 kit-i>{{ h.bind }}</h3>
<blockquote class="m-0 m-b-l">
Your name is
<strong kit:observe="last"></strong>
<strong kit:observe="first"></strong>
</blockquote>
<kit-formgroup>
<input type="text" class="textbox -flat kit-width-50" kit:bind="first" placeholder="Last Name" />
<input type="text" class="textbox -flat kit-width-50" kit:bind="last" placeholder="First Name" />
</kit-formgroup>
<div class="kit-notice m-0 m-t-l" kit:if="first == last">SAME</div>
<p>
Default Value:
<strong kit:observe="fruit"></strong>
</p>
<kit-formgroup>
<input type="text" class="textbox -flat kit-width-100" kit:bind="fruit" placeholder="Fruit" />
</kit-formgroup>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-black">
<h3 kit-i>{{ h.tab }}</h3>
<a kit:assign="tab 'a'" class="kit-button -flat">Tab A</a>
<a kit:assign="tab 'b'" class="kit-button -flat">Tab B</a>
<a kit:assign="tab 'c'" class="kit-button -flat">Tab C</a>
<pre kit:if="tab == 'a'">Content of section A.</pre>
<pre kit:if="tab == 'b'">This is a content of B.</pre>
<pre kit:if="tab == 'c'">This is C's content.</pre>
<pre kit:if="tab != 'c'">It is NOT C!</pre>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-green">
<h3 kit-i>{{ h.if }}</h3>
<label class="kit-toggle kit-line-l">
Show(<span kit:observe="show"></span>)
<input type="checkbox" id="show" kit:bind="show">
<label for="show"></label>
</label>
<div class="kit-notice -black m-0 m-t-l" kit:if="show">This is visible when the checkbox is on.</div>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-dodgerblue">
<h3 kit-i>{{ h.locale }}</h3>
<a class="kit-button-alt -silver" kit:assign="__locale 'en'">English</a>
<a class="kit-button-alt -silver" kit:assign="__locale 'ja'">日本語</a>
<a class="kit-button-alt -silver" kit:assign="__locale 'cn'">中文</a>
<div class="kit-notice -black m-0 m-t-l" kit:observe="__locale"></div>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-orange">
<h3 kit-i>{{ h.e }}</h3>
<kit-button kit-e="hello">Do "Hello"</kit-button>
<kit-button kit-e="greet">Do "Greet"</kit-button>
<kit-space></kit-space>
<kit-button kit-e="hello mouseover">Mouseover to "Hello"</kit-button>
<kit-button kit-e="greet dblclick">Dblclick to "Greet"</kit-button>
<kit-space></kit-space>
<input type="text" value="Click me!" class="kit-textbox" kit-e="getContext" />
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-deeppink">
<h3 kit-i>{{ h.style }}</h3>
<div class="mystyle">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat.
<div class="mybox">
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
</div>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-green">
<h3 kit-i>{{ h.for }}</h3>
<template kit:for="items">
<div>
<label class="kit-left kit-clr-white">{{ key }}</label>
<code>{{ value }}</code>
</div>
</template>
</div>
<div class="kit-pane p-l p-b-xl kit-bgclr-black">
<h3 kit-i>{{ h.calc }}</h3>
<blockquote class="m-0 m-b-l">
Area is <strong kit::observe="area"></strong>
</blockquote>
<input type="text" class="textbox -flat kit-width-100" kit:bind="radius" placeholder="Radius" />
</div>
</main>
<script type="module">
import Kaf from "./kaf.js";
Kaf.debugging = true;
const kaf = new Kaf({
locale: 'en',
elem: '#kaf',
data: {
today: (new Date()).toLocaleDateString(),
items: {
Andy: 765,
Bob: 961,
Cyan: 346,
David: 315
},
fruit: 'ORANGE',
tab: 'a'
},
calc: {
radius: {
area() {
return Number(this.radius) ** 2 * Math.PI;
}
}
},
events: {
hello() {
alert('Hello');
},
greet() {
this.hello();
},
getContext(e) {
alert(`Client X: ${e.clientX}`);
}
},
styles: {
background: '#f0f0f0',
'h3': {
color: '#ffffff'
},
'.mystyle': {
color: 'skyblue',
background: '#303030',
padding: '5px',
'.mybox': {
color: 'beige',
fontWeight: '700',
}
}
},
dictionary: {
en: {
h: {
observe: 'Data binding',
bind: 'Data binding with form',
tab: 'Tabs',
if: 'Conditional rendering',
locale: 'I18n',
e: 'Events binding',
style: 'Style controlling',
for: 'Iterated rendering',
calc: 'Calculated value'
}
},
ja: {
h: {
observe: 'データ束縛',
bind: 'フォームによるデータ束縛',
tab: 'タブ',
if: '条件付きレンダリング',
locale: 'I18n(国際化)',
e: 'イベント束縛',
style: 'スタイル制御',
for: '反復レンダリング',
calc: '計算された値'
}
},
cn: {
h: {
observe: '数据绑定',
bind: '使用表单进行数据绑定',
tab: '选项卡',
if: '条件与渲染',
locale: 'I18n(国际化)',
e: '事件绑定',
style: '控制样式表',
for: '迭代渲染',
calc: '計算された値'
}
}
}
});
</script>
</body>
</html>