element-book 0.0.8 → 0.0.9
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/dist/ui/elements/entry-display/element-book-example-viewer.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/element-book-example-viewer.element.js +1 -2
- package/dist/ui/elements/entry-display/element-book-page-examples.element.d.ts +1 -1
- package/dist/ui/elements/entry-display/element-book-page-examples.element.js +20 -15
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementBookPageExample } from '../../../data/element-book-entry/element-book-page/element-book-page-example';
|
|
2
2
|
export declare const ElementBookExampleViewer: import("element-vir").DeclarativeElementDefinition<"element-book-example-viewer", {
|
|
3
3
|
example: ElementBookPageExample;
|
|
4
|
-
|
|
4
|
+
breadcrumbs: ReadonlyArray<string>;
|
|
5
5
|
}, {
|
|
6
6
|
internalState: any;
|
|
7
7
|
}, {}, string, string, string | import("lit-html").HTMLTemplateResult, undefined>;
|
|
@@ -8,7 +8,6 @@ export const ElementBookExampleViewer = defineElementBookElement()({
|
|
|
8
8
|
internalState: unsetInternalState,
|
|
9
9
|
},
|
|
10
10
|
renderCallback({ state, inputs, updateState }) {
|
|
11
|
-
const fullExampleBreadcrumbs = inputs.parentBreadcrumbs.concat(inputs.example.title);
|
|
12
11
|
if (state.internalState === unsetInternalState) {
|
|
13
12
|
updateState({ internalState: inputs.example.stateInit });
|
|
14
13
|
}
|
|
@@ -35,7 +34,7 @@ export const ElementBookExampleViewer = defineElementBookElement()({
|
|
|
35
34
|
}
|
|
36
35
|
catch (error) {
|
|
37
36
|
console.error(error);
|
|
38
|
-
return `${
|
|
37
|
+
return `${inputs.breadcrumbs.join(' > ')} failed: ${extractErrorMessage(error)}`;
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
});
|
|
@@ -2,4 +2,4 @@ import { ElementBookPage } from '../../../data/element-book-entry/element-book-p
|
|
|
2
2
|
export declare const ElementBookPageExamples: import("element-vir").DeclarativeElementDefinition<"element-book-page-examples", {
|
|
3
3
|
page: ElementBookPage;
|
|
4
4
|
parentBreadcrumbs: ReadonlyArray<string>;
|
|
5
|
-
}, {}, {}, string, string,
|
|
5
|
+
}, {}, {}, string, string, unknown, undefined>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assign, classMap, css, html, renderIf } from 'element-vir';
|
|
1
|
+
import { assign, classMap, css, html, renderIf, repeat } from 'element-vir';
|
|
2
2
|
import { defineElementBookElement } from '../define-book-element';
|
|
3
3
|
import { ElementBookExampleControls } from './element-book-example-controls.element';
|
|
4
4
|
import { ElementBookExampleViewer } from './element-book-example-viewer.element';
|
|
@@ -24,23 +24,28 @@ export const ElementBookPageExamples = defineElementBookElement()({
|
|
|
24
24
|
renderCallback({ inputs }) {
|
|
25
25
|
const examples = inputs.page.examples;
|
|
26
26
|
const allControlsHidden = examples.every((example) => example.hideControls);
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Use the repeat directive here, instead of just a map, so that lit doesn't accidentally
|
|
29
|
+
* keep state cached between element book pages.
|
|
30
|
+
*/
|
|
31
|
+
return repeat(examples, (example) => inputs.parentBreadcrumbs.concat(example.title).join('>'), (example) => {
|
|
32
|
+
const exampleBreadcrumbs = inputs.parentBreadcrumbs.concat(example.title);
|
|
28
33
|
return html `
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
<div class="individual-example-wrapper">
|
|
35
|
+
${renderIf(!allControlsHidden, html `
|
|
36
|
+
<${ElementBookExampleControls}
|
|
37
|
+
class=${classMap({ 'hidden-controls': !!example.hideControls })}
|
|
38
|
+
${assign(ElementBookExampleControls, { example })}
|
|
39
|
+
></${ElementBookExampleControls}>
|
|
40
|
+
`)}
|
|
41
|
+
<${ElementBookExampleViewer}
|
|
42
|
+
${assign(ElementBookExampleViewer, {
|
|
38
43
|
example,
|
|
39
|
-
|
|
44
|
+
breadcrumbs: exampleBreadcrumbs,
|
|
40
45
|
})}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
></${ElementBookExampleViewer}>
|
|
47
|
+
</div>
|
|
48
|
+
`;
|
|
44
49
|
});
|
|
45
50
|
},
|
|
46
51
|
});
|