@jsenv/plugin-toolbar 1.0.1 → 1.0.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.
@@ -235,6 +235,25 @@
235
235
  Toggle light/dark mode on jsenv toolbar.
236
236
  </div>
237
237
  </div>
238
+
239
+ <div class="settings_box_item" id="ribbon_box" style="display: none">
240
+ <div class="category_title">
241
+ <svg width="20px" height="20px" viewBox="0 0 448 512">
242
+ <path d="M120.12 208.29c-3.88-2.9-7.77-4.35-11.65-4.35H91.03v104.47h17.45c3.88 0 7.77-1.45 11.65-4.35 3.88-2.9 5.82-7.25 5.82-13.06v-69.65c-.01-5.8-1.96-10.16-5.83-13.06zM404.1 32H43.9C19.7 32 .06 51.59 0 75.8v360.4C.06 460.41 19.7 480 43.9 480h360.2c24.21 0 43.84-19.59 43.9-43.8V75.8c-.06-24.21-19.7-43.8-43.9-43.8zM154.2 291.19c0 18.81-11.61 47.31-48.36 47.25h-46.4V172.98h47.38c35.44 0 47.36 28.46 47.37 47.28l.01 70.93zm100.68-88.66H201.6v38.42h32.57v29.57H201.6v38.41h53.29v29.57h-62.18c-11.16.29-20.44-8.53-20.72-19.69V193.7c-.27-11.15 8.56-20.41 19.71-20.69h63.19l-.01 29.52zm103.64 115.29c-13.2 30.75-36.85 24.63-47.44 0l-38.53-144.8h32.57l29.71 113.72 29.57-113.72h32.58l-38.46 144.8z"></path>
243
+ </svg>
244
+ Ribbon
245
+ </div>
246
+ <label class="switch" data-contains-hidden-input="">
247
+ <input id="checkbox_dark_theme" type="checkbox">
248
+ <div>
249
+ <div class="slider"></div>
250
+ <div class="square"></div>
251
+ </div>
252
+ </label>
253
+ <div class="category_subtitle">
254
+ Toggle dev ribbon visibility
255
+ </div>
256
+ </div>
238
257
  </div>
239
258
  </div>
240
259
  </div>
@@ -50,7 +50,7 @@ l$2.__b = function (n) {
50
50
  var i = (r$1 = n.__c).__H;
51
51
  i && (u$1 === r$1 ? (i.__h = [], r$1.__h = [], i.__.forEach(function (n) {
52
52
  n.__N && (n.__ = n.__N), n.__V = c$2, n.__N = n.i = void 0;
53
- })) : (i.__h.forEach(k), i.__h.forEach(w$1), i.__h = [])), u$1 = r$1;
53
+ })) : (i.__h.forEach(k), i.__h.forEach(w$1), i.__h = [], t$1 = 0)), u$1 = r$1;
54
54
  }, l$2.diffed = function (t) {
55
55
  v$1 && v$1(t);
56
56
  var o = t.__c;
@@ -1701,6 +1701,33 @@ const renderToolbarThemeSetting = () => {
1701
1701
  };
1702
1702
  };
1703
1703
 
1704
+ const ribbonDisplayedSignal = u(typeof stateFromLocalStorage.ribbonDisplayed === "boolean" ? stateFromLocalStorage.ribbonDisplayed : true);
1705
+
1706
+ const ribbonBox = document.querySelector("#ribbon_box");
1707
+ const ribbonCheckbox = ribbonBox.querySelector("input");
1708
+ const renderToolbarRibbonSetting = () => {
1709
+ const ribbonContainer = window.parent.document.querySelector("#jsenv_ribbon_container");
1710
+ if (ribbonContainer) {
1711
+ ribbonBox.style.display = "block";
1712
+ b(() => {
1713
+ const ribbonDisplayed = ribbonDisplayedSignal.value;
1714
+ ribbonCheckbox.checked = ribbonDisplayed;
1715
+ if (ribbonDisplayed) {
1716
+ ribbonContainer.style.display = "block";
1717
+ } else {
1718
+ ribbonContainer.style.display = "none";
1719
+ }
1720
+ });
1721
+ ribbonCheckbox.onchange = () => {
1722
+ if (ribbonCheckbox.checked) {
1723
+ ribbonDisplayedSignal.value = true;
1724
+ } else {
1725
+ ribbonDisplayedSignal.value = false;
1726
+ }
1727
+ };
1728
+ }
1729
+ };
1730
+
1704
1731
  const renderToolbarSettings = () => {
1705
1732
  document.querySelector("#settings_open_button").onclick = toggleSettings;
1706
1733
  document.querySelector("#settings_close_button").onclick = toggleSettings;
@@ -1709,6 +1736,7 @@ const renderToolbarSettings = () => {
1709
1736
  renderToolbarAnimationSetting();
1710
1737
  renderToolbarNotificationSetting();
1711
1738
  renderToolbarThemeSetting();
1739
+ renderToolbarRibbonSetting();
1712
1740
  b(() => {
1713
1741
  const settingsOpened = settingsOpenedSignal.value;
1714
1742
  if (settingsOpened) {
@@ -1797,11 +1825,13 @@ const toolbarStateSignal = w(() => {
1797
1825
  const theme = themeSignal.value;
1798
1826
  const animationsEnabled = animationsEnabledSignal.value;
1799
1827
  const notificationsEnabled = notificationsEnabledSignal.value;
1828
+ const ribbonDisplayed = ribbonDisplayedSignal.value;
1800
1829
  return {
1801
1830
  opened,
1802
1831
  theme,
1803
1832
  animationsEnabled,
1804
- notificationsEnabled
1833
+ notificationsEnabled,
1834
+ ribbonDisplayed
1805
1835
  };
1806
1836
  });
1807
1837
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-toolbar",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/jsenv/core",
8
- "directory": "packages/jsenv-plugin-toolbar"
8
+ "directory": "packages/plugins/jsenv-plugin-toolbar"
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public"
@@ -26,7 +26,7 @@
26
26
  "/src/"
27
27
  ],
28
28
  "dependencies": {
29
- "@jsenv/ast": "4.0.0",
29
+ "@jsenv/ast": "4.0.2",
30
30
  "@preact/signals": "1.1.3"
31
31
  },
32
32
  "scripts": {
@@ -0,0 +1,9 @@
1
+ import { signal } from "@preact/signals";
2
+
3
+ import { stateFromLocalStorage } from "./toolbar_state_context.js";
4
+
5
+ export const ribbonDisplayedSignal = signal(
6
+ typeof stateFromLocalStorage.ribbonDisplayed === "boolean"
7
+ ? stateFromLocalStorage.ribbonDisplayed
8
+ : true,
9
+ );
@@ -4,17 +4,20 @@ import { openedSignal } from "./toolbar_open_signals.js";
4
4
  import { themeSignal } from "./theme_signals.js";
5
5
  import { animationsEnabledSignal } from "./animation_signals.js";
6
6
  import { notificationsEnabledSignal } from "./notification_signals.js";
7
+ import { ribbonDisplayedSignal } from "./ribbon_signals.js";
7
8
 
8
9
  export const toolbarStateSignal = computed(() => {
9
10
  const opened = openedSignal.value;
10
11
  const theme = themeSignal.value;
11
12
  const animationsEnabled = animationsEnabledSignal.value;
12
13
  const notificationsEnabled = notificationsEnabledSignal.value;
14
+ const ribbonDisplayed = ribbonDisplayedSignal.value;
13
15
 
14
16
  return {
15
17
  opened,
16
18
  theme,
17
19
  animationsEnabled,
18
20
  notificationsEnabled,
21
+ ribbonDisplayed,
19
22
  };
20
23
  });
@@ -347,6 +347,31 @@
347
347
  Toggle light/dark mode on jsenv toolbar.
348
348
  </div>
349
349
  </div>
350
+
351
+ <div
352
+ class="settings_box_item"
353
+ id="ribbon_box"
354
+ style="display: none"
355
+ >
356
+ <div class="category_title">
357
+ <svg width="20px" height="20px" viewBox="0 0 448 512">
358
+ <path
359
+ d="M120.12 208.29c-3.88-2.9-7.77-4.35-11.65-4.35H91.03v104.47h17.45c3.88 0 7.77-1.45 11.65-4.35 3.88-2.9 5.82-7.25 5.82-13.06v-69.65c-.01-5.8-1.96-10.16-5.83-13.06zM404.1 32H43.9C19.7 32 .06 51.59 0 75.8v360.4C.06 460.41 19.7 480 43.9 480h360.2c24.21 0 43.84-19.59 43.9-43.8V75.8c-.06-24.21-19.7-43.8-43.9-43.8zM154.2 291.19c0 18.81-11.61 47.31-48.36 47.25h-46.4V172.98h47.38c35.44 0 47.36 28.46 47.37 47.28l.01 70.93zm100.68-88.66H201.6v38.42h32.57v29.57H201.6v38.41h53.29v29.57h-62.18c-11.16.29-20.44-8.53-20.72-19.69V193.7c-.27-11.15 8.56-20.41 19.71-20.69h63.19l-.01 29.52zm103.64 115.29c-13.2 30.75-36.85 24.63-47.44 0l-38.53-144.8h32.57l29.71 113.72 29.57-113.72h32.58l-38.46 144.8z"
360
+ ></path>
361
+ </svg>
362
+ Ribbon
363
+ </div>
364
+ <label class="switch" data-contains-hidden-input>
365
+ <input id="checkbox_dark_theme" type="checkbox" />
366
+ <div>
367
+ <div class="slider"></div>
368
+ <div class="square"></div>
369
+ </div>
370
+ </label>
371
+ <div class="category_subtitle">
372
+ Toggle dev ribbon visibility
373
+ </div>
374
+ </div>
350
375
  </div>
351
376
  </div>
352
377
  </div>
@@ -0,0 +1,33 @@
1
+ import { effect } from "@preact/signals";
2
+
3
+ import { ribbonDisplayedSignal } from "../../core/ribbon_signals.js";
4
+
5
+ const ribbonBox = document.querySelector("#ribbon_box");
6
+ const ribbonCheckbox = ribbonBox.querySelector("input");
7
+
8
+ export const renderToolbarRibbonSetting = () => {
9
+ const ribbonContainer = window.parent.document.querySelector(
10
+ "#jsenv_ribbon_container",
11
+ );
12
+ if (ribbonContainer) {
13
+ ribbonBox.style.display = "block";
14
+ effect(() => {
15
+ const ribbonDisplayed = ribbonDisplayedSignal.value;
16
+ ribbonCheckbox.checked = ribbonDisplayed;
17
+
18
+ if (ribbonDisplayed) {
19
+ ribbonContainer.style.display = "block";
20
+ } else {
21
+ ribbonContainer.style.display = "none";
22
+ }
23
+ });
24
+
25
+ ribbonCheckbox.onchange = () => {
26
+ if (ribbonCheckbox.checked) {
27
+ ribbonDisplayedSignal.value = true;
28
+ } else {
29
+ ribbonDisplayedSignal.value = false;
30
+ }
31
+ };
32
+ }
33
+ };
@@ -11,6 +11,7 @@ import { renderToolbarAutoreloadSetting } from "./toolbar_autoreload_setting.js"
11
11
  import { renderToolbarAnimationSetting } from "./toolbar_animation_setting.js";
12
12
  import { renderToolbarNotificationSetting } from "./toolbar_notification_setting.js";
13
13
  import { renderToolbarThemeSetting } from "./toolbar_theme_setting.js";
14
+ import { renderToolbarRibbonSetting } from "./toolbar_ribbon_setting.js";
14
15
 
15
16
  export const renderToolbarSettings = () => {
16
17
  document.querySelector("#settings_open_button").onclick = toggleSettings;
@@ -21,6 +22,7 @@ export const renderToolbarSettings = () => {
21
22
  renderToolbarAnimationSetting();
22
23
  renderToolbarNotificationSetting();
23
24
  renderToolbarThemeSetting();
25
+ renderToolbarRibbonSetting();
24
26
 
25
27
  effect(() => {
26
28
  const settingsOpened = settingsOpenedSignal.value;