on master help sign in
Extract playground default content to separate file
commitd35ef65ba80fec0058de8bcd6273065bb99d153c authoriko <mail@iko.soy> dateThu 16 Apr 2026, 11:20 (6 months ago) parentceeee0a
2 files changed+170−168
src/main.rs+2−168 src/playground_default.hl+168
src/main.rs+2−168
@@ -2682,6 +2682,7 @@ fn main() {
26822682 js_glue, b64,
26832683 );
26842684 let compile_fn = "function compileSource(src){return window._wasmCompile(src);}";
2685+ let editor_content = include_str!("playground_default.hl");
26852686
26862687 let playground_html = format!(
26872688 r##"<!DOCTYPE html>
@@ -2715,174 +2716,7 @@ button{{padding:6px 16px;border:none;border-radius:4px;cursor:pointer;font-size:
27152716<div class="panel" id="editor-panel">
27162717<div class="header"><h1>htmlang</h1><span class="tag">playground</span></div>
27172718<div class="editor-wrap">
2718−<textarea id="editor" spellcheck="false">@page htmlang Showcase
2719−@lang en
2720−
2721−-- Design tokens
2722−@let primary #3b82f6
2723−@let accent #ec4899
2724−@let ink #0f172a
2725−@let muted #64748b
2726−@let surface white
2727−@let bg #f8fafc
2728−@let radius 10
2729−@let base 8
2730−@let gap = $base * 2
2731−
2732−-- Style presets
2733−@define card [
2734− padding 24, background $surface, rounded $radius,
2735− border 1 #e2e8f0,
2736− dark:background #1e293b, dark:border 1 #334155
2737−]
2738−
2739−@mixin lift [
2740− transition all 0.2s ease,
2741− hover:shadow 0 12px 24px rgba(0,0,0,0.08)
2742−]
2743−
2744−-- Components (functions with parameters, defaults, and slots)
2745−@fn button $label $variant=primary
2746− @el [
2747− padding 10 20, rounded 8, cursor pointer, bold,
2748− background if($variant == primary, $primary, transparent),
2749− color if($variant == primary, white, $primary),
2750− border 1 $primary, transition all 0.15s ease,
2751− hover:opacity 0.9, active:opacity 0.8
2752− ]
2753− @text $label
2754−
2755−@fn feature $title $emoji
2756− @el [$card, ...$lift, spacing 10]
2757− @text [size 32] $emoji
2758− @text [bold, size 18, color $ink, dark:color #f1f5f9] $title
2759− @paragraph [color $muted, line-height 1.6]
2760− @children
2761−
2762−@fn stat $value $label
2763− @column [spacing 4, text-align center, padding 12]
2764− @text [bold, size 40, color $primary] $value
2765− @text [color $muted, size 12, text-transform uppercase, letter-spacing 2] $label
2766−
2767−-- Page
2768−@column [background $bg, dark:background #0f172a, min-height 100vh]
2769−
2770− -- Header
2771− @header [
2772− padding 16 32, background $surface, dark:background #1e293b,
2773− border-bottom 1 #e2e8f0, dark:border-bottom 1 #334155
2774− ]
2775− @row [center-y, max-width 1100, center-x, width 100%]
2776− @text [bold, size 18, color $ink, dark:color #f1f5f9] htmlang
2777− @el [width fill]
2778− @row [spacing 24]
2779− @link [color $muted, hover:color $primary] #docs Docs
2780− @link [color $muted, hover:color $primary] #blog Blog
2781− @link [color $muted, hover:color $primary] #github GitHub
2782−
2783− -- Hero
2784− @section [padding 80 32, max-width 900, center-x, text-align center, spacing 20]
2785− @el [
2786− padding 6 14, rounded 999,
2787− background $primary|alpha:0.12, color $primary,
2788− bold, size 12, text-transform uppercase, letter-spacing 2,
2789− before:content "* "
2790− ]
2791− Built with htmlang
2792− @text [bold, size 56, color $ink, dark:color #f1f5f9, line-height 1.1]
2793− Layouts that just {{@text [italic, color $primary] make sense}}.
2794− @paragraph [max-width 600, center-x, color $muted, line-height 1.7, size 18]
2795− A minimalist DSL that compiles to a single static HTML file.
2796− No cascade, no JavaScript, no build chain.
2797− @row [center-x, spacing 12, wrap]
2798− @button [label Get Started]
2799− @button [label Star on GitHub, variant ghost]
2800−
2801− -- Stats (each iteration could go here too)
2802− @section [padding 24 32, max-width 800, center-x]
2803− @row [wrap, center-x, spacing 20]
2804− @stat [value 0kb, label JavaScript]
2805− @stat [value 1, label HTML File]
2806− @stat [value 100%, label Static]
2807−
2808− -- Features (grid layout)
2809− @section [padding 64 32, max-width 1100, center-x, spacing 24]
2810− @column [spacing 8, text-align center]
2811− @text [bold, size 32, color $ink, dark:color #f1f5f9] Why htmlang?
2812− @text [color $muted] Primitives over CSS quirks.
2813−
2814− @el [grid, grid-cols 3, gap $gap]
2815− @feature [title Composable, emoji X]
2816− Functions, mixins, and slots make components first-class.
2817− @feature [title Predictable, emoji Y]
2818− Flex-based layout - no cascade, no surprises.
2819− @feature [title Static, emoji Z]
2820− One file out. Deploy anywhere. Loads instantly.
2821−
2822− -- Quote (semantic blockquote + cite)
2823− @section [padding 32, max-width 720, center-x]
2824− @blockquote [
2825− padding 24 32, background $surface, dark:background #1e293b,
2826− border-left 4 $primary, rounded $radius, italic,
2827− color $ink, dark:color #f1f5f9, line-height 1.7, size 18
2828− ]
2829− "I want to lay out an interface, not argue with the cascade."
2830− @cite [color $muted, size 13, italic]
2831− - every frontend dev, eventually
2832−
2833− -- Team (each + destructuring)
2834− @section [padding 48 32, max-width 1100, center-x, spacing 16]
2835− @text [bold, size 24, color $ink, dark:color #f1f5f9] The team
2836−
2837− @row [wrap, spacing 12]
2838− @each $name, $role in Ada Engineer, Grace Architect, Linus Maintainer, Ken Researcher
2839− @column [$card, ...$lift, spacing 6, width 200, text-align center]
2840− @text [bold, color $ink, dark:color #f1f5f9] $name
2841− @text [color $muted, size 13] $role
2842−
2843− -- FAQ (native disclosure widget + inline elements)
2844− @section [padding 48 32, max-width 720, center-x, spacing 12]
2845− @text [bold, size 24, color $ink, dark:color #f1f5f9] FAQ
2846−
2847− @details [$card]
2848− @summary [bold, color $ink, dark:color #f1f5f9, cursor pointer]
2849− Does it support dark mode?
2850− @paragraph [color $muted, line-height 1.7]
2851− Yes - prefix any style with {{@code [background $bg, padding 2 6, rounded 4, color $accent] dark:}} and it generates a media query.
2852−
2853− @details [$card]
2854− @summary [bold, color $ink, dark:color #f1f5f9, cursor pointer]
2855− How do reusable components work?
2856− @paragraph [color $muted, line-height 1.7]
2857− Use {{@code [background $bg, padding 2 6, rounded 4, color $accent] @fn}} for parameters and {{@code [background $bg, padding 2 6, rounded 4, color $accent] @children}} as a slot.
2858−
2859− -- Native widgets (progress + meter)
2860− @section [padding 48 32, max-width 720, center-x, spacing 16]
2861− @text [bold, size 24, color $ink, dark:color #f1f5f9] Native widgets
2862−
2863− @column [$card, spacing 16]
2864− @column [spacing 6]
2865− @row [center-y, spacing 12]
2866− @text [color $ink, dark:color #f1f5f9] Coverage
2867− @el [width fill]
2868− @text [color $muted, size 13] 70%
2869− @progress [value 70, max 100, width 100%]
2870−
2871− @column [spacing 6]
2872− @text [color $ink, dark:color #f1f5f9] Battery
2873− @meter [value 6, min 0, max 10, low 3, high 8, width 100%]
2874−
2875− -- Footer (hr divider + breadcrumb)
2876− @hr [border-top 1 #e2e8f0, dark:border-top 1 #334155]
2877− @footer [padding 32, max-width 1100, center-x]
2878− @row [center-y, wrap, spacing 16, width 100%]
2879− @text [color $muted, size 13]
2880− Made with htmlang.
2881− @el [width fill]
2882− @breadcrumb [spacing 8]
2883− @link [color $muted, hover:color $primary] / Home
2884− @link [color $muted, hover:color $primary] /docs Docs
2885− @text [color $muted, size 13] v1.0</textarea>
2719+<textarea id="editor" spellcheck="false">{editor_content}</textarea>
28862720</div>
28872721<div class="toolbar">
28882722<button class="btn-run" onclick="compile()">&#9654; Run (Ctrl+Enter)</button>
src/playground_default.hlnew file+168
@@ -0,0 +1,168 @@
1+@page htmlang Showcase
2+@lang en
3+
4+-- Design tokens
5+@let primary #3b82f6
6+@let accent #ec4899
7+@let ink #0f172a
8+@let muted #64748b
9+@let surface white
10+@let bg #f8fafc
11+@let radius 10
12+@let base 8
13+@let gap = $base * 2
14+
15+-- Style presets
16+@define card [
17+ padding 24, background $surface, rounded $radius,
18+ border 1 #e2e8f0,
19+ dark:background #1e293b, dark:border 1 #334155
20+]
21+
22+@mixin lift [
23+ transition all 0.2s ease,
24+ hover:shadow 0 12px 24px rgba(0,0,0,0.08)
25+]
26+
27+-- Components (functions with parameters, defaults, and slots)
28+@fn button $label $variant=primary
29+ @el [
30+ padding 10 20, rounded 8, cursor pointer, bold,
31+ background if($variant == primary, $primary, transparent),
32+ color if($variant == primary, white, $primary),
33+ border 1 $primary, transition all 0.15s ease,
34+ hover:opacity 0.9, active:opacity 0.8
35+ ]
36+ @text $label
37+
38+@fn feature $title $emoji
39+ @el [$card, ...$lift, spacing 10]
40+ @text [size 32] $emoji
41+ @text [bold, size 18, color $ink, dark:color #f1f5f9] $title
42+ @paragraph [color $muted, line-height 1.6]
43+ @children
44+
45+@fn stat $value $label
46+ @column [spacing 4, text-align center, padding 12]
47+ @text [bold, size 40, color $primary] $value
48+ @text [color $muted, size 12, text-transform uppercase, letter-spacing 2] $label
49+
50+-- Page
51+@column [background $bg, dark:background #0f172a, min-height 100vh]
52+
53+ -- Header
54+ @header [
55+ padding 16 32, background $surface, dark:background #1e293b,
56+ border-bottom 1 #e2e8f0, dark:border-bottom 1 #334155
57+ ]
58+ @row [center-y, max-width 1100, center-x, width 100%]
59+ @text [bold, size 18, color $ink, dark:color #f1f5f9] htmlang
60+ @el [width fill]
61+ @row [spacing 24]
62+ @link [color $muted, hover:color $primary] #docs Docs
63+ @link [color $muted, hover:color $primary] #blog Blog
64+ @link [color $muted, hover:color $primary] #github GitHub
65+
66+ -- Hero
67+ @section [padding 80 32, max-width 900, center-x, text-align center, spacing 20]
68+ @el [
69+ padding 6 14, rounded 999,
70+ background $primary|alpha:0.12, color $primary,
71+ bold, size 12, text-transform uppercase, letter-spacing 2,
72+ before:content "* "
73+ ]
74+ Built with htmlang
75+ @text [bold, size 56, color $ink, dark:color #f1f5f9, line-height 1.1]
76+ Layouts that just {@text [italic, color $primary] make sense}.
77+ @paragraph [max-width 600, center-x, color $muted, line-height 1.7, size 18]
78+ A minimalist DSL that compiles to a single static HTML file.
79+ No cascade, no JavaScript, no build chain.
80+ @row [center-x, spacing 12, wrap]
81+ @button [label Get Started]
82+ @button [label Star on GitHub, variant ghost]
83+
84+ -- Stats (each iteration could go here too)
85+ @section [padding 24 32, max-width 800, center-x]
86+ @row [wrap, center-x, spacing 20]
87+ @stat [value 0kb, label JavaScript]
88+ @stat [value 1, label HTML File]
89+ @stat [value 100%, label Static]
90+
91+ -- Features (grid layout)
92+ @section [padding 64 32, max-width 1100, center-x, spacing 24]
93+ @column [spacing 8, text-align center]
94+ @text [bold, size 32, color $ink, dark:color #f1f5f9] Why htmlang?
95+ @text [color $muted] Primitives over CSS quirks.
96+
97+ @el [grid, grid-cols 3, gap $gap]
98+ @feature [title Composable, emoji X]
99+ Functions, mixins, and slots make components first-class.
100+ @feature [title Predictable, emoji Y]
101+ Flex-based layout - no cascade, no surprises.
102+ @feature [title Static, emoji Z]
103+ One file out. Deploy anywhere. Loads instantly.
104+
105+ -- Quote (semantic blockquote + cite)
106+ @section [padding 32, max-width 720, center-x]
107+ @blockquote [
108+ padding 24 32, background $surface, dark:background #1e293b,
109+ border-left 4 $primary, rounded $radius, italic,
110+ color $ink, dark:color #f1f5f9, line-height 1.7, size 18
111+ ]
112+ "I want to lay out an interface, not argue with the cascade."
113+ @cite [color $muted, size 13, italic]
114+ - every frontend dev, eventually
115+
116+ -- Team (each + destructuring)
117+ @section [padding 48 32, max-width 1100, center-x, spacing 16]
118+ @text [bold, size 24, color $ink, dark:color #f1f5f9] The team
119+
120+ @row [wrap, spacing 12]
121+ @each $name, $role in Ada Engineer, Grace Architect, Linus Maintainer, Ken Researcher
122+ @column [$card, ...$lift, spacing 6, width 200, text-align center]
123+ @text [bold, color $ink, dark:color #f1f5f9] $name
124+ @text [color $muted, size 13] $role
125+
126+ -- FAQ (native disclosure widget + inline elements)
127+ @section [padding 48 32, max-width 720, center-x, spacing 12]
128+ @text [bold, size 24, color $ink, dark:color #f1f5f9] FAQ
129+
130+ @details [$card]
131+ @summary [bold, color $ink, dark:color #f1f5f9, cursor pointer]
132+ Does it support dark mode?
133+ @paragraph [color $muted, line-height 1.7]
134+ Yes - prefix any style with {@code [background $bg, padding 2 6, rounded 4, color $accent] dark:} and it generates a media query.
135+
136+ @details [$card]
137+ @summary [bold, color $ink, dark:color #f1f5f9, cursor pointer]
138+ How do reusable components work?
139+ @paragraph [color $muted, line-height 1.7]
140+ Use {@code [background $bg, padding 2 6, rounded 4, color $accent] @fn} for parameters and {@code [background $bg, padding 2 6, rounded 4, color $accent] @children} as a slot.
141+
142+ -- Native widgets (progress + meter)
143+ @section [padding 48 32, max-width 720, center-x, spacing 16]
144+ @text [bold, size 24, color $ink, dark:color #f1f5f9] Native widgets
145+
146+ @column [$card, spacing 16]
147+ @column [spacing 6]
148+ @row [center-y, spacing 12]
149+ @text [color $ink, dark:color #f1f5f9] Coverage
150+ @el [width fill]
151+ @text [color $muted, size 13] 70%
152+ @progress [value 70, max 100, width 100%]
153+
154+ @column [spacing 6]
155+ @text [color $ink, dark:color #f1f5f9] Battery
156+ @meter [value 6, min 0, max 10, low 3, high 8, width 100%]
157+
158+ -- Footer (hr divider + breadcrumb)
159+ @hr [border-top 1 #e2e8f0, dark:border-top 1 #334155]
160+ @footer [padding 32, max-width 1100, center-x]
161+ @row [center-y, wrap, spacing 16, width 100%]
162+ @text [color $muted, size 13]
163+ Made with htmlang.
164+ @el [width fill]
165+ @breadcrumb [spacing 8]
166+ @link [color $muted, hover:color $primary] / Home
167+ @link [color $muted, hover:color $primary] /docs Docs
168+ @text [color $muted, size 13] v1.0