cornfield 0.22.0 → 0.24.0

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.
@@ -15,57 +15,51 @@
15
15
  .hx-house-plan .floor-map__floor[hidden] { display: none; }
16
16
  .hx-house-plan svg { display: block; width: 100%; height: 100%; overflow: visible; }
17
17
 
18
- /* The plan, dark: the house's outline faint, each room a box with its name (pop-floor-map's markup, or the tool's plain boxes) */
18
+ /* The plan: the house's outline faint (--corn-house-line; a little stronger on the light ground), each room a box with its name (pop-floor-map's markup, or the tool's plain boxes) */
19
19
  .hx-house-plan .floor-map__svg,
20
- .hx-house-plan .hx-plain-floor { background: var(--hx-well-soft); border: 1px solid rgba(163, 230, 53, 0.18); border-radius: 6px; font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, sans-serif; }
20
+ .hx-house-plan .hx-plain-floor { background: color-mix(in srgb, var(--corn-ground) 55%, transparent); border: var(--corn-border) solid var(--corn-house-line); border-radius: var(--corn-radius-sm); font-family: var(--corn-font); }
21
21
  .hx-house-plan .floor-map__box,
22
- .hx-house-plan .hx-plain-room rect { fill: rgba(190, 242, 100, 0.06); stroke: rgba(190, 242, 100, 0.45); stroke-width: 1.2; }
22
+ .hx-house-plan .hx-plain-room rect { fill: color-mix(in srgb, var(--corn-hue-lime) 6%, transparent); stroke: var(--corn-house-room); stroke-width: 1.2; }
23
23
  .hx-house-plan .floor-map__label,
24
- .hx-house-plan .hx-plain-room text { fill: var(--hx-lime-text); font-size: 13px; font-weight: 600; }
24
+ .hx-house-plan .hx-plain-room text { fill: var(--corn-hue-lime); font-size: var(--corn-text-md); font-weight: 600; }
25
25
  .hx-house-plan .floor-map__badge { display: none; }
26
26
  .hx-house-plan [aria-current="true"] .floor-map__box,
27
- .hx-house-plan .hx-plain-room[aria-current="true"] rect { fill: rgba(129, 140, 248, 0.18); stroke: var(--hx-indigo, #818cf8); stroke-width: 2.5; }
27
+ .hx-house-plan .hx-plain-room[aria-current="true"] rect { fill: color-mix(in srgb, var(--corn-accent-text) 18%, transparent); stroke: var(--corn-accent-text); stroke-width: 2.5; }
28
28
 
29
29
  /* The floor chips at the stage's top left; on a phone the people and the Software and Cloud toggles in a row under them */
30
- .hx-house-bar { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; z-index: 12; pointer-events: none; }
30
+ .hx-house-bar { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: var(--corn-space-2); z-index: 12; pointer-events: none; }
31
31
  .hx-house-bar[hidden] { display: none; }
32
- .hx-house-floors, .hx-house-people { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; pointer-events: auto; }
33
- .hx-house-floors { max-width: 100%; padding: 3px; border-radius: 9999px; }
32
+ .hx-house-floors, .hx-house-people { display: flex; flex-wrap: wrap; align-items: center; gap: var(--corn-space-1); pointer-events: auto; }
33
+ .hx-house-floors { max-width: 100%; padding: var(--corn-space-1); border-radius: var(--corn-radius-pill); }
34
34
  .hx-house-people[hidden] { display: none; }
35
- .hx-house-chip { min-height: 28px; padding: 3px 12px; border: 1px solid rgba(148, 163, 184, 0.25); border-radius: 9999px; background: var(--hx-well); color: var(--hx-slate-300, #cbd5e1); font-weight: 600; font-size: 12px; line-height: 1.2; font-family: inherit; cursor: pointer; white-space: nowrap; }
36
- .hx-house-chip:hover { border-color: rgba(163, 230, 53, 0.5); color: var(--hx-ink); }
37
- .hx-house-chip:focus-visible { outline: 2px solid var(--hx-indigo, #818cf8); outline-offset: 2px; }
38
- .hx-house-chip[aria-pressed="true"] { background: rgba(77, 124, 15, 0.9); border-color: #a3e635; color: #fff; }
39
- .hx-house-chip--person { border-color: rgba(251, 113, 133, 0.45); }
35
+ .hx-house-chip { min-height: 28px; padding: var(--corn-space-1) var(--corn-space-4); border: var(--corn-border) solid color-mix(in srgb, var(--corn-text-3) 25%, transparent); border-radius: var(--corn-radius-pill); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); color: var(--corn-text-2); font-weight: 600; font-size: var(--corn-text-sm); line-height: 1.2; font-family: inherit; cursor: pointer; white-space: nowrap; }
36
+ .hx-house-chip:hover { border-color: color-mix(in srgb, var(--corn-hue-lime) 50%, transparent); color: var(--corn-text); }
37
+ .hx-house-chip:focus-visible { outline: var(--corn-focus-width) solid var(--corn-focus); outline-offset: 2px; }
38
+ .hx-house-chip[aria-pressed="true"] { background: var(--corn-hue-lime); border-color: var(--corn-hue-lime); color: var(--corn-ground); }
39
+ .hx-house-chip--person { border-color: color-mix(in srgb, var(--corn-hue-pink) 45%, transparent); }
40
40
  .hx-house-chip--software, .hx-house-chip--cloud { border-style: dashed; }
41
- .hx-house-tag { padding: 2px 10px; font-size: 11px; color: var(--hx-amber, #fcd34d); }
41
+ .hx-house-tag { padding: calc(var(--corn-space-1) / 2) var(--corn-space-3); font-size: var(--corn-text-xs); color: var(--corn-warn); }
42
42
  /* "Edit layout": a link to where the plan is edited, looking like a chip; the arrow says it leaves the map */
43
43
  .hx-house-edit { display: inline-flex; align-items: center; text-decoration: none; border-style: dashed; }
44
- .hx-house-edit::after { content: "\2197"; margin-left: 5px; opacity: 0.7; }
44
+ .hx-house-edit::after { content: "\2197"; margin-left: var(--corn-space-1); opacity: 0.7; }
45
45
 
46
46
  /* "+3": a room that holds more than its grid, where its last slot is */
47
47
  .hx-house-over { position: absolute; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
48
48
  .hx-house-over[hidden] { display: none; }
49
- .hx-house-more { position: absolute; left: 0; top: 0; min-width: 34px; height: 24px; padding: 0 8px; border: 1px solid #2dd4bf; border-radius: 9999px; background: var(--hx-well); color: var(--hx-teal-strong); font-weight: 700; font-size: 12px; line-height: 1; font-family: inherit; cursor: pointer; pointer-events: auto; }
50
- .hx-house-more:hover, .hx-house-more:focus-visible { background: #0f766e; color: #fff; outline: none; }
49
+ .hx-house-more { position: absolute; left: 0; top: 0; min-width: 34px; height: 24px; padding: 0 var(--corn-space-3); border: var(--corn-border) solid var(--corn-added); border-radius: var(--corn-radius-pill); background: color-mix(in srgb, var(--corn-ground) 80%, transparent); color: var(--corn-added-text); font-weight: 700; font-size: var(--corn-text-sm); line-height: 1; font-family: inherit; cursor: pointer; pointer-events: auto; }
50
+ .hx-house-more:hover, .hx-house-more:focus-visible { background: var(--corn-added-text); color: var(--corn-ground); outline: none; }
51
51
 
52
52
  /* The House button joins the toolbar: up to a wide screen the live chip's line is cut shorter (the whole line is in its
53
53
  menu and its title), and on a narrow phone the toolbar tightens, so the toolbar still fits on one line */
54
54
  @media (min-width: 768px) and (max-width: 1439px) { .hx-live-chip-text { max-width: 140px; } }
55
55
  @media (max-width: 420px) {
56
- .hx-header .hx-header-left, .hx-header .hx-header-right { gap: 4px; }
57
- .hx-header .hx-btn { padding-left: 7px; padding-right: 7px; }
56
+ .hx-header .hx-header-left, .hx-header .hx-header-right { gap: var(--corn-space-1); }
57
+ .hx-header .hx-btn { padding-left: var(--corn-space-2); padding-right: var(--corn-space-2); }
58
58
  }
59
59
 
60
60
  @media (max-width: 767px) {
61
61
  .hx-house-bar { top: 8px; left: 8px; right: 8px; }
62
- .hx-house-chip { min-height: 32px; padding: 4px 12px; }
62
+ .hx-house-chip { min-height: 32px; padding: var(--corn-space-1) var(--corn-space-4); }
63
63
  .hx-house-people { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
64
64
  }
65
65
 
66
- /* The plan on the light ground (MAP-01): the rooms' lime deepened the way theme-model.js `lightColor` deepens the map's */
67
- :root[data-theme="light"] .hx-house-plan .floor-map__svg,
68
- :root[data-theme="light"] .hx-house-plan .hx-plain-floor { border-color: rgba(101, 152, 19, 0.3); }
69
- :root[data-theme="light"] .hx-house-plan .floor-map__box,
70
- :root[data-theme="light"] .hx-house-plan .hx-plain-room rect { fill: rgba(101, 152, 13, 0.06); stroke: rgba(101, 152, 13, 0.55); }
71
- :root[data-theme="light"] .hx-house-more { border-color: #209a8b; }
@@ -8,8 +8,11 @@
8
8
  <!--@importmap-->
9
9
 
10
10
  <!-- The explorer's own stylesheet and modules (explorer/): no build step, no CDN -->
11
+ <link rel="stylesheet" href="/explorer/tokens.css" />
11
12
  <link rel="stylesheet" href="/explorer/explorer.css" />
12
13
  <link rel="stylesheet" href="/explorer/house.css" />
14
+ <!-- The config's brand (server/server.js puts it here): the favicon, the web app manifest and the tab colour -->
15
+ <!--@brand-->
13
16
  <!-- The config's theme (server/server.js puts it here, so it comes after cornfield's own CSS): font stylesheets, the repo's theme.css, a named theme -->
14
17
  <!--@theme-->
15
18
  <!-- Light or dark on <html data-theme>, and the named theme on <html data-theme-name>, before the first paint (theme-boot.js; theme.js
@@ -23,8 +26,8 @@
23
26
  <!-- The page's one heading, for a screen reader's list of headings (plugins.js puts the config's title in it) -->
24
27
  <h1 id="cf-heading" class="hx-sr-only">cornfield: the map</h1>
25
28
  <div class="hx-header-left">
26
- <button type="button" class="hx-brand" data-action="reset-view" title="Reset View" aria-label="cornfield: reset the view">
27
- <span class="hx-live-dot"></span>
29
+ <button type="button" id="cf-brand" class="hx-brand" data-action="reset-view" title="Reset View" aria-label="cornfield: reset the view">
30
+ <span id="cf-mark" class="hx-live-dot"></span>
28
31
  <span id="cf-title" class="hx-title gradient-text">cornfield</span>
29
32
  </button>
30
33
 
@@ -37,13 +37,51 @@ export async function loadClientConfig(fetcher = (...a) => globalThis.fetch(...a
37
37
  }
38
38
  }
39
39
 
40
- /** Puts the repo's title and links in the header, and Sign out when the server says who is signed in */
40
+ /** An <img> for a brand image (the server's same-origin URL): decorative, the button it sits in carries the name; `alt` only shows if it fails to load */
41
+ function brandImage(doc, src, kind, alt = '') {
42
+ const img = doc.createElement('img');
43
+ img.setAttribute('src', src);
44
+ img.setAttribute('alt', alt);
45
+ img.setAttribute('data-corn', `brand-${kind}`);
46
+ img.setAttribute('style', `height:${kind === 'logo' ? 22 : 18}px;width:auto;max-width:${kind === 'logo' ? 48 : 160}px;display:block`);
47
+ return img;
48
+ }
49
+
50
+ /**
51
+ * The repo's brand in the header (docs/config.md#brand): the logo takes the brand mark's place and the wordmark the title text, inside
52
+ * the same button, so its accessible name stays. The header text stays the repo's own title; `appName` replaces "cornfield" where
53
+ * cornfield names itself: the button's accessible name and the page's heading (the tab title and the manifest are the server's).
54
+ */
55
+ function applyBrand(doc, brand, title) {
56
+ const button = doc.getElementById('cf-brand');
57
+ if (button && brand.appName) button.setAttribute('aria-label', `${brand.appName}: reset the view`);
58
+ const text = doc.getElementById('cf-title');
59
+ if (brand.logo && typeof doc.createElement === 'function') {
60
+ const mark = doc.getElementById('cf-mark');
61
+ if (mark) mark.replaceWith(brandImage(doc, brand.logo, 'logo'));
62
+ }
63
+ if (brand.wordmark && text && typeof doc.createElement === 'function') {
64
+ text.textContent = '';
65
+ text.appendChild(brandImage(doc, brand.wordmark, 'wordmark', title || brand.appName || ''));
66
+ }
67
+ const heading = doc.getElementById('cf-heading');
68
+ if (heading && brand.appName) heading.textContent = `${brand.appName}: the map`;
69
+ }
70
+
71
+ /** The small "powered by cornfield" link that stays in the header when a repo brands cornfield */
72
+ function poweredBy(brand) {
73
+ if (!brand || typeof brand.poweredBy !== 'string' || !/^https:\/\//.test(brand.poweredBy)) return '';
74
+ return `<a class="hx-btn hx-btn--quiet" data-corn="powered-by" href="${escHtml(brand.poweredBy)}" target="_blank" rel="noreferrer">powered by cornfield</a>`;
75
+ }
76
+
77
+ /** Puts the repo's title, brand and links in the header, and Sign out when the server says who is signed in */
41
78
  export function applyBranding(doc, config) {
42
79
  if (!config || !doc) return;
43
80
  const title = doc.getElementById('cf-title');
44
81
  if (title && config.title) title.textContent = config.title;
45
82
  const heading = doc.getElementById('cf-heading');
46
83
  if (heading && config.title) heading.textContent = `${config.title}: the map`;
84
+ if (config.brand) applyBrand(doc, config.brand, config.title);
47
85
  initThemePicker(doc, config.theme);
48
86
  const links = doc.getElementById('cf-links');
49
87
  if (!links) return;
@@ -56,7 +94,8 @@ export function applyBranding(doc, config) {
56
94
  const signOut = config.signIn && typeof config.signIn.login === 'string'
57
95
  ? `<form class="cf-sign-out" method="post" action="/auth/sign-out"><button type="submit" class="hx-btn hx-btn--quiet" title="Signed in as ${escHtml(config.signIn.login)}"><span class="cf-sign-out-icon" aria-hidden="true">⎋</span><span class="cf-sign-out-text">Sign out</span></button></form>`
58
96
  : '';
59
- if (html || signOut) links.innerHTML = html + signOut;
97
+ const powered = poweredBy(config.brand);
98
+ if (html || powered || signOut) links.innerHTML = html + powered + signOut;
60
99
  }
61
100
 
62
101
  /**
@@ -0,0 +1,271 @@
1
+ /* ==========================================================================
2
+ The explorer's design tokens (docs/theming.md)
3
+ ==========================================================================
4
+ The ONLY file in explorer/ that holds a literal colour, font, size, radius, border width, shadow or spacing:
5
+ explorer.css and house.css read these `--corn-*` custom properties and nothing else (a test holds it,
6
+ test/explorer/tokens.test.js). A brand re-skins the explorer by loading a stylesheet after this one that
7
+ redefines some of them.
8
+
9
+ Dark is on :root. Light is under BOTH the system setting (when the page has not been told dark) and the
10
+ page's own choice (<html data-theme="light">, set by theme-boot.js and theme.js), so the page is right
11
+ before and without the script. The two light blocks below are the same; keep them in step. */
12
+
13
+ :root {
14
+ /* Ground and surfaces */
15
+ --corn-ground: #090d16;
16
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.28) 0%, transparent 45%),
17
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.22) 0%, transparent 45%),
18
+ radial-gradient(circle at 50% 50%, rgba(66, 153, 225, 0.10) 0%, transparent 60%);
19
+ --corn-surface-1: rgba(26, 34, 52, 0.72);
20
+ --corn-surface-2: rgba(30, 41, 59, 0.8);
21
+ --corn-surface-3: rgba(51, 65, 85, 0.8);
22
+ --corn-line: rgba(255, 255, 255, 0.12);
23
+ --corn-line-soft: rgba(255, 255, 255, 0.07);
24
+ --corn-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
25
+ --corn-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
26
+ --corn-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
27
+ --corn-shadow-color: rgba(0, 0, 0, 0.5);
28
+ --corn-glow: 8px;
29
+ --corn-scrim: rgba(0, 0, 0, 0.6);
30
+ --corn-blur: 16px;
31
+
32
+ /* Text */
33
+ --corn-text: #f8fafc;
34
+ --corn-text-2: #cbd5e1;
35
+ --corn-text-3: #94a3b8;
36
+ --corn-text-on-accent: #fff;
37
+ --corn-mockup-ground: #fff;
38
+
39
+ /* Accent */
40
+ --corn-accent: #4f46e5;
41
+ --corn-accent-hover: #6366f1;
42
+ --corn-accent-text: #818cf8;
43
+ --corn-accent-soft: color-mix(in srgb, var(--corn-accent-hover) 20%, transparent);
44
+ --corn-focus: #818cf8;
45
+ --corn-brand-gradient: linear-gradient(135deg, #4299e1 0%, #818cf8 50%, #e53e3e 100%);
46
+
47
+ /* Status: only ever means status */
48
+ --corn-ok: #34d399;
49
+ --corn-warn: #fcd34d;
50
+ --corn-bad: #fca5a5;
51
+ --corn-info: #7dd3fc;
52
+ --corn-ok-soft: color-mix(in srgb, var(--corn-ok) 15%, transparent);
53
+ --corn-warn-soft: color-mix(in srgb, var(--corn-warn) 14%, transparent);
54
+ --corn-bad-soft: color-mix(in srgb, var(--corn-bad) 12%, transparent);
55
+ --corn-info-soft: color-mix(in srgb, var(--corn-info) 15%, transparent);
56
+
57
+ /* Diff: what a proposal adds, changes, removes and edits (the map draws the same four) */
58
+ --corn-added: #2dd4bf;
59
+ --corn-changed: #fbbf24;
60
+ --corn-removed: #f87171;
61
+ --corn-edit: #a78bfa;
62
+ /* The same as text: mixed toward the text colour, so it reads on either ground */
63
+ --corn-added-text: color-mix(in srgb, var(--corn-added) 60%, var(--corn-text));
64
+ --corn-edit-text: color-mix(in srgb, var(--corn-edit) 60%, var(--corn-text));
65
+
66
+ /* Category hues (never status): the preset, ROM, variable and House accents */
67
+ --corn-hue-orange: #fb923c;
68
+ --corn-hue-fuchsia: #e879f9;
69
+ --corn-hue-pink: #f472b6;
70
+ --corn-hue-lime: #a3e635;
71
+
72
+ /* Type */
73
+ --corn-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
74
+ --corn-font-display: var(--corn-font);
75
+ --corn-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
76
+ --corn-text-2xs: 10px;
77
+ --corn-text-xs: 11px;
78
+ --corn-text-sm: 12px;
79
+ --corn-text-md: 13px;
80
+ --corn-text-base: 14px;
81
+ --corn-text-lg: 15px;
82
+
83
+ /* Shape */
84
+ --corn-radius-xs: 3px;
85
+ --corn-radius-sm: 6px;
86
+ --corn-radius: 10px;
87
+ --corn-radius-lg: 14px;
88
+ --corn-radius-pill: 999px;
89
+ --corn-border: 1px;
90
+ --corn-border-strong: 2px;
91
+ --corn-focus-width: 2px;
92
+
93
+ /* Spacing: padding, gaps and margins are steps of this scale (or calc() over it) */
94
+ --corn-space: 4px;
95
+ --corn-space-1: var(--corn-space);
96
+ --corn-space-2: 6px;
97
+ --corn-space-3: 8px;
98
+ --corn-space-4: 12px;
99
+ --corn-space-5: 16px;
100
+ --corn-space-6: 24px;
101
+
102
+ /* The House view's plan: the house's outline and each room's */
103
+ --corn-house-line: color-mix(in srgb, var(--corn-hue-lime) 18%, transparent);
104
+ --corn-house-room: color-mix(in srgb, var(--corn-hue-lime) 45%, transparent);
105
+
106
+ /* How much of a panel glyph's own colour is kept (.hx-glyph) */
107
+ --corn-glyph-mix: 100%;
108
+
109
+ color-scheme: dark;
110
+ }
111
+
112
+ /* Light: the same names, for the light ground */
113
+ @media (prefers-color-scheme: light) {
114
+ :root:not([data-theme="dark"]) {
115
+ --corn-ground: #f4f6fa;
116
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.12) 0%, transparent 45%),
117
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.07) 0%, transparent 45%);
118
+ --corn-surface-1: rgba(255, 255, 255, 0.8);
119
+ --corn-surface-2: rgba(241, 245, 249, 0.92);
120
+ --corn-surface-3: rgba(226, 232, 240, 0.95);
121
+ --corn-line: rgba(15, 23, 42, 0.12);
122
+ --corn-line-soft: rgba(15, 23, 42, 0.07);
123
+ --corn-shadow: 0 8px 28px 0 rgba(15, 23, 42, 0.12);
124
+ --corn-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.25);
125
+ --corn-shadow-lg: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
126
+ --corn-shadow-color: rgba(15, 23, 42, 0.25);
127
+ --corn-glow: 0px;
128
+ --corn-scrim: rgba(15, 23, 42, 0.35);
129
+
130
+ --corn-text: #0f172a;
131
+ --corn-text-2: #334155;
132
+ --corn-text-3: #475569;
133
+
134
+ --corn-accent-text: #4f46e5;
135
+ --corn-focus: #4f46e5;
136
+ --corn-brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #dc2626 100%);
137
+
138
+ --corn-ok: #047857;
139
+ --corn-warn: #854d0e;
140
+ --corn-bad: #b91c1c;
141
+ --corn-info: #0369a1;
142
+
143
+ --corn-added: #209a8b;
144
+ --corn-changed: #b28103;
145
+ --corn-removed: #f64c4c;
146
+ --corn-edit: #9472f9;
147
+
148
+ --corn-hue-orange: #c2410c;
149
+ --corn-hue-fuchsia: #a21caf;
150
+ --corn-hue-pink: #be185d;
151
+ --corn-hue-lime: #4d7c0f;
152
+
153
+ --corn-house-line: color-mix(in srgb, var(--corn-hue-lime) 30%, transparent);
154
+ --corn-house-room: color-mix(in srgb, var(--corn-hue-lime) 55%, transparent);
155
+
156
+ --corn-glyph-mix: 45%;
157
+
158
+ color-scheme: light;
159
+ }
160
+ }
161
+
162
+ :root[data-theme="light"] {
163
+ --corn-ground: #f4f6fa;
164
+ --corn-ground-image: radial-gradient(circle at 14% 18%, rgba(66, 153, 225, 0.12) 0%, transparent 45%),
165
+ radial-gradient(circle at 86% 82%, rgba(229, 62, 62, 0.07) 0%, transparent 45%);
166
+ --corn-surface-1: rgba(255, 255, 255, 0.8);
167
+ --corn-surface-2: rgba(241, 245, 249, 0.92);
168
+ --corn-surface-3: rgba(226, 232, 240, 0.95);
169
+ --corn-line: rgba(15, 23, 42, 0.12);
170
+ --corn-line-soft: rgba(15, 23, 42, 0.07);
171
+ --corn-shadow: 0 8px 28px 0 rgba(15, 23, 42, 0.12);
172
+ --corn-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.25);
173
+ --corn-shadow-lg: 0 10px 30px -12px rgba(15, 23, 42, 0.18);
174
+ --corn-shadow-color: rgba(15, 23, 42, 0.25);
175
+ --corn-glow: 0px;
176
+ --corn-scrim: rgba(15, 23, 42, 0.35);
177
+
178
+ --corn-text: #0f172a;
179
+ --corn-text-2: #334155;
180
+ --corn-text-3: #475569;
181
+
182
+ --corn-accent-text: #4f46e5;
183
+ --corn-focus: #4f46e5;
184
+ --corn-brand-gradient: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #dc2626 100%);
185
+
186
+ --corn-ok: #047857;
187
+ --corn-warn: #854d0e;
188
+ --corn-bad: #b91c1c;
189
+ --corn-info: #0369a1;
190
+
191
+ --corn-added: #209a8b;
192
+ --corn-changed: #b28103;
193
+ --corn-removed: #f64c4c;
194
+ --corn-edit: #9472f9;
195
+
196
+ --corn-hue-orange: #c2410c;
197
+ --corn-hue-fuchsia: #a21caf;
198
+ --corn-hue-pink: #be185d;
199
+ --corn-hue-lime: #4d7c0f;
200
+
201
+ --corn-house-line: color-mix(in srgb, var(--corn-hue-lime) 30%, transparent);
202
+ --corn-house-room: color-mix(in srgb, var(--corn-hue-lime) 55%, transparent);
203
+
204
+ --corn-glyph-mix: 45%;
205
+
206
+ color-scheme: light;
207
+ }
208
+
209
+ /* ==========================================================================
210
+ The old --hx-* names, as aliases of the tokens above, for one release (scene.js, proposal.js and plugin
211
+ CSS still read them). They go in the next minor: write --corn-* in new CSS. proposal.js writes
212
+ --hx-mark-* on :root for the map's own ground; nothing in explorer/*.css reads them any more.
213
+ ========================================================================== */
214
+ :root {
215
+ --hx-bg: var(--corn-ground);
216
+ --hx-text: var(--corn-text);
217
+ --hx-ink: var(--corn-text);
218
+ --hx-text-1: var(--corn-text);
219
+ --hx-text-2: var(--corn-text-2);
220
+ --hx-slate-300: var(--corn-text-2);
221
+ --hx-slate-400: var(--corn-text-3);
222
+ --hx-slate-500: var(--corn-text-3);
223
+ --hx-slate-600: var(--corn-text-3);
224
+ --hx-slate-700: var(--corn-surface-3);
225
+ --hx-slate-800: var(--corn-surface-2);
226
+ --hx-slate-900: var(--corn-ground);
227
+ --hx-slate-950: var(--corn-ground);
228
+ --hx-indigo: var(--corn-accent-text);
229
+ --hx-indigo-strong: var(--corn-accent);
230
+ --hx-emerald: var(--corn-ok);
231
+ --hx-amber: var(--corn-warn);
232
+ --hx-sky: var(--corn-info);
233
+ --hx-pink: var(--corn-hue-pink);
234
+ --hx-fuchsia: var(--corn-hue-fuchsia);
235
+ --hx-fuchsia-strong: var(--corn-hue-fuchsia);
236
+ --hx-red: var(--corn-bad);
237
+ --hx-code: var(--corn-warn);
238
+ --hx-orange-text: var(--corn-hue-orange);
239
+ --hx-orange-strong: var(--corn-hue-orange);
240
+ --hx-teal-text: var(--corn-added-text);
241
+ --hx-teal-strong: var(--corn-added-text);
242
+ --hx-violet-text: var(--corn-edit-text);
243
+ --hx-green-text: var(--corn-ok);
244
+ --hx-lime-text: var(--corn-hue-lime);
245
+ --hx-mark-added: var(--corn-added);
246
+ --hx-mark-changed: var(--corn-changed);
247
+ --hx-mark-removed: var(--corn-removed);
248
+ --hx-mark-edit: var(--corn-edit);
249
+ --hx-control: var(--corn-surface-2);
250
+ --hx-control-hover: var(--corn-surface-3);
251
+ --hx-control-off: color-mix(in srgb, var(--corn-ground) 40%, transparent);
252
+ --hx-well: color-mix(in srgb, var(--corn-ground) 80%, transparent);
253
+ --hx-well-soft: color-mix(in srgb, var(--corn-ground) 55%, transparent);
254
+ --hx-line: var(--corn-line);
255
+ --hx-line-soft: var(--corn-line-soft);
256
+ --hx-scroll: color-mix(in srgb, var(--corn-text) 18%, transparent);
257
+ --hx-scroll-hover: color-mix(in srgb, var(--corn-text) 28%, transparent);
258
+ --hx-swatch-solid: color-mix(in srgb, var(--corn-text) 55%, transparent);
259
+ --hx-backdrop: var(--corn-scrim);
260
+ --hx-glyph-mix: var(--corn-glyph-mix);
261
+ --surface-glass: var(--corn-surface-1);
262
+ --surface-glass-header: color-mix(in srgb, var(--corn-ground) 88%, transparent);
263
+ --border-glass: var(--corn-line);
264
+ --border-subtle: var(--corn-line-soft);
265
+ --glass-blur: blur(var(--corn-blur));
266
+ --glass-shadow: var(--corn-shadow);
267
+ --gradient-primary: var(--corn-brand-gradient);
268
+ --bg-gradient: var(--corn-ground-image), var(--corn-ground);
269
+ --pop-font-body: var(--corn-font);
270
+ --pop-font-mono: var(--corn-mono);
271
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cornfield",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "A self-hostable dev dashboard with the topology map at its centre: proposals on the map, scenarios, outages and what-if edits, for any repo.",
5
5
  "license": "MIT",
6
6
  "author": "popcorn245 (https://github.com/popcorn245)",
package/server/server.js CHANGED
@@ -19,6 +19,8 @@
19
19
  * GET /cornfield/theme.css, /cornfield/theme/<name>.css
20
20
  * the stylesheets the config's `theme` names (css, names): those files only, as text/css
21
21
  * GET /cornfield/theme/assets/<path> an image or font beside the theme files (png, svg, webp, gif, avif, woff2, woff; 1 MB each)
22
+ * GET /cornfield/brand/<key>.<ext> a brand image the config's `brand` names (logo, wordmark, favicon; svg or png, 512 KB each): those files only
23
+ * GET /manifest.webmanifest the web app manifest: the repo's title, or built from `brand` when the config sets one
22
24
  * GET /api/forge/… issues, pull requests, their files and checks, release notes: read from the forge (server/forge-routes.js)
23
25
  * POST /api/forge/pulls/<n>/merge|rerun land a green pull request, re-run a failed check (server/forge-actions.js)
24
26
  * POST /api/forge/issues/<n>/spec, /pulls/<n>/build the pipeline's steps (server/pipeline.js, server/forge-actions.js)
@@ -53,6 +55,7 @@ import { createHash, randomBytes } from 'node:crypto';
53
55
  import { fileURLToPath } from 'node:url';
54
56
  import { browserSources, BUILTIN_SOURCES, parseDuration, specPollMs, triggersOf, DEFAULTS, hookWants, ideaLabel, runnerQuietAfterMs } from '../core/config.js';
55
57
  import { CLOUD_FILE } from '../core/cloud.js';
58
+ import { BRAND_SVG_CSP, MANIFEST_PATH, appNameOf, brandAssetFile, brandImages, clientBrand, colorOf, manifestOf } from '../core/brand.js';
56
59
  import { MAX_THEME_ASSET_BYTES, MAX_THEME_BYTES, THEME_ASSET_PREFIX, THEME_NAME, THEME_SVG_CSP, clientTheme, cssProblems, fontOrigins, fontUrl, themeAssetFile, themeAssetPath } from '../core/theme.js';
57
60
  import { decodePath, inside, notFound, sendFile } from './files.js';
58
61
  import { serveProposals } from './proposals.js';
@@ -184,6 +187,57 @@ function sendThemeAsset(req, res, config, reqPath) {
184
187
  }
185
188
  }
186
189
 
190
+ /** The brand images the config names, by the path they are served at: `Map<'/cornfield/brand/<key>.<ext>', rel>` */
191
+ function brandFilesOf(config) {
192
+ return new Map(brandImages(config.brand).map((i) => [i.url, i.rel]));
193
+ }
194
+
195
+ /**
196
+ * The `<head>` lines of a brand: the favicon, the manifest (always, so any cornfield installs as an app; fetched with the sign-in
197
+ * cookie, since the page is behind it) and the tab colour
198
+ */
199
+ function brandHead(brand) {
200
+ const out = [];
201
+ const favicon = brandImages(brand).find((i) => i.key === 'favicon');
202
+ if (favicon) out.push(`<link rel="icon" href="${escapeHtml(favicon.url)}" type="${favicon.type}" />`);
203
+ out.push(`<link rel="manifest" href="${MANIFEST_PATH}" crossorigin="use-credentials" />`);
204
+ const color = colorOf(brand && brand.color);
205
+ if (color) out.push(`<meta name="theme-color" content="${escapeHtml(color)}" />`);
206
+ return out.join('\n ');
207
+ }
208
+
209
+ /** The page's title: the repo's, then the app's name (cornfield, unless the brand names the app) */
210
+ function titleOf(config) {
211
+ const app = appNameOf(config.brand);
212
+ return app && app === config.title ? app : `${config.title} · ${app || 'cornfield'}`;
213
+ }
214
+
215
+ /**
216
+ * Serves one brand image: only a file the config names (`brand.logo`, `wordmark`, `favicon`), a plain svg or png file whose real path
217
+ * is inside the repo, whose bytes match its extension, at most 512 KB (core/brand.js `brandAssetFile`, the check `cornfield validate`
218
+ * makes). nosniff always; an SVG gets a policy of its own and is never inlined into the page.
219
+ */
220
+ function sendBrand(req, res, config, rel, reqPath) {
221
+ try {
222
+ const found = brandAssetFile(config.root, rel);
223
+ if ('problem' in found) return notFound(res, reqPath);
224
+ res.writeHead(200, {
225
+ 'Content-Type': found.type, 'Content-Length': found.body.length, 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff',
226
+ ...(found.type === 'image/svg+xml' ? { 'Content-Security-Policy': BRAND_SVG_CSP } : {}),
227
+ });
228
+ return res.end(req.method === 'HEAD' ? undefined : found.body);
229
+ } catch {
230
+ return notFound(res, reqPath);
231
+ }
232
+ }
233
+
234
+ /** The web app manifest (core/brand.js `manifestOf`), as application/manifest+json: served with or without a brand */
235
+ function sendManifest(req, res, config) {
236
+ const body = JSON.stringify(manifestOf(config.brand, config.title, (rel) => brandAssetFile(config.root, rel)));
237
+ res.writeHead(200, { 'Content-Type': 'application/manifest+json; charset=utf-8', 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff' });
238
+ return res.end(req.method === 'HEAD' ? undefined : body);
239
+ }
240
+
187
241
  /** The browser modules the config names from the repo: each one's folder may be served (its .js files only) */
188
242
  function repoModuleDirs(config) {
189
243
  const dirs = [];
@@ -208,6 +262,8 @@ export function clientConfig(config, signIn = false) {
208
262
  links: config.links || [],
209
263
  // The theme's names and default, never a file's path (docs/config.md#theme)
210
264
  theme: clientTheme(config.theme),
265
+ // The brand's image URLs and name, never a file's path (docs/config.md#brand)
266
+ brand: clientBrand(config.brand, PKG.homepage),
211
267
  forge: config.forge ? { type: config.forge.type, url: config.forge.url || (config.forge.type === 'github' ? 'https://github.com' : null), repo: config.forge.repo, mergeMethod: config.forge.mergeMethod || 'merge', ...(config.approveLands ? { approveLands: true } : {}) } : null,
212
268
  // Threads (docs/threads.md): the idea label, or false when `threads: false` turns the Threads tab off
213
269
  threads: config.threads === false ? false : { label: ideaLabel(config) },
@@ -258,6 +314,7 @@ export function createCornfieldServer(config, opts = {}) {
258
314
  const theme = config.theme || {};
259
315
  const csp = cspOf(importMap, theme);
260
316
  const themeFile = themeFilesOf(config);
317
+ const brandFile = brandFilesOf(config);
261
318
  const repoModules = repoModuleDirs(config);
262
319
  const publicHost = config.publicUrl ? new URL(config.publicUrl).hostname : null;
263
320
  const where = { root, proposals: config.proposals, worktrees: config.worktrees, worktreeMaxAgeDays: config.worktreeMaxAgeDays, topology: config.topology, dataDir: config.dataDir, publicHost };
@@ -312,7 +369,8 @@ export function createCornfieldServer(config, opts = {}) {
312
369
  .replace('<!--@importmap-->', importMap ? `<script type="importmap">${importMap}</script>` : '')
313
370
  .replace('<html lang="en">', () => themeHtmlTag(theme))
314
371
  .replace('<!--@theme-->', () => themeHead(theme)) // a function, so a `$` in a font URL is not a replacement pattern
315
- .replace(/<title>[^<]*<\/title>/, `<title>${escapeHtml(config.title)} · cornfield</title>`);
372
+ .replace('<!--@brand-->', () => brandHead(config.brand))
373
+ .replace(/<title>[^<]*<\/title>/, () => `<title>${escapeHtml(titleOf(config))}</title>`); // a function: a `$` in a name is not a pattern
316
374
  return html;
317
375
  };
318
376
 
@@ -407,6 +465,8 @@ export function createCornfieldServer(config, opts = {}) {
407
465
  }
408
466
  if (themeFile.has(reqPath)) return sendTheme(req, res, config, themeFile.get(reqPath), reqPath);
409
467
  if (reqPath.startsWith(THEME_ASSET_PREFIX)) return sendThemeAsset(req, res, config, reqPath);
468
+ if (brandFile.has(reqPath)) return sendBrand(req, res, config, brandFile.get(reqPath), reqPath);
469
+ if (reqPath === MANIFEST_PATH) return sendManifest(req, res, config);
410
470
  if (reqPath === '/cornfield/config.json') return sendJson(res, 200, clientConfig(config, signedIn));
411
471
  if (reqPath === '/topology.json') {
412
472
  const file = inside(root, config.topology);