jekyll-dice-tray 0.5.1 → 0.5.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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f94a0efe5f9d8e77660ad59f9a455d7639c5c84f0aba09664f26d707bef1ad5f
|
|
4
|
+
data.tar.gz: ae0e7be86f93d73b93753b7394a38e2a0f45b9f77856803775c16b49048464d8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6a7a8507c6a193051373cb66ae7b6f7a71f911e87ac7c01a172c0ba26b62b5eb76793212ca38da475a64ff0bad0572de1518e9f12bb6088aff2f615580e2ed4
|
|
7
|
+
data.tar.gz: 7f3c908b2eee3946f710de9af643e79dd9d001eeb7838654cb818defd6b921f8b33025950a07ad782eb7619af96f471650fb9043c77e115a9b857619acd73179
|
|
@@ -34,13 +34,16 @@
|
|
|
34
34
|
border-radius: 12px;
|
|
35
35
|
box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
|
|
36
36
|
overflow: hidden;
|
|
37
|
-
|
|
37
|
+
/* Stay collapsed until data-expanded="true". A default of flex overrides the
|
|
38
|
+
hidden attribute and paints the open tray before hydration. */
|
|
39
|
+
display: none;
|
|
38
40
|
flex-direction: column;
|
|
39
41
|
max-height: 360px;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
/* Only the pre-paint script or dice_tray.js sets this; absent means minimized. */
|
|
45
|
+
#jekyll-dice-tray[data-expanded="true"] .jdt-body {
|
|
46
|
+
display: flex;
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
#jekyll-dice-tray .jdt-clue {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var STORAGE_PREFIX = "jekyll_dice_tray:";
|
|
5
|
+
// Also read before first paint by the inline script in HtmlRewriter.inject_tray.
|
|
5
6
|
var STORAGE_EXPANDED = STORAGE_PREFIX + "expanded";
|
|
6
7
|
var STORAGE_HISTORY = STORAGE_PREFIX + "history_v1";
|
|
7
8
|
var STORAGE_INPUT_HISTORY = STORAGE_PREFIX + "input_history_v1";
|
|
@@ -521,6 +522,7 @@
|
|
|
521
522
|
root.setAttribute("data-expanded", expanded ? "true" : "false");
|
|
522
523
|
// Some themes override [hidden], so enforce display too.
|
|
523
524
|
body.hidden = !expanded;
|
|
525
|
+
// Clear the pre-paint inline lock so the expanded stylesheet rule can show the body.
|
|
524
526
|
body.style.display = expanded ? "" : "none";
|
|
525
527
|
saveBool(STORAGE_EXPANDED, expanded);
|
|
526
528
|
if (expanded) {
|
|
@@ -199,18 +199,42 @@ module Jekyll
|
|
|
199
199
|
def self.inject_tray(html, assets_path:)
|
|
200
200
|
return html if html.include?('data-dice-tray-root="true"')
|
|
201
201
|
|
|
202
|
+
# Start collapsed. Inline display:none holds the body shut until the script
|
|
203
|
+
# below runs: the hidden attribute loses to author CSS (including ours), and
|
|
204
|
+
# the deferred dice_tray.js can run after first paint, which flashes the
|
|
205
|
+
# open tray on navigation. This script reads the same localStorage key as
|
|
206
|
+
# STORAGE_EXPANDED in dice_tray.js and applies it before first paint.
|
|
202
207
|
tray = <<~HTML
|
|
203
|
-
<div id="jekyll-dice-tray" data-dice-tray-root="true" data-version="#{VERSION}" aria-live="polite">
|
|
208
|
+
<div id="jekyll-dice-tray" data-dice-tray-root="true" data-version="#{VERSION}" data-expanded="false" aria-live="polite">
|
|
204
209
|
<div class="jdt-header">
|
|
205
210
|
<button type="button" class="jdt-toggle" aria-expanded="false" title="Toggle dice tray">Dice</button>
|
|
206
211
|
</div>
|
|
207
|
-
<div class="jdt-body" hidden>
|
|
212
|
+
<div class="jdt-body" hidden style="display:none">
|
|
208
213
|
<div class="jdt-clue">Type <code>1d20+5</code> or <code>/help</code>, then press Enter.</div>
|
|
209
214
|
<div class="jdt-log" role="log" aria-label="Dice roll log"></div>
|
|
210
215
|
<input class="jdt-input" type="text" inputmode="text" autocomplete="off" spellcheck="false"
|
|
211
216
|
placeholder="Roll: 1d6, d4, 2d8+1, /help" />
|
|
212
217
|
</div>
|
|
213
218
|
</div>
|
|
219
|
+
<script>
|
|
220
|
+
// Synchronous on purpose: must finish before the browser paints the tray.
|
|
221
|
+
(function () {
|
|
222
|
+
try {
|
|
223
|
+
// Keep in sync with STORAGE_EXPANDED in dice_tray.js.
|
|
224
|
+
var expanded = localStorage.getItem("jekyll_dice_tray:expanded") === "true";
|
|
225
|
+
var root = document.getElementById("jekyll-dice-tray");
|
|
226
|
+
if (!root) return;
|
|
227
|
+
root.setAttribute("data-expanded", expanded ? "true" : "false");
|
|
228
|
+
var toggle = root.querySelector(".jdt-toggle");
|
|
229
|
+
if (toggle) toggle.setAttribute("aria-expanded", expanded ? "true" : "false");
|
|
230
|
+
var body = root.querySelector(".jdt-body");
|
|
231
|
+
if (!body) return;
|
|
232
|
+
body.hidden = !expanded;
|
|
233
|
+
// Inline display wins over theme rules that override [hidden].
|
|
234
|
+
body.style.display = expanded ? "flex" : "none";
|
|
235
|
+
} catch (e) {}
|
|
236
|
+
})();
|
|
237
|
+
</script>
|
|
214
238
|
HTML
|
|
215
239
|
|
|
216
240
|
tags = <<~HTML
|