Skip to content

Commit de7ad9d

Browse files
fix: pretty-print + visible palette + single-file data browser (#9)
* fix: pretty-print JSON-LD + visible cream palette (data browser) Two visual fixes to the minimal data browser shipped in 0.0.11: 1. JSON-LD is now pretty-printed with 2-space indent before being handed to the URI-linking regex. The previous version just dumped the raw single-line JSON; white-space:pre-wrap made it wrap but the result was a wall of text with no visible structure. The PR description that introduced this file used the word "pretty-print" but the code that landed didn't actually parse+stringify. 2. CSS palette tuned so the styling is actually visible: - Body background #fafaf8 -> #f3eee5 (warm cream that's clearly distinguishable from white at normal monitor calibration; the old value was 5 RGB units off from #fff so the card vanished) - Card border-radius 8 -> 12px, padding 1 -> 1.5em, shadow opacity 6% -> 8% with a softer larger blur for a visible lift - Link color #0366d6 -> #0a66c2 (more saturated, reads better against the cream) The CSS rules in 0.0.11 were applying correctly — verified by inspecting computed styles. The bug was that I picked colors too close to each other for the difference to be perceivable, not that the rules weren't taking effect. Bumps jspod to 0.0.12. Refs #1 * refactor: collapse data browser into a single self-styling JS file CSS now lives inside data-browser.js as a <style> tag injected on load. data-browser.css becomes an intentionally-empty stub so JSS's auto-fetch of the .css sibling (mashlib/index.js:307) still 200s — no console warning, no two-file version-skew risk, one file owns the experience. A future JSS PR can drop the sibling fetch and the stub goes away entirely. Refs #1
1 parent 1531910 commit de7ad9d

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

data-browser.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/* jspod minimal data-browser styles. Auto-loaded by JSS as the .css
2-
sibling of data-browser.js (see generateModuleDatabrowserHtml). */
3-
body{font:14px/1.6 system-ui,-apple-system,sans-serif;margin:2em;color:#222;background:#fafaf8}
4-
#mashlib pre{padding:1em;background:#fff;border-radius:8px;box-shadow:0 1px 3px rgba(0,0,0,.06);overflow:auto;white-space:pre-wrap;word-break:break-all}
5-
a{color:#0366d6;text-decoration:none}
6-
a:hover{text-decoration:underline}
1+
/* Intentionally empty. Styles live inside data-browser.js so the
2+
browser is a single file. JSS auto-fetches this sibling URL
3+
(mashlib/index.js:307); shipping an empty 200 keeps the console
4+
warning-free until JSS makes the .css fetch optional. */

data-browser.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// jspod minimal data browser — the page is the data. JSS embeds the
2-
// resource as JSON-LD in #dataisland; this module just makes it visible
3-
// in #mashlib with clickable URIs. See data-browser.css for the styling.
4-
const d=document.getElementById('dataisland'),m=document.getElementById('mashlib');
5-
m.innerHTML=`<pre>${d.textContent.replace(/https?:\/\/[^"\s]+/g,'<a href="$&">$&</a>')}</pre>`
2+
// resource as JSON-LD in #dataisland; this single module:
3+
// 1. Injects its own <style> (no separate .css fetch needed)
4+
// 2. Parses the JSON-LD and pretty-prints with 2-space indent
5+
// 3. Renders into #mashlib with every URI as a clickable <a>
6+
// Goal: a baseline mashlib that fits in one file, ~800 bytes total.
7+
document.head.insertAdjacentHTML('beforeend','<style>body{font:14px/1.6 system-ui,-apple-system,sans-serif;margin:2em;color:#222;background:#f3eee5}#mashlib pre{padding:1.5em;background:#fff;border-radius:12px;box-shadow:0 2px 12px rgba(0,0,0,.08);overflow:auto;white-space:pre-wrap;word-break:break-all}a{color:#0a66c2;text-decoration:none}a:hover{text-decoration:underline}</style>')
8+
const d=JSON.parse(document.getElementById('dataisland').textContent)
9+
document.getElementById('mashlib').innerHTML='<pre>'+JSON.stringify(d,null,2).replace(/https?:\/\/[^"\s]+/g,'<a href="$&">$&</a>')+'</pre>'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspod",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"description": "JavaScript Solid Pod - Just works, batteries included",
55
"type": "module",
66
"main": "index.js",

0 commit comments

Comments
 (0)