cronwatch 0.11.0 → 0.11.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f5d4d303ae53fd20968b2f416e805a3f840b07b152004878147c3d3c3e4e899
4
- data.tar.gz: 184ac01a139983fdabc2344586a4bc6c6669b987864a8c84d7f7b8f8bd90909d
3
+ metadata.gz: 4a31800c33f9abb5092e104cc1572940190883006bab28dfc5c389d01ab3d5c8
4
+ data.tar.gz: 2e85fbf87e5c1929124d105f54791eb36726f69eae05db77ff22b6b665672471
5
5
  SHA512:
6
- metadata.gz: 333767b7bcffda2b75c1349644c7fa870c371c9a5c1ee0491083effcdbb1030c54dfc561a36a883b8588411caa59b19ca4c36c06638c61c5652917c29f1252fa
7
- data.tar.gz: 0ecbafab015195219f3dfb53e03dd202766342fc11195b7d97cdac4610821940a2e8d777898834aa8b015236b5b5a1a11eb0f1ecd424c42f52a4b84eddfb14b1
6
+ metadata.gz: dd728e8770453f91445d006f0ce7f15d709c04e4c130366a5adfb99f104570fca428e6363c91b69a55c0b58a6e4b90472ec13fd3588b85548b195161a4a2c0f8
7
+ data.tar.gz: 951158243f2598f6d75fe9cb4095138a4480af3f1d9dc9de1d9f24af011d63ad4df5001bbc6e3227c70f9cdb3c1b3e031e4a4b175b570a12ab04786946484ad8
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Cronwatch
4
4
  # Kept in step with @cronwatch/sdk.
5
- VERSION = "0.11.0"
5
+ VERSION = "0.11.1"
6
6
  end
@@ -3,7 +3,7 @@
3
3
  module Cronwatch
4
4
  class Web
5
5
  # The dashboard's pages, markup for markup the SDK's routes/html.ts. The
6
- # one script, app.js, only registers the service worker: the pages refresh
6
+ # one script, app.js, registers the service worker and toggles the theme: the pages refresh
7
7
  # themselves and the forget button confirms with a <details>.
8
8
  #
9
9
  # Set like cronwatch.dev: a printed sheet on grey paper, a serif for what a
@@ -26,7 +26,8 @@ module Cronwatch
26
26
  module HTML
27
27
  CSS = "\n" + <<~'CSS'
28
28
  :root{color-scheme:light dark;--paper:#f4f4f5;--sheet:#fff;--sunk:#fafafa;--rule:#e4e4e7;--rule-2:#d4d4d8;--tick:#909098;--ink:#000;--body:#18181b;--muted:#71717a;--ok:#15803d;--warn:#a16207;--bad:#b91c1c;--serif:"Newsreader",ui-serif,Georgia,Cambria,"Times New Roman",serif;--mono:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--who:200px}
29
- @media(prefers-color-scheme:dark){:root{--paper:#09090b;--sheet:#111113;--sunk:#18181b;--rule:#27272a;--rule-2:#3f3f46;--tick:#66666f;--ink:#fff;--body:#e4e4e7;--muted:#a1a1aa;--ok:#4ade80;--warn:#fbbf24;--bad:#f87171}}
29
+ @media(prefers-color-scheme:dark){:root:not([data-theme=light]){--paper:#09090b;--sheet:#111113;--sunk:#18181b;--rule:#27272a;--rule-2:#3f3f46;--tick:#66666f;--ink:#fff;--body:#e4e4e7;--muted:#a1a1aa;--ok:#4ade80;--warn:#fbbf24;--bad:#f87171}}
30
+ :root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark;--paper:#09090b;--sheet:#111113;--sunk:#18181b;--rule:#27272a;--rule-2:#3f3f46;--tick:#66666f;--ink:#fff;--body:#e4e4e7;--muted:#a1a1aa;--ok:#4ade80;--warn:#fbbf24;--bad:#f87171}
30
31
  *{box-sizing:border-box}html{-webkit-text-size-adjust:100%}
31
32
  body{margin:0;background:var(--paper);color:var(--ink);font:400 16px/1.55 var(--serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
32
33
  a{color:inherit;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:.16em;text-decoration-color:var(--rule-2)}a:hover{text-decoration-color:currentColor}
@@ -251,7 +252,7 @@ module Cronwatch
251
252
 
252
253
  # A page. `base` is where the dashboard is mounted ("" at the root): the
253
254
  # head links the web app manifest, the icons and app.js, the one script,
254
- # which only registers the service worker (Web::PWA). Everything works
255
+ # which registers the service worker and toggles the theme (Web::PWA). Everything works
255
256
  # without it.
256
257
  def layout(title, body, base, refresh: nil)
257
258
  b = h(base)
@@ -16,11 +16,27 @@ module Cronwatch
16
16
  THEME_COLOR = "#ffffff"
17
17
  THEME_COLOR_DARK = "#111113"
18
18
 
19
- # Registers the service worker, and does nothing else. The page works
20
- # the same without it. Its own URL gives the base, so it is the same
19
+ # Registers the service worker, and switches between light and dark on
20
+ # Cmd+Shift+D (Ctrl+Shift+D elsewhere), keeping the choice in
21
+ # localStorage. The page works the same without it. Its own URL gives the base, so it is the same
21
22
  # text wherever the dashboard is mounted.
22
23
  APP_JS = <<~'JS'
23
24
  "use strict";
25
+ (function () {
26
+ var root = document.documentElement;
27
+ try {
28
+ var stored = localStorage.getItem("cronwatch-theme");
29
+ if (stored === "light" || stored === "dark") root.setAttribute("data-theme", stored);
30
+ } catch (e) {}
31
+ document.addEventListener("keydown", function (event) {
32
+ if (!(event.metaKey || event.ctrlKey) || !event.shiftKey || event.altKey || event.code !== "KeyD") return;
33
+ event.preventDefault();
34
+ var shown = root.getAttribute("data-theme") || (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
35
+ var next = shown === "dark" ? "light" : "dark";
36
+ root.setAttribute("data-theme", next);
37
+ try { localStorage.setItem("cronwatch-theme", next); } catch (e) {}
38
+ });
39
+ })();
24
40
  (function () {
25
41
  var script = document.currentScript;
26
42
  if (!script || !("serviceWorker" in navigator)) return;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon C. Phillips