paper_view 0.2.1 → 0.2.3

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: e74561ab048bdc7e58f0b46e1771ed22dc0639248fabd4f73cc4d57255b03351
4
- data.tar.gz: eb30982ddad7c762f35f63bd1e2e9fde35a47616584fe0dbc446fde562f2836b
3
+ metadata.gz: b5987bab41c6b08b669d05da7cb0331e056f1d05dfa1d9bceae4e1555615a020
4
+ data.tar.gz: c37ad5a8c3499c47b191fc12219a1cf3cb515193b0c5ca44e4e28153a6916fa5
5
5
  SHA512:
6
- metadata.gz: e8bd5fa49f64607df5b87c31747759a8f5b0a46a90b490f42504b74733cadaebbd86d9c342bdf4ee9a89012c260522abd3c91062ff5a6b795b2517ac4015e5c2
7
- data.tar.gz: be954c77e76e95a4ad341bb41c97e3499ca69c661eaae800ddd8aa13fbf8c4fd8d5142c2876376f789872af4a1134ac11c8fa059bdfc56e97a2fcf949f3ded64
6
+ metadata.gz: 3b00f0527ce236c1b3184a6004ea6811a40e8abc64dbcfe266554ec9c8a8c52ec0afc6ad55aa5217bcdf2b5874946d4be19ea060a863e41ea7ee869e66ec7d5b
7
+ data.tar.gz: 72bbab79a05fc2e021f90c7b7baa65e1ca0cba077d0cf5dc009589f0c1cd1c5895b68e52922ef550211a63cec792158a08852853939043979b8f2dbc7ff09032
@@ -19,6 +19,8 @@
19
19
  </head>
20
20
 
21
21
  <body>
22
+ <%= render "paper_view/shared/theme" %>
23
+
22
24
  <header class="pv-header">
23
25
  <%= link_to root_path, class: "pv-header__brand" do %>
24
26
  PaperView
@@ -29,9 +31,16 @@
29
31
  <%= link_to "Stats", stats_path, class: paper_view_nav_class(controller_name == "stats") %>
30
32
  </nav>
31
33
 
32
- <% if main_app.respond_to?(:root_path) %>
33
- <span class="pv-header__meta"><%= link_to "← Back to app", main_app.root_path, data: {turbo: false} %></span>
34
- <% end %>
34
+ <div class="pv-header__right">
35
+ <% if main_app.respond_to?(:root_path) %>
36
+ <span class="pv-header__meta"><%= link_to "← Back to app", main_app.root_path, data: {turbo: false} %></span>
37
+ <% end %>
38
+
39
+ <button type="button" class="pv-header__theme" data-pv-theme-toggle title="Switch between light and dark">
40
+ <span class="pv-theme__to-dark">☾ Dark</span>
41
+ <span class="pv-theme__to-light">☀ Light</span>
42
+ </button>
43
+ </div>
35
44
  </header>
36
45
 
37
46
  <main class="pv-main pv-stack">
@@ -176,6 +176,18 @@
176
176
  }
177
177
  });
178
178
 
179
+ document.addEventListener("click", function (event) {
180
+ if (!event.target.closest("[data-pv-theme-toggle]")) return;
181
+
182
+ var root = document.documentElement;
183
+ var stored = root.getAttribute("data-pv-theme");
184
+ var dark = stored ? stored === "dark" : window.matchMedia("(prefers-color-scheme: dark)").matches;
185
+ var next = dark ? "light" : "dark";
186
+
187
+ root.setAttribute("data-pv-theme", next);
188
+ try { localStorage.setItem("pv-theme", next); } catch (error) {}
189
+ });
190
+
179
191
  document.addEventListener("change", function (event) {
180
192
  var select = event.target.closest("select[data-pv-autosubmit]");
181
193
  if (!select || !select.form) return;
@@ -38,8 +38,13 @@
38
38
  --pv-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
39
39
  }
40
40
 
41
+ :root[data-pv-theme="light"] { color-scheme: light; }
42
+ :root[data-pv-theme="dark"] { color-scheme: dark; }
43
+ .pv-theme__to-light { display: none; }
44
+
45
+ /* The dark palette is spelled out twice because a media query and the attribute override cannot share a selector. */
41
46
  @media (prefers-color-scheme: dark) {
42
- :root {
47
+ :root:not([data-pv-theme="light"]) {
43
48
  --pv-bg: #0d1117;
44
49
  --pv-surface: #161b22;
45
50
  --pv-surface-muted: #1b212a;
@@ -68,7 +73,41 @@
68
73
  --pv-warn: #e3b341;
69
74
  --pv-warn-bg: #2b2209;
70
75
  }
76
+ :root:not([data-pv-theme="light"]) .pv-theme__to-dark { display: none; }
77
+ :root:not([data-pv-theme="light"]) .pv-theme__to-light { display: inline; }
78
+ }
79
+
80
+ :root[data-pv-theme="dark"] {
81
+ --pv-bg: #0d1117;
82
+ --pv-surface: #161b22;
83
+ --pv-surface-muted: #1b212a;
84
+ --pv-row-hover: #1b212a;
85
+ --pv-row-selected: #16233b;
86
+ --pv-border: #272e38;
87
+ --pv-border-subtle: #21262d;
88
+ --pv-border-input: #39414d;
89
+ --pv-pill-bg: #21262d;
90
+ --pv-ink: #e6edf3;
91
+ --pv-ink-secondary: #c9d1d9;
92
+ --pv-ink-muted: #b1bac4;
93
+ --pv-ink-soft: #9198a1;
94
+ --pv-ink-faint: #6e7681;
95
+ --pv-accent: #4a8bff;
96
+ --pv-accent-hover: #79a9ff;
97
+ --pv-dot: #39414d;
98
+ --pv-skeleton: #232a33;
99
+ --pv-skeleton-sheen: #2f3945;
100
+ --pv-del: #ff7b72;
101
+ --pv-del-bg: #2d1618;
102
+ --pv-del-rule: #7d2a2a;
103
+ --pv-add: #57d364;
104
+ --pv-add-bg: #12261a;
105
+ --pv-add-rule: #2b6b36;
106
+ --pv-warn: #e3b341;
107
+ --pv-warn-bg: #2b2209;
71
108
  }
109
+ :root[data-pv-theme="dark"] .pv-theme__to-dark { display: none; }
110
+ :root[data-pv-theme="dark"] .pv-theme__to-light { display: inline; }
72
111
 
73
112
  body {
74
113
  margin: 0;
@@ -99,7 +138,8 @@
99
138
  }
100
139
  .pv-header__brand { display: flex; align-items: center; gap: 8px; color: var(--pv-ink); font-size: 15px; font-weight: 650; }
101
140
  .pv-header__brand:hover { color: var(--pv-ink); text-decoration: none; }
102
- .pv-header__meta { display: flex; align-items: center; margin-left: auto; color: var(--pv-ink-soft); font-size: 12.5px; }
141
+ .pv-header__right { display: flex; align-items: center; gap: 16px; margin-left: auto; }
142
+ .pv-header__meta { display: flex; align-items: center; color: var(--pv-ink-soft); font-size: 12.5px; }
103
143
  .pv-header__nav { display: flex; align-items: stretch; gap: 20px; }
104
144
  .pv-header__link {
105
145
  display: flex;
@@ -111,6 +151,18 @@
111
151
  }
112
152
  .pv-header__link:hover { color: var(--pv-ink); text-decoration: none; }
113
153
  .pv-header__link--active { color: var(--pv-ink); font-weight: 600; box-shadow: inset 0 -2px 0 var(--pv-ink); }
154
+ .pv-header__theme {
155
+ padding: 4px 11px;
156
+ background: transparent;
157
+ border: 1px solid var(--pv-border);
158
+ border-radius: 999px;
159
+ color: var(--pv-ink-soft);
160
+ font: inherit;
161
+ font-size: 12.5px;
162
+ line-height: 1.5;
163
+ cursor: pointer;
164
+ }
165
+ .pv-header__theme:hover { border-color: var(--pv-border-input); color: var(--pv-ink); }
114
166
 
115
167
  .pv-main { max-width: 1560px; margin: 0 auto; padding: 24px; }
116
168
  .pv-stack { display: flex; flex-direction: column; gap: 16px; }
@@ -205,6 +257,7 @@
205
257
  background: var(--pv-surface);
206
258
  border: 1px solid var(--pv-border);
207
259
  border-radius: var(--pv-radius);
260
+ overflow: clip;
208
261
  }
209
262
  .pv-card__head {
210
263
  display: flex;
@@ -213,7 +266,6 @@
213
266
  padding: 14px 18px;
214
267
  background: var(--pv-surface-muted);
215
268
  border-bottom: 1px solid var(--pv-border);
216
- border-radius: var(--pv-radius) var(--pv-radius) 0 0;
217
269
  }
218
270
  .pv-card__title { font: 600 14px/1.2 var(--pv-sans); color: var(--pv-ink); }
219
271
  .pv-card__meta { font: 400 13px/1.2 var(--pv-sans); color: var(--pv-ink-soft); }
@@ -0,0 +1,8 @@
1
+ <%= javascript_tag nonce: true do %>
2
+ (function () {
3
+ try {
4
+ var theme = localStorage.getItem("pv-theme");
5
+ if (theme === "dark" || theme === "light") document.documentElement.setAttribute("data-pv-theme", theme);
6
+ } catch (error) {}
7
+ })();
8
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module PaperView
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paper_view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leon Vogt
@@ -53,6 +53,7 @@ files:
53
53
  - app/views/paper_view/shared/_flash.html.erb
54
54
  - app/views/paper_view/shared/_script.html.erb
55
55
  - app/views/paper_view/shared/_styles.html.erb
56
+ - app/views/paper_view/shared/_theme.html.erb
56
57
  - app/views/paper_view/stats/_stats.html.erb
57
58
  - app/views/paper_view/stats/show.html.erb
58
59
  - app/views/paper_view/versions/_filters.html.erb