@3sln/deck 0.0.9 → 0.0.11
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/package.json +2 -2
- package/src/deck-demo.js +43 -22
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3sln/deck",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "A Vite plugin for building scalable, zero-config, Markdown-based component playgrounds and documentation sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Ray Stubbs",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@3sln/bones": "^0.0.4",
|
|
40
|
-
"@3sln/dodo": "^0.0.
|
|
40
|
+
"@3sln/dodo": "^0.0.7",
|
|
41
41
|
"@3sln/ngin": "^0.0.1",
|
|
42
42
|
"fs-extra": "^11.3.2",
|
|
43
43
|
"glob": "^10.3.10",
|
package/src/deck-demo.js
CHANGED
|
@@ -62,16 +62,9 @@ const propertiesStyle = css`
|
|
|
62
62
|
gap: 1em;
|
|
63
63
|
margin-bottom: 0.75em;
|
|
64
64
|
width: 250px;
|
|
65
|
-
}
|
|
66
|
-
.property-label {
|
|
67
|
-
flex: 1;
|
|
68
|
-
text-align: right;
|
|
69
|
-
font-size: 0.9em;
|
|
70
65
|
color: var(--text-color);
|
|
71
|
-
opacity: 0.8;
|
|
72
66
|
}
|
|
73
67
|
.property-item input {
|
|
74
|
-
flex: 2;
|
|
75
68
|
flex-grow: 0;
|
|
76
69
|
}
|
|
77
70
|
input[type='text'] {
|
|
@@ -144,15 +137,17 @@ function propertyControl(engine, name) {
|
|
|
144
137
|
return input({type: 'range', min: options.min, max: options.max, value}).on({
|
|
145
138
|
input: e => engine.dispatch(new UpdatePropertyValue(name, e.target.valueAsNumber)),
|
|
146
139
|
});
|
|
147
|
-
case '
|
|
148
|
-
return input({type: '
|
|
149
|
-
input: e => engine.dispatch(new UpdatePropertyValue(name, e.target.
|
|
140
|
+
case 'checkbox':
|
|
141
|
+
return input({type: 'checkbox', checked: value}).on({
|
|
142
|
+
input: e => engine.dispatch(new UpdatePropertyValue(name, e.target.checked)),
|
|
150
143
|
});
|
|
151
144
|
default:
|
|
152
|
-
return
|
|
145
|
+
return input({type: options?.type ?? 'text', value}).on({
|
|
146
|
+
input: e => engine.dispatch(new UpdatePropertyValue(name, e.target.value)),
|
|
147
|
+
});
|
|
153
148
|
}
|
|
154
149
|
});
|
|
155
|
-
return
|
|
150
|
+
return label({className: 'property-item'}, name, control);
|
|
156
151
|
});
|
|
157
152
|
}
|
|
158
153
|
|
|
@@ -208,6 +203,8 @@ function createEngine(src, canonicalSrc) {
|
|
|
208
203
|
return;
|
|
209
204
|
}
|
|
210
205
|
|
|
206
|
+
propertyPanelCreated = true;
|
|
207
|
+
|
|
211
208
|
engine.dispatch(
|
|
212
209
|
new CreateOrUpdatePanel({
|
|
213
210
|
name: propsPanelName,
|
|
@@ -225,12 +222,14 @@ function createEngine(src, canonicalSrc) {
|
|
|
225
222
|
};
|
|
226
223
|
|
|
227
224
|
const driver = {
|
|
228
|
-
panel: (name, render, {pane = 'left', order = undefined} = {}) => {
|
|
225
|
+
panel: (name, render, {pane = 'left', order = undefined, mode = 'shadow', colorScheme = undefined} = {}) => {
|
|
229
226
|
const panel = {
|
|
230
227
|
name,
|
|
231
228
|
pane,
|
|
232
229
|
render,
|
|
233
230
|
order,
|
|
231
|
+
mode,
|
|
232
|
+
colorScheme,
|
|
234
233
|
};
|
|
235
234
|
engine.dispatch(new CreateOrUpdatePanel(panel));
|
|
236
235
|
},
|
|
@@ -740,7 +739,7 @@ const demoStyle = css`
|
|
|
740
739
|
.panel-content.active {
|
|
741
740
|
pointer-events: auto;
|
|
742
741
|
overflow: auto;
|
|
743
|
-
width:
|
|
742
|
+
width: 100%;
|
|
744
743
|
}
|
|
745
744
|
pre > code {
|
|
746
745
|
padding: 1em;
|
|
@@ -817,16 +816,38 @@ class DeckDemo extends HTMLElement {
|
|
|
817
816
|
.key(p.name)
|
|
818
817
|
.opaque()
|
|
819
818
|
.on({
|
|
820
|
-
$
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
819
|
+
$update: el => {
|
|
820
|
+
if (p.render === el._renderer) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
824
823
|
|
|
825
|
-
el.
|
|
824
|
+
el._aborter?.abort();
|
|
825
|
+
const aborter = new AbortController();
|
|
826
826
|
el._aborter = aborter;
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
p.
|
|
827
|
+
el._renderer = p.render;
|
|
828
|
+
|
|
829
|
+
if (p.mode === 'iframe') {
|
|
830
|
+
const iframe = document.createElement('iframe');
|
|
831
|
+
iframe.style.cssText = 'border: none; width: 100%; height: 100%; display: block;';
|
|
832
|
+
|
|
833
|
+
iframe.onload = () => {
|
|
834
|
+
const doc = iframe.contentDocument;
|
|
835
|
+
if (!doc) return;
|
|
836
|
+
|
|
837
|
+
if (p.colorScheme) {
|
|
838
|
+
doc.documentElement.style.colorScheme = p.colorScheme;
|
|
839
|
+
}
|
|
840
|
+
doc.body.style.margin = '0';
|
|
841
|
+
|
|
842
|
+
p.render(doc.body, aborter.signal);
|
|
843
|
+
};
|
|
844
|
+
el.replaceChildren(iframe);
|
|
845
|
+
} else {
|
|
846
|
+
const div = document.createElement('div');
|
|
847
|
+
const shadow = div.attachShadow({mode: 'open'});
|
|
848
|
+
el.replaceChildren(div);
|
|
849
|
+
p.render(shadow, aborter.signal);
|
|
850
|
+
}
|
|
830
851
|
},
|
|
831
852
|
$detach: el => {
|
|
832
853
|
el._aborter?.abort();
|