Skip to content

Commit 8c96477

Browse files
committed
Add a param for #theme
This allows embedders to control the theme. The hash param theme overrides the user setting, but does not change the stored user setting. The related change in CPO controls this – instead of eagerly changing the user setting to the set param value, instead let them differ until the user explicitly changes it with a UI action.
1 parent 673616b commit 8c96477

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/web/editor.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
</head>
3030
<body class="default">
3131
<script>
32-
var themeOnLoad = localSettings.getItem('theme') || 'default';
33-
document.body.classList.remove("default");
34-
document.body.classList.add(themeOnLoad);
3532
var optionalTemplatedHash = "{{ &HASH_OPTIONS }}";
3633
var params = {};
3734
let hash;
@@ -70,6 +67,13 @@
7067
default:
7168
// nothing to do
7269
}
70+
71+
var themeOnLoad = params['theme'] || localSettings.getItem('theme') || 'default';
72+
document.body.classList.remove("default");
73+
document.body.classList.add(themeOnLoad);
74+
75+
console.log("Theme info", String(document.body.classList), themeOnLoad, params, localSettings.getItem('theme'));
76+
7377
window.addEventListener('load', function() {
7478
document.getElementById('theme-select').value = themeOnLoad;
7579
}, { once: true });

src/web/js/cpo-main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -593,11 +593,7 @@
593593
curTheme = theme;
594594
}
595595

596-
if (localSettings.getItem('theme') !== null) {
597-
applyTheme(localSettings.getItem('theme'));
598-
} else {
599-
localSettings.setItem('theme', curTheme);
600-
}
596+
applyTheme(curTheme);
601597

602598
$("#theme").change(function(e) {
603599
var value = e.target.value;

src/web/js/trove/chart-lib.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
({
2+
23
requires: [
34
{ 'import-type': 'builtin', 'name': 'image-lib' },
45
],

0 commit comments

Comments
 (0)