@justai/cuts 0.47.0 → 0.48.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/Posts.astro +52 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justai/cuts",
3
- "version": "0.47.0",
4
- "description": "A persona's named parts \u2014 the page shell that holds them, and the cuts themselves.",
3
+ "version": "0.48.0",
4
+ "description": "A persona's named parts the page shell that holds them, and the cuts themselves.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
7
7
  "type": "git",
package/src/Posts.astro CHANGED
@@ -29,8 +29,27 @@ interface Props {
29
29
  displayHandle?: string; // the rendered @handle when it differs from the key (app.zone → @appzone)
30
30
  avatarBg?: string; // post-avatar tile background (default #fff)
31
31
  avatarBgLight?: string; // light-scheme override for that tile (a dark gradient must invert, not stay dark)
32
+ // Which file is THIS persona's face in the feed. Defaults to /icon.svg, which every persona serves at its
33
+ // root, and which is a tile-with-a-mark-inside — right for an app, and what the tile knobs above are for.
34
+ avatarSrc?: string;
35
+ // A mark with no tile of its own, shown on the feed's ground rather than on a tile. app.zone is the case
36
+ // this exists for: the platform mark is a different kind of object from an app icon (the house rule is in
37
+ // app-zone/.justai/expert/how-an-app-zone-icon-is-lit.md — the platform mark is inset, app marks are
38
+ // raised), so wrapping it in a tile states a sibling relationship that is not true.
39
+ //
40
+ // Measured, because it decides the size too: /icon.svg puts its coloured ink across 72% of a 42px box,
41
+ // since the mark sits inset within its own tile. A bare mark spans 98% of the same box. So dropping the
42
+ // tile does not shrink the mark — it renders it about a third larger, which is why nothing here scales it.
43
+ avatarBare?: boolean;
44
+ // The dark-scheme twin of avatarSrc, for a bare mark whose centre has to invert.
45
+ //
46
+ // Two files rather than one file with `@media (prefers-color-scheme)` inside it, and that is a measurement
47
+ // rather than a preference: an SVG referenced by <img> renders in its own document, and the embedding page's
48
+ // scheme did NOT reach it — the centre stayed #2B2724 on a dark feed, where it is all but invisible against
49
+ // the ground. The page's own media query is reliable, so the page picks the file and the file stays dumb.
50
+ avatarSrcDark?: string;
32
51
  }
33
- const { handle, name, footer, displayHandle, avatarBg, avatarBgLight } = Astro.props;
52
+ const { handle, name, footer, displayHandle, avatarBg, avatarBgLight, avatarSrc, avatarBare, avatarSrcDark } = Astro.props;
34
53
  const vars = [
35
54
  avatarBg && `--feed-av-bg:${avatarBg}`,
36
55
  avatarBgLight && `--feed-av-bg-light:${avatarBgLight}`,
@@ -43,6 +62,9 @@ const vars = [
43
62
  data-persona={handle}
44
63
  data-handle={displayHandle ?? handle}
45
64
  data-name={name}
65
+ data-av={avatarSrc ?? "/icon.svg"}
66
+ data-av-dark={avatarSrcDark}
67
+ data-av-bare={avatarBare ? "" : undefined}
46
68
  style={vars || undefined}
47
69
  >
48
70
  <!-- filled at runtime by the loader below (lazy, on Posts-cut intersection) — single source: the console -->
@@ -81,6 +103,22 @@ const vars = [
81
103
  pass avatarBgLight; the rest fall back to their single background. */
82
104
  @media (prefers-color-scheme: light) { .pa, .rav { background: var(--feed-av-bg-light, var(--feed-av-bg, #fff)); } }
83
105
 
106
+ /* A bare mark stands on the feed's own ground, so the tile and its hairline have to go — and they have to
107
+ go from the CONTAINER, which is why this reads upward from the image with :has(). Scoping it to the image
108
+ is what keeps a sibling persona's tiled icon tiled: .rav wraps their reply as well as a self-reply.
109
+ `contain` rather than `cover`, because a mark with transparent margins must not be cropped to fill. */
110
+ .pa:has(.mk.bare), .rav:has(.mk.bare) { background: none; border-color: transparent; }
111
+ .pa .mk.bare, .rav .mk.bare { object-fit: contain; }
112
+ /* The scheme pair: the page decides, because the SVG's own media query does not survive <img>.
113
+ Written as `.pa .mk.av-*` rather than `.av-*` deliberately — `.pa .mk { display: block }` above is two
114
+ classes deep, so a single-class `.av-light { display: none }` loses on specificity and the toggle silently
115
+ does nothing. Measured: it showed the pale-ground file in both schemes until these selectors matched. */
116
+ .pa .mk.av-dark, .rav .mk.av-dark { display: none; }
117
+ @media (prefers-color-scheme: dark) {
118
+ .pa .mk.av-light, .rav .mk.av-light { display: none; }
119
+ .pa .mk.av-dark, .rav .mk.av-dark { display: block; }
120
+ }
121
+
84
122
  .ph { display: flex; align-items: center; gap: 5px; font-size: var(--fs-xs); flex-wrap: wrap; }
85
123
  .ph b { font-weight: 600; }
86
124
  .phandle, .dot, .pt { color: var(--text-dim); font-weight: 400; }
@@ -142,8 +180,19 @@ const vars = [
142
180
 
143
181
  const esc = (s: unknown): string =>
144
182
  String(s ?? "").replace(/[&<>"]/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[c] as string);
145
- // every persona signs its posts with its own /icon.svg (each app serves one at its root)
146
- const AV = `<img class="mk" src="/icon.svg" alt="">`;
183
+ // Every persona signs its posts with its own face, /icon.svg by default (each app serves one at its
184
+ // root). The path is a data attribute rather than a literal because a persona may sign with a mark that
185
+ // has no tile — see avatarSrc / avatarBare above. `bare` rides on the IMAGE, not on the container:
186
+ // .rav wraps both a self-reply and ANOTHER persona's reply, so a container rule would strip the tile
187
+ // from siblings who legitimately have one.
188
+ const bare = section.hasAttribute("data-av-bare") ? " bare" : "";
189
+ const avLight = esc(section.dataset.av || "/icon.svg");
190
+ // When a dark twin is declared, BOTH are in the markup and CSS shows one. The alternative — one <img>
191
+ // whose src is chosen in JS off matchMedia — would be a second source of truth for the same decision and
192
+ // would not follow a scheme change without a listener.
193
+ const AV = section.dataset.avDark
194
+ ? `<img class="mk${bare} av-light" src="${avLight}" alt=""><img class="mk${bare} av-dark" src="${esc(section.dataset.avDark)}" alt="">`
195
+ : `<img class="mk${bare}" src="${avLight}" alt="">`;
147
196
  const ck = `<svg class="ck" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2l2.4 1.8 3 .2.9 2.8 2.3 1.9-1 2.8 1 2.8-2.3 1.9-.9 2.8-3 .2L12 22l-2.4-1.8-3-.2-.9-2.8L3.4 14l1-2.8-1-2.8 2.3-1.9.9-2.8 3-.2z" fill="var(--accent)"/><path d="M9 12.5l2 2 4-4.5" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
148
197
  const pact = `<div class="pact"><span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8.5a5.5 5.5 0 0 0-9-4.2A5.5 5.5 0 0 0 3 8.5c0 5 9 11 9 11s9-6 9-11z"/></svg></span><span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.3 9.6 9.6 0 0 1-4-.9L3 21l1.1-5A8.4 8.4 0 1 1 21 11.5z"/></svg></span></div>`;
149
198