-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·1729 lines (1559 loc) · 81.9 KB
/
index.html
File metadata and controls
executable file
·1729 lines (1559 loc) · 81.9 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
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<title>State.js Documentation</title>
<!-- State JS -->
<script src="src/state.js"></script>
<!-- State Animations CSS -->
<link rel="stylesheet" href="src/state-animations.css">
<!-- Google Fonts -->
<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=Bebas+Neue&family=Space+Mono&display=swap" rel="stylesheet" media="print" onload="this.media='all'">
<!--End Fonts -->
<!-- Mobile viewport meta tag -->
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Styles -->
<style>
body{
margin:0px;
padding:0px;
background-color:#060606;
color:#FFF;
font-family: 'Space Mono', monospace;
}
a{
color:#FFF;
}
hr{
margin:0px;
}
.state.background1{
overflow:hidden;
}
.state.background1:after{
content:"";
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
background-image:url("assets/img/clouds.png");
background-size: cover;
background-repeat: no-repeat;
background-position: 0;
opacity: 9;
transition:transform ease-out 0.3s;
}
.state.background2{
overflow:hidden;
}
.state.background2:before{
content:"";
width:400%;
height:100%;
position:absolute;
top:0;
left:0;
background-image:url("assets/img/plane.jpg");
background-size: contain;
background-repeat: no-repeat;
background-position: 0;
transform:translateX(calc(var(--state-viewport-x) - 40%)) translateY(calc(var(--state-viewport-y) - 10%));
opacity: 0.1;
transition:transform ease-out 0.3s;
}
.state.background2:after{
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: rgb(63,210,251);
background: linear-gradient(0deg, rgba(63,210,251,0) 0%, rgba(196,241,255,1) 50%);
opacity: var(--state-intersection);
transition:opacity ease-out 0.3s;
}
.state.background3{
overflow:hidden;
}
.state.background3 div{
position: relative;
z-index:3;
}
.state.background3:before{
content:"";
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
background-image:url("assets/img/planet1.jpg");
background-size: cover;
background-repeat: no-repeat;
background-position: 0;
opacity: 0.8;
}
.state.background3:after{
content:"";
width:100%;
height:100%;
position:absolute;
top:0;
left:0;
background: rgb(63,210,251);
background: linear-gradient(194deg, rgba(63,210,251,0) 0%, rgba(0,0,0,1) 100%);
background-position: 0;
opacity: calc(var(--state-intersection) + 50%);
z-index:0;
}
.state.background4{
overflow:hidden;
}
.state.background4:before{
content:"";
width:200%;
height:100%;
position:absolute;
top:0;
left:0px;
background-image:url("assets/img/wheel.png");
background-size: contain;
background-position: center;
background-repeat: no-repeat;
opacity: 0.8;
transition:all ease-out 2s;
}
.state.background5{
overflow:hidden;
transition:all ease-out 0.3s;
}
.state.background5:before{
content:"";
width:200%;
height:100%;
position:absolute;
top:0;
left:0px;
background-image:url("assets/img/living-room.jpg");
background-size: cover;
background-position: left bottom;
background-repeat: no-repeat;
mix-blend-mode: screen;
transition:transform ease-out 1s;
}
.state.background6{
overflow:hidden;
background:rgba(255,255,255, 0.2);
transition:opacity ease-out 0.3s;
}
.state.background6:before{
content:"";
width:100%;
height:200%;
position:absolute;
top:0;
left:0px;
background-image:url("assets/img/skyscraper.jpg");
background-size:200%;
background-position: center top;
background-repeat: no-repeat;
mix-blend-mode: screen;
transition:transform ease-out 1s;
}
.state.background7{
overflow:hidden;
}
.state.background7:before{
content:"";
width:100%;
height:100%;
clip-path: rect(0% 100% var(--state-intersection) 0%);
position:absolute;
top:0;
left:0px;
background: rgb(252,176,69);
background: linear-gradient(0deg, rgba(252,176,69,1) 25%, rgba(253,124,41,1) 25%, rgba(253,124,41,1) 50%, rgba(253,29,29,1) 50%, rgba(253,29,29,1) 75%, rgba(208,0,0,1) 75%);
background-size: 100vw 100vh;
background-position:top;
background-repeat: no-repeat;
transition:clip-path ease-out 0.7s;
}
.state.background8{
overflow:hidden;
background:rgba(255,255,255,calc(var(--state-intersection) - 40%));
}
.state.background8:before{
content:"";
width:100%;
height:100%;
position:absolute;
top:0;
left:0px;
background-image:url("assets/img/servers.jpg");
background-size: 100vw 100vh;
background-position: center top;
background-repeat: no-repeat;
filter: blur(calc((var(--state-intersection) / 5) - 10px));
}
.state.background9{
overflow:hidden;
background: #111111;
}
.state.background9:before{
content: "";
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0px;
background: #0b0a0a;
background-size: 100vw 100vh;
background-position: center top;
background-repeat: no-repeat;
transform: translateY(calc(var(--state-intersection) * 2.5));
transition:transform ease-out 0.4s;
}
.pageContainer{
max-width:100%;
overflow:hidden;
}
.container{
background-color:#060606;
width:100%;
min-height:100vh;
position:relative;
margin:auto;
display:flex;
align-items: center;
justify-content: center;
flex-direction: column;
max-width: 1800px;
}
hr{
border-color:#AAAAAA;
}
pre{
font-size: 22px;
white-space: pre-line;
background-color: #111;
padding: 20px;
}
.box{
position:relative;
display: inline-block;
width:auto;
margin:auto;
margin:20px;
padding:20px;
max-width: 100%;
}
.boxBG{
background-color: rgba(0, 0, 0, 0.8);
}
.alignCenter{
text-align:center;
}
h1, .stateText{
font-family: 'Bebas Neue', cursive;
color: #700c0c;
text-shadow: 2px 2px 2px #000000;
font-size:72px;
}
#logo{
transition: transform ease-out 0.3s;
}
.listItem{
font-size: 20px;
background-color: #111;
padding: 20px;
display:inline-block;
margin-top:10px;
}
.headerText{
font-family: 'Bebas Neue', cursive;
color: #FFF;
text-shadow: 2px 2px 2px #000000;
font-size:52px;
width:238px;
}
.moreExamples{
display: inline-block;
margin: auto;
background-color: #F1F1F1;
color: #060606;
font-weight: bold;
padding: 10px 45px;
text-decoration: none;
}
#headerLine{
transition: transform ease-out 0.3s;
}
#headerLine2{
background:#AAAAAA;
width:200px;
transition: transform ease-out 0.3s;
}
#Whatis{
width:100%;
z-index:2;
transition: transform ease-out 0.3s;
}
#creative{
transition:all ease-out 0.8s;
}
#withcss{
transition:all ease-out 0.8s;
}
.fadeIn{
opacity:0;
}
.fadeIn.state{
animation: fadeIn 1s normal forwards ease-in-out;
}
.fadeIn.animdelay1{
animation-delay: 0.25s;
}
.fadeIn.animdelay2{
animation-delay: 0.5s;
}
@keyframes fadeIn {
0% {
opacity:0;
}
100% {
opacity:1;
}
}
/* Interactive Demo Styles */
.demo-interactive {
background: #1a1a1a;
padding: 30px;
border-radius: 10px;
margin: 20px;
}
.health-bar-demo {
width: 300px;
height: 40px;
background: #333;
border-radius: 20px;
overflow: hidden;
position: relative;
margin: 20px auto;
}
.health-bar-fill {
height: 100%;
background: linear-gradient(90deg, #ff0000 0%, #ffff00 50%, #00ff00 100%);
width: var(--state-health-percent);
transition: width 0.3s ease-out;
}
.slider-demo {
width: 300px;
margin: 20px auto;
}
.slider-demo input[type="range"] {
width: 100%;
height: 8px;
background: #333;
border-radius: 5px;
outline: none;
}
.value-display {
font-family: 'Bebas Neue', cursive;
font-size: 48px;
color: #700c0c;
text-shadow: 2px 2px 2px #000000;
margin: 10px 0;
}
.code-box {
background: #000;
padding: 20px;
border-radius: 8px;
margin: 20px 0;
border: 1px solid #333;
overflow-x: auto;
}
.code-box pre {
margin: 0;
color: #e8e8e8;
font-family: 'Courier New', monospace;
font-size: 13px;
line-height: 1.6;
}
@media screen and (min-width: 768px) {
#documentation{
transform:translateY(calc(var(--state-intersection) * 4));
transition: transform ease-out 0.3s;
}
#textBlock{
transform:translateY(var(--state-intersection));
transition: transform ease-out 0.3s;
}
.title{
transition: transform ease-out 0.3s;
}
.headerText{
font-size:122px;
width: 100%;
}
#examples{
position:relative;
z-index:2;
transform:translateY(calc(var(--state-intersection) * 2));
transition:transform ease-out 0.3s;
}
}
</style>
<!-- End of styles -->
</head>
<body>
<div class="pageContainer">
<div class="container alignCenter background1">
<div class="box">
<h1 id="logo">State.js</h1>
<hr id="headerLine" />
<h2 id="documentation">Documentation <sup>v1.4.0</sup></h2>
</div>
</div>
<hr/>
<div class="container alignCenter background2">
<div class="box" id="Whatis">
<h2>What is State.js?</h2>
</div>
<hr id="headerLine2"/>
<div id="textBlock">
<div class="box boxBG fadeIn" data-state>
State.js is a super simple, efficient and lightweight CSS framework that exposes DOM element states as CSS variables. Track data attributes, form inputs, media playback, and element visibility - all automatically exposed for use in your CSS animations and transitions.
</div>
<div class="box boxBG fadeIn animdelay1" data-state>
Using nothing but the power of CSS, HTML and State.js, you can create dynamic dashboards, reactive web applications, and interactive experiences! State.js is really lightweight and created with javascript without requiring any dependencies.
</div>
<div class="box boxBG fadeIn animdelay2" data-state>
State.js includes state-animations.css with predefined UI animations. Pair with <a href="https://github.com/iDev-Games/Cursor-JS">Cursor.js</a>, <a href="https://github.com/iDev-Games/Keys-JS">Keys.js</a>, and <a href="https://github.com/iDev-Games/Motion-JS">Motion.js</a> for a complete CSS/HTML development toolkit - perfect for games, dashboards, and interactive interfaces.
</div>
</div>
</div>
<hr/>
<div class="container alignCenter background9">
<div class="box" id="animationsCSS">
<h2 class="stateText">State-Animations.css</h2>
</div>
<hr id="headerLine2"/>
<div id="textBlock">
<div class="box boxBG fadeIn" data-state>
Predefined CSS animations for UI feedback, notifications, progress indicators, status effects, and interactive elements
</div>
</div>
<div id="examples" class="box" data-state>
<a class="moreExamples" href="animations.html" target="_Blank">View Documentation</a>
</div>
</div>
<hr/>
<div class="container alignCenter background3">
<div class="box boxBG title" id="install">
<h2>How To Install?</h2>
</div>
<div class="box boxBG fadeIn" data-state>
<p>All you need to do is add the state.js file into your projects JS folder and add the following code with your state.js location as the src. Put this code in to your head HTML tags.</p>
<pre>
<script src="/js/state.js"></script>
</pre>
<p>Or just add a CDN instead (coming soon)</p>
<pre>
<script src="https://cdn.jsdelivr.net/npm/@idevgames/state-js/src/state.js"></script>
</pre>
</div>
</div>
<hr/>
<div class="container alignCenter background4">
<div class="box boxBG title" id="use">
<h2>How To Use?</h2>
</div>
<div class="box boxBG fadeIn" data-state>
<p>To activate state.js add the data attribute "data-state" or a class "enable-state" to your html element. State.js automatically tracks element visibility and adds the "state" and "state-visible" classes when elements appear on screen.</p>
<pre>
<div class="fadeIn" data-state> </div>
</pre>
<pre>
.fadeIn{ opacity:0; }
.fadeIn.state{ animation: fadeIn 1s normal forwards ease-in-out; }
@keyframes fadeIn { 0% { opacity:0; } 100% { opacity:1; } }
</pre>
</div>
</div>
<hr/>
<div class="container alignCenter background5">
<div class="box boxBG title" id="tracking">
<h2>Data Attribute Tracking</h2>
</div>
<div class="box boxBG fadeIn" data-state>
<p>State.js can watch data attributes and automatically expose them as CSS variables. Perfect for progress indicators, counters, stats, and dynamic data visualization!</p>
<pre>
<div id="player" data-state
data-state-watch="health,score"
data-health="100"
data-health-min="0"
data-health-max="100"
data-score="0">
</div>
</pre>
<pre>
#player .health-bar {
width: var(--state-health-percent);
background: linear-gradient(90deg, red, yellow, green);
}
[data-health="0"] {
animation: death 2s forwards;
}
</pre>
</div>
</div>
<hr/>
<div class="container alignCenter background6" data-state data-state-var="true">
<div class="box boxBG title">
<h2>Interactive Demo</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p>Move the slider to change the health value (no JavaScript needed!):</p>
<div class="slider-demo">
<input type="range"
id="healthSlider"
data-state
data-state-bind="healthDemo"
data-state-attr="health"
min="0"
max="100"
value="75">
</div>
<div id="healthDemo"
data-state
data-state-watch="health"
data-health="75"
data-health-min="0"
data-health-max="100">
<div class="health-bar-demo">
<div class="health-bar-fill" style="width: var(--state-health-percent);"></div>
</div>
<div class="value-display">Health: <span data-state-display="health">75</span>%</div>
</div>
<h3 style="margin-top: 30px; color: #fff;">The Code Behind This Demo:</h3>
<div class="code-box">
<pre><!-- Slider automatically updates healthDemo element -->
<input type="range"
data-state
data-state-bind="healthDemo"
data-state-attr="health"
min="0" max="100" value="75">
<!-- Health bar watches the health attribute -->
<div id="healthDemo"
data-state
data-state-watch="health"
data-health="75"
data-health-min="0"
data-health-max="100">
<div class="health-bar">
<div class="health-fill"
style="width: var(--state-health-percent);">
</div>
</div>
<div>Health: <span data-state-display="health">75</span>%</div>
</div></pre>
</div>
</div>
</div>
<hr/>
<div class="container alignCenter background6" style="background: #0a0a0a;">
<div class="box boxBG title">
<h2>Button Triggers & Increment</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p>Make buttons control state without writing JavaScript! Use increment for clickers and counters:</p>
<div id="clickerDemo"
data-state
data-state-watch="clicks"
data-state-var="true"
data-clicks="0"
data-clicks-min="0"
data-clicks-max="50">
<div class="value-display">Clicks: <span data-state-display="clicks">0</span></div>
<button class="button"
data-state
data-state-trigger
data-state-bind="clickerDemo"
data-state-attr="clicks"
data-state-increment="1"
style="margin: 10px; padding: 15px 30px; background: #700c0c; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 20px; letter-spacing: 2px;">
CLICK ME +1
</button>
<button class="button"
data-state
data-state-trigger
data-state-bind="clickerDemo"
data-state-attr="clicks"
data-state-increment="5"
style="margin: 10px; padding: 15px 30px; background: #0369a1; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 20px; letter-spacing: 2px;">
CLICK ME +5
</button>
<div style="width: 300px; height: 20px; background: #333; border-radius: 10px; margin: 20px auto; overflow: hidden;">
<div style="width: var(--state-clicks-percent); height: 100%; background: linear-gradient(90deg, #700c0c, #ff6b6b); transition: width 0.3s;"></div>
</div>
</div>
<h3 style="margin-top: 30px; color: #fff;">The Code:</h3>
<div class="code-box">
<pre><div id="clickerDemo"
data-state
data-state-watch="clicks"
data-clicks="0">
<div>Clicks: <span data-state-display="clicks">0</span></div>
<!-- Button increments by 1 -->
<button data-state
data-state-trigger
data-state-bind="clickerDemo"
data-state-attr="clicks"
data-state-increment="1">
CLICK ME +1
</button>
<!-- Button increments by 5 -->
<button data-state
data-state-trigger
data-state-bind="clickerDemo"
data-state-attr="clicks"
data-state-increment="5">
CLICK ME +5
</button>
<!-- Progress bar using CSS variable -->
<div class="progress-bar"
style="width: var(--state-clicks-percent);"></div>
</div></pre>
</div>
</div>
</div>
<hr/>
<div class="container alignCenter background5" style="background: #1a0a2e;">
<div class="box boxBG title">
<h2>Auto-firing Triggers: The Missing Primitive</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p>Automatically fire triggers when conditions become true - perfect for passive income, auto-unlocks, achievements, and automatic progression!</p>
<div id="autofireDemo"
data-state
data-state-watch="gold,gems,unlocked"
data-state-var="true"
data-gold="0"
data-gems="0"
data-unlocked="false">
<div class="value-display" style="margin-bottom: 20px;">
<div style="font-size: 24px; color: #ffd700;">Gold: <span data-state-display="gold">0</span></div>
<div style="font-size: 24px; color: #00ffff;">Gems: <span data-state-display="gems">0</span></div>
<div style="font-size: 18px; color: #00ff88; margin-top: 10px;">
Status: <span id="unlockStatus">Locked (need 20 gold)</span>
</div>
</div>
<button class="button"
data-state
data-state-trigger
data-state-bind="autofireDemo"
data-state-attr="gold"
data-state-increment="5"
style="margin: 10px; padding: 15px 30px; background: #ffd700; color: #000; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 20px; letter-spacing: 2px;">
Mine Gold +5
</button>
<!-- Hidden auto-collect: converts 10 gold to 1 gem automatically! -->
<button id="autoConvert"
data-state
data-state-trigger
data-state-bind="autofireDemo"
data-state-attr="gold"
data-state-decrement="10"
data-state-condition="gold >= 10"
data-state-autofire="true"
data-state-trigger-chain="addGem"
style="display:none">
</button>
<button id="addGem"
data-state
data-state-trigger
data-state-bind="autofireDemo"
data-state-attr="gems"
data-state-increment="1"
style="display:none">
</button>
<!-- Auto-unlock: automatically unlocks at 20 gold! -->
<button id="autoUnlock"
data-state
data-state-trigger
data-state-bind="autofireDemo"
data-state-attr="unlocked"
data-state-set="true"
data-state-condition="gold >= 20"
data-state-autofire="true"
style="display:none">
</button>
<div style="margin-top: 20px; padding: 15px; background: rgba(0,255,136,0.1); border-radius: 8px; border: 2px solid #00ff88;">
<strong style="color: #00ff88;">What's happening:</strong>
<ul style="text-align: left; color: #ccc; margin: 10px 0;">
<li>Every 10 gold automatically converts to 1 gem (passive income!)</li>
<li>When you reach 20 gold, status automatically unlocks</li>
<li>No clicks required - pure automatic progression!</li>
</ul>
</div>
</div>
<h3 style="margin-top: 30px; color: #fff;">The Code:</h3>
<div class="code-box">
<pre><!-- Passive income: auto-convert 10 gold → 1 gem -->
<button id="autoConvert"
data-state
data-state-trigger
data-state-bind="player"
data-state-attr="gold"
data-state-decrement="10"
data-state-condition="gold >= 10"
data-state-autofire="true"
data-state-trigger-chain="addGem"
style="display:none">
</button>
<!-- Auto-unlock at level 20 -->
<button data-state
data-state-trigger
data-state-bind="player"
data-state-attr="unlocked"
data-state-set="true"
data-state-condition="gold >= 20"
data-state-autofire="true"
style="display:none">
</button></pre>
</div>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,255,255,0.05); border-radius: 8px;">
<p style="color: #fff; font-weight: bold;">The Magic:</p>
<p style="color: #ccc;">When a condition transitions from <code>false</code> → <code>true</code>, the trigger fires automatically! No click required. No visibility required. <strong>This is the missing primitive for automatic game mechanics.</strong></p>
</div>
</div>
</div>
<script>
// Update unlock status display for demo
const autofireDemo = document.getElementById('autofireDemo');
const unlockStatus = document.getElementById('unlockStatus');
const updateUnlockStatus = () => {
const gold = parseInt(autofireDemo.getAttribute('data-gold') || 0);
const unlocked = autofireDemo.getAttribute('data-unlocked') === 'true';
if (unlocked) {
unlockStatus.textContent = '🎉 UNLOCKED!';
unlockStatus.style.color = '#00ff88';
unlockStatus.style.fontSize = '28px';
} else {
unlockStatus.textContent = `Locked (need ${20 - gold} more gold)`;
unlockStatus.style.color = '#ff6b6b';
}
};
const observer = new MutationObserver(updateUnlockStatus);
observer.observe(autofireDemo, { attributes: true });
updateUnlockStatus();
</script>
<hr/>
<div class="container alignCenter background8" style="background: #0a1a0a;">
<div class="box boxBG title">
<h2>New in v1.1.0: Game Development Extensions</h2>
</div>
<div class="box boxBG fadeIn" data-state>
<p style="color: #00ff88; font-weight: bold;">Seven new declarative primitives for building complete games with ZERO hand-written JavaScript logic!</p>
</div>
</div>
<hr/>
<div class="container alignCenter background6" style="background: #1a0520;">
<div class="box boxBG title">
<h2>Extension 1: Interval Triggers (Passive Income)</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p>Triggers that fire automatically on a timer - perfect for passive income and cooldowns!</p>
<div id="intervalDemo"
data-state
data-state-watch="gold,workers"
data-state-var="true"
data-gold="0"
data-workers="0">
<div class="value-display" style="margin-bottom: 20px;">
<div style="font-size: 28px; color: #ffd700;">Gold: <span data-state-display="gold">0</span></div>
<div style="font-size: 20px; color: #88ccff;">Workers: <span data-state-display="workers">0</span></div>
</div>
<button class="button"
data-state
data-state-trigger
data-state-bind="intervalDemo"
data-state-attr="workers"
data-state-increment="1"
style="margin: 10px; padding: 15px 30px; background: #0369a1; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 20px; letter-spacing: 2px;">
Hire Worker
</button>
<!-- Passive income: each worker generates gold every second -->
<button data-state
data-state-trigger
data-state-bind="intervalDemo"
data-state-attr="gold"
data-state-increment="calc(var(--state-workers))"
data-state-interval="1000"
data-state-condition="workers > 0"
style="display:none">
</button>
<div style="margin-top: 20px; padding: 15px; background: rgba(255,215,0,0.1); border-radius: 8px; border: 2px solid #ffd700;">
<strong style="color: #ffd700;">Watch the magic:</strong>
<p style="color: #ccc; margin: 10px 0;">Each worker generates 1 gold per second automatically! Hire more workers to increase your income.</p>
</div>
</div>
<h3 style="margin-top: 30px; color: #fff;">The Code:</h3>
<div class="code-box">
<pre><!-- Hidden trigger fires every 1000ms -->
<button data-state
data-state-trigger
data-state-bind="player"
data-state-attr="gold"
data-state-increment="calc(var(--state-workers))"
data-state-interval="1000"
data-state-condition="workers > 0"
style="display:none">
</button></pre>
</div>
</div>
</div>
<hr/>
<div class="container alignCenter background5" style="background: #0a0a2e;">
<div class="box boxBG title">
<h2>Extension 2 & 3: data-state-set & data-state-text</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p><strong>data-state-set</strong> sets exact values, <strong>data-state-text</strong> uses template strings!</p>
<div id="textDemo"
data-state
data-state-watch="health,healthmax,level,name"
data-state-var="true"
data-health="75"
data-healthmax="100"
data-level="5"
data-name="Hero">
<!-- Template string interpolation -->
<h2 data-state
data-state-bind="textDemo"
data-state-text="Level {level} {name}"
style="color: #fff; font-size: 32px;">
</h2>
<p data-state
data-state-bind="textDemo"
data-state-text="HP: {health}/{healthmax}"
style="color: #ff6b6b; font-size: 24px; font-weight: bold;">
</p>
<div style="margin: 20px 0;">
<button class="button"
data-state
data-state-trigger
data-state-bind="textDemo"
data-state-attr="health"
data-state-decrement="10"
data-state-condition="health >= 10"
style="margin: 5px; padding: 10px 20px; background: #dc2626; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 18px;">
Take Damage -10
</button>
<button class="button"
data-state
data-state-trigger
data-state-bind="textDemo"
data-state-attr="health"
data-state-set="calc(var(--state-healthmax))"
data-state-condition="health < 100"
style="margin: 5px; padding: 10px 20px; background: #16a34a; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 18px;">
Full Heal (data-state-set)
</button>
<button class="button"
data-state
data-state-trigger
data-state-bind="textDemo"
data-state-attr="level"
data-state-increment="1"
style="margin: 5px; padding: 10px 20px; background: #7c3aed; color: white; border: none; border-radius: 5px; cursor: pointer; font-family: 'Bebas Neue', cursive; font-size: 18px;">
Level Up +1
</button>
</div>
<div style="margin-top: 20px; padding: 15px; background: rgba(124,58,237,0.1); border-radius: 8px; border: 2px solid #7c3aed;">
<strong style="color: #a78bfa;">Notice:</strong>
<p style="color: #ccc; margin: 10px 0;">Text updates automatically using {token} syntax! Full Heal uses data-state-set with calc() to restore to max.</p>
</div>
</div>
<h3 style="margin-top: 30px; color: #fff;">The Code:</h3>
<div class="code-box">
<pre><!-- Template string with tokens -->
<h2 data-state
data-state-bind="player"
data-state-text="Level {level} {name}">
</h2>
<!-- Set to exact value using calc() -->
<button data-state-trigger
data-state-bind="player"
data-state-attr="health"
data-state-set="calc(var(--state-healthmax))">
Full Heal
</button></pre>
</div>
</div>
</div>
<hr/>
<div class="container alignCenter background9" style="background: #2e0a1a;">
<div class="box boxBG title">
<h2>Extension 4: Conditional CSS Classes</h2>
</div>
<div class="box boxBG fadeIn demo-interactive" data-state>
<p>Automatically add/remove CSS classes based on conditions - perfect for visual feedback!</p>
<div id="classDemo"
data-state
data-state-watch="health"
data-state-var="true"
data-health="100">
<div class="value-display" style="margin-bottom: 20px;">
<div style="font-size: 28px; color: #fff;">Health: <span data-state-display="health">100</span>/100</div>
</div>
<!-- Health bar with conditional classes -->
<div id="healthBarContainer"
data-state
data-state-bind="classDemo"
data-state-class="health-low"
data-state-class-condition="health <= 50"
data-state-class-2="health-critical"