-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.html
More file actions
273 lines (262 loc) · 13.8 KB
/
examples.html
File metadata and controls
273 lines (262 loc) · 13.8 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Tan Compose Examples - Interactive demos" />
<title>Tan Compose - Examples</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;900&display=swap" rel="stylesheet" />
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Inter",</head> -apple-system, BlinkMacSystemFont</style>, "Segoe UI", Roboto, sans-serif; line-height: 1.6; color: #333; background: #f5f5f5; min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
header { background: #ffffff; padding: 20px 0; border-bottom: 1px solid #e9ecef; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.nav { display: flex; justify-content: space-between; align-items: center; }
.nav h1 { font-size: 1.8rem; font-weight: 700; color: #6c757d; }
.nav a { color: #6c757d; text-decoration: none; font-weight: 500; transition: color 0.3s; }
.nav a:hover { color: #333; }
main { padding: 40px 0; }
.example-section { background: #ffffff; border-radius: 12px; padding: 40px; margin-bottom: 30px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.example-section h2 { font-size: 2rem; margin-bottom: 20px; color: #555; border-bottom: 2px solid #e9ecef; padding-bottom: 10px; }
.example-section h3 { font-size: 1.5rem; margin: 30px 0 15px; color: #6c757d; }
.demo-area { background: #f8f9fa; border-radius: 12px; padding: 30px; margin: 20px 0; border: 2px dashed #dee2e6; text-align: center; }
.code-block { background: #1e1e1e; border-radius: 8px; padding: 20px; margin: 20px 0; overflow-x: auto; }
.code-block code { color: #d4d4d4; font-family: "Courier New", monospace; font-size: 14px; line-height: 1.6; }
footer { text-align: center; padding: 20px; background: #e9ecef; color: #333; margin-top: 40px; }
@media (max-width: 768px) { .nav { flex-direction: column; gap: 15px; } .example-section { padding: 20px; } .example-section h2 { font-size: 1.5rem; } .code-block { font-size: 12px; } }
@media (max-width: 480px) { .container { padding: 0 15px; } .example-section { padding: 15px; } }
</style>
</head>
<body>
<header>
<div class="container">
<nav class="nav">
<h1>Tan Compose</h1>
<div>
<a href="index.html"></body></header></div>Home</a> |
<a href="examples.html">Examples</a> |
<a href="docs.html">Docs</a>
</div>
</nav>
</div>
</header>
<main class="container">
<div class="example-section">
<h2>Interactive Counter</h2>
<p>A</h2> simple counter component with increment, decrement, and reset buttons.</p>
<div class="demo-area">
<demo-counter></demo-counter>
</div>
<h3>Code</h3>
<div class="code-block">
<code>const demoCounter = describe({
tag: "</h3>div",
styles: {</code> display: "inline-block" },
children: [
describe({
tag: "div",
styles: { fontSize: "3rem", fontWeight: "bold", color: "#6c757d", marginBottom: "20px", textAlign: "center" },
attributes: { id: "counter-value" },
template: "0"
}),
describe({
tag: "div",
styles: { display: "flex", gap: "10px", justifyContent: "center" },
children: [
describe({
tag: "button",
template: "-",
styles: { padding: "10px 20px", fontSize: "20px", backgroundColor: "#dc3545", color: "white", border: "none", borderRadius: "8px", cursor: "pointer", fontWeight: "bold" },
action: () => { const el = document.getElementById("counter-value"); el.textContent = parseInt(el.textContent) - 1; }
}),
describe({
tag: "button",
template: "Reset",
styles: { padding: "10px 20px", fontSize: "16px", backgroundColor: "#6c757d", color: "white", border: "none", borderRadius: "8px", cursor: "pointer" },
action: () => { document.getElementById("counter-value").textContent = "0"; }
}),
describe({
tag: "button",
template: "+",
styles: { padding: "10px 20px", fontSize: "20px", backgroundColor: "#28a745", color: "white", border: "none", borderRadius: "8px", cursor: "pointer", fontWeight: "bold" },
action: () => { const el = document.getElementById("counter-value"); el.textContent = parseInt(el.textContent) + 1; }
})
]
})
]
});
build("demo-counter", demoCounter);</code>
</div>
</div>
<div class="example-section">
<h2>Themed Buttons</h2>
<p>Buttons</p> with different styles and themes.</p>
<div class="demo-area">
<demo-buttons></demo-buttons>
</div>
<h3>Code</h3>
<div class="code-block">
<code>const demoButtons = describe({
tag: "div",
styles: { display: "</h3></code>flex", gap: "15px", justifyContent: "center", flexWrap: "wrap" },
children: [
describe({
tag: "button",
template: "Primary",
styles: { padding: "12px 24px", backgroundColor: "#007bff", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Primary button clicked!")
}),
describe({
tag: "button",
template: "Success",
styles: { padding: "12px 24px", backgroundColor: "#28a745", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Success button clicked!")
}),
describe({
tag: "button",
template: "Danger",
styles: { padding: "12px 24px", backgroundColor: "#dc3545", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Danger button clicked!")
})
]
});
build("demo-buttons", demoButtons);</code>
</div>
</div>
<div class="example-section">
<h2>Custom Card</h2>
<p>A themed</h2> card component with custom styling.</p>
<div class="demo-area">
<demo-card></demo-card>
</div>
<h3>Code</h3>
<div class="code-block">
<code>const demoCard = describe({
tag: "div",
theme: { cardBg: "#ffffff", primaryColor: "#6c757d", textColor: "#333" },
styles: { backgroundColor: "var(--</h3></code>cardBg)", border: "1px solid #e0e0e0", borderRadius: "12px", padding: "30px", maxWidth: "500px", margin: "0 auto", boxShadow: "0 4px 12px rgba(0,0,0,0.1)", textAlign: "left" },
children: [
describe({
tag: "h3",
template: "Beautiful Component Card",
styles: { color: "var(--primaryColor)", marginBottom: "15px", fontSize: "1.8rem" }
}),
describe({
tag: "p",
template: "This card component is built entirely with Tan Compose. It features custom theming, nested children, and beautiful styling - all defined declaratively.",
styles: { color: "var(--textColor)", lineHeight: "1.8", marginBottom: "20px" }
}),
describe({
tag: "button",
template: "Learn More",
styles: { padding: "12px 24px", backgroundColor: "var(--primaryColor)", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => window.location.href = "https://github.com/yourusername/tan-compose"
})
]
});
build("demo-card", demoCard);</code>
</div>
</div>
</main>
<footer>
<div class="container">
<p>© 2024 Tan Compose. MIT License.</p>
</div>
</footer>
<script type="module" src="./dist/mod.js"></script>
<script type="module">
// Counter component
const demo</footer>Counter = window.describe({
tag: "div",
styles: { display: "inline-block" },
children: [
window.describe({
tag: "div",
styles: { fontSize: "3rem", fontWeight: "bold", color: "#6c757d", marginBottom: "20px", textAlign: "center" },
attributes: { id: "counter-value" },
template: "0"
}),
window.describe({
tag: "div",
styles: { display: "flex", gap: "10px", justifyContent: "center" },
children: [
window.describe({
tag: "button",
template: "-",
styles: { padding: "10px 20px", fontSize: "20px", backgroundColor: "#dc3545", color: "white", border: "none", borderRadius: "8px", cursor: "pointer", fontWeight: "bold" },
action: () => { const el = document.getElementById("counter-value"); el.textContent = parseInt(el.textContent) - 1; }
}),
window.describe({
tag: "button",
template: "Reset",
styles: { padding: "10px 20px", fontSize: "16px", backgroundColor: "#6c757d", color: "white", border: "none", borderRadius: "8px", cursor: "pointer" },
action: () => { document.getElementById("counter-value").textContent = "0"; }
}),
window.describe({
tag: "button",
template: "+",
styles: { padding: "10px 20px", fontSize: "20px", backgroundColor: "#28a745", color: "white", border: "none", borderRadius: "8px", cursor: "pointer", fontWeight: "bold" },
action: () => { const el = document.getElementById("counter-value"); el.textContent = parseInt(el.textContent) + 1; }
})
]
})
]
});
// Buttons component
const demoButtons = window.describe({
tag: "div",
styles: { display: "flex", gap: "15px", justifyContent: "center", flexWrap: "wrap" },
children: [
window.describe({
tag: "button",
template: "Primary",
styles: { padding: "12px 24px", backgroundColor: "#007bff", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Primary button clicked!")
}),
window.describe({
tag: "button",
template: "Success",
styles: { padding: "12px 24px", backgroundColor: "#28a745", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Success button clicked!")
}),
window.describe({
tag: "button",
template: "Danger",
styles: { padding: "12px 24px", backgroundColor: "#dc3545", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => alert("Danger button clicked!")
})
]
});
// Card component
const demoCard = window.describe({
tag: "div",
theme: { cardBg: "#ffffff", primaryColor: "#6c757d", textColor: "#333" },
styles: { backgroundColor: "var(--cardBg)", border: "1px solid #e0e0e0", borderRadius: "12px", padding: "30px", maxWidth: "500px", margin: "0 auto", boxShadow: "0 4px 12px rgba(0,0,0,0.1)", textAlign: "left" },
children: [
window.describe({
tag: "h3",
template: "Beautiful Component Card",
styles: { color: "var(--primaryColor)", marginBottom: "15px", fontSize: "1.8rem" }
}),
window.describe({
tag: "p",
template: "This card component is built entirely with Tan Compose. It features custom theming, nested children, and beautiful styling - all defined declaratively.",
styles: { color: "var(--textColor)", lineHeight: "1.8", marginBottom: "20px" }
}),
window.describe({
tag: "button",
template: "Learn More",
styles: { padding: "12px 24px", backgroundColor: "var(--primaryColor)", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontSize: "16px" },
action: () => window.location.href = "https://github.com/yourusername/tan-compose"
})
]
});
// Build components
window.build("demo-counter", demoCounter);
window.build("demo-buttons", demoButtons);
window.build("demo-card", demoCard);
</script>
</body>
</html>