@soffits/dsh-card-board 0.7.1 → 0.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0
4
+
5
+ - Cards keep their own height: the board packs them like masonry (no card stretches to match a neighbour), and fills gaps with shorter cards.
6
+ - Breaking: a board's `layout` gives each card a `size` (`small`, `medium`, `large`, `wide`) instead of `w` and `h`. Without it, a card takes its type's default (summary and timeline wide, countdown large, stat small, the rest medium).
7
+ - A list longer than six rows shows six, then "N more", which opens the rest in place; rows that are new or just changed stay visible.
8
+
3
9
  ## 0.7.1
4
10
 
5
11
  - A countdown step in another zone shows the wall-clock time of its own offset (`…T14:20:00-07:00` reads 14:20), and the zone's short name only when the browser's zone data agrees; otherwise it shows the offset ("GMT−7"). A browser with older zone rules no longer moves a ticket's time by an hour.
package/README.md CHANGED
@@ -77,12 +77,12 @@ Board and card ids are lowercase letters, digits, `-` and `_`, up to 64 characte
77
77
  "title": "Home",
78
78
  "viewers": ["alex", "sam"],
79
79
  "order": ["weather", "savings", "energy"],
80
- "layout": { "next-weeks": { "w": 2, "h": 1 } },
80
+ "layout": { "weather": { "size": "small" }, "energy": { "size": "wide" } },
81
81
  "assistant": "Robin"
82
82
  }
83
83
  ```
84
84
 
85
- `order` lists cards to put first; the rest follow by id. `layout` sets a card's width and height in grid cells (1 to 3). The grid has four columns on a very wide screen, three on a wide one, two on a medium one and one on a phone; a wide card shrinks to fit. `assistant` is optional: the name the chat buttons ask ("Ask Robin" instead of "Ask"). `title` can be [text in several languages](#languages).
85
+ `order` lists cards to put first; the rest follow by id. `layout` sets how wide a card is: `small` (a third of a wide screen), `medium` (a half), `large` (two thirds) or `wide` (all of it). Without it a card takes its type's default: `summary` and `timeline` are wide, `countdown` large, `stat` small, the rest medium; a summary is always wide. On a tablet small and medium cards take half the width and large and wide ones all of it; on a phone every card is full width. Heights are the cards' own: the board packs them like masonry, so a long card never stretches its neighbours and short ones fill the space beside it. A list longer than six rows shows six, then "N more", which opens the rest in place (a row that is new or just changed always shows). `assistant` is optional: the name the chat buttons ask ("Ask Robin" instead of "Ask"). `title` can be [text in several languages](#languages).
86
86
 
87
87
  A card:
88
88
 
package/client.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @soffits/dsh-card-board 0.7.1: built by scripts/build.mjs from src/client/. Do not edit. */
1
+ /* @soffits/dsh-card-board 0.8.0: built by scripts/build.mjs from src/client/. Do not edit. */
2
2
  window.__ModuleLoader__.load({
3
3
  id: "@soffits/dsh-card-board",
4
4
  factory: (require) => {
@@ -41,7 +41,8 @@ var CSS = `
41
41
  .cb-heading h1{margin:0;font-size:20px;font-weight:500;line-height:28px}
42
42
  .cb-sub{margin-top:4px;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px}
43
43
  .cb-tabs{display:flex;flex-wrap:wrap;gap:6px 8px;margin:0 0 18px}
44
- .cb-grid{display:grid;gap:14px;grid-auto-flow:row dense;align-items:stretch}
44
+ .cb-grid{display:grid;row-gap:0;grid-auto-flow:row dense;align-items:start}
45
+ .cb-more{align-self:flex-start;margin-top:2px}
45
46
  .cb-card{container-type:inline-size;box-sizing:border-box;min-width:0;display:flex;flex-direction:column;gap:12px;padding:16px 18px 18px;border-radius:16px;background:var(--dsw-alias-bg-base);box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l2)}
46
47
  .cb-cardHead{display:flex;align-items:center;gap:10px;min-height:28px}
47
48
  .cb-cardHead h3{flex:1;min-width:0;margin:0;font-size:15px;font-weight:600;line-height:22px}
@@ -101,9 +102,12 @@ h3.cb-truncOpen{overflow:visible}
101
102
  .cb-strip li{display:flex;flex-direction:column;align-items:center;gap:3px;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:11px;font-variant-numeric:tabular-nums}
102
103
  .cb-strip b{color:var(--dsw-alias-label-primary);font-size:13px;font-weight:500}
103
104
  .cb-strip li[data-on=true],.cb-strip li[data-on=true] b{color:var(--dsw-alias-state-business-primary)}
105
+ /* a narrow card shows the first hours that fit: 6 under 360 px, 8 under 480 px */
106
+ @container (width<480px){.cb-strip li:nth-child(n+9){display:none}}
107
+ @container (width<360px){.cb-strip li:nth-child(n+7){display:none}}
104
108
  /* a chart card with headline numbers: side by side when there is room */
105
109
  .cb-split{display:flex;flex-direction:column;gap:12px}
106
- @container (width>=640px){.cb-split{display:grid;grid-template-columns:minmax(0,max-content) minmax(0,1fr);align-items:center;gap:28px}.cb-split .cb-stats{display:grid;grid-template-columns:repeat(2,max-content);gap:14px 40px}}
110
+ @container (width>=640px){.cb-split{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);align-items:center;gap:28px}.cb-split .cb-stats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 24px}}
107
111
 
108
112
  /* rows of lists and status cards */
109
113
  .cb-list{display:flex;flex-direction:column;gap:10px}
@@ -690,6 +694,21 @@ function stepTimes(steps, locale, here = Intl.DateTimeFormat().resolvedOptions()
690
694
  });
691
695
  }
692
696
 
697
+ // src/client/layout.js
698
+ var DEFAULT_SIZE = { summary: "wide", countdown: "large", timeline: "wide", stat: "small" };
699
+ var SPAN = { 6: { small: 2, medium: 3, large: 4, wide: 6 }, 2: { small: 1, medium: 1, large: 2, wide: 2 }, 1: {} };
700
+ var ROW = 4;
701
+ var GAP = 14;
702
+ function spanOf(type, size, tracks) {
703
+ const chosen = type === "summary" ? "wide" : size ?? DEFAULT_SIZE[type] ?? "medium";
704
+ return SPAN[tracks]?.[chosen] ?? 1;
705
+ }
706
+ var LIST_ROWS = 6;
707
+ function shownRows(rows, open, limit, live) {
708
+ if (open || rows.length <= limit + 1) return rows;
709
+ return rows.filter((row, i) => i < limit || row.key !== void 0 && (live?.freshRows?.has(row.key) || live?.rows?.[row.key] > 0));
710
+ }
711
+
693
712
  // src/client/cards.js
694
713
  var STATE_OF_TONE = { ok: "done", warn: "warning", bad: "error" };
695
714
  var DIRECTION_ICON = { up: "trending-up", down: "trending-down" };
@@ -762,6 +781,9 @@ function Row({ lead, title, sub, meta, value, spark, row, index, washCount, fres
762
781
  var rowLive = (live, row) => ({ washCount: live.rows?.[row.key] ?? 0, fresh: row.key !== void 0 && live.freshRows.has(row.key) });
763
782
  function ListCard({ data, live, locale, t, rowActions }) {
764
783
  const kit = useKit();
784
+ const [open, setOpen] = (0, import_react5.useState)(false);
785
+ const rows = shownRows(data.rows, open, LIST_ROWS, live);
786
+ const hidden = data.rows.length - rows.length;
765
787
  const checkable = data.rows.some((row) => "checked" in row);
766
788
  const progress = data.progress;
767
789
  return (0, import_react5.createElement)(
@@ -783,7 +805,7 @@ function ListCard({ data, live, locale, t, rowActions }) {
783
805
  progress.sub && (0, import_react5.createElement)("div", { className: "cb-rowSub" }, progress.sub)
784
806
  )
785
807
  ),
786
- data.rows.length === 0 ? (0, import_react5.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react5.createElement)("ul", { className: "cb-rows" }, data.rows.map((row, i) => (0, import_react5.createElement)(Row, {
808
+ data.rows.length === 0 ? (0, import_react5.createElement)("p", { className: "cb-muted" }, data.empty ?? t("listEmpty")) : (0, import_react5.createElement)("ul", { className: "cb-rows" }, rows.map((row, i) => (0, import_react5.createElement)(Row, {
787
809
  key: row.key ?? i,
788
810
  index: i,
789
811
  row,
@@ -801,7 +823,12 @@ function ListCard({ data, live, locale, t, rowActions }) {
801
823
  row.chip && (0, import_react5.createElement)(import_dsh_client_ui_primitives2.Tag, { tone: kit.tagTone(row.chip.tone ?? "muted") }, row.chip.text),
802
824
  (0, import_react5.createElement)(RowWhen, { row, locale, t })
803
825
  )
804
- })))
826
+ }))),
827
+ (hidden > 0 || open) && data.rows.length > LIST_ROWS + 1 && (0, import_react5.createElement)(
828
+ import_dsh_client_ui_primitives2.Button,
829
+ { variant: "ghost", size: "sm", className: "cb-more", onClick: () => setOpen((value) => !value) },
830
+ open ? t("showFewer") : t("showMore", { n: hidden })
831
+ )
805
832
  );
806
833
  }
807
834
  function StatusCard({ data, live, locale, rowActions }) {
@@ -987,15 +1014,28 @@ function useActiveLocale() {
987
1014
  }
988
1015
 
989
1016
  // src/client/card.js
990
- var CHART_HEIGHT = { 1: 150, 2: 360, 3: 560 };
991
- var CHART_HEIGHT_NARROW = { 1: 150, 2: 220, 3: 260 };
1017
+ var CHART_HEIGHT = 150;
1018
+ function useRowSpan() {
1019
+ const ref = (0, import_react7.useRef)(null);
1020
+ const [rows, setRows] = (0, import_react7.useState)(0);
1021
+ (0, import_react7.useLayoutEffect)(() => {
1022
+ const el = ref.current;
1023
+ if (!el || typeof ResizeObserver === "undefined") return void 0;
1024
+ const measure = () => setRows(Math.ceil((el.getBoundingClientRect().height + GAP) / ROW));
1025
+ measure();
1026
+ const observer = new ResizeObserver(measure);
1027
+ observer.observe(el);
1028
+ return () => observer.disconnect();
1029
+ }, []);
1030
+ return [ref, rows];
1031
+ }
992
1032
  var CHARTS = { line: LineChart, bar: BarChart, donut: Donut, timeline: Timeline };
993
1033
  function statesOf(presses, row) {
994
1034
  const states = {};
995
1035
  for (const press of presses ?? []) if (press.row === row) states[press.id] = press.state;
996
1036
  return states;
997
1037
  }
998
- function Body({ card, size, narrow, live, wash, locale, t, rowActions }) {
1038
+ function Body({ card, live, wash, locale, t, rowActions }) {
999
1039
  const data = card.data;
1000
1040
  switch (card.type) {
1001
1041
  case "stat":
@@ -1009,23 +1049,21 @@ function Body({ card, size, narrow, live, wash, locale, t, rowActions }) {
1009
1049
  default: {
1010
1050
  const Chart = CHARTS[card.type];
1011
1051
  if (Chart === void 0) return null;
1012
- const height = (narrow ? CHART_HEIGHT_NARROW : CHART_HEIGHT)[size.h];
1013
- return (0, import_react7.createElement)(Chart, { data, locale, height: card.type === "bar" ? Math.min(height, 130 + (size.h - 1) * 200) : card.type === "donut" ? Math.max(height, 160) : height });
1052
+ return (0, import_react7.createElement)(Chart, { data, locale, height: card.type === "bar" ? 130 : card.type === "donut" ? 160 : CHART_HEIGHT });
1014
1053
  }
1015
1054
  }
1016
1055
  }
1017
- function Card({ entry, live, boardId, assistant, columns, active, locale, t, press }) {
1056
+ function Card({ entry, live, boardId, assistant, tracks, active, locale, t, press }) {
1018
1057
  const kit = useKit();
1019
1058
  const actions = useButtons();
1020
1059
  const now = kit.useNow();
1021
1060
  const wash = kit.useWash(live.wash, entry.id);
1022
- const full = entry.card?.type === "summary";
1023
- const size = { w: full ? columns : Math.min(entry.w ?? 1, columns), h: entry.h ?? 1 };
1024
- const style = { gridColumn: `span ${size.w}`, gridRow: size.h > 1 && columns > 1 && !full ? `span ${size.h}` : void 0 };
1061
+ const [ref, rows] = useRowSpan();
1062
+ const style = { gridColumn: `span ${spanOf(entry.card?.type, entry.size, tracks)}`, gridRowEnd: rows > 0 ? `span ${rows}` : void 0 };
1025
1063
  if (!entry.card) {
1026
1064
  return (0, import_react7.createElement)(
1027
1065
  "section",
1028
- { className: "cb-card cb-cardError", style },
1066
+ { ref, className: "cb-card cb-cardError", style },
1029
1067
  (0, import_react7.createElement)("header", { className: "cb-cardHead" }, (0, import_react7.createElement)("h3", { title: entry.id }, entry.id)),
1030
1068
  (0, import_react7.createElement)("p", { className: "cb-errorText" }, t("cardError")),
1031
1069
  (0, import_react7.createElement)("ul", { className: "cb-problems" }, (entry.problems ?? []).map((p, i) => (0, import_react7.createElement)("li", { key: i }, p)))
@@ -1069,16 +1107,16 @@ function Card({ entry, live, boardId, assistant, columns, active, locale, t, pre
1069
1107
  if (card.type === "summary") {
1070
1108
  return (0, import_react7.createElement)(
1071
1109
  "section",
1072
- { className, style, "data-type": card.type },
1110
+ { ref, className, style, "data-type": card.type },
1073
1111
  (0, import_react7.createElement)("div", { className: "cb-summaryMain" }, (0, import_react7.createElement)(SummaryBody, { card, locale, t, wash: wash !== "" }), steps, footer),
1074
1112
  (0, import_react7.createElement)("div", { className: "cb-summaryAside" }, live.fresh && (0, import_react7.createElement)(kit.NewDot), chat)
1075
1113
  );
1076
1114
  }
1077
1115
  const statBlock = card.stat && (0, import_react7.createElement)(StatBlock, { data: card.stat, locale, compact: true, wash: wash !== "" });
1078
- const body = (0, import_react7.createElement)(Body, { card, size, narrow: columns === 1, live, wash: wash !== "", locale, t, rowActions });
1116
+ const body = (0, import_react7.createElement)(Body, { card, live, wash: wash !== "", locale, t, rowActions });
1079
1117
  return (0, import_react7.createElement)(
1080
1118
  "section",
1081
- { className, style, "data-type": card.type },
1119
+ { ref, className, style, "data-type": card.type },
1082
1120
  (0, import_react7.createElement)(
1083
1121
  "header",
1084
1122
  { className: "cb-cardHead" },
@@ -1152,9 +1190,9 @@ async function getJson(path, etag) {
1152
1190
  }
1153
1191
  var ERROR_KEYS = { 403: "error.forbidden", 404: "error.notFound", 409: "error.gone", 503: "error.noProvider" };
1154
1192
  var errorText = (error, t) => error.status === void 0 ? error.message : t(ERROR_KEYS[error.status] ?? "error.http", { status: error.status });
1155
- function useColumns() {
1193
+ function useTracks() {
1156
1194
  const [ref, width] = useWidth();
1157
- return [ref, width >= 1400 ? 4 : width >= 980 ? 3 : width >= 620 ? 2 : 1];
1195
+ return [ref, width >= 900 ? 6 : width >= 560 ? 2 : 1];
1158
1196
  }
1159
1197
  var visible = () => document.visibilityState === "visible";
1160
1198
  function BoardsPage() {
@@ -1173,7 +1211,7 @@ function BoardsPage() {
1173
1211
  const [boardError, setBoardError] = (0, import_react8.useState)(null);
1174
1212
  const [pollSeconds, setPollSeconds] = (0, import_react8.useState)(30);
1175
1213
  const etag = (0, import_react8.useRef)(null);
1176
- const [gridRef, columns] = useColumns();
1214
+ const [gridRef, tracks] = useTracks();
1177
1215
  const currentRef = (0, import_react8.useRef)(null);
1178
1216
  const translateRef = (0, import_react8.useRef)(t);
1179
1217
  translateRef.current = t;
@@ -1321,8 +1359,8 @@ function BoardsPage() {
1321
1359
  board.cards.length === 0 && (0, import_react8.createElement)("p", { className: "cb-muted" }, t("noCards")),
1322
1360
  (0, import_react8.createElement)(
1323
1361
  "div",
1324
- { className: "cb-grid", style: { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` } },
1325
- board.cards.map((entry) => (0, import_react8.createElement)(Card, { key: entry.id, entry, live: liveOf(view.live, entry.id), boardId: board.id, assistant: board.assistant, columns, active, locale, t, press }))
1362
+ { className: "cb-grid", style: { gridTemplateColumns: `repeat(${tracks}, minmax(0, 1fr))`, gridAutoRows: `${ROW}px`, columnGap: GAP } },
1363
+ board.cards.map((entry) => (0, import_react8.createElement)(Card, { key: entry.id, entry, live: liveOf(view.live, entry.id), boardId: board.id, assistant: board.assistant, tracks, active, locale, t, press }))
1326
1364
  )
1327
1365
  );
1328
1366
  return (0, import_react8.createElement)(
@@ -19,17 +19,14 @@
19
19
  "house"
20
20
  ],
21
21
  "layout": {
22
- "savings": {
23
- "w": 1,
24
- "h": 1
22
+ "weather": {
23
+ "size": "small"
25
24
  },
26
- "next-weeks": {
27
- "w": 2,
28
- "h": 1
25
+ "energy": {
26
+ "size": "medium"
29
27
  },
30
- "countdown": {
31
- "w": 2,
32
- "h": 1
28
+ "spending": {
29
+ "size": "medium"
33
30
  }
34
31
  }
35
32
  }
package/locale/en.json CHANGED
@@ -34,6 +34,8 @@
34
34
  "dayPart.morning": "morning",
35
35
  "dayPart.afternoon": "afternoon",
36
36
  "dayPart.evening": "evening",
37
- "dayPart.night": "night"
37
+ "dayPart.night": "night",
38
+ "showMore": "{n} more",
39
+ "showFewer": "Show fewer"
38
40
  }
39
41
  }
package/locale/fr.json CHANGED
@@ -34,6 +34,8 @@
34
34
  "dayPart.morning": "matin",
35
35
  "dayPart.afternoon": "après-midi",
36
36
  "dayPart.evening": "soir",
37
- "dayPart.night": "nuit"
37
+ "dayPart.night": "nuit",
38
+ "showMore": "{n} de plus",
39
+ "showFewer": "Afficher moins"
38
40
  }
39
41
  }
package/locale/zh.json CHANGED
@@ -34,6 +34,8 @@
34
34
  "dayPart.morning": "上午",
35
35
  "dayPart.afternoon": "下午",
36
36
  "dayPart.evening": "傍晚",
37
- "dayPart.night": "夜里"
37
+ "dayPart.night": "夜里",
38
+ "showMore": "还有 {n} 项",
39
+ "showFewer": "收起"
38
40
  }
39
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soffits/dsh-card-board",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "A data-driven card board for DeepSeek Harness: scripts write small JSON cards, the Web UI shows each person the boards they may see.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/schema.js CHANGED
@@ -8,6 +8,9 @@
8
8
  * fails at write time instead of quietly not showing.
9
9
  */
10
10
 
11
+ /** How wide a card is on the board: a third, a half, two thirds or the whole width (on a wide screen). */
12
+ export const SIZES = Object.freeze(['small', 'medium', 'large', 'wide'])
13
+
11
14
  export const CARD_TYPES = Object.freeze(['summary', 'countdown', 'stat', 'line', 'bar', 'donut', 'list', 'timeline', 'status'])
12
15
  export const TONES = Object.freeze(['ok', 'warn', 'bad', 'muted', 'accent', 'violet'])
13
16
  /** Icon names: the page draws the ones its icon set has (Lucide names) and nothing for the rest. */
@@ -533,9 +536,8 @@ export function checkBoard(board) {
533
536
  for (const [id, size] of Object.entries(layout)) {
534
537
  const p = join('layout', id)
535
538
  if (!ID_PATTERN.test(id)) c.fail(p, 'is not a card id')
536
- if (!c.object(size, p, [], ['w', 'h'])) continue
537
- c.optional(size, 'w', v => (Number.isInteger(v) && v >= 1 && v <= 3) || c.fail(join(p, 'w'), 'must be 1, 2 or 3'))
538
- c.optional(size, 'h', v => (Number.isInteger(v) && v >= 1 && v <= 3) || c.fail(join(p, 'h'), 'must be 1, 2 or 3'))
539
+ if (!c.object(size, p, [], ['size'])) continue
540
+ c.optional(size, 'size', v => SIZES.includes(v) || c.fail(join(p, 'size'), `must be one of ${SIZES.join(', ')}`))
539
541
  }
540
542
  })
541
543
  return c.problems
package/src/store.js CHANGED
@@ -147,7 +147,7 @@ export async function readCards(root, id, board, only) {
147
147
  const cards = []
148
148
  const ids = await cardFiles(root, id, board?.order)
149
149
  for (const card of only === undefined ? ids : ids.filter(card => card === only)) {
150
- const size = { w: layout[card]?.w ?? 1, h: layout[card]?.h ?? 1 }
150
+ const size = layout[card]?.size ? { size: layout[card].size } : {}
151
151
  const result = await readJson(root, join(root, id, 'cards', `${card}.json`), MAX_CARD_BYTES, checkCard)
152
152
  cards.push(result.problems.length > 0 ? { id: card, ...size, problems: result.problems.slice(0, 5) } : { id: card, ...size, card: result.value })
153
153
  }