-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.html
More file actions
775 lines (704 loc) · 35.4 KB
/
tutorial.html
File metadata and controls
775 lines (704 loc) · 35.4 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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Build a Todo App with core.js - Interactive Tutorial</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<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=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap"
rel="stylesheet">
<meta name="description"
content="Learn core.js by building a real todo app. Step-by-step tutorial covering pockets, templates, data binding, and state management.">
<meta name="keywords"
content="core.js tutorial, JavaScript framework tutorial, todo app, learn core.js, web development tutorial">
<meta name="author" content="core.js Team">
<meta name="robots" content="index, follow">
<meta name="language" content="English">
<meta property="og:type" content="website">
<meta property="og:url" content="https://core.sbs/tutorial.html">
<meta property="og:title" content="Build a Todo App with core.js">
<meta property="og:description" content="Learn core.js by building a real todo app. Step-by-step tutorial.">
<meta property="og:image" content="https://core.sbs/banner.png">
<meta name="theme-color" content="#0a0a0a">
<link rel="canonical" href="https://core.sbs/tutorial.html">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: {
DEFAULT: '#10b981',
dark: '#047857',
light: '#34d399',
glow: 'rgba(16, 185, 129, 0.5)',
},
accent: {
DEFAULT: '#06b6d4',
glow: 'rgba(6, 182, 212, 0.5)',
},
dark: {
DEFAULT: '#0f172a',
darker: '#020617',
}
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
outfit: ['Outfit', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
animation: {
'float': 'float 8s ease-in-out infinite',
'fade-in-up': 'fadeInUp 0.6s ease-out forwards',
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-20px)' },
},
fadeInUp: {
'from': { opacity: '0', transform: 'translateY(20px)' },
'to': { opacity: '1', transform: 'translateY(0)' },
}
}
}
}
}
</script>
<link rel="stylesheet" href="core.css">
<link rel="icon" href="/favicon.png">
<link rel="shortcut icon" href="/favicon.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://cdn.jsdelivr.net">
</head>
<body>
<!-- Navbar -->
<nav
class="fixed top-0 left-0 right-0 z-50 bg-dark-darker/80 backdrop-blur-xl border-b border-white/5 py-4 transition-all duration-300">
<div class="container mx-auto px-4 flex items-center justify-between">
<div class="flex items-center">
<a href="./core.html" class="flex items-center -mt-4" style="width: 140px;">
<img src="/core.svg" alt="core.js"
style="width: 100%; filter: brightness(1.5) drop-shadow(0 0 8px rgba(99, 102, 241, 0.5));">
</a>
</div>
<div class="flex items-center gap-4">
<a href="./docs.html" class="flex items-center gap-2">← Docs</a>
<a href="./core.html" class="flex items-center gap-2">← Home</a>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="pt-32 sm:pt-32 pb-16 sm:pb-20 min-h-screen">
<div class="container mx-auto px-4 sm:px-6 max-w-8xl">
<!-- Hero Section -->
<div class="mb-12 sm:mb-16">
<span class="badge-premium mb-4 sm:mb-6 inline-block text-xs sm:text-sm">Interactive Tutorial</span>
<h1
class="text-2xl sm:text-3xl md:text-4xl lg:text-5xl xl:text-6xl font-extrabold font-outfit leading-[1.1] mb-4 sm:mb-6 text-white tracking-tight px-4">
Build a <span class="text-transparent bg-clip-text bg-gradient-to-r from-primary-light to-accent">Todo
App</span><br class="hidden sm:block">with core.js
</h1>
<p class="text-sm sm:text-base md:text-lg text-slate-400 mb-6 sm:mb-8 leading-relaxed font-medium">
Learn core.js by building a real application from scratch. No build tools, no npm, no dependencies - just one
CDN link and you're ready to go.
</p>
</div>
<!-- Live Demo Section -->
<div class="mb-12 sm:mb-16">
<div class="glass p-3 sm:p-4 md:p-6 lg:p-8">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4 mb-4 sm:mb-6">
<h2 class="text-xl sm:text-2xl md:text-3xl font-bold text-white">✨ Live Demo</h2>
<span class="text-xs font-bold uppercase tracking-widest text-primary-light">Try it now</span>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-4 sm:mb-6 px-2">This is what you'll build. Try adding,
checking, and deleting todos:</p>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-4 sm:gap-6">
<!-- Todo App -->
<div class="lg:col-span-2">
<div class="core-pocket" data-core-templates="todoApp"></div>
</div>
<!-- Stats -->
<div class="bg-white/5 border border-white/10 rounded-xl p-3 sm:p-4 md:p-6">
<h4 class="text-base sm:text-lg font-bold text-white mb-3 sm:mb-4">📊 App Stats</h4>
<div class="space-y-4">
<div class="text-center">
<div id="totalCount" class="text-2xl sm:text-3xl md:text-4xl font-bold text-primary-light">0</div>
<div class="text-xs sm:text-sm text-slate-400 uppercase tracking-wider mt-1">Total Todos</div>
</div>
<div class="text-center">
<div id="doneCount" class="text-2xl sm:text-3xl md:text-4xl font-bold text-accent">0</div>
<div class="text-xs sm:text-sm text-slate-400 uppercase tracking-wider mt-1">Completed</div>
</div>
<div class="text-center">
<div id="remainingCount" class="text-2xl sm:text-3xl md:text-4xl font-bold text-slate-400">0</div>
<div class="text-xs sm:text-sm text-slate-400 uppercase tracking-wider mt-1">Remaining</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- How To Build It -->
<div class="mb-12 sm:mb-16">
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-6 sm:mb-8">📚 How To Build It</h2>
<p class="text-slate-300 mb-6 sm:mb-8 text-base sm:text-lg px-2">Follow these steps to build your own todo app
from scratch:</p>
<div class="space-y-4 sm:space-y-6">
<!-- Step 0: CDN Setup -->
<div class="glass p-3 sm:p-4 md:p-6 border-2 border-primary/30">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
0</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Start with Basic HTML + CDN</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
<strong>This is the foundation.</strong> Create a new HTML file with this complete structure. core.js
works entirely through a CDN link - no npm, no build tools, no installation:
</p>
<div
class="relative bg-black/40 p-2 sm:p-3 md:p-4 rounded-lg font-mono text-xs sm:text-sm text-emerald-400 overflow-x-auto mb-3 sm:mb-4">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-1 sm:top-2 right-1 sm:right-2 px-2 sm:px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all">Copy</button>
<pre><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo App - core.js</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-slate-900 text-white p-8">
<div class="max-w-2xl mx-auto">
<h1 class="text-4xl font-bold mb-8">My Todo App</h1>
<!-- Content will go here -->
</div>
<!-- Load core.js from CDN -->
<script src="https://cdn.jsdelivr.net/gh/Sitezip/core.sbs/core.js"></script>
</body>
</html></pre>
</div>
<p class="text-slate-400 text-xs sm:text-sm px-2">
💡 Save this as <code
class="text-primary-light bg-black/40 px-2 py-1 rounded text-xs sm:text-sm">todo.html</code> and open it
in your browser to test.
</p>
</div>
<!-- Step 1 -->
<div class="glass p-3 sm:p-4 md:p-6">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
1</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Add a Pocket</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
A <code class="text-primary-light bg-black/40 px-2 py-1 rounded">core-pocket</code> is where core.js
injects content. <strong class="text-white">Replace the <code
class="text-primary-light bg-black/40 px-1"><!-- Content will go here --></code> comment</strong>
with:
</p>
<div
class="relative bg-black/40 p-3 sm:p-4 rounded-lg font-mono text-xs sm:text-sm text-emerald-400 overflow-x-auto border-l-4 border-primary">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-1 sm:top-2 right-1 sm:right-2 px-2 sm:px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all">Copy</button>
<pre><!-- The pocket - core.js will fill this -->
<div class="core-pocket" data-core-templates="todoApp"></div></pre>
</div>
<p class="text-slate-400 text-xs sm:text-sm px-2 mt-3">
💡 The <code class="text-primary-light bg-black/40 px-1 text-xs">data-core-templates="todoApp"</code>
tells core.js which template to load here.
</p>
</div>
<!-- Step 2 -->
<div class="glass p-3 sm:p-4 md:p-6">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
2</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Add the Template</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
Add this template code before the core.js script tag:
</p>
<div
class="relative bg-black/40 p-3 sm:p-4 rounded-lg font-mono text-xs sm:text-sm text-emerald-400 overflow-x-auto border-l-4 border-primary">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-1 sm:top-2 right-1 sm:right-2 px-2 sm:px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all">Copy</button>
<pre><section id="cr-data" style="display:none;">
<template name="todoApp">
<form onsubmit="addTodo(event)" class="flex gap-2 mb-4">
<input type="text" id="todoInput" placeholder="What needs to be done?"
class="flex-1 px-4 py-2 bg-slate-800 border border-slate-700 rounded text-white">
<button type="submit" class="px-6 py-2 bg-emerald-500 rounded">Add</button>
</form>
<div class="core-clone" data-core-data="todos">
<div class="flex items-center gap-3 p-4 bg-slate-800 rounded mb-2">
<input type="checkbox" onchange="toggleTodo({{rec:id}})"
{{rec:done:core_pk_checked}} class="w-5 h-5">
<span class="flex-1 {{rec:done:core_pk_strikethrough}}">{{rec:text}}</span>
<button onclick="deleteTodo({{rec:id}})" class="text-red-400">Delete</button>
</div>
</div>
</template>
</section></pre>
</div>
<div class="bg-slate-800/50 p-3 rounded-lg mt-3 text-xs sm:text-sm">
<p class="text-slate-300 mb-2"><strong class="text-white">🔍 What's happening here:</strong></p>
<ul class="text-slate-400 space-y-1 ml-4">
<li>• <code class="text-primary-light bg-black/40 px-1">core-clone</code> duplicates for each todo item
</li>
<li>• <code class="text-primary-light bg-black/40 px-1">{{rec:text}}</code> shows the todo text</li>
<li>• <code class="text-primary-light bg-black/40 px-1">{{rec:done:core_pk_checked}}</code> adds
"checked" if done</li>
<li>• <code class="text-primary-light bg-black/40 px-1">{{rec:done:core_pk_strikethrough}}</code>
strikes through completed items</li>
</ul>
</div>
</div>
<!-- Step 3 -->
<div class="glass p-3 sm:p-4 md:p-6">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
3</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Initialize with Data</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
<strong class="text-white">Add a script tag AFTER core.js</strong> to set up your data and initialize:
</p>
<div
class="relative bg-black/40 p-3 sm:p-4 rounded-lg font-mono text-xs sm:text-sm text-emerald-400 overflow-x-auto border-l-4 border-primary">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-1 sm:top-2 right-1 sm:right-2 px-2 sm:px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all">Copy</button>
<pre>let todos = [
{ id: 1, text: 'Learn core.js', done: false },
{ id: 2, text: 'Build an app', done: false }
];
core.cr.setData('todos', todos);
core.init();</pre>
</div>
<div class="bg-slate-800/50 p-3 rounded-lg mt-3 text-xs sm:text-sm">
<p class="text-slate-300 mb-2"><strong class="text-white">🔍 What's happening:</strong></p>
<ul class="text-slate-400 space-y-1 ml-4">
<li>• <code class="text-primary-light bg-black/40 px-1">core.cr.setData()</code> stores the todos array
</li>
<li>• <code class="text-primary-light bg-black/40 px-1">core.init()</code> renders everything</li>
<li>• Each todo needs an <code class="text-primary-light bg-black/40 px-1">id</code> for tracking</li>
</ul>
</div>
</div>
<!-- Step 4 -->
<div class="glass p-3 sm:p-4 md:p-6">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
4</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Add Functions</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
Add the functions for add, toggle, and delete. Put these BEFORE <code
class="text-primary-light bg-black/40 px-2 py-1 rounded">core.init()</code>:
</p>
<div
class="relative bg-black/40 p-4 rounded-lg font-mono text-xs text-emerald-400 overflow-x-auto max-h-96">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-2 right-2 px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all z-10">Copy</button>
<pre><span class="text-emerald-400">function addTodo(event) {
event.preventDefault();
const input = document.getElementById('todoInput');
const text = input.value.trim();
if (text) {
todos.push({ id: Date.now(), text, done: false });
input.value = '';
updateTodos();
}
}
function toggleTodo(id) {
const todo = todos.find(t => t.id === id);
if (todo) {
todo.done = !todo.done;
updateTodos();
}
}
function deleteTodo(id) {
todos = todos.filter(t => t.id !== id);
updateTodos();
}
function updateTodos() {
core.cr.setData('todos', todos);
core.pk.soc();
}</span></pre>
</div>
</div>
<!-- Step 5: Custom Formatters -->
<div class="glass p-3 sm:p-4 md:p-6">
<div class="flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<div
class="w-8 h-8 sm:w-10 sm:h-10 rounded-full bg-primary/20 flex items-center justify-center text-primary-light font-bold text-sm sm:text-lg">
5</div>
<h3 class="text-lg sm:text-xl md:text-2xl font-bold text-white">Add Custom Formatters</h3>
</div>
<p class="text-sm sm:text-base text-slate-300 mb-3 sm:mb-4 px-2">
To make checkboxes and strikethrough work, add this formatter BEFORE <code
class="text-primary-light bg-black/40 px-2 py-1 rounded">core.init()</code>. This is the COMPLETE
working file:
</p>
<div
class="relative bg-black/40 p-4 rounded-lg font-mono text-xs text-emerald-400 overflow-x-auto max-h-96">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-2 right-2 px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all z-10">Copy</button>
<pre><span class="text-green-400">// Custom formatters
core.ud.format = function(value, formatStr) {
if (formatStr === 'core_pk_checked') return value ? 'checked' : '';
if (formatStr === 'core_pk_strikethrough') return value ? 'line-through opacity-50' : '';
return value;
};</span></pre>
</div>
</div>
<!-- Full Code -->
<div class="mb-16">
<h2 class="text-2xl sm:text-3xl font-bold text-white mb-8">📄 Complete Code</h2>
<div class="glass p-4 sm:p-6">
<p class="text-slate-300 mb-4">Copy this entire file and save it as <code
class="text-primary-light bg-black/40 px-2 py-1 rounded">todo.html</code> - it's a complete, working
todo app:</p>
<div
class="relative bg-black/40 p-4 rounded-lg font-mono text-xs text-emerald-400 overflow-x-auto max-h-96">
<button onclick="navigator.clipboard.writeText(this.nextElementSibling.textContent)"
class="absolute top-2 right-2 px-3 py-1 bg-primary/20 hover:bg-primary/30 rounded text-xs text-white transition-all z-10">Copy
All</button>
<pre><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Todo App - core.js</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-slate-900 text-white p-8">
<!-- Pocket -->
<div class="max-w-2xl mx-auto">
<h1 class="text-4xl font-bold mb-8">My Todo App</h1>
<div class="core-pocket" data-core-templates="todoApp"></div>
</div>
<!-- Templates -->
<section id="cr-data" style="display:none;">
<template name="todoApp">
<form onsubmit="addTodo(event)" class="flex gap-2 mb-4">
<input type="text" id="todoInput" placeholder="What needs to be done?"
class="flex-1 px-4 py-2 bg-slate-800 border border-slate-700 rounded text-white">
<button type="submit" class="px-6 py-2 bg-emerald-500 hover:bg-emerald-600 rounded font-semibold">Add</button>
</form>
<div class="space-y-2">
<div class="core-clone" data-core-data="todos">
<div class="flex items-center gap-3 p-4 bg-slate-800 rounded hover:bg-slate-700 transition-colors">
<input type="checkbox" onchange="toggleTodo({{rec:id}})"
{{rec:done:core_pk_checked}} class="w-5 h-5 cursor-pointer">
<span class="flex-1 {{rec:done:core_pk_strikethrough}}">{{rec:text}}</span>
<button onclick="deleteTodo({{rec:id}})"
class="px-3 py-1 text-red-400 hover:text-red-300 hover:bg-red-500/10 rounded">Delete</button>
</div>
</div>
</div>
</template>
</section>
<!-- Load core.js from CDN -->
<script src="https://cdn.jsdelivr.net/gh/Sitezip/core.sbs/core.js"></script>
<!-- App Logic -->
<script>
let todos = [
{ id: 1, text: 'Learn core.js', done: false },
{ id: 2, text: 'Build a todo app', done: false }
];
function addTodo(event) {
event.preventDefault();
const input = document.getElementById('todoInput');
const text = input.value.trim();
if (text) {
todos.push({ id: Date.now(), text, done: false });
input.value = '';
updateTodos();
}
}
function toggleTodo(id) {
const todo = todos.find(t => t.id === id);
if (todo) {
todo.done = !todo.done;
updateTodos();
}
}
function deleteTodo(id) {
todos = todos.filter(t => t.id !== id);
updateTodos();
}
function updateTodos() {
core.cr.setData('todos', todos);
core.pk.soc();
}
// Custom formatters for checkbox and strikethrough
core.ud.format = function(value, formatStr) {
if (formatStr === 'core_pk_checked') return value ? 'checked' : '';
if (formatStr === 'core_pk_strikethrough') return value ? 'line-through opacity-50' : '';
return value;
};
// Initialize
core.cr.setData('todos', todos);
core.init();
</script>
</body>
</html></pre>
</div>
<p class="text-slate-400 text-sm mt-4">
💡 <strong>To run:</strong> Save this file and open it in your browser. That's it! No build step, no npm
install, nothing else needed.
</p>
</div>
</div>
<!-- Key Concepts -->
<div class="glass p-3 sm:p-4 md:p-6 lg:p-8 mb-12 sm:mb-16">
<h2 class="text-xl sm:text-2xl md:text-3xl font-bold text-white mb-4 sm:mb-6">🎯 Key Concepts You Just
Learned</h2>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 sm:gap-6">
<div class="flex gap-4">
<div class="text-3xl">📦</div>
<div>
<h3 class="text-xl font-bold text-primary-light mb-2">Pockets</h3>
<p class="text-slate-300">Containers that hold dynamic content. Just add <code
class="text-primary-light bg-black/40 px-2 py-1 rounded text-sm">core-pocket</code> class.</p>
</div>
</div>
<div class="flex gap-4">
<div class="text-3xl">📝</div>
<div>
<h3 class="text-xl font-bold text-primary-light mb-2">Templates</h3>
<p class="text-slate-300">Reusable HTML patterns with data binding using <code
class="text-primary-light bg-black/40 px-2 py-1 rounded text-sm">{{rec:field}}</code> syntax.</p>
</div>
</div>
<div class="flex gap-4">
<div class="text-3xl">🔄</div>
<div>
<h3 class="text-xl font-bold text-primary-light mb-2">Clone</h3>
<p class="text-slate-300">Automatically loops through arrays. No manual iteration needed.</p>
</div>
</div>
<div class="flex gap-4">
<div class="text-3xl">💾</div>
<div>
<h3 class="text-xl font-bold text-primary-light mb-2">State Management</h3>
<p class="text-slate-300">Use <code
class="text-primary-light bg-black/40 px-2 py-1 rounded text-sm">core.cr.setData()</code> to
update state and trigger re-renders.</p>
</div>
</div>
</div>
</div>
<!-- Next Steps -->
<div class="glass p-4 border-2 border-primary/30 mb-8">
<div class="flex items-start gap-4">
<div class="flex-1">
<h3 class="text-lg font-bold mb-3 text-white">You're Ready to Build!
</h3>
<p class="text-sm text-slate-300 leading-relaxed mb-4">
You've just built a working todo app with core.js. You now understand the fundamentals: pockets,
templates, data binding, and state management.
</p>
<h4 class="text-base font-bold text-white mb-3">Learn More</h4>
<div class="flex flex-col gap-2 mb-4">
<a href="docs.html" class="btn-premium text-sm">
Read Full Docs
</a>
<a href="playground.html"
class="px-4 py-2 bg-white/5 backdrop-blur-md border border-white/10 text-white font-bold rounded-lg hover:bg-white/10 hover:border-white/20 transition-all text-sm text-center">
Try Playground
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Templates Section (Hidden) -->
<section id="cr-data" style="display:none;">
<!-- Todo App Template -->
<template name="todoApp">
<div class="space-y-4">
<!-- Input Form -->
<form onsubmit="addTodo(event)" class="flex flex-col sm:flex-row gap-1 sm:gap-2">
<input type="text" id="todoInput" placeholder="What needs to be done?"
class="flex-1 bg-black/40 border border-white/10 rounded-xl px-4 py-3 text-white placeholder-slate-500 focus:border-primary/50 outline-none transition-all"
required>
<button type="submit" class="btn-premium whitespace-nowrap">
+ Add
</button>
</form>
<!-- Todo List -->
<div class="space-y-2">
<div class="core-clone" data-core-data="todos">
<div
class="flex items-center gap-3 bg-white/5 border border-white/10 rounded-xl p-4 hover:bg-white/10 transition-all group">
<input type="checkbox" onchange="toggleTodo({{rec:id}})" {{rec:done:core_pk_checked}}
class="w-5 h-5 cursor-pointer rounded" style="background-color: #f3f4f6; border: 2px solid #d1d5db; color: #1f2937;">
<span class="flex-1 text-white {{rec:done:core_pk_strikethrough}}">{{rec:text}}</span>
<button onclick="deleteTodo({{rec:id}})"
class="opacity-0 group-hover:opacity-100 text-red-400 hover:text-red-300 transition-all px-3 py-1 rounded-lg hover:bg-red-500/10">
Delete
</button>
</div>
</div>
</div>
<!-- Empty State -->
<div id="emptyState" class="text-center py-12 text-slate-400" style="display:none;">
<div class="text-6xl mb-4">📝</div>
<p class="text-lg">No todos yet. Add one above to get started!</p>
</div>
</div>
</template>
</section>
<!-- Load core.js -->
<script src="core.js"></script>
<!-- App Logic -->
<script>
let todos = [
{ id: 1, text: 'Learn core.js basics', done: true },
{ id: 2, text: 'Build a todo app', done: false },
{ id: 3, text: 'Deploy to production', done: false }
];
function addTodo(event) {
event.preventDefault();
const input = document.getElementById('todoInput');
const text = input.value.trim();
if (text) {
todos.push({
id: Date.now(),
text: text,
done: false
});
input.value = '';
updateTodos();
}
}
function toggleTodo(id) {
const todo = todos.find(t => t.id === id);
if (todo) {
todo.done = !todo.done;
updateTodos();
}
}
function deleteTodo(id) {
todos = todos.filter(t => t.id !== id);
updateTodos();
}
function updateTodos() {
core.cr.setData('todos', todos);
core.pk.soc();
updateStats();
updateEmptyState();
}
function updateStats() {
const total = todos.length;
const done = todos.filter(t => t.done).length;
const remaining = total - done;
document.getElementById('totalCount').textContent = total;
document.getElementById('doneCount').textContent = done;
document.getElementById('remainingCount').textContent = remaining;
}
function updateEmptyState() {
const emptyState = document.getElementById('emptyState');
if (emptyState) {
emptyState.style.display = todos.length === 0 ? 'block' : 'none';
}
}
core.ud.format = function (value, formatStr) {
if (formatStr === 'core_pk_checked') {
return value ? 'checked' : '';
}
if (formatStr === 'core_pk_strikethrough') {
return value ? 'line-through opacity-50' : '';
}
return value;
};
core.cr.setData('todos', todos);
core.init();
setTimeout(() => {
updateStats();
updateEmptyState();
}, 100);
</script>
<!-- Footer -->
<footer
class="container mx-auto px-4 py-8 sm:py-12 md:py-20 mt-16 sm:mt-20 border-t border-white/5 relative overflow-hidden"
style="max-width: none;">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 sm:gap-8 lg:gap-12 relative z-10 p-2">
<!-- About Column -->
<div>
<a class="flex items-center mb-4 sm:mb-6" href="core.html">
<img src="/core.svg" alt="core.js" style="width: 100px; filter: brightness(1.2);">
</a>
<p class="text-slate-400 text-xs sm:text-sm mb-4 sm:mb-6 leading-relaxed">
A high-performance JavaScript orchestration layer. Zero virtual DOM overhead, async-native rendering.
</p>
</div>
<!-- Resources Column -->
<div>
<h4 class="text-white font-bold mb-3 sm:mb-6 uppercase text-xs tracking-[0.2em]">Resources</h4>
<ul class="space-y-2 sm:space-y-3">
<li><a href="tutorial.html"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Tutorial</a></li>
<li><a href="docs.html"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Full API Docs</a></li>
<li><a href="playground.html"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Playground</a></li>
</ul>
</div>
<!-- Community Column -->
<div>
<h4 class="text-white font-bold mb-3 sm:mb-6 uppercase text-xs tracking-[0.2em]">Community</h4>
<ul class="space-y-2 sm:space-y-3">
<li><a href="https://github.com/Sitezip/core.sbs" target="_blank" rel="noopener noreferrer"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm flex items-center gap-2">GitHub
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
</svg></a></li>
<li><a href="https://github.com/Sitezip/core.sbs/blob/main/CONTRIBUTING.md" target="_blank"
rel="noopener noreferrer"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm flex items-center gap-2">Contributing
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"></path>
</svg></a></li>
<li><a href="./CHANGELOG.md"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Changelog</a></li>
<li><a href="./ROADMAP.md"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Roadmap</a></li>
</ul>
</div>
<!-- Legal Column -->
<div>
<h4 class="text-white font-bold mb-3 sm:mb-6 uppercase text-xs tracking-[0.2em]">Legal</h4>
<ul class="space-y-2 sm:space-y-3">
<li><a href="core.html" class="text-slate-400 hover:text-white transition-colors no-underline text-sm">MIT
License</a></li>
<li><a href="core.html"
class="text-slate-400 hover:text-white transition-colors no-underline text-sm">Philosophy</a></li>
</ul>
</div>
</div>
<div class="mt-20 pt-8 border-t border-white/5 flex flex-col md:flex-row justify-between items-center gap-4">
<div class="text-[10px] font-mono text-slate-600 uppercase tracking-widest">
© 2025 CORE_ORCHESTRATOR // VERSION_2.0.4
</div>
<div class="flex gap-6">
<div class="text-[10px] font-bold text-slate-500 uppercase tracking-widest">SHADOW-LESS</div>
<div class="text-[10px] font-bold text-slate-500 uppercase tracking-widest">ASYNC-NATIVE</div>
<div class="text-[10px] font-bold text-slate-500 uppercase tracking-widest">RECURSIVE</div>
</div>
</div>
</footer>
</body>
</html>