element-book 26.17.0 → 26.17.2
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/color-theme/color-theme.d.ts +0 -12
- package/dist/ui/color-theme/color-theme.js +0 -14
- package/dist/ui/color-theme/create-color-theme.d.ts +2 -2
- package/dist/ui/color-theme/create-color-theme.js +18 -57
- package/dist/ui/elements/book-breadcrumbs.element.js +2 -1
- package/dist/ui/elements/book-nav/book-nav-filter.js +1 -1
- package/dist/ui/elements/book-nav/book-nav.element.js +4 -2
- package/dist/ui/elements/element-book-app/element-book-app.element.d.ts +3 -0
- package/dist/ui/elements/element-book-app/element-book-app.element.js +35 -15
- package/dist/ui/elements/element-book-app/element-book-config.d.ts +2 -0
- package/dist/ui/elements/entry-display/book-breadcrumbs-bar.element.js +4 -3
- package/dist/ui/elements/entry-display/book-entry-description.element.js +4 -3
- package/dist/ui/elements/entry-display/book-page/book-page-controls.element.js +4 -10
- package/dist/ui/elements/entry-display/book-page/book-page-wrapper.element.js +2 -4
- package/dist/ui/elements/entry-display/element-example/book-element-example-title.element.js +2 -2
- package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js +5 -5
- package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.js +2 -6
- package/dist/ui/elements/entry-display/entry-display/book-entry-display.element.js +5 -2
- package/dist/ui/elements/entry-display/entry-display/create-node-templates.js +4 -4
- package/dist/util/fuzzy-search.js +1 -2
- package/package.json +15 -13
- package/dist/ui/elements/common/book-error.element.d.ts +0 -3
- package/dist/ui/elements/common/book-error.element.js +0 -25
|
@@ -22,12 +22,6 @@ export type ColorTheme = {
|
|
|
22
22
|
accent: {
|
|
23
23
|
icon: CSSResult;
|
|
24
24
|
};
|
|
25
|
-
page: ColorPair & {
|
|
26
|
-
backgroundFaint1: CSSResult;
|
|
27
|
-
backgroundFaint2: CSSResult;
|
|
28
|
-
foregroundFaint1: CSSResult;
|
|
29
|
-
foregroundFaint2: CSSResult;
|
|
30
|
-
};
|
|
31
25
|
};
|
|
32
26
|
/**
|
|
33
27
|
* All color theme CSS vars for the element-book app.
|
|
@@ -42,12 +36,6 @@ export declare const colorThemeCssVars: import("lit-css-vars").CssVarDefinitions
|
|
|
42
36
|
readonly 'element-book-nav-selected-background-color': "magenta";
|
|
43
37
|
readonly 'element-book-nav-selected-foreground-color': "magenta";
|
|
44
38
|
readonly 'element-book-accent-icon-color': "magenta";
|
|
45
|
-
readonly 'element-book-page-background-color': "magenta";
|
|
46
|
-
readonly 'element-book-page-background-faint-level-1-color': "magenta";
|
|
47
|
-
readonly 'element-book-page-background-faint-level-2-color': "magenta";
|
|
48
|
-
readonly 'element-book-page-foreground-color': "magenta";
|
|
49
|
-
readonly 'element-book-page-foreground-faint-level-1-color': "magenta";
|
|
50
|
-
readonly 'element-book-page-foreground-faint-level-2-color': "magenta";
|
|
51
39
|
}>;
|
|
52
40
|
/**
|
|
53
41
|
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
@@ -13,12 +13,6 @@ export const colorThemeCssVars = defineCssVars({
|
|
|
13
13
|
'element-book-nav-selected-background-color': 'magenta',
|
|
14
14
|
'element-book-nav-selected-foreground-color': 'magenta',
|
|
15
15
|
'element-book-accent-icon-color': 'magenta',
|
|
16
|
-
'element-book-page-background-color': 'magenta',
|
|
17
|
-
'element-book-page-background-faint-level-1-color': 'magenta',
|
|
18
|
-
'element-book-page-background-faint-level-2-color': 'magenta',
|
|
19
|
-
'element-book-page-foreground-color': 'magenta',
|
|
20
|
-
'element-book-page-foreground-faint-level-1-color': 'magenta',
|
|
21
|
-
'element-book-page-foreground-faint-level-2-color': 'magenta',
|
|
22
16
|
});
|
|
23
17
|
const colorThemeCssVarMapping = {
|
|
24
18
|
nav: {
|
|
@@ -38,14 +32,6 @@ const colorThemeCssVarMapping = {
|
|
|
38
32
|
accent: {
|
|
39
33
|
icon: colorThemeCssVars['element-book-accent-icon-color'],
|
|
40
34
|
},
|
|
41
|
-
page: {
|
|
42
|
-
background: colorThemeCssVars['element-book-page-background-color'],
|
|
43
|
-
backgroundFaint1: colorThemeCssVars['element-book-page-background-faint-level-1-color'],
|
|
44
|
-
backgroundFaint2: colorThemeCssVars['element-book-page-background-faint-level-2-color'],
|
|
45
|
-
foreground: colorThemeCssVars['element-book-page-foreground-color'],
|
|
46
|
-
foregroundFaint1: colorThemeCssVars['element-book-page-foreground-faint-level-1-color'],
|
|
47
|
-
foregroundFaint2: colorThemeCssVars['element-book-page-foreground-faint-level-2-color'],
|
|
48
|
-
},
|
|
49
35
|
};
|
|
50
36
|
/**
|
|
51
37
|
* Sets a new color theme's CSS vars on the given HTML element for the element-book app.
|
|
@@ -5,7 +5,7 @@ import { type ColorTheme } from './color-theme.js';
|
|
|
5
5
|
*
|
|
6
6
|
* @category Internal
|
|
7
7
|
*/
|
|
8
|
-
export declare const defaultThemeStartColor
|
|
8
|
+
export declare const defaultThemeStartColor: string;
|
|
9
9
|
/**
|
|
10
10
|
* Theme style options for the element-book app.
|
|
11
11
|
*
|
|
@@ -29,4 +29,4 @@ export type ThemeConfig = PartialWithUndefined<{
|
|
|
29
29
|
*
|
|
30
30
|
* @category Internal
|
|
31
31
|
*/
|
|
32
|
-
export declare function createTheme({ themeColor: inputThemeColor,
|
|
32
|
+
export declare function createTheme({ themeColor: inputThemeColor, }?: ThemeConfig): ColorTheme;
|
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
import { mapObjectValues } from '@augment-vir/common';
|
|
2
1
|
import Color from 'colorjs.io';
|
|
3
2
|
import { unsafeCSS } from 'element-vir';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}));
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
return colorsObjectToCssResult(value);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
3
|
+
import { viraColorPalette } from 'vira';
|
|
4
|
+
function colorToCss(color) {
|
|
5
|
+
return unsafeCSS(color.toString({
|
|
6
|
+
format: 'hex',
|
|
7
|
+
}));
|
|
15
8
|
}
|
|
16
9
|
/**
|
|
17
10
|
* The default theme color.
|
|
18
11
|
*
|
|
19
12
|
* @category Internal
|
|
20
13
|
*/
|
|
21
|
-
export const defaultThemeStartColor = '
|
|
14
|
+
export const defaultThemeStartColor = viraColorPalette['vira-brand-500'].default;
|
|
22
15
|
function calculateTextColorString(color) {
|
|
23
16
|
const onWhite = Math.abs(color.contrast('white', 'APCA'));
|
|
24
17
|
const onBlack = Math.abs(color.contrast('black', 'APCA'));
|
|
25
18
|
const textColorString = onWhite > onBlack ? 'white' : 'black';
|
|
26
19
|
return textColorString;
|
|
27
20
|
}
|
|
28
|
-
function
|
|
21
|
+
function createCssColorPair({ background, foreground, }) {
|
|
22
|
+
const bg = background ?? new Color(calculateTextColorString(foreground));
|
|
23
|
+
const fg = foreground ?? new Color(calculateTextColorString(background));
|
|
29
24
|
return {
|
|
30
|
-
background:
|
|
31
|
-
foreground:
|
|
25
|
+
background: colorToCss(bg),
|
|
26
|
+
foreground: colorToCss(fg),
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
29
|
/**
|
|
@@ -41,69 +36,35 @@ export var ThemeStyle;
|
|
|
41
36
|
ThemeStyle["Dark"] = "dark";
|
|
42
37
|
ThemeStyle["Light"] = "light";
|
|
43
38
|
})(ThemeStyle || (ThemeStyle = {}));
|
|
44
|
-
function flipBackForeground(input) {
|
|
45
|
-
return input === 'black' ? 'white' : 'black';
|
|
46
|
-
}
|
|
47
|
-
const faintForegroundColors = {
|
|
48
|
-
black: {
|
|
49
|
-
foregroundFaint1: new Color('#ccc'),
|
|
50
|
-
foregroundFaint2: new Color('#eee'),
|
|
51
|
-
},
|
|
52
|
-
white: {
|
|
53
|
-
foregroundFaint1: new Color('#ccc'),
|
|
54
|
-
foregroundFaint2: new Color('#eee'),
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
const faintBackgroundColors = {
|
|
58
|
-
black: {
|
|
59
|
-
backgroundFaint1: new Color('#666'),
|
|
60
|
-
backgroundFaint2: new Color('#444'),
|
|
61
|
-
},
|
|
62
|
-
white: {
|
|
63
|
-
backgroundFaint1: new Color('#ccc'),
|
|
64
|
-
backgroundFaint2: new Color('#fafafa'),
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
39
|
/**
|
|
68
40
|
* Creates a theme from the given theme configuration.
|
|
69
41
|
*
|
|
70
42
|
* @category Internal
|
|
71
43
|
*/
|
|
72
|
-
export function createTheme({ themeColor: inputThemeColor = defaultThemeStartColor,
|
|
44
|
+
export function createTheme({ themeColor: inputThemeColor = defaultThemeStartColor, } = {}) {
|
|
73
45
|
const themeColor = new Color(inputThemeColor);
|
|
74
|
-
|
|
75
|
-
const foregroundColorString = calculateTextColorString(backgroundColor);
|
|
76
|
-
const foregroundColor = new Color(foregroundColorString);
|
|
77
|
-
const colors = {
|
|
46
|
+
return {
|
|
78
47
|
nav: {
|
|
79
|
-
hover:
|
|
48
|
+
hover: createCssColorPair({
|
|
80
49
|
background: themeColor.clone().set({
|
|
81
50
|
'hsl.l': 93,
|
|
82
51
|
}),
|
|
83
52
|
}),
|
|
84
|
-
active:
|
|
53
|
+
active: createCssColorPair({
|
|
85
54
|
background: themeColor.clone().set({
|
|
86
55
|
'hsl.l': 90,
|
|
87
56
|
}),
|
|
88
57
|
}),
|
|
89
|
-
selected:
|
|
58
|
+
selected: createCssColorPair({
|
|
90
59
|
background: themeColor.clone().set({
|
|
91
60
|
'hsl.l': 85,
|
|
92
61
|
}),
|
|
93
62
|
}),
|
|
94
63
|
},
|
|
95
64
|
accent: {
|
|
96
|
-
icon: themeColor.clone().set({
|
|
65
|
+
icon: colorToCss(themeColor.clone().set({
|
|
97
66
|
'hsl.l': 40,
|
|
98
|
-
}),
|
|
99
|
-
},
|
|
100
|
-
page: {
|
|
101
|
-
background: backgroundColor,
|
|
102
|
-
...faintBackgroundColors[flipBackForeground(foregroundColorString)],
|
|
103
|
-
foreground: foregroundColor,
|
|
104
|
-
...faintForegroundColors[foregroundColorString],
|
|
67
|
+
})),
|
|
105
68
|
},
|
|
106
69
|
};
|
|
107
|
-
const convertedToCssResults = colorsObjectToCssResult(colors);
|
|
108
|
-
return convertedToCssResults;
|
|
109
70
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { BookMainRoute } from '../../routing/book-routing.js';
|
|
3
4
|
import { BookRouteLink } from './common/book-route-link.element.js';
|
|
4
5
|
import { defineBookElement } from './define-book-element.js';
|
|
@@ -7,7 +8,7 @@ export const BookBreadcrumbs = defineBookElement()({
|
|
|
7
8
|
styles: css `
|
|
8
9
|
:host {
|
|
9
10
|
display: flex;
|
|
10
|
-
color:
|
|
11
|
+
color: ${viraTheme.colors['vira-grey-foreground-header'].foreground.value};
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
.spacer {
|
|
@@ -4,7 +4,7 @@ export function shouldShowTreeNodeInNav(currentNode, selectedPath) {
|
|
|
4
4
|
if (currentNode.entry.entryType === BookEntryType.Root) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
if (currentNode.entry.entryType === BookEntryType.Page) {
|
|
7
|
+
else if (currentNode.entry.entryType === BookEntryType.Page) {
|
|
8
8
|
return true;
|
|
9
9
|
}
|
|
10
10
|
const isParentSelected = check.jsonEquals(selectedPath, currentNode.fullUrlBreadcrumbs.slice(0, -1));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { classMap, css, html, renderIf } from 'element-vir';
|
|
3
|
-
import { Element16Icon, ViraIcon } from 'vira';
|
|
3
|
+
import { Element16Icon, ViraIcon, viraTheme } from 'vira';
|
|
4
4
|
import { BookEntryType } from '../../../data/book-entry/book-entry-type.js';
|
|
5
5
|
import { isBookTreeNode } from '../../../data/book-tree/book-tree.js';
|
|
6
6
|
import { BookMainRoute, defaultBookFullRoute } from '../../../routing/book-routing.js';
|
|
@@ -18,7 +18,9 @@ export const BookNav = defineBookElement()({
|
|
|
18
18
|
display: flex;
|
|
19
19
|
flex-direction: column;
|
|
20
20
|
padding: 16px 0;
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
background-color: ${viraTheme.colors['vira-grey-behind-fg-highest-contrast'].background
|
|
23
|
+
.value};
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
.title-row:hover {
|
|
@@ -30,6 +30,9 @@ export declare const ElementBookApp: import("element-vir").DeclarativeElementDef
|
|
|
30
30
|
controls: ControlsWrapper;
|
|
31
31
|
} | undefined;
|
|
32
32
|
originalWindowTitle: string | undefined;
|
|
33
|
+
isDarkMode: boolean;
|
|
34
|
+
/** Cleanup callback for the dark mode media query listener. */
|
|
35
|
+
darkModeCleanup: (() => void) | undefined;
|
|
33
36
|
}, {
|
|
34
37
|
pathUpdate: import("element-vir").DefineEvent<readonly string[]>;
|
|
35
38
|
}, "element-book-app-", "element-book-app-", readonly ["footer", "navHeader"], readonly []>;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { extractErrorMessage, makeWritable } from '@augment-vir/common';
|
|
3
3
|
import { waitForAnimationFrame } from '@augment-vir/web';
|
|
4
|
+
import { colorCss } from '@electrovir/color';
|
|
4
5
|
import { css, defineElement, defineElementEvent, html, listen, nothing } from 'element-vir';
|
|
6
|
+
import { applyCssVarsViaStyleElement } from 'lit-css-vars';
|
|
7
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
8
|
+
import { ViraError, viraTheme, viraThemeDarkOverride } from 'vira';
|
|
5
9
|
import { createNewControls, updateTreeControls, } from '../../../data/book-entry/book-page/controls-wrapper.js';
|
|
6
10
|
import { createBookTreeFromEntries } from '../../../data/book-tree/book-tree.js';
|
|
7
11
|
import { searchFlattenedNodes } from '../../../data/book-tree/search-nodes.js';
|
|
8
12
|
import { createBookRouter } from '../../../routing/book-router.js';
|
|
9
13
|
import { defaultBookFullRoute, extractSearchQuery, } from '../../../routing/book-routing.js';
|
|
10
|
-
import {
|
|
14
|
+
import { setThemeCssVars } from '../../color-theme/color-theme.js';
|
|
11
15
|
import { createTheme } from '../../color-theme/create-color-theme.js';
|
|
12
16
|
import { ChangeRouteEvent } from '../../events/change-route.event.js';
|
|
13
17
|
import { BookNav } from '../book-nav/book-nav.element.js';
|
|
14
|
-
import { BookError } from '../common/book-error.element.js';
|
|
15
18
|
import { BookPageControls } from '../entry-display/book-page/book-page-controls.element.js';
|
|
16
19
|
import { BookEntryDisplay } from '../entry-display/entry-display/book-entry-display.element.js';
|
|
17
20
|
import { getCurrentNodes } from './get-current-nodes.js';
|
|
@@ -34,6 +37,9 @@ export const ElementBookApp = defineElement()({
|
|
|
34
37
|
},
|
|
35
38
|
treeBasedControls: undefined,
|
|
36
39
|
originalWindowTitle: undefined,
|
|
40
|
+
isDarkMode: globalThis.matchMedia('(prefers-color-scheme: dark)').matches,
|
|
41
|
+
/** Cleanup callback for the dark mode media query listener. */
|
|
42
|
+
darkModeCleanup: undefined,
|
|
37
43
|
};
|
|
38
44
|
},
|
|
39
45
|
events: {
|
|
@@ -58,12 +64,7 @@ export const ElementBookApp = defineElement()({
|
|
|
58
64
|
height: 100%;
|
|
59
65
|
width: 100%;
|
|
60
66
|
font-family: sans-serif;
|
|
61
|
-
|
|
62
|
-
color: ${colorThemeCssVars['element-book-page-foreground-color'].value};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.error {
|
|
66
|
-
color: red;
|
|
67
|
+
${colorCss(viraTheme.colors[themeDefaultKey])}
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
.root {
|
|
@@ -90,10 +91,14 @@ export const ElementBookApp = defineElement()({
|
|
|
90
91
|
cleanup({ state, updateState }) {
|
|
91
92
|
if (state.router) {
|
|
92
93
|
state.router.destroy();
|
|
93
|
-
updateState({
|
|
94
|
-
router: undefined,
|
|
95
|
-
});
|
|
96
94
|
}
|
|
95
|
+
if (state.darkModeCleanup) {
|
|
96
|
+
state.darkModeCleanup();
|
|
97
|
+
}
|
|
98
|
+
updateState({
|
|
99
|
+
router: undefined,
|
|
100
|
+
darkModeCleanup: undefined,
|
|
101
|
+
});
|
|
97
102
|
},
|
|
98
103
|
render: ({ state, inputs, host, updateState, dispatch, events, slotNames }) => {
|
|
99
104
|
if (inputs._debug) {
|
|
@@ -179,6 +184,23 @@ export const ElementBookApp = defineElement()({
|
|
|
179
184
|
});
|
|
180
185
|
setThemeCssVars(host, newTheme);
|
|
181
186
|
}
|
|
187
|
+
if (!state.darkModeCleanup) {
|
|
188
|
+
const query = globalThis.matchMedia('(prefers-color-scheme: dark)');
|
|
189
|
+
const listener = (event) => {
|
|
190
|
+
updateState({
|
|
191
|
+
isDarkMode: event.matches,
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
query.addEventListener('change', listener);
|
|
195
|
+
updateState({
|
|
196
|
+
isDarkMode: query.matches,
|
|
197
|
+
darkModeCleanup: () => {
|
|
198
|
+
query.removeEventListener('change', listener);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const isDarkMode = inputs.darkMode ?? state.isDarkMode;
|
|
203
|
+
applyCssVarsViaStyleElement(isDarkMode ? viraThemeDarkOverride.overrides : {}, 'element-book-dark-mode');
|
|
182
204
|
const debug = inputs._debug ?? false;
|
|
183
205
|
const originalTree = createBookTreeFromEntries({
|
|
184
206
|
entries: inputs.pages,
|
|
@@ -214,9 +236,7 @@ export const ElementBookApp = defineElement()({
|
|
|
214
236
|
const currentControls = state.treeBasedControls?.controls;
|
|
215
237
|
if (!currentControls) {
|
|
216
238
|
return html `
|
|
217
|
-
<${
|
|
218
|
-
message: 'Failed to generate page controls.',
|
|
219
|
-
})}></${BookError}>
|
|
239
|
+
<${ViraError}>Failed to generate page controls.</${ViraError}>
|
|
220
240
|
`;
|
|
221
241
|
}
|
|
222
242
|
if (inputs._debug) {
|
|
@@ -303,7 +323,7 @@ export const ElementBookApp = defineElement()({
|
|
|
303
323
|
catch (error) {
|
|
304
324
|
console.error(error);
|
|
305
325
|
return html `
|
|
306
|
-
|
|
326
|
+
<${ViraError}>${extractErrorMessage(error)}</${ViraError}>
|
|
307
327
|
`;
|
|
308
328
|
}
|
|
309
329
|
},
|
|
@@ -20,6 +20,8 @@ export type ElementBookConfig = {
|
|
|
20
20
|
export type OptionalConfig = {
|
|
21
21
|
/** The base theme color from which all other element-book colors will be generated from. */
|
|
22
22
|
themeColor: string;
|
|
23
|
+
/** Force dark mode on or off. When `undefined`, follows the system preference. */
|
|
24
|
+
darkMode: boolean;
|
|
23
25
|
_debug: boolean;
|
|
24
26
|
globalValues: GlobalValues;
|
|
25
27
|
preventWindowTitleChange: boolean;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { wait } from '@augment-vir/common';
|
|
2
2
|
import { css, html, listen, renderIf } from 'element-vir';
|
|
3
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
4
|
+
import { viraTheme } from 'vira';
|
|
3
5
|
import { BookMainRoute, defaultBookFullRoute, } from '../../../routing/book-routing.js';
|
|
4
|
-
import { colorThemeCssVars } from '../../color-theme/color-theme.js';
|
|
5
6
|
import { ChangeRouteEvent } from '../../events/change-route.event.js';
|
|
6
7
|
import { BookBreadcrumbs } from '../book-breadcrumbs.element.js';
|
|
7
8
|
import { defineBookElement } from '../define-book-element.js';
|
|
@@ -10,9 +11,9 @@ export const BookBreadcrumbsBar = defineBookElement()({
|
|
|
10
11
|
styles: css `
|
|
11
12
|
:host {
|
|
12
13
|
border-bottom: 1px solid
|
|
13
|
-
${
|
|
14
|
+
${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
14
15
|
padding: 4px 8px;
|
|
15
|
-
background-color: ${
|
|
16
|
+
background-color: ${viraTheme.colors[themeDefaultKey].background.value};
|
|
16
17
|
display: flex;
|
|
17
18
|
gap: 16px;
|
|
18
19
|
justify-content: space-between;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
-
import {
|
|
2
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
3
|
+
import { viraTheme } from 'vira';
|
|
3
4
|
import { defineBookElement } from '../define-book-element.js';
|
|
4
5
|
export const BookEntryDescription = defineBookElement()({
|
|
5
6
|
tagName: 'book-entry-description',
|
|
6
7
|
styles: css `
|
|
7
8
|
:host {
|
|
8
|
-
color: ${
|
|
9
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
9
10
|
display: inline-flex;
|
|
10
11
|
flex-direction: column;
|
|
11
12
|
gap: 8px;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
:host(:hover) {
|
|
15
|
-
color: ${
|
|
16
|
+
color: ${viraTheme.colors[themeDefaultKey].foreground.value};
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
p {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { VirColorPicker } from '@electrovir/color';
|
|
3
3
|
import { css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
4
|
-
import { Options24Icon, ViraCheckbox, ViraIcon, ViraInput, ViraSelect } from 'vira';
|
|
4
|
+
import { Options24Icon, ViraCheckbox, ViraError, ViraIcon, ViraInput, ViraSelect, viraTheme, } from 'vira';
|
|
5
5
|
import { BookPageControlType, isControlInitType, } from '../../../../data/book-entry/book-page/book-page-controls.js';
|
|
6
|
-
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
7
6
|
import { defineBookElement } from '../../define-book-element.js';
|
|
8
7
|
export const BookPageControls = defineBookElement()({
|
|
9
8
|
tagName: 'book-page-controls',
|
|
@@ -22,7 +21,7 @@ export const BookPageControls = defineBookElement()({
|
|
|
22
21
|
align-content: flex-start;
|
|
23
22
|
gap: 16px;
|
|
24
23
|
row-gap: 10px;
|
|
25
|
-
color: ${
|
|
24
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
${hostClasses['book-page-controls-has-controls'].selector} {
|
|
@@ -36,11 +35,6 @@ export const BookPageControls = defineBookElement()({
|
|
|
36
35
|
flex-direction: column;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
.error {
|
|
40
|
-
font-weight: bold;
|
|
41
|
-
color: red;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
38
|
${ViraInput}, ${ViraSelect} {
|
|
45
39
|
height: 24px;
|
|
46
40
|
max-width: 128px;
|
|
@@ -185,9 +179,9 @@ function createControlInput(value, controlInit, valueChange) {
|
|
|
185
179
|
}
|
|
186
180
|
else {
|
|
187
181
|
return html `
|
|
188
|
-
|
|
182
|
+
<${ViraError}>
|
|
189
183
|
${controlInit.controlType} controls are not implemented yet.
|
|
190
|
-
|
|
184
|
+
</${ViraError}>
|
|
191
185
|
`;
|
|
192
186
|
}
|
|
193
187
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { combineErrors } from '@augment-vir/common';
|
|
2
2
|
import { css, html } from 'element-vir';
|
|
3
|
+
import { ViraError } from 'vira';
|
|
3
4
|
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper.js';
|
|
4
5
|
import { BookMainRoute } from '../../../../routing/book-routing.js';
|
|
5
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
6
6
|
import { BookRouteLink } from '../../common/book-route-link.element.js';
|
|
7
7
|
import { defineBookElement } from '../../define-book-element.js';
|
|
8
8
|
import { BookEntryDescription } from '../book-entry-description.element.js';
|
|
@@ -72,9 +72,7 @@ export const BookPageWrapper = defineBookElement()({
|
|
|
72
72
|
${headerTemplate}
|
|
73
73
|
${error
|
|
74
74
|
? html `
|
|
75
|
-
<${
|
|
76
|
-
message: error.message,
|
|
77
|
-
})}></${BookError}>
|
|
75
|
+
<${ViraError}>${error.message}</${ViraError}>
|
|
78
76
|
`
|
|
79
77
|
: html `
|
|
80
78
|
<${BookEntryDescription.assign({
|
package/dist/ui/elements/entry-display/element-example/book-element-example-title.element.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { BookMainRoute } from '../../../../routing/book-routing.js';
|
|
3
|
-
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
4
4
|
import { BookRouteLink } from '../../common/book-route-link.element.js';
|
|
5
5
|
import { defineBookElement } from '../../define-book-element.js';
|
|
6
6
|
export const BookElementExampleTitle = defineBookElement()({
|
|
@@ -8,7 +8,7 @@ export const BookElementExampleTitle = defineBookElement()({
|
|
|
8
8
|
styles: css `
|
|
9
9
|
:host {
|
|
10
10
|
display: flex;
|
|
11
|
-
color: ${
|
|
11
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
12
12
|
border-bottom: 1px solid currentColor;
|
|
13
13
|
padding: 0 8px 4px;
|
|
14
14
|
}
|
package/dist/ui/elements/entry-display/element-example/book-element-example-viewer.element.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { combineErrors, extractErrorMessage } from '@augment-vir/common';
|
|
2
2
|
import { html, renderIf } from 'element-vir';
|
|
3
|
+
import { ViraError } from 'vira';
|
|
3
4
|
import { unsetInternalState } from '../../../../data/unset.js';
|
|
4
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
5
5
|
import { defineBookElement } from '../../define-book-element.js';
|
|
6
6
|
export const BookElementExampleViewer = defineBookElement()({
|
|
7
7
|
tagName: 'book-element-example-viewer',
|
|
@@ -15,7 +15,7 @@ export const BookElementExampleViewer = defineBookElement()({
|
|
|
15
15
|
if (inputs.elementExampleNode.entry.errors.length) {
|
|
16
16
|
throw combineErrors(inputs.elementExampleNode.entry.errors);
|
|
17
17
|
}
|
|
18
|
-
if (
|
|
18
|
+
else if (
|
|
19
19
|
/** This is a check to make sure the input entry _does_ match the expected type. */
|
|
20
20
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
21
21
|
!inputs.elementExampleNode.entry.render ||
|
|
@@ -49,9 +49,9 @@ export const BookElementExampleViewer = defineBookElement()({
|
|
|
49
49
|
console.error('ERROR HERE', extractErrorMessage(error));
|
|
50
50
|
console.error(error);
|
|
51
51
|
return html `
|
|
52
|
-
<${
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
<${ViraError}>
|
|
53
|
+
${inputs.elementExampleNode.entry.title} failed: ${extractErrorMessage(error)}
|
|
54
|
+
</${ViraError}>
|
|
55
55
|
`;
|
|
56
56
|
}
|
|
57
57
|
},
|
package/dist/ui/elements/entry-display/element-example/book-element-example-wrapper.element.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraTheme } from 'vira';
|
|
2
3
|
import { colorThemeCssVars } from '../../../color-theme/color-theme.js';
|
|
3
4
|
import { defineBookElement } from '../../define-book-element.js';
|
|
4
5
|
import { BookElementExampleTitle } from './book-element-example-title.element.js';
|
|
@@ -17,11 +18,6 @@ export const BookElementExampleWrapper = defineBookElement()({
|
|
|
17
18
|
flex-wrap: wrap;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
.error {
|
|
21
|
-
color: red;
|
|
22
|
-
font-weight: bold;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
21
|
.individual-example-wrapper {
|
|
26
22
|
display: flex;
|
|
27
23
|
flex-direction: column;
|
|
@@ -31,7 +27,7 @@ export const BookElementExampleWrapper = defineBookElement()({
|
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
${BookElementExampleTitle} {
|
|
34
|
-
color: ${
|
|
30
|
+
color: ${viraTheme.colors['vira-grey-foreground-placeholder'].foreground.value};
|
|
35
31
|
}
|
|
36
32
|
|
|
37
33
|
:host(:hover) ${BookElementExampleTitle} {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { colorCss } from '@electrovir/color';
|
|
1
2
|
import { css, defineElementEvent, html, onDomCreated, renderIf } from 'element-vir';
|
|
2
|
-
import {
|
|
3
|
+
import { themeDefaultKey } from 'theme-vir';
|
|
4
|
+
import { LoaderAnimated24Icon, ViraIcon, viraAnimationDurations, viraTheme } from 'vira';
|
|
3
5
|
import { extractSearchQuery } from '../../../../routing/book-routing.js';
|
|
4
6
|
import { defineBookElement } from '../../define-book-element.js';
|
|
5
7
|
import { BookBreadcrumbsBar } from '../book-breadcrumbs-bar.element.js';
|
|
@@ -19,6 +21,7 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
.all-book-entries-wrapper {
|
|
24
|
+
background-color: ${viraTheme.colors[themeDefaultKey].background.value};
|
|
22
25
|
flex-grow: 1;
|
|
23
26
|
padding: 32px;
|
|
24
27
|
}
|
|
@@ -53,7 +56,7 @@ export const BookEntryDisplay = defineBookElement()({
|
|
|
53
56
|
flex-grow: 1;
|
|
54
57
|
padding: 64px;
|
|
55
58
|
position: absolute;
|
|
56
|
-
|
|
59
|
+
${colorCss(viraTheme.colors[themeDefaultKey])}
|
|
57
60
|
animation: fade-in linear
|
|
58
61
|
${viraAnimationDurations['vira-interaction-animation-duration'].value} forwards;
|
|
59
62
|
z-index: 100;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { check } from '@augment-vir/assert';
|
|
2
2
|
import { mapObjectValues } from '@augment-vir/common';
|
|
3
3
|
import { classMap, html, nothing, repeat, } from 'element-vir';
|
|
4
|
+
import { ViraError } from 'vira';
|
|
4
5
|
import { BookEntryType } from '../../../../data/book-entry/book-entry-type.js';
|
|
5
6
|
import { traverseControls, } from '../../../../data/book-entry/book-page/controls-wrapper.js';
|
|
6
7
|
import { isBookTreeNode, traverseToImmediateParent } from '../../../../data/book-tree/book-tree.js';
|
|
7
|
-
import { BookError } from '../../common/book-error.element.js';
|
|
8
8
|
import { BookPageControls } from '../book-page/book-page-controls.element.js';
|
|
9
9
|
import { BookPageWrapper } from '../book-page/book-page-wrapper.element.js';
|
|
10
10
|
import { BookElementExampleWrapper } from '../element-example/book-element-example-wrapper.element.js';
|
|
@@ -110,9 +110,9 @@ export function createNodeTemplates({ blockNavigation, currentNodes, isTopLevel,
|
|
|
110
110
|
}
|
|
111
111
|
else {
|
|
112
112
|
const content = html `
|
|
113
|
-
<${
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
<${ViraError}>
|
|
114
|
+
Unknown entry type for rendering: '${currentNode.entry.entryType}'
|
|
115
|
+
</${ViraError}>
|
|
116
116
|
`;
|
|
117
117
|
return html `
|
|
118
118
|
<${BookLazyEntry.assign({
|
|
@@ -36,12 +36,11 @@ searchIn, }) {
|
|
|
36
36
|
if (searchQueryLength > searchInLength) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
if (searchQueryLength === searchInLength) {
|
|
39
|
+
else if (searchQueryLength === searchInLength) {
|
|
40
40
|
return searchQuery === searchIn;
|
|
41
41
|
}
|
|
42
42
|
const lowercaseSearchIn = searchIn.toLowerCase();
|
|
43
43
|
const lowercaseSearchQuery = searchQuery.toLowerCase();
|
|
44
|
-
// eslint-disable-next-line sonarjs/no-labels
|
|
45
44
|
outer: for (let i = 0, j = 0; i < searchQueryLength; i++) {
|
|
46
45
|
const charCode = lowercaseSearchQuery.codePointAt(i);
|
|
47
46
|
while (j < searchInLength) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-book",
|
|
3
|
-
"version": "26.17.
|
|
3
|
+
"version": "26.17.2",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"book",
|
|
6
6
|
"design system",
|
|
@@ -41,33 +41,35 @@
|
|
|
41
41
|
"test:docs": "virmator docs check"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@augment-vir/assert": "^31.
|
|
45
|
-
"@augment-vir/common": "^31.
|
|
46
|
-
"@augment-vir/web": "^31.
|
|
47
|
-
"@electrovir/color": "^1.7.
|
|
44
|
+
"@augment-vir/assert": "^31.68.4",
|
|
45
|
+
"@augment-vir/common": "^31.68.4",
|
|
46
|
+
"@augment-vir/web": "^31.68.4",
|
|
47
|
+
"@electrovir/color": "^1.7.9",
|
|
48
48
|
"colorjs.io": "^0.6.1",
|
|
49
|
-
"date-vir": "^8.2.
|
|
50
|
-
"lit-css-vars": "^3.
|
|
49
|
+
"date-vir": "^8.2.1",
|
|
50
|
+
"lit-css-vars": "^3.6.2",
|
|
51
51
|
"spa-router-vir": "^6.4.1",
|
|
52
|
-
"typed-event-target": "^4.
|
|
52
|
+
"typed-event-target": "^4.3.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@augment-vir/test": "^31.
|
|
55
|
+
"@augment-vir/test": "^31.68.4",
|
|
56
56
|
"@web/dev-server-esbuild": "^1.0.5",
|
|
57
57
|
"@web/test-runner": "^0.20.2",
|
|
58
58
|
"@web/test-runner-commands": "^0.9.0",
|
|
59
59
|
"@web/test-runner-playwright": "^0.11.1",
|
|
60
60
|
"@web/test-runner-visual-regression": "^0.10.0",
|
|
61
|
-
"element-vir": "^26.
|
|
61
|
+
"element-vir": "^26.15.1",
|
|
62
62
|
"istanbul-smart-text-reporter": "^1.1.5",
|
|
63
63
|
"markdown-code-example-inserter": "^3.0.3",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"theme-vir": "^28.25.0",
|
|
65
|
+
"type-fest": "^5.5.0",
|
|
66
|
+
"typedoc": "^0.28.18",
|
|
66
67
|
"typescript": "5.9.3",
|
|
67
|
-
"vira": "^
|
|
68
|
+
"vira": "^31.14.1"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"element-vir": ">=17",
|
|
72
|
+
"theme-vir": ">=28.0.0",
|
|
71
73
|
"vira": ">=28.0.0"
|
|
72
74
|
},
|
|
73
75
|
"engines": {
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { check } from '@augment-vir/assert';
|
|
2
|
-
import { css, html } from 'element-vir';
|
|
3
|
-
import { defineBookElement } from '../define-book-element.js';
|
|
4
|
-
export const BookError = defineBookElement()({
|
|
5
|
-
tagName: 'book-error',
|
|
6
|
-
styles: css `
|
|
7
|
-
:host {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
color: red;
|
|
11
|
-
font-weight: bold;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
p {
|
|
15
|
-
margin: 0;
|
|
16
|
-
padding: 0;
|
|
17
|
-
}
|
|
18
|
-
`,
|
|
19
|
-
render({ inputs }) {
|
|
20
|
-
const paragraphs = check.isArray(inputs.message) ? inputs.message : [inputs.message];
|
|
21
|
-
return paragraphs.map((paragraph) => html `
|
|
22
|
-
<p>${paragraph}</p>
|
|
23
|
-
`);
|
|
24
|
-
},
|
|
25
|
-
});
|