@jbrowse/embedded-core 5.0.0-beta.1 → 5.0.0-beta.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/esm/EmbeddedSessionMixin.d.ts +250 -759
- package/esm/EmbeddedSessionMixin.js +19 -12
- package/esm/EmbeddedSessionThemeMixin.d.ts +70 -345
- package/esm/EmbeddedSessionThemeMixin.js +31 -22
- package/esm/createEmbeddedRootModel.d.ts +192 -454
- package/esm/createEmbeddedRootModel.js +29 -16
- package/esm/ui/EmbeddedViewContainer.js +8 -8
- package/package.json +7 -7
- package/esm/ui/VersionAboutDialog.d.ts +0 -5
- package/esm/ui/VersionAboutDialog.js +0 -13
- package/esm/ui/ViewTitle.d.ts +0 -5
- package/esm/ui/ViewTitle.js +0 -65
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConf
|
|
1
|
+
import { getConf } from '@jbrowse/core/configuration';
|
|
2
2
|
import { createJBrowseThemeFromArgs } from '@jbrowse/core/ui';
|
|
3
3
|
import { resolvePalette } from '@jbrowse/core/ui/palette';
|
|
4
4
|
import { resolveStyleTheme } from '@jbrowse/core/ui/styleTheme';
|
|
@@ -7,11 +7,15 @@ import { BaseSessionModel } from '@jbrowse/product-core';
|
|
|
7
7
|
* #stateModel EmbeddedSessionThemeMixin
|
|
8
8
|
* Theme getters shared by the single-view embedded sessions
|
|
9
9
|
* (react-linear-genome-view, react-circular-genome-view). Embedded products
|
|
10
|
-
* have no theme
|
|
11
|
-
* `theme` slot
|
|
10
|
+
* have no theme picker, so the palette is always `default` and the config
|
|
11
|
+
* `theme` slot supplies it; light or dark is the host's to drive, through
|
|
12
|
+
* `setThemeMode`.
|
|
12
13
|
*/
|
|
13
14
|
export function EmbeddedSessionThemeMixin(pluginManager) {
|
|
14
15
|
return BaseSessionModel(pluginManager)
|
|
16
|
+
.volatile(() => ({
|
|
17
|
+
sessionThemeMode: undefined,
|
|
18
|
+
}))
|
|
15
19
|
.views(self => ({
|
|
16
20
|
/**
|
|
17
21
|
* #getter
|
|
@@ -25,6 +29,7 @@ export function EmbeddedSessionThemeMixin(pluginManager) {
|
|
|
25
29
|
return {
|
|
26
30
|
configTheme: getConf(self, 'theme'),
|
|
27
31
|
themeName: 'default',
|
|
32
|
+
mode: self.sessionThemeMode,
|
|
28
33
|
};
|
|
29
34
|
},
|
|
30
35
|
/**
|
|
@@ -64,6 +69,8 @@ export function EmbeddedSessionThemeMixin(pluginManager) {
|
|
|
64
69
|
* preset up in `allThemes()`.
|
|
65
70
|
*/
|
|
66
71
|
getActiveThemeOptions(_name) {
|
|
72
|
+
// the mode rides along, for the reason the comment below gives: these
|
|
73
|
+
// options are the whole of what the export path is handed
|
|
67
74
|
// Its absence did not read as an unthemed export, it read as a *light*
|
|
68
75
|
// one. Every view's export calls this optionally
|
|
69
76
|
// (`session.getActiveThemeOptions?.(themeName)`), so a session without
|
|
@@ -72,33 +79,35 @@ export function EmbeddedSessionThemeMixin(pluginManager) {
|
|
|
72
79
|
// colors each display bakes into its own bodies, the background rect. A
|
|
73
80
|
// host following its own dark mode got a light figure out of
|
|
74
81
|
// `view.exportSvg()` with nothing anywhere saying why.
|
|
75
|
-
|
|
82
|
+
const configTheme = this.themeOptions.configTheme;
|
|
83
|
+
return self.sessionThemeMode
|
|
84
|
+
? {
|
|
85
|
+
...configTheme,
|
|
86
|
+
palette: {
|
|
87
|
+
...configTheme?.palette,
|
|
88
|
+
mode: self.sessionThemeMode,
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
: configTheme;
|
|
76
92
|
},
|
|
77
93
|
}))
|
|
78
94
|
.actions(self => ({
|
|
79
95
|
/**
|
|
80
96
|
* #action
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* in the worker follow it, and `palette` is derived from
|
|
84
|
-
* so
|
|
85
|
-
* React-side palette leaves the
|
|
97
|
+
* Switch the session to light or dark, leaving the host's configured
|
|
98
|
+
* colours alone. `themeOptions` carries the mode to the renderer, so
|
|
99
|
+
* labels drawn in the worker follow it, and `palette` is derived from
|
|
100
|
+
* the same args, so React-drawn elements follow it too. An embedder who
|
|
101
|
+
* sets only a React-side palette leaves the worker-drawn labels in the
|
|
102
|
+
* old mode.
|
|
86
103
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* as `createViewState`'s `configuration.theme` (a brand `primary`, say)
|
|
92
|
-
* the first time their dark-mode toggle fires. `resolvePalette` spreads
|
|
93
|
-
* `configTheme.palette` over the preset shallowly, so `mode` and
|
|
94
|
-
* `primary` are siblings and both levels have to survive.
|
|
104
|
+
* This used to write `palette.mode` into the config `theme` slot, which
|
|
105
|
+
* meant merging at two levels to avoid discarding the brand the host had
|
|
106
|
+
* passed to `createViewState`. Mode is its own axis now, so there is
|
|
107
|
+
* nothing to merge and nothing to discard.
|
|
95
108
|
*/
|
|
96
109
|
setThemeMode(mode) {
|
|
97
|
-
|
|
98
|
-
setConf(self, 'theme', {
|
|
99
|
-
...theme,
|
|
100
|
-
palette: { ...theme.palette, mode },
|
|
101
|
-
});
|
|
110
|
+
self.sessionThemeMode = mode;
|
|
102
111
|
},
|
|
103
112
|
}));
|
|
104
113
|
}
|