ripple 0.3.68 → 0.3.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -2
- package/src/runtime/element.js +1 -1
- package/src/runtime/index-client.js +11 -11
- package/src/runtime/index-server.js +7 -4
- package/src/runtime/internal/client/bindings.js +1 -1
- package/src/runtime/internal/client/blocks.js +13 -4
- package/src/runtime/internal/client/component.js +55 -0
- package/src/runtime/internal/client/composite.js +4 -2
- package/src/runtime/internal/client/expression.js +65 -7
- package/src/runtime/internal/client/hmr.js +54 -43
- package/src/runtime/internal/client/index.js +5 -1
- package/src/runtime/internal/client/portal.js +70 -69
- package/src/runtime/internal/client/render.js +3 -0
- package/src/runtime/internal/server/index.js +92 -8
- package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
- package/tests/client/array/array.copy-within.test.tsrx +33 -31
- package/tests/client/array/array.derived.test.tsrx +186 -169
- package/tests/client/array/array.iteration.test.tsrx +40 -37
- package/tests/client/array/array.mutations.test.tsrx +113 -101
- package/tests/client/array/array.static.test.tsrx +119 -101
- package/tests/client/array/array.to-methods.test.tsrx +24 -21
- package/tests/client/async-suspend.test.tsrx +247 -246
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
- package/tests/client/basic/basic.attributes.test.tsrx +428 -423
- package/tests/client/basic/basic.collections.test.tsrx +109 -102
- package/tests/client/basic/basic.components.test.tsrx +323 -205
- package/tests/client/basic/basic.errors.test.tsrx +91 -91
- package/tests/client/basic/basic.events.test.tsrx +114 -115
- package/tests/client/basic/basic.get-set.test.tsrx +97 -87
- package/tests/client/basic/basic.hmr.test.tsrx +19 -16
- package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
- package/tests/client/basic/basic.rendering.test.tsrx +272 -182
- package/tests/client/basic/basic.styling.test.tsrx +23 -22
- package/tests/client/basic/basic.utilities.test.tsrx +10 -8
- package/tests/client/boundaries.test.tsrx +26 -26
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
- package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
- package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
- package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
- package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
- package/tests/client/composite/composite.generics.test.tsrx +168 -192
- package/tests/client/composite/composite.props.test.tsrx +97 -81
- package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
- package/tests/client/composite/composite.render.test.tsrx +122 -105
- package/tests/client/computed-properties.test.tsrx +28 -28
- package/tests/client/context.test.tsrx +21 -21
- package/tests/client/css/global-additional-cases.test.tsrx +58 -58
- package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
- package/tests/client/css/global-at-rules.test.tsrx +10 -10
- package/tests/client/css/global-basic.test.tsrx +14 -14
- package/tests/client/css/global-classes-ids.test.tsrx +14 -14
- package/tests/client/css/global-combinators.test.tsrx +10 -10
- package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
- package/tests/client/css/global-edge-cases.test.tsrx +18 -18
- package/tests/client/css/global-keyframes.test.tsrx +12 -12
- package/tests/client/css/global-nested.test.tsrx +10 -10
- package/tests/client/css/global-pseudo.test.tsrx +12 -12
- package/tests/client/css/global-scoping.test.tsrx +20 -20
- package/tests/client/css/style-identifier.test.tsrx +143 -291
- package/tests/client/date.test.tsrx +146 -133
- package/tests/client/dynamic-elements.test.tsrx +398 -365
- package/tests/client/events.test.tsrx +292 -290
- package/tests/client/for.test.tsrx +156 -153
- package/tests/client/head.test.tsrx +105 -96
- package/tests/client/html.test.tsrx +122 -26
- package/tests/client/input-value.test.tsrx +1361 -1314
- package/tests/client/lazy-array.test.tsrx +16 -13
- package/tests/client/lazy-destructuring.test.tsrx +257 -213
- package/tests/client/map.test.tsrx +65 -60
- package/tests/client/media-query.test.tsrx +22 -20
- package/tests/client/object.test.tsrx +87 -81
- package/tests/client/portal.test.tsrx +57 -51
- package/tests/client/ref.test.tsrx +233 -202
- package/tests/client/return.test.tsrx +71 -2560
- package/tests/client/set.test.tsrx +54 -45
- package/tests/client/svg.test.tsrx +216 -186
- package/tests/client/switch.test.tsrx +194 -193
- package/tests/client/track-async-hydration.test.tsrx +18 -14
- package/tests/client/tracked-index-access.test.tsrx +28 -18
- package/tests/client/try.test.tsrx +675 -548
- package/tests/client/tsx.test.tsrx +373 -311
- package/tests/client/typescript-generics.test.tsrx +145 -145
- package/tests/client/url/url.derived.test.tsrx +33 -28
- package/tests/client/url/url.parsing.test.tsrx +61 -51
- package/tests/client/url/url.partial-removal.test.tsrx +56 -48
- package/tests/client/url/url.reactivity.test.tsrx +142 -125
- package/tests/client/url/url.serialization.test.tsrx +13 -11
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
- package/tests/hydration/basic.test.js +3 -3
- package/tests/hydration/compiled/client/basic.js +586 -651
- package/tests/hydration/compiled/client/composite.js +79 -104
- package/tests/hydration/compiled/client/events.js +140 -148
- package/tests/hydration/compiled/client/for.js +1005 -1018
- package/tests/hydration/compiled/client/head.js +124 -134
- package/tests/hydration/compiled/client/hmr.js +41 -48
- package/tests/hydration/compiled/client/html-in-template.js +38 -41
- package/tests/hydration/compiled/client/html.js +970 -1314
- package/tests/hydration/compiled/client/if-children.js +234 -249
- package/tests/hydration/compiled/client/if.js +182 -189
- package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
- package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
- package/tests/hydration/compiled/client/portal.js +65 -85
- package/tests/hydration/compiled/client/reactivity.js +84 -90
- package/tests/hydration/compiled/client/return.js +38 -1939
- package/tests/hydration/compiled/client/switch.js +218 -224
- package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
- package/tests/hydration/compiled/client/try.js +123 -132
- package/tests/hydration/compiled/server/basic.js +773 -831
- package/tests/hydration/compiled/server/composite.js +166 -191
- package/tests/hydration/compiled/server/events.js +170 -184
- package/tests/hydration/compiled/server/for.js +851 -909
- package/tests/hydration/compiled/server/head.js +206 -216
- package/tests/hydration/compiled/server/hmr.js +64 -72
- package/tests/hydration/compiled/server/html-in-template.js +42 -76
- package/tests/hydration/compiled/server/html.js +1362 -1667
- package/tests/hydration/compiled/server/if-children.js +419 -445
- package/tests/hydration/compiled/server/if.js +194 -208
- package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
- package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
- package/tests/hydration/compiled/server/portal.js +152 -160
- package/tests/hydration/compiled/server/reactivity.js +94 -106
- package/tests/hydration/compiled/server/return.js +28 -2172
- package/tests/hydration/compiled/server/switch.js +274 -286
- package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
- package/tests/hydration/compiled/server/try.js +167 -185
- package/tests/hydration/components/basic.tsrx +320 -272
- package/tests/hydration/components/composite.tsrx +44 -32
- package/tests/hydration/components/events.tsrx +101 -91
- package/tests/hydration/components/for.tsrx +510 -452
- package/tests/hydration/components/head.tsrx +87 -80
- package/tests/hydration/components/hmr.tsrx +22 -17
- package/tests/hydration/components/html-in-template.tsrx +22 -17
- package/tests/hydration/components/html.tsrx +525 -443
- package/tests/hydration/components/if-children.tsrx +158 -148
- package/tests/hydration/components/if.tsrx +109 -95
- package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
- package/tests/hydration/components/nested-control-flow.tsrx +215 -203
- package/tests/hydration/components/portal.tsrx +41 -34
- package/tests/hydration/components/reactivity.tsrx +37 -27
- package/tests/hydration/components/return.tsrx +12 -556
- package/tests/hydration/components/switch.tsrx +120 -114
- package/tests/hydration/components/track-async-serialization.tsrx +107 -91
- package/tests/hydration/components/try.tsrx +55 -40
- package/tests/hydration/html.test.js +4 -4
- package/tests/hydration/return.test.js +13 -532
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +264 -195
- package/tests/server/basic.components.test.tsrx +296 -169
- package/tests/server/basic.test.tsrx +300 -198
- package/tests/server/compiler.test.tsrx +62 -60
- package/tests/server/composite.props.test.tsrx +77 -63
- package/tests/server/composite.test.tsrx +168 -192
- package/tests/server/context.test.tsrx +18 -12
- package/tests/server/dynamic-elements.test.tsrx +197 -180
- package/tests/server/for.test.tsrx +85 -78
- package/tests/server/head.test.tsrx +50 -43
- package/tests/server/html-nesting-validation.test.tsrx +8 -8
- package/tests/server/if.test.tsrx +57 -51
- package/tests/server/lazy-destructuring.test.tsrx +366 -294
- package/tests/server/return.test.tsrx +76 -1355
- package/tests/server/streaming-ssr.test.tsrx +4 -75
- package/tests/server/style-identifier.test.tsrx +169 -148
- package/tests/server/switch.test.tsrx +91 -85
- package/tests/server/track-async-serialization.test.tsrx +105 -85
- package/tests/server/try.test.tsrx +374 -280
- package/tests/utils/compiler-compat-config.test.js +2 -2
- package/tests/utils/runtime-imports.test.js +10 -0
- package/types/index.d.ts +8 -0
- package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
|
@@ -1,95 +1,121 @@
|
|
|
1
|
-
import { track } from 'ripple';
|
|
1
|
+
import { Fragment, track } from 'ripple';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export function StaticHtml() {
|
|
4
|
+
return <>
|
|
5
|
+
const html = '<p><strong>Bold</strong> text</p>';
|
|
6
|
+
<div innerHTML={html} />
|
|
7
|
+
</>;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
export function DynamicHtml() {
|
|
11
|
+
return <>
|
|
12
|
+
const content = '<p>Dynamic <span>HTML</span> content</p>';
|
|
13
|
+
<div innerHTML={content} />
|
|
14
|
+
</>;
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
export function EmptyHtml() {
|
|
18
|
+
return <>
|
|
19
|
+
const html = '';
|
|
20
|
+
<div innerHTML={html} />
|
|
21
|
+
</>;
|
|
16
22
|
}
|
|
17
23
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
export function ComplexHtml() {
|
|
25
|
+
return <>
|
|
26
|
+
const html = '<div class="nested"><span>Nested <em>content</em></span></div>';
|
|
27
|
+
<section innerHTML={html} />
|
|
28
|
+
</>;
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export component HtmlWithReactivity() {
|
|
33
|
-
<div>
|
|
34
|
-
{html '<p>Count: 0</p>'}
|
|
35
|
-
<button>{'Increment'}</button>
|
|
36
|
-
</div>
|
|
31
|
+
export function MultipleHtml() {
|
|
32
|
+
return <>
|
|
33
|
+
const html1 = '<p>First paragraph</p>';
|
|
34
|
+
const html2 = '<p>Second paragraph</p>';
|
|
35
|
+
<div>
|
|
36
|
+
<Fragment innerHTML={html1} />
|
|
37
|
+
<Fragment innerHTML={html2} />
|
|
38
|
+
</div>
|
|
39
|
+
</>;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
<div
|
|
42
|
-
|
|
42
|
+
export function HtmlWithReactivity() {
|
|
43
|
+
return <>
|
|
44
|
+
<div>
|
|
45
|
+
<Fragment innerHTML="<p>Count: 0</p>" />
|
|
46
|
+
<button>{'Increment'}</button>
|
|
47
|
+
</div>
|
|
48
|
+
</>;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
export function HtmlWrapper({ children }: { children: any }) {
|
|
52
|
+
return <>
|
|
53
|
+
<div class="wrapper">
|
|
54
|
+
<div class="inner">{children}</div>
|
|
55
|
+
</div>
|
|
56
|
+
</>;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
export function HtmlInChildren() {
|
|
60
|
+
return <>
|
|
61
|
+
const content = '<p><strong>Bold</strong> text</p>';
|
|
62
|
+
<HtmlWrapper>
|
|
63
|
+
<div class="vp-doc" innerHTML={content} />
|
|
64
|
+
</HtmlWrapper>
|
|
65
|
+
</>;
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
export
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
export function HtmlInChildrenWithSiblings() {
|
|
69
|
+
return <>
|
|
70
|
+
const content = '<p>Dynamic content</p>';
|
|
71
|
+
<HtmlWrapper>
|
|
72
|
+
<h1>{'Title'}</h1>
|
|
73
|
+
<div class="content" innerHTML={content} />
|
|
74
|
+
</HtmlWrapper>
|
|
75
|
+
</>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function MultipleHtmlInChildren() {
|
|
79
|
+
return <>
|
|
80
|
+
const html1 = '<p>First</p>';
|
|
81
|
+
const html2 = '<p>Second</p>';
|
|
82
|
+
<HtmlWrapper>
|
|
83
|
+
<div class="doc">
|
|
84
|
+
<Fragment innerHTML={html1} />
|
|
85
|
+
<Fragment innerHTML={html2} />
|
|
86
|
+
</div>
|
|
87
|
+
</HtmlWrapper>
|
|
88
|
+
</>;
|
|
69
89
|
}
|
|
70
90
|
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
export function HtmlWithComments() {
|
|
92
|
+
return <>
|
|
93
|
+
const content = '<p>Before comment</p><!-- TODO: Elaborate --><p>After comment</p>';
|
|
94
|
+
<div innerHTML={content} />
|
|
95
|
+
</>;
|
|
74
96
|
}
|
|
75
97
|
|
|
76
|
-
export
|
|
77
|
-
|
|
78
|
-
|
|
98
|
+
export function HtmlWithEmptyComment() {
|
|
99
|
+
return <>
|
|
100
|
+
const content = '<p>Before</p><!----><p>After</p>';
|
|
101
|
+
<div innerHTML={content} />
|
|
102
|
+
</>;
|
|
79
103
|
}
|
|
80
104
|
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
<
|
|
85
|
-
|
|
105
|
+
export function HtmlWithCommentsInChildren() {
|
|
106
|
+
return <>
|
|
107
|
+
const content = '<h2 id="intro">Introduction</h2><p>Some text</p><!-- TODO --><p>More text</p>';
|
|
108
|
+
<HtmlWrapper>
|
|
109
|
+
<div class="vp-doc" innerHTML={content} />
|
|
110
|
+
</HtmlWrapper>
|
|
111
|
+
</>;
|
|
86
112
|
}
|
|
87
113
|
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
function DocFooter() {
|
|
115
|
+
return <><footer class="doc-footer">{'Footer content'}</footer></>;
|
|
90
116
|
}
|
|
91
117
|
|
|
92
|
-
export
|
|
118
|
+
export function DocLayout({
|
|
93
119
|
children,
|
|
94
120
|
editPath = '',
|
|
95
121
|
nextLink = null,
|
|
@@ -100,106 +126,122 @@ export component DocLayout({
|
|
|
100
126
|
nextLink?: { href: string; text: string } | null;
|
|
101
127
|
toc?: { href: string; text: string }[];
|
|
102
128
|
}) {
|
|
103
|
-
|
|
104
|
-
<div class="
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
<
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
return <>
|
|
130
|
+
<div class="layout">
|
|
131
|
+
<div class="content-container">
|
|
132
|
+
<article>
|
|
133
|
+
<div>{children}</div>
|
|
134
|
+
</article>
|
|
135
|
+
if (editPath) {
|
|
136
|
+
<div class="edit-link">
|
|
137
|
+
<a href={`https://github.com/edit/${editPath}`}>{'Edit'}</a>
|
|
138
|
+
</div>
|
|
139
|
+
}
|
|
140
|
+
if (nextLink) {
|
|
141
|
+
<nav class="prev-next">
|
|
142
|
+
<a href={nextLink.href}>{nextLink.text}</a>
|
|
143
|
+
</nav>
|
|
144
|
+
}
|
|
145
|
+
<DocFooter />
|
|
146
|
+
</div>
|
|
147
|
+
<aside>
|
|
148
|
+
if (toc.length > 0) {
|
|
149
|
+
<div class="toc">
|
|
150
|
+
<ul>
|
|
151
|
+
for (const item of toc) {
|
|
152
|
+
<li>
|
|
153
|
+
<a href={item.href}>{item.text}</a>
|
|
154
|
+
</li>
|
|
155
|
+
}
|
|
156
|
+
</ul>
|
|
157
|
+
</div>
|
|
158
|
+
}
|
|
159
|
+
</aside>
|
|
119
160
|
</div>
|
|
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
|
-
case 1: {
|
|
167
|
-
<h1 class="heading">{children}</h1>
|
|
168
|
-
}
|
|
169
|
-
case 2: {
|
|
170
|
-
<h2 class="heading">{children}</h2>
|
|
161
|
+
</>;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function HtmlWithServerData() {
|
|
165
|
+
return <>
|
|
166
|
+
const content = '<h1 id="intro" class="doc-h1">Introduction</h1><p>Ripple is a framework.</p>';
|
|
167
|
+
<DocLayout
|
|
168
|
+
editPath="docs/introduction.md"
|
|
169
|
+
nextLink={{ href: '/docs/quick-start', text: 'Quick Start' }}
|
|
170
|
+
toc={[
|
|
171
|
+
{ href: '#intro', text: 'Introduction' },
|
|
172
|
+
{ href: '#features', text: 'Features' },
|
|
173
|
+
]}
|
|
174
|
+
>
|
|
175
|
+
<div class="vp-doc" innerHTML={content} />
|
|
176
|
+
</DocLayout>
|
|
177
|
+
</>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function HtmlWithClientDefaults() {
|
|
181
|
+
return <>
|
|
182
|
+
const content = '<h1 id="intro" class="doc-h1">Introduction</h1><p>Ripple is a framework.</p>';
|
|
183
|
+
<DocLayout>
|
|
184
|
+
<div class="vp-doc" innerHTML={content} />
|
|
185
|
+
</DocLayout>
|
|
186
|
+
</>;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function HtmlWithUndefinedContent() {
|
|
190
|
+
return <>
|
|
191
|
+
const content: string | undefined = undefined;
|
|
192
|
+
<DocLayout>
|
|
193
|
+
<div class="vp-doc" innerHTML={content} />
|
|
194
|
+
</DocLayout>
|
|
195
|
+
</>;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function DynamicHeading({ level, children }: { level: number; children: any }) {
|
|
199
|
+
return <>
|
|
200
|
+
switch (level) {
|
|
201
|
+
case 1:
|
|
202
|
+
<h1 class="heading">{children}</h1>
|
|
203
|
+
break;
|
|
204
|
+
case 2:
|
|
205
|
+
<h2 class="heading">{children}</h2>
|
|
206
|
+
break;
|
|
171
207
|
}
|
|
172
|
-
|
|
208
|
+
</>;
|
|
173
209
|
}
|
|
174
210
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
<div class="
|
|
179
|
-
<
|
|
180
|
-
|
|
211
|
+
function CodeBlock({ code }: { code: string }) {
|
|
212
|
+
return <>
|
|
213
|
+
const highlighted = `<pre class="shiki"><code>${code}</code></pre>`;
|
|
214
|
+
<div class="code-block">
|
|
215
|
+
<div class="header">
|
|
216
|
+
<button>{'Copy'}</button>
|
|
217
|
+
<span class="lang">{'js'}</span>
|
|
218
|
+
</div>
|
|
219
|
+
<div class="content" innerHTML={highlighted} />
|
|
181
220
|
</div>
|
|
182
|
-
|
|
183
|
-
</div>
|
|
221
|
+
</>;
|
|
184
222
|
}
|
|
185
223
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<div class="
|
|
189
|
-
|
|
224
|
+
function ContentWrapper({ children }: { children: any }) {
|
|
225
|
+
return <>
|
|
226
|
+
<div class="wrapper">
|
|
227
|
+
<div class="inner">{children}</div>
|
|
228
|
+
</div>
|
|
229
|
+
</>;
|
|
190
230
|
}
|
|
191
231
|
|
|
192
|
-
export
|
|
193
|
-
|
|
194
|
-
<
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
232
|
+
export function HtmlAfterSwitchInChildren() {
|
|
233
|
+
return <>
|
|
234
|
+
<ContentWrapper>
|
|
235
|
+
<DynamicHeading level={1}>{'Title'}</DynamicHeading>
|
|
236
|
+
<p>{'First paragraph'}</p>
|
|
237
|
+
<p>{'Second paragraph'}</p>
|
|
238
|
+
<CodeBlock code="const x = 1;" />
|
|
239
|
+
<p>{'After code'}</p>
|
|
240
|
+
</ContentWrapper>
|
|
241
|
+
</>;
|
|
200
242
|
}
|
|
201
243
|
|
|
202
|
-
|
|
244
|
+
function NavItem({
|
|
203
245
|
href,
|
|
204
246
|
text: label,
|
|
205
247
|
active = false,
|
|
@@ -208,156 +250,176 @@ component NavItem({
|
|
|
208
250
|
text: string;
|
|
209
251
|
active?: boolean;
|
|
210
252
|
}) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
<
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
component SidebarSection({ title, children }: { title: string; children: any }) {
|
|
222
|
-
let &[expanded] = track(true);
|
|
223
|
-
<section class="sidebar-section">
|
|
224
|
-
<div class="section-header">
|
|
225
|
-
<h2>{title}</h2>
|
|
226
|
-
<button onClick={() => (expanded = !expanded)}>{'Toggle'}</button>
|
|
253
|
+
return <>
|
|
254
|
+
<div class={`nav-item${active ? ' active' : ''}`}>
|
|
255
|
+
if (active) {
|
|
256
|
+
<div class="indicator" />
|
|
257
|
+
}
|
|
258
|
+
<a {href}>
|
|
259
|
+
<span>{label}</span>
|
|
260
|
+
</a>
|
|
227
261
|
</div>
|
|
228
|
-
|
|
229
|
-
<div class="section-items">{children}</div>
|
|
230
|
-
}
|
|
231
|
-
</section>
|
|
262
|
+
</>;
|
|
232
263
|
}
|
|
233
264
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
</SidebarSection>
|
|
265
|
+
function SidebarSection({ title, children }: { title: string; children: any }) {
|
|
266
|
+
return <>
|
|
267
|
+
let &[expanded] = track(true);
|
|
268
|
+
<section class="sidebar-section">
|
|
269
|
+
<div class="section-header">
|
|
270
|
+
<h2>{title}</h2>
|
|
271
|
+
<button onClick={() => (expanded = !expanded)}>{'Toggle'}</button>
|
|
242
272
|
</div>
|
|
243
|
-
|
|
244
|
-
<
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
export component LayoutWithSidebarAndMain() {
|
|
260
|
-
<div class="layout">
|
|
261
|
-
<PageHeader />
|
|
262
|
-
<div class="content-wrapper">
|
|
263
|
-
<SideNav currentPath="/intro" />
|
|
264
|
-
<main class="main-content">
|
|
265
|
-
<div class="article">
|
|
266
|
-
<div>
|
|
267
|
-
<h1>{'Introduction'}</h1>
|
|
268
|
-
<p>{'Welcome to the docs.'}</p>
|
|
269
|
-
</div>
|
|
273
|
+
if (expanded) {
|
|
274
|
+
<div class="section-items">{children}</div>
|
|
275
|
+
}
|
|
276
|
+
</section>
|
|
277
|
+
</>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function SideNav({ currentPath }: { currentPath: string }) {
|
|
281
|
+
return <>
|
|
282
|
+
<aside class="sidebar">
|
|
283
|
+
<nav>
|
|
284
|
+
<div class="group">
|
|
285
|
+
<SidebarSection title="Getting Started">
|
|
286
|
+
<NavItem href="/intro" text="Introduction" active={currentPath === '/intro'} />
|
|
287
|
+
<NavItem href="/start" text="Quick Start" active={currentPath === '/start'} />
|
|
288
|
+
</SidebarSection>
|
|
270
289
|
</div>
|
|
271
|
-
|
|
272
|
-
<
|
|
273
|
-
<
|
|
290
|
+
<div class="group">
|
|
291
|
+
<SidebarSection title="Guide">
|
|
292
|
+
<NavItem href="/guide/app" text="Application" active={currentPath === '/guide/app'} />
|
|
293
|
+
<NavItem href="/guide/syntax" text="Syntax" active={currentPath === '/guide/syntax'} />
|
|
294
|
+
</SidebarSection>
|
|
295
|
+
</div>
|
|
296
|
+
</nav>
|
|
297
|
+
</aside>
|
|
298
|
+
</>;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function PageHeader() {
|
|
302
|
+
return <>
|
|
303
|
+
<header class="page-header">
|
|
304
|
+
<div class="logo">{'MyApp'}</div>
|
|
305
|
+
</header>
|
|
306
|
+
</>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export function LayoutWithSidebarAndMain() {
|
|
310
|
+
return <>
|
|
311
|
+
<div class="layout">
|
|
312
|
+
<PageHeader />
|
|
313
|
+
<div class="content-wrapper">
|
|
314
|
+
<SideNav currentPath="/intro" />
|
|
315
|
+
<main class="main-content">
|
|
316
|
+
<div class="article">
|
|
317
|
+
<div>
|
|
318
|
+
<h1>{'Introduction'}</h1>
|
|
319
|
+
<p>{'Welcome to the docs.'}</p>
|
|
320
|
+
</div>
|
|
274
321
|
</div>
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
322
|
+
if (true) {
|
|
323
|
+
<div class="edit-link">
|
|
324
|
+
<a href="/edit">{'Edit'}</a>
|
|
325
|
+
</div>
|
|
326
|
+
}
|
|
327
|
+
<PageHeader />
|
|
328
|
+
</main>
|
|
329
|
+
</div>
|
|
278
330
|
</div>
|
|
279
|
-
|
|
331
|
+
</>;
|
|
280
332
|
}
|
|
281
333
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
<
|
|
285
|
-
|
|
334
|
+
function ArticleWrapper({ children }: { children: any }) {
|
|
335
|
+
return <>
|
|
336
|
+
<article class="doc-content">
|
|
337
|
+
<div>{children}</div>
|
|
338
|
+
</article>
|
|
339
|
+
</>;
|
|
286
340
|
}
|
|
287
341
|
|
|
288
|
-
|
|
289
|
-
|
|
342
|
+
function SimpleFooter() {
|
|
343
|
+
return <><footer class="doc-footer">{'Footer'}</footer></>;
|
|
290
344
|
}
|
|
291
345
|
|
|
292
|
-
export
|
|
293
|
-
|
|
294
|
-
<
|
|
295
|
-
<
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
<
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
<
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
export component ArticleWithHtmlChildThenSibling() {
|
|
313
|
-
const htmlContent = '<pre><code>const x = 1;</code></pre>';
|
|
314
|
-
<div class="content-container">
|
|
315
|
-
<ArticleWrapper>
|
|
316
|
-
<div class="doc-content">{html htmlContent}</div>
|
|
317
|
-
</ArticleWrapper>
|
|
318
|
-
if (true) {
|
|
319
|
-
<div class="edit-link">
|
|
320
|
-
<a href="/edit">{'Edit'}</a>
|
|
321
|
-
</div>
|
|
322
|
-
}
|
|
323
|
-
<SimpleFooter />
|
|
324
|
-
</div>
|
|
346
|
+
export function ArticleWithChildrenThenSibling() {
|
|
347
|
+
return <>
|
|
348
|
+
<div class="content-container">
|
|
349
|
+
<ArticleWrapper>
|
|
350
|
+
<h1>{'Title'}</h1>
|
|
351
|
+
<p>{'Content goes here.'}</p>
|
|
352
|
+
</ArticleWrapper>
|
|
353
|
+
if (true) {
|
|
354
|
+
<div class="edit-link">
|
|
355
|
+
<a href="/edit">{'Edit'}</a>
|
|
356
|
+
</div>
|
|
357
|
+
}
|
|
358
|
+
if (true) {
|
|
359
|
+
<nav class="prev-next">
|
|
360
|
+
<a href="/prev">{'Previous'}</a>
|
|
361
|
+
</nav>
|
|
362
|
+
}
|
|
363
|
+
<SimpleFooter />
|
|
364
|
+
</div>
|
|
365
|
+
</>;
|
|
325
366
|
}
|
|
326
367
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
<
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
368
|
+
export function ArticleWithHtmlChildThenSibling() {
|
|
369
|
+
return <>
|
|
370
|
+
const htmlContent = '<pre><code>const x = 1;</code></pre>';
|
|
371
|
+
<div class="content-container">
|
|
372
|
+
<ArticleWrapper>
|
|
373
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
374
|
+
</ArticleWrapper>
|
|
375
|
+
if (true) {
|
|
376
|
+
<div class="edit-link">
|
|
377
|
+
<a href="/edit">{'Edit'}</a>
|
|
378
|
+
</div>
|
|
379
|
+
}
|
|
380
|
+
<SimpleFooter />
|
|
381
|
+
</div>
|
|
382
|
+
</>;
|
|
339
383
|
}
|
|
340
384
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
385
|
+
function InlineArticleLayout({ children }: { children: any }) {
|
|
386
|
+
return <>
|
|
387
|
+
<div class="content-container">
|
|
388
|
+
<article class="doc-content">
|
|
389
|
+
<div>{children}</div>
|
|
390
|
+
</article>
|
|
391
|
+
if (true) {
|
|
392
|
+
<div class="edit-link">
|
|
393
|
+
<a href="/edit">{'Edit'}</a>
|
|
394
|
+
</div>
|
|
395
|
+
}
|
|
396
|
+
<SimpleFooter />
|
|
397
|
+
</div>
|
|
398
|
+
</>;
|
|
346
399
|
}
|
|
347
400
|
|
|
348
|
-
|
|
349
|
-
|
|
401
|
+
export function InlineArticleWithHtmlChild() {
|
|
402
|
+
return <>
|
|
403
|
+
const htmlContent = '<pre><code>const x = 1;</code></pre>';
|
|
404
|
+
<InlineArticleLayout>
|
|
405
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
406
|
+
</InlineArticleLayout>
|
|
407
|
+
</>;
|
|
350
408
|
}
|
|
351
409
|
|
|
352
|
-
|
|
353
|
-
|
|
410
|
+
function HeaderStub() {
|
|
411
|
+
return <><header class="header">{'Header'}</header></>;
|
|
354
412
|
}
|
|
355
413
|
|
|
356
|
-
|
|
357
|
-
|
|
414
|
+
function SidebarStub() {
|
|
415
|
+
return <><aside class="sidebar">{'Sidebar'}</aside></>;
|
|
358
416
|
}
|
|
359
417
|
|
|
360
|
-
|
|
418
|
+
function FooterStub() {
|
|
419
|
+
return <><footer class="footer">{'Footer'}</footer></>;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function DocsLayoutInner({
|
|
361
423
|
children,
|
|
362
424
|
editPath = '',
|
|
363
425
|
nextLink = null,
|
|
@@ -366,51 +428,57 @@ component DocsLayoutInner({
|
|
|
366
428
|
editPath?: string;
|
|
367
429
|
nextLink?: { href: string; text: string } | null;
|
|
368
430
|
}) {
|
|
369
|
-
|
|
370
|
-
<
|
|
371
|
-
|
|
372
|
-
<
|
|
373
|
-
|
|
374
|
-
<
|
|
375
|
-
<div class="
|
|
376
|
-
<div class="content
|
|
377
|
-
<
|
|
378
|
-
<
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
<
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
<
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
431
|
+
return <>
|
|
432
|
+
<div class="layout">
|
|
433
|
+
<HeaderStub />
|
|
434
|
+
<div class="docs-wrapper">
|
|
435
|
+
<SidebarStub />
|
|
436
|
+
<main class="docs-main">
|
|
437
|
+
<div class="docs-container">
|
|
438
|
+
<div class="content">
|
|
439
|
+
<div class="content-container">
|
|
440
|
+
<article class="doc-content">
|
|
441
|
+
<div>{children}</div>
|
|
442
|
+
</article>
|
|
443
|
+
if (editPath) {
|
|
444
|
+
<div class="edit-link">
|
|
445
|
+
<a href="/edit">{'Edit on GitHub'}</a>
|
|
446
|
+
</div>
|
|
447
|
+
}
|
|
448
|
+
if (nextLink) {
|
|
449
|
+
<nav class="prev-next">
|
|
450
|
+
<a href={nextLink.href}>{nextLink.text}</a>
|
|
451
|
+
</nav>
|
|
452
|
+
}
|
|
453
|
+
<FooterStub />
|
|
454
|
+
</div>
|
|
391
455
|
</div>
|
|
392
456
|
</div>
|
|
393
|
-
</
|
|
394
|
-
</
|
|
457
|
+
</main>
|
|
458
|
+
</div>
|
|
395
459
|
</div>
|
|
396
|
-
|
|
460
|
+
</>;
|
|
397
461
|
}
|
|
398
462
|
|
|
399
|
-
export
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
<
|
|
403
|
-
|
|
463
|
+
export function DocsLayoutWithData() {
|
|
464
|
+
return <>
|
|
465
|
+
const htmlContent = '<h1>Title</h1><p>Content</p>';
|
|
466
|
+
<DocsLayoutInner editPath="docs/styling.md" nextLink={{ href: '/next', text: 'Next' }}>
|
|
467
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
468
|
+
</DocsLayoutInner>
|
|
469
|
+
</>;
|
|
404
470
|
}
|
|
405
471
|
|
|
406
|
-
export
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
<
|
|
410
|
-
|
|
472
|
+
export function DocsLayoutWithoutData() {
|
|
473
|
+
return <>
|
|
474
|
+
const htmlContent: string | undefined = undefined;
|
|
475
|
+
<DocsLayoutInner>
|
|
476
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
477
|
+
</DocsLayoutInner>
|
|
478
|
+
</>;
|
|
411
479
|
}
|
|
412
480
|
|
|
413
|
-
|
|
481
|
+
function DocsLayoutExact({
|
|
414
482
|
children,
|
|
415
483
|
editPath = '',
|
|
416
484
|
prevLink = null,
|
|
@@ -423,136 +491,150 @@ component DocsLayoutExact({
|
|
|
423
491
|
nextLink?: { href: string; text: string } | null;
|
|
424
492
|
toc?: { href: string; text: string }[];
|
|
425
493
|
}) {
|
|
426
|
-
|
|
427
|
-
<
|
|
428
|
-
|
|
429
|
-
<
|
|
430
|
-
|
|
431
|
-
<
|
|
432
|
-
<div class="
|
|
433
|
-
<div class="content
|
|
434
|
-
<
|
|
435
|
-
<
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
<
|
|
494
|
+
return <>
|
|
495
|
+
<div class="layout">
|
|
496
|
+
<HeaderStub />
|
|
497
|
+
<div class="docs-wrapper">
|
|
498
|
+
<SidebarStub />
|
|
499
|
+
<main class="docs-main">
|
|
500
|
+
<div class="docs-container">
|
|
501
|
+
<div class="content">
|
|
502
|
+
<div class="content-container">
|
|
503
|
+
<article class="doc-content">
|
|
504
|
+
<div>{children}</div>
|
|
505
|
+
</article>
|
|
506
|
+
if (editPath) {
|
|
507
|
+
<div class="edit-link">
|
|
508
|
+
<a href={`/edit/${editPath}`}>{'Edit on GitHub'}</a>
|
|
509
|
+
</div>
|
|
510
|
+
}
|
|
511
|
+
if (prevLink || nextLink) {
|
|
512
|
+
<nav class="prev-next">
|
|
513
|
+
if (prevLink) {
|
|
514
|
+
<a href={prevLink.href} class="pager prev">
|
|
515
|
+
<span class="title">{prevLink.text}</span>
|
|
516
|
+
</a>
|
|
517
|
+
} else {
|
|
518
|
+
<span />
|
|
519
|
+
}
|
|
520
|
+
if (nextLink) {
|
|
521
|
+
<a href={nextLink.href} class="pager next">
|
|
522
|
+
<span class="title">{nextLink.text}</span>
|
|
523
|
+
</a>
|
|
524
|
+
}
|
|
525
|
+
</nav>
|
|
526
|
+
}
|
|
527
|
+
<FooterStub />
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
<aside class="aside">
|
|
531
|
+
if (toc.length > 0) {
|
|
532
|
+
<div class="aside-content">
|
|
533
|
+
<nav class="outline">
|
|
534
|
+
for (const item of toc) {
|
|
535
|
+
<a href={item.href}>{item.text}</a>
|
|
536
|
+
}
|
|
537
|
+
</nav>
|
|
440
538
|
</div>
|
|
441
539
|
}
|
|
442
|
-
|
|
443
|
-
<nav class="prev-next">
|
|
444
|
-
if (prevLink) {
|
|
445
|
-
<a href={prevLink.href} class="pager prev">
|
|
446
|
-
<span class="title">{prevLink.text}</span>
|
|
447
|
-
</a>
|
|
448
|
-
} else {
|
|
449
|
-
<span />
|
|
450
|
-
}
|
|
451
|
-
if (nextLink) {
|
|
452
|
-
<a href={nextLink.href} class="pager next">
|
|
453
|
-
<span class="title">{nextLink.text}</span>
|
|
454
|
-
</a>
|
|
455
|
-
}
|
|
456
|
-
</nav>
|
|
457
|
-
}
|
|
458
|
-
<FooterStub />
|
|
459
|
-
</div>
|
|
540
|
+
</aside>
|
|
460
541
|
</div>
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
542
|
+
</main>
|
|
543
|
+
</div>
|
|
544
|
+
</div>
|
|
545
|
+
</>;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export function DocsLayoutExactWithData() {
|
|
549
|
+
return <>
|
|
550
|
+
const htmlContent = '<h1>Styling Guide</h1><p>Content</p>';
|
|
551
|
+
<DocsLayoutExact
|
|
552
|
+
editPath="docs/guide/styling.md"
|
|
553
|
+
prevLink={{ href: '/prev', text: 'Previous' }}
|
|
554
|
+
nextLink={{ href: '/next', text: 'Next' }}
|
|
555
|
+
toc={[
|
|
556
|
+
{ href: '#intro', text: 'Introduction' },
|
|
557
|
+
{ href: '#usage', text: 'Usage' },
|
|
558
|
+
]}
|
|
559
|
+
>
|
|
560
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
561
|
+
</DocsLayoutExact>
|
|
562
|
+
</>;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
export function DocsLayoutExactWithoutData() {
|
|
566
|
+
return <>
|
|
567
|
+
const htmlContent: string | undefined = undefined;
|
|
568
|
+
const editPath: string | undefined = undefined;
|
|
569
|
+
const prevLink: { href: string; text: string } | null | undefined = undefined;
|
|
570
|
+
const nextLink: { href: string; text: string } | null | undefined = undefined;
|
|
571
|
+
const toc: { href: string; text: string }[] | undefined = undefined;
|
|
572
|
+
<DocsLayoutExact {editPath} {prevLink} {nextLink} {toc}>
|
|
573
|
+
<div class="doc-content" innerHTML={htmlContent} />
|
|
574
|
+
</DocsLayoutExact>
|
|
575
|
+
</>;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export function TemplateWithHtmlContent() {
|
|
579
|
+
return <>
|
|
580
|
+
const data = { title: 'Test', value: 42 };
|
|
581
|
+
<div>
|
|
582
|
+
<template id="t1" innerHTML={JSON.stringify(data)} />
|
|
583
|
+
<p class="content">{'Main content'}</p>
|
|
584
|
+
</div>
|
|
585
|
+
</>;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export function TemplateWithHtmlAndSiblings() {
|
|
589
|
+
return <>
|
|
590
|
+
const data = { name: 'Ripple', version: '1.0' };
|
|
591
|
+
<div class="wrapper">
|
|
592
|
+
<h1>{'Title'}</h1>
|
|
593
|
+
<template id="data-template" innerHTML={JSON.stringify(data)} />
|
|
594
|
+
<p class="after-template">{'Content after template'}</p>
|
|
595
|
+
</div>
|
|
596
|
+
</>;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function LayoutWithTemplate({ children, data }: { children: any; data: object }) {
|
|
600
|
+
return <>
|
|
601
|
+
<div class="layout">
|
|
602
|
+
<template id="page-data" innerHTML={JSON.stringify(data)} />
|
|
603
|
+
<main>{children}</main>
|
|
474
604
|
</div>
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
export
|
|
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
|
-
</div>
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export component TemplateWithHtmlAndSiblings() {
|
|
514
|
-
const data = { name: 'Ripple', version: '1.0' };
|
|
515
|
-
<div class="wrapper">
|
|
516
|
-
<h1>{'Title'}</h1>
|
|
517
|
-
<template id="data-template">{html JSON.stringify(data)}</template>
|
|
518
|
-
<p class="after-template">{'Content after template'}</p>
|
|
519
|
-
</div>
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
component LayoutWithTemplate({ children, data }: { children: any; data: object }) {
|
|
523
|
-
<div class="layout">
|
|
524
|
-
<template id="page-data">{html JSON.stringify(data)}</template>
|
|
525
|
-
<main>{children}</main>
|
|
526
|
-
</div>
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
export component NestedTemplateInLayout() {
|
|
530
|
-
const doc = { title: 'Comparison', html: '<p>Content</p>' };
|
|
531
|
-
<LayoutWithTemplate data={doc}>
|
|
532
|
-
<div class="doc-content">{html doc.html}</div>
|
|
533
|
-
</LayoutWithTemplate>
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
export component HtmlCodeBlocksWithSiblingChain() {
|
|
537
|
-
const html1 = '<span class="kw">const</span> <span class="id">a</span> = 1;';
|
|
538
|
-
const html2 = '<span class="kw">const</span> <span class="id">b</span> = 2;';
|
|
539
|
-
const html3 = '<span class="kw">const</span> <span class="id">c</span> = 3;';
|
|
540
|
-
|
|
541
|
-
<section class="readable-section">
|
|
542
|
-
<p>{'Ergonomics'}</p>
|
|
543
|
-
<h2>{'Sibling traversal pattern'}</h2>
|
|
544
|
-
<p>{'Before first block'}</p>
|
|
545
|
-
<p>{'Before second block'}</p>
|
|
546
|
-
<pre class="code-block">
|
|
547
|
-
<code>{html html1}</code>
|
|
548
|
-
</pre>
|
|
549
|
-
<p>{'Between one and two'}</p>
|
|
550
|
-
<pre class="code-block">
|
|
551
|
-
<code>{html html2}</code>
|
|
552
|
-
</pre>
|
|
553
|
-
<p>{'Between two and three'}</p>
|
|
554
|
-
<pre class="code-block">
|
|
555
|
-
<code>{html html3}</code>
|
|
556
|
-
</pre>
|
|
557
|
-
</section>
|
|
605
|
+
</>;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
export function NestedTemplateInLayout() {
|
|
609
|
+
return <>
|
|
610
|
+
const doc = { title: 'Comparison', html: '<p>Content</p>' };
|
|
611
|
+
<LayoutWithTemplate data={doc}>
|
|
612
|
+
<div class="doc-content" innerHTML={doc.html} />
|
|
613
|
+
</LayoutWithTemplate>
|
|
614
|
+
</>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export function HtmlCodeBlocksWithSiblingChain() {
|
|
618
|
+
return <>
|
|
619
|
+
const html1 = '<span class="kw">const</span> <span class="id">a</span> = 1;';
|
|
620
|
+
const html2 = '<span class="kw">const</span> <span class="id">b</span> = 2;';
|
|
621
|
+
const html3 = '<span class="kw">const</span> <span class="id">c</span> = 3;';
|
|
622
|
+
<section class="readable-section">
|
|
623
|
+
<p>{'Ergonomics'}</p>
|
|
624
|
+
<h2>{'Sibling traversal pattern'}</h2>
|
|
625
|
+
<p>{'Before first block'}</p>
|
|
626
|
+
<p>{'Before second block'}</p>
|
|
627
|
+
<pre class="code-block">
|
|
628
|
+
<code innerHTML={html1} />
|
|
629
|
+
</pre>
|
|
630
|
+
<p>{'Between one and two'}</p>
|
|
631
|
+
<pre class="code-block">
|
|
632
|
+
<code innerHTML={html2} />
|
|
633
|
+
</pre>
|
|
634
|
+
<p>{'Between two and three'}</p>
|
|
635
|
+
<pre class="code-block">
|
|
636
|
+
<code innerHTML={html3} />
|
|
637
|
+
</pre>
|
|
638
|
+
</section>
|
|
639
|
+
</>;
|
|
558
640
|
}
|