@purview-dev/pm-docs-site 0.1.0-pre.1 → 0.1.0-pre.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.
Files changed (47) hide show
  1. package/README.md +63 -11
  2. package/dist/cli.d.ts +2 -0
  3. package/dist/cli.js +90 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +118 -0
  6. package/dist/options.d.ts +5 -0
  7. package/dist/options.js +46 -0
  8. package/dist/repo-docs.d.ts +33 -0
  9. package/dist/repo-docs.js +94 -0
  10. package/dist/schema-version.d.ts +10 -0
  11. package/dist/schema-version.js +19 -0
  12. package/dist/sidebar.d.ts +10 -0
  13. package/dist/sidebar.js +30 -0
  14. package/dist/site-options.d.ts +9 -0
  15. package/dist/site-options.js +39 -0
  16. package/dist/types.d.ts +47 -0
  17. package/dist/types.js +4 -0
  18. package/lib/{repo-docs.mjs → repo-docs.ts} +22 -46
  19. package/lib/{schema-version.mjs → schema-version.ts} +4 -9
  20. package/package.json +14 -8
  21. package/src/components/PlanInteractions.astro +15 -3
  22. package/src/components/board/Board.tsx +244 -0
  23. package/src/components/board/KanbanItemCard.tsx +129 -0
  24. package/src/components/board/LinkRuns.tsx +21 -0
  25. package/src/components/board/TaskKanbanCard.tsx +81 -0
  26. package/src/components/board/useBoardUrlState.ts +41 -0
  27. package/src/components/timeline/Timeline.tsx +159 -0
  28. package/src/components/timeline/useTimelineLayout.ts +39 -0
  29. package/src/env.d.ts +2 -2
  30. package/src/lib/board-data.ts +84 -0
  31. package/src/lib/board.ts +209 -0
  32. package/src/lib/planning.ts +66 -38
  33. package/src/lib/references.ts +1 -1
  34. package/src/lib/timeline.ts +156 -0
  35. package/src/loaders/repo-docs.ts +3 -3
  36. package/src/pages/plan/board.astro +14 -113
  37. package/src/pages/plan/roadmap.astro +20 -2
  38. package/src/scripts/plan.ts +3 -49
  39. package/src/styles/components.css +127 -10
  40. package/src/styles/kanban.css +277 -0
  41. package/src/styles/timeline.css +210 -0
  42. package/cli.mjs +0 -120
  43. package/index.d.ts +0 -49
  44. package/index.mjs +0 -97
  45. package/lib/options.mjs +0 -67
  46. package/lib/sidebar.mjs +0 -47
  47. package/lib/site-options.mjs +0 -38
@@ -0,0 +1,47 @@
1
+ /** An optional plan view. Home, Board, Roadmap, Log and Risks are always on. */
2
+ export type ViewName = 'now' | 'milestones' | 'features' | 'inbox' | 'briefs' | 'strategy';
3
+ /** One folder of repository Markdown, shown as one sidebar group. */
4
+ export interface DocsSource {
5
+ /** The sidebar group for this source's pages. */
6
+ label: string;
7
+ /** The folder to read, relative to the docs root (`.` for the root). */
8
+ base: string;
9
+ /** Files to read, as globs relative to `base` (`*` within a folder, `**` across folders). */
10
+ include: string[];
11
+ /** Prepended to each page's path to make its URL. Default: none. */
12
+ prefix?: string;
13
+ /** A file name that stands for its folder, such as `SKILL.md` or `README.md`. */
14
+ indexFile?: string;
15
+ /** Sidebar order by page path. Default: `asc`. */
16
+ order?: 'asc' | 'desc';
17
+ collapsed?: boolean;
18
+ /** Load the pages without listing them in the sidebar. */
19
+ hidden?: boolean;
20
+ }
21
+ export interface PmDocsSiteOptions {
22
+ /** The site title. */
23
+ title: string;
24
+ description?: string;
25
+ /** The pm-export file, relative to the site root. Default: `../planning/planning.json`. */
26
+ planning?: string;
27
+ /** Repository Markdown to render as pages; `root` is relative to the site root. Default: none. */
28
+ docs?: {
29
+ root: string;
30
+ sources: DocsSource[];
31
+ };
32
+ /** The optional views to render. Default: all six. */
33
+ views?: ViewName[];
34
+ }
35
+ /** The options with defaults applied and every path absolute. */
36
+ export interface ResolvedOptions {
37
+ title: string;
38
+ description: string | null;
39
+ planning: string;
40
+ /** The export path as the options wrote it, `/`-separated: shown on pages instead of the machine path. */
41
+ planningLabel: string;
42
+ docs: {
43
+ root: string;
44
+ sources: DocsSource[];
45
+ } | null;
46
+ views: Record<ViewName, boolean>;
47
+ }
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ // The integration's option types, re-exported by index.ts. A separate module
2
+ // so the other lib/ modules and src/ can import them without importing the
3
+ // integration itself.
4
+ export {};
@@ -1,8 +1,7 @@
1
- // @ts-check
2
1
  // Repository Markdown as pages: which files a docs source matches, their page
3
- // IDs, and each page's title and body. Plain JavaScript because the sidebar is
4
- // built from it while astro.config.mjs loads; the Astro loader in
5
- // src/loaders/repo-docs.ts uses the same functions.
2
+ // IDs, and each page's title and body. Node-loadable (no Astro or Vite import)
3
+ // because the sidebar is built from it while astro.config loads; the Astro
4
+ // loader in src/loaders/repo-docs.ts uses the same functions.
6
5
  //
7
6
  // Starlight requires a `title` in every page's frontmatter; repository Markdown
8
7
  // rarely has one. The title is frontmatter `title`, else the first `# Title`
@@ -12,15 +11,15 @@
12
11
  import { existsSync, readdirSync } from 'node:fs';
13
12
  import { basename, dirname, join, resolve, sep } from 'node:path';
14
13
 
15
- /** @typedef {import('../index').DocsSource} DocsSource */
16
- /** @typedef {{ id: string; file: string }} DocsPage */
14
+ import type { DocsSource } from './types.ts';
17
15
 
18
- /**
19
- * A glob as a regular expression over `/`-separated paths.
20
- * @param {string} glob
21
- * @returns {RegExp}
22
- */
23
- export function globToRegExp(glob) {
16
+ export interface DocsPage {
17
+ id: string;
18
+ file: string;
19
+ }
20
+
21
+ /** A glob as a regular expression over `/`-separated paths. */
22
+ export function globToRegExp(glob: string): RegExp {
24
23
  const pattern = glob
25
24
  .split(/(\*\*\/|\*\*|\*)/)
26
25
  .map((part) =>
@@ -31,13 +30,8 @@ export function globToRegExp(glob) {
31
30
  return new RegExp(`^${pattern}$`, 'i');
32
31
  }
33
32
 
34
- /**
35
- * The page ID (and URL path) for a file: prefix, path without `.md`, lower case.
36
- * @param {DocsSource} source
37
- * @param {string} path
38
- * @returns {string}
39
- */
40
- export function pageId(source, path) {
33
+ /** The page ID (and URL path) for a file: prefix, path without `.md`, lower case. */
34
+ export function pageId(source: DocsSource, path: string): string {
41
35
  let page = path.replace(/\.md$/i, '');
42
36
 
43
37
  if (source.indexFile && basename(path).toLowerCase() === source.indexFile.toLowerCase()) {
@@ -47,19 +41,14 @@ export function pageId(source, path) {
47
41
  return `${source.prefix ?? ''}${page}`.toLowerCase();
48
42
  }
49
43
 
50
- /**
51
- * Every file a source matches, as page IDs in its sidebar order.
52
- * @param {DocsSource} source
53
- * @param {string} repoRoot
54
- * @returns {DocsPage[]}
55
- */
56
- export function pagesOf(source, repoRoot) {
44
+ /** Every file a source matches, as page IDs in its sidebar order. */
45
+ export function pagesOf(source: DocsSource, repoRoot: string): DocsPage[] {
57
46
  const base = resolve(repoRoot, source.base);
58
47
 
59
48
  if (!existsSync(base)) return [];
60
49
 
61
50
  const patterns = source.include.map(globToRegExp);
62
- const pages = /** @type {string[]} */ (readdirSync(base, { recursive: true }))
51
+ const pages = (readdirSync(base, { recursive: true }) as string[])
63
52
  .map((file) => file.split(sep).join('/'))
64
53
  .filter((file) => !file.split('/').includes('node_modules') && patterns.some((pattern) => pattern.test(file)))
65
54
  .map((file) => ({ id: pageId(source, file), file: join(base, file) }))
@@ -68,18 +57,13 @@ export function pagesOf(source, repoRoot) {
68
57
  return source.order === 'desc' ? pages.reverse() : pages;
69
58
  }
70
59
 
71
- /**
72
- * Simple `key: value` frontmatter (one line per key) and the body after it.
73
- * @param {string} markdown
74
- * @returns {{ data: Record<string, string>; body: string }}
75
- */
76
- export function splitFrontmatter(markdown) {
60
+ /** Simple `key: value` frontmatter (one line per key) and the body after it. */
61
+ export function splitFrontmatter(markdown: string): { data: Record<string, string>; body: string } {
77
62
  const match = /^---\n([\s\S]*?)\n---\n?/.exec(markdown);
78
63
 
79
64
  if (!match) return { data: {}, body: markdown };
80
65
 
81
- /** @type {Record<string, string>} */
82
- const data = {};
66
+ const data: Record<string, string> = {};
83
67
 
84
68
  for (const line of (match[1] ?? '').split('\n')) {
85
69
  const pair = /^([\w-]+):\s*(.*?)\s*$/.exec(line);
@@ -96,11 +80,8 @@ export function splitFrontmatter(markdown) {
96
80
  * The title is the first `# ` heading when nothing but blank lines and HTML
97
81
  * comments come before it; otherwise the fallback is the title and the body is
98
82
  * kept whole.
99
- * @param {string} markdown
100
- * @param {string} fallback
101
- * @returns {{ title: string; body: string }}
102
83
  */
103
- export function splitTitle(markdown, fallback) {
84
+ export function splitTitle(markdown: string, fallback: string): { title: string; body: string } {
104
85
  const lines = markdown.split('\n');
105
86
  let index = 0;
106
87
  let inComment = false;
@@ -133,13 +114,8 @@ export function splitTitle(markdown, fallback) {
133
114
  return { title: heading[1], body: lines.slice(start).join('\n') };
134
115
  }
135
116
 
136
- /**
137
- * Title, description, and body for one page.
138
- * @param {string} markdown
139
- * @param {string} file
140
- * @returns {{ title: string; description?: string; body: string }}
141
- */
142
- export function readPage(markdown, file) {
117
+ /** Title, description, and body for one page. */
118
+ export function readPage(markdown: string, file: string): { title: string; description?: string; body: string } {
143
119
  const { data, body } = splitFrontmatter(markdown);
144
120
  const fallback = data.name ?? basename(file, '.md');
145
121
  const split = data.title ? { title: data.title, body } : splitTitle(body, fallback);
@@ -1,14 +1,11 @@
1
- // @ts-check
2
1
  // The pm-export schemaVersions this package reads, declared once. A new export
3
2
  // format is supported by adding its version here, with the page changes it needs.
4
3
 
5
- /** @type {readonly number[]} */
6
- export const SUPPORTED_SCHEMA_VERSIONS = Object.freeze([3]);
4
+ export const SUPPORTED_SCHEMA_VERSIONS: readonly number[] = Object.freeze([3]);
7
5
 
8
6
  /** The plan export is missing, unreadable, or in a format this package does not read. */
9
7
  export class PlanningExportError extends Error {
10
- /** @param {string} message */
11
- constructor(message) {
8
+ constructor(message: string) {
12
9
  super(`${message} Run the pm-export skill to write planning.json.`);
13
10
  this.name = 'PlanningExportError';
14
11
  }
@@ -16,11 +13,9 @@ export class PlanningExportError extends Error {
16
13
 
17
14
  /**
18
15
  * Throw unless the export's schemaVersion is one this package reads.
19
- * @param {unknown} version
20
- * @param {string} path the export's path, for the message
21
- * @returns {void}
16
+ * @param path the export's path, for the message
22
17
  */
23
- export function checkSchemaVersion(version, path) {
18
+ export function checkSchemaVersion(version: unknown, path: string): void {
24
19
  if (typeof version === 'number' && SUPPORTED_SCHEMA_VERSIONS.includes(version)) return;
25
20
 
26
21
  throw new PlanningExportError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@purview-dev/pm-docs-site",
3
- "version": "0.1.0-pre.1",
3
+ "version": "0.1.0-pre.2",
4
4
  "type": "module",
5
5
  "description": "A local, searchable project site for pm-skills: the board, roadmap, milestones, features, log, and risks from pm-export's planning.json, with the repository's Markdown, as an Astro and Starlight integration.",
6
6
  "license": "MIT",
@@ -32,32 +32,38 @@
32
32
  "access": "public"
33
33
  },
34
34
  "engines": {
35
- "node": ">=22"
35
+ "node": ">=24"
36
36
  },
37
37
  "bin": {
38
- "pm-docs-site": "./cli.mjs"
38
+ "pm-docs-site": "./dist/cli.js"
39
39
  },
40
40
  "exports": {
41
41
  ".": {
42
- "types": "./index.d.ts",
43
- "default": "./index.mjs"
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
44
  }
45
45
  },
46
- "files": ["index.mjs", "index.d.ts", "cli.mjs", "lib", "src", "README.md", "LICENSE.md"],
46
+ "files": ["dist", "src", "lib/repo-docs.ts", "lib/schema-version.ts", "README.md", "LICENSE.md"],
47
47
  "scripts": {
48
- "prepublishOnly": "node scripts/check-exports.mjs",
48
+ "build": "node scripts/build.ts",
49
+ "prepack": "node scripts/build.ts && node scripts/check-exports.ts",
49
50
  "test": "bun test",
50
51
  "check": "astro-check --root .",
51
52
  "test:browser": "playwright test"
52
53
  },
53
54
  "dependencies": {
55
+ "@astrojs/react": "7.1.9",
54
56
  "@astrojs/starlight": "0.42.10",
55
- "astro": "7.4.8"
57
+ "astro": "7.4.8",
58
+ "react": "19.3.1",
59
+ "react-dom": "19.3.1"
56
60
  },
57
61
  "devDependencies": {
58
62
  "@astrojs/check": "0.9.12",
59
63
  "@playwright/test": "1.65.1",
60
64
  "@types/bun": "1.4.4",
65
+ "@types/react": "19.3.0",
66
+ "@types/react-dom": "19.3.0",
61
67
  "typescript": "6.0.3"
62
68
  }
63
69
  }
@@ -1,7 +1,9 @@
1
1
  ---
2
- // The Board's and Roadmap's client script (src/scripts/plan.ts). The inline
3
- // part runs as the page is parsed, before the columns paint, so a collapsed
4
- // column never flashes open; it must stay in step with STORAGE_KEY there.
2
+ // The Board's and Roadmap's client script (src/scripts/plan.ts, the item
3
+ // popup). The inline part runs as the page is parsed, before the Board's
4
+ // columns paint, so a collapsed column never flashes open and a filtered link
5
+ // never shows the unfiltered board; it must stay in step with STORAGE_KEY in
6
+ // src/components/board/Board.tsx and the URL keys in src/lib/board.ts.
5
7
  ---
6
8
 
7
9
  <script is:inline>
@@ -12,6 +14,16 @@
12
14
  } catch {
13
15
  // Junk or no storage: every column stays open.
14
16
  }
17
+
18
+ // A board key in the URL: hide the Board's body until the island has
19
+ // rendered that state and deleted the mark (useBoardUrlState.ts), so a
20
+ // filtered link never shows the unfiltered board first.
21
+ // A block, so the binding stays out of the page's global scope.
22
+ {
23
+ const params = new URLSearchParams(location.search);
24
+
25
+ if (['owner', 'milestone', 'size', 'rag', 'group'].some((key) => params.has(key))) document.documentElement.dataset.boardPending = '';
26
+ }
15
27
  </script>
16
28
  <script>
17
29
  import '../scripts/plan.ts';
@@ -0,0 +1,244 @@
1
+ // The Board island: the filter bar, the five column headers with their
2
+ // collapse toggles, and the cards in lanes, in one CSS grid (.plan-columns in
3
+ // board.astro, components.css). It is server-rendered, so without JavaScript
4
+ // every card shows and the filter bar stays hidden. The item popup is not
5
+ // here: a card's title keeps `a.plan-item-link[data-item]`, which
6
+ // src/scripts/plan.ts opens from the page's ItemDetail templates. The filter
7
+ // and group state lives in the URL (useBoardUrlState.ts); `.plan-board__body`
8
+ // (the header row and the lanes) is hidden while <html> has the pending mark.
9
+ import { useEffect, useState } from 'react';
10
+
11
+ import { COLUMNS, DEFAULT_STATE, isFiltered, lanes, matches } from '../../lib/board';
12
+ import type { BoardCard, BoardFilters, ColumnName, GroupBy } from '../../lib/board';
13
+ import KanbanItemCard from './KanbanItemCard';
14
+ import TaskKanbanCard from './TaskKanbanCard';
15
+ import { useBoardUrlState } from './useBoardUrlState';
16
+
17
+ interface Props {
18
+ cards: BoardCard[];
19
+ milestones: { id: string; name: string }[];
20
+ }
21
+
22
+ /** Collapsed columns: the key the inline pre-paint script in PlanInteractions.astro also reads. */
23
+ const STORAGE_KEY = 'pm-docs-site:board:collapsed';
24
+
25
+ /** The collapsed column names in storage; junk or no storage is none. */
26
+ function readCollapsed(): Set<string> {
27
+ try {
28
+ const value: unknown = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '[]');
29
+
30
+ return new Set(Array.isArray(value) ? value.filter((name): name is string => typeof name === 'string') : []);
31
+ } catch {
32
+ return new Set();
33
+ }
34
+ }
35
+
36
+ function writeCollapsed(names: ReadonlySet<string>): void {
37
+ try {
38
+ localStorage.setItem(STORAGE_KEY, JSON.stringify([...names]));
39
+ } catch {
40
+ // No storage (private mode, a blocked origin): the state lasts until the page closes.
41
+ }
42
+ }
43
+
44
+ /** The root attribute the collapse CSS reads (components.css). */
45
+ function applyCollapsed(names: ReadonlySet<string>): void {
46
+ document.documentElement.dataset.boardCollapsed = [...names].join(' ');
47
+ }
48
+
49
+ /** The id of a column's cell in a lane: `col-x-cards` in the ungrouped lane, `col-x-cards-<lane>` otherwise. */
50
+ function cellId(column: ColumnName, lane: string): string {
51
+ return lane === 'all' ? `col-${column}-cards` : `col-${column}-cards-${lane}`;
52
+ }
53
+
54
+ function Card({ card }: { card: BoardCard }) {
55
+ return (
56
+ <div data-card={card.key} data-owner={card.owner ?? 'none'} data-milestone={card.milestone ?? 'none'} data-size={card.size ?? 'none'} data-rag={card.rag}>
57
+ {card.column === 'now' ? (
58
+ <TaskKanbanCard
59
+ task={card.title}
60
+ taskRuns={card.titleRuns}
61
+ date={card.started ?? ''}
62
+ assigneeInitials={card.initials}
63
+ size={card.size}
64
+ rag={card.rag}
65
+ progress={card.progress ?? 0}
66
+ href={card.href}
67
+ itemId={card.id}
68
+ />
69
+ ) : (
70
+ <KanbanItemCard
71
+ title={card.title}
72
+ titleRuns={card.titleRuns}
73
+ size={card.size}
74
+ rag={card.rag}
75
+ tag={card.tag}
76
+ tagHref={card.tagHref}
77
+ assignee={card.initials}
78
+ detail={card.detail}
79
+ href={card.href}
80
+ itemId={card.id}
81
+ />
82
+ )}
83
+ </div>
84
+ );
85
+ }
86
+
87
+ interface FilterProps {
88
+ id: string;
89
+ label: string;
90
+ value: string | null;
91
+ options: { value: string; label: string }[];
92
+ onChange: (value: string | null) => void;
93
+ }
94
+
95
+ function Filter({ id, label, value, options, onChange }: FilterProps) {
96
+ return (
97
+ <div className="plan-board__filter">
98
+ <label htmlFor={id}>{label}</label>
99
+ <select id={id} value={value ?? ''} onChange={(event) => onChange(event.target.value === '' ? null : event.target.value)}>
100
+ <option value="">All</option>
101
+ {options.map((option) => (
102
+ <option key={option.value} value={option.value}>
103
+ {option.label}
104
+ </option>
105
+ ))}
106
+ </select>
107
+ </div>
108
+ );
109
+ }
110
+
111
+ const GROUPS: { value: GroupBy; label: string }[] = [
112
+ { value: 'none', label: 'None' },
113
+ { value: 'milestone', label: 'Milestone' },
114
+ { value: 'owner', label: 'Owner' },
115
+ ];
116
+
117
+ export default function Board({ cards, milestones }: Props) {
118
+ const [state, setState, hydrated] = useBoardUrlState(milestones.map((milestone) => milestone.id));
119
+ const [collapsed, setCollapsed] = useState<ReadonlySet<string>>(() => new Set());
120
+
121
+ useEffect(() => {
122
+ const stored = readCollapsed();
123
+
124
+ applyCollapsed(stored);
125
+ setCollapsed(stored);
126
+ }, []);
127
+
128
+ const toggle = (name: ColumnName) => {
129
+ const next = new Set(collapsed);
130
+
131
+ if (next.has(name)) next.delete(name);
132
+ else next.add(name);
133
+ writeCollapsed(next);
134
+ applyCollapsed(next);
135
+ setCollapsed(next);
136
+ };
137
+
138
+ const setFilter = (key: keyof BoardFilters) => (value: string | null) => setState((current) => ({ ...current, filters: { ...current.filters, [key]: value } }));
139
+
140
+ const visible = cards.filter((card) => matches(card, state.filters));
141
+ const filtered = isFiltered(state);
142
+ const grouped = state.group !== 'none';
143
+ // Clear resets every filter and the grouping, so it is live while either is set.
144
+ const rows = lanes(visible, state.group, milestones);
145
+
146
+ return (
147
+ <>
148
+ <div className="plan-board__filters" hidden={!hydrated}>
149
+ <Filter
150
+ id="board-owner"
151
+ label="Owner"
152
+ value={state.filters.owner}
153
+ options={[
154
+ { value: 'agent', label: 'agent' },
155
+ { value: 'user', label: 'user' },
156
+ { value: 'both', label: 'both' },
157
+ ]}
158
+ onChange={setFilter('owner')}
159
+ />
160
+ <Filter
161
+ id="board-milestone"
162
+ label="Milestone"
163
+ value={state.filters.milestone}
164
+ options={[...milestones.map((milestone) => ({ value: milestone.id, label: `${milestone.id} ${milestone.name}` })), { value: 'none', label: 'No milestone' }]}
165
+ onChange={setFilter('milestone')}
166
+ />
167
+ <Filter
168
+ id="board-size"
169
+ label="Size"
170
+ value={state.filters.size}
171
+ options={[
172
+ { value: 'S', label: 'S' },
173
+ { value: 'M', label: 'M' },
174
+ { value: 'L', label: 'L' },
175
+ ]}
176
+ onChange={setFilter('size')}
177
+ />
178
+ <Filter
179
+ id="board-rag"
180
+ label="RAG"
181
+ value={state.filters.rag}
182
+ options={[
183
+ { value: 'red', label: 'red' },
184
+ { value: 'amber', label: 'amber' },
185
+ { value: 'green', label: 'green' },
186
+ { value: 'none', label: 'No risk' },
187
+ ]}
188
+ onChange={setFilter('rag')}
189
+ />
190
+ <div className="plan-board__filter">
191
+ <label htmlFor="board-group">Group by</label>
192
+ <select id="board-group" value={state.group} onChange={(event) => setState((current) => ({ ...current, group: event.target.value as GroupBy }))}>
193
+ {GROUPS.map((group) => (
194
+ <option key={group.value} value={group.value}>
195
+ {group.label}
196
+ </option>
197
+ ))}
198
+ </select>
199
+ </div>
200
+ <button type="button" id="board-clear" className="plan-board__clear" disabled={!filtered && !grouped} onClick={() => setState(DEFAULT_STATE)}>
201
+ Clear
202
+ </button>
203
+ </div>
204
+
205
+ <div className="plan-board__body">
206
+ {COLUMNS.map(({ name, title }) => {
207
+ const shut = collapsed.has(name);
208
+
209
+ return (
210
+ <section key={name} className={grouped ? 'plan-column' : 'plan-column plan-column--joined'} data-column={name} data-collapsed={shut ? '' : undefined} aria-labelledby={`col-${name}`}>
211
+ <h2 id={`col-${name}`}>
212
+ <button type="button" className="plan-column__toggle" aria-expanded={!shut} aria-controls={rows.map((lane) => cellId(name, lane.key)).join(' ')} onClick={() => toggle(name)}>
213
+ <span className="plan-column__name">{title}</span> <span className="plan-column__count">{visible.filter((card) => card.column === name).length}</span>
214
+ </button>
215
+ </h2>
216
+ </section>
217
+ );
218
+ })}
219
+
220
+ {rows.map((lane) => (
221
+ <div key={lane.key} className="plan-lane" data-lane={lane.key}>
222
+ {grouped && (
223
+ <div className="plan-lane__header">
224
+ <span className="plan-lane__name">{lane.label}</span> <span className="plan-lane__count">{lane.cards.length}</span>
225
+ </div>
226
+ )}
227
+ {COLUMNS.map(({ name }) => {
228
+ const inCell = lane.cards.filter((card) => card.column === name);
229
+
230
+ return (
231
+ <div key={name} className="plan-column__cards" data-lane-column={name} id={cellId(name, lane.key)}>
232
+ {!grouped && inCell.length === 0 && <p className="plan-empty">{filtered ? 'Nothing matches' : 'Nothing here'}</p>}
233
+ {inCell.map((card) => (
234
+ <Card key={card.key} card={card} />
235
+ ))}
236
+ </div>
237
+ );
238
+ })}
239
+ </div>
240
+ ))}
241
+ </div>
242
+ </>
243
+ );
244
+ }
@@ -0,0 +1,129 @@
1
+ /**
2
+ * KanbanItemCard — Polished agile kanban ticket with priority pill, assignee avatar, attachment count, and comment indicators.
3
+ *
4
+ * From the Astro Components Kit by Konstantin (https://astrocomponents.dev/docs/kanban-item-card/,
5
+ * https://github.com/konstantinWDK/astro-components), MIT License. Ported to React from its
6
+ * manual-install source (via ../lib/KanbanItemCard.astro); the changes are that hard-coded
7
+ * dark-theme colours use Starlight theme variables, so the card reads in light and dark themes;
8
+ * the title (and tag) can be a link, for the site's item popup and backlinks (href, itemId,
9
+ * tagHref), and the due-date line (and a title that is not a link) links known IDs; the pill
10
+ * shows the item's size (S, M, L in the kit's low, medium, high colours) and is omitted without
11
+ * one; a RAG dot sits beside it; the assignee chip is omitted for a card with no owner; and the
12
+ * card is not focusable and has no role. Its styles are in src/styles/kanban.css.
13
+ */
14
+ import type { CardRag, LinkRun } from '../../lib/board';
15
+ import type { Size } from '../../lib/planning-types';
16
+ import LinkRuns from './LinkRuns';
17
+
18
+ interface Props {
19
+ title: string;
20
+ titleRuns: LinkRun[];
21
+ size: Size | null;
22
+ rag: CardRag;
23
+ tag: string;
24
+ tagHref: string | null;
25
+ /** Null with no owner: no chip, as the owner filter hides the card. */
26
+ assignee: string | null;
27
+ detail: LinkRun[];
28
+ commentsCount?: number;
29
+ attachmentsCount?: number;
30
+ href: string | null;
31
+ itemId: string | null;
32
+ }
33
+
34
+ /** The kit's low, medium, and high pill colours, by size. */
35
+ const sizeMap: Record<Size, { color: string; bg: string }> = {
36
+ S: { color: '#059669', bg: 'rgba(16, 185, 129, 0.12)' },
37
+ M: { color: '#d97706', bg: 'rgba(245, 158, 11, 0.12)' },
38
+ L: { color: '#dc2626', bg: 'rgba(239, 68, 68, 0.12)' },
39
+ };
40
+
41
+ const iconProps = {
42
+ className: 'k-item__icon',
43
+ width: 13,
44
+ height: 13,
45
+ viewBox: '0 0 24 24',
46
+ fill: 'none',
47
+ stroke: 'currentColor',
48
+ strokeWidth: 2,
49
+ strokeLinecap: 'round',
50
+ strokeLinejoin: 'round',
51
+ 'aria-hidden': true,
52
+ } as const;
53
+
54
+ export default function KanbanItemCard({ title, titleRuns, size, rag, tag, tagHref, assignee, detail, commentsCount = 0, attachmentsCount = 0, href, itemId }: Props) {
55
+ const pill = size ? sizeMap[size] : null;
56
+
57
+ return (
58
+ <div className="k-item">
59
+ <div className="k-item__head">
60
+ {tagHref ? (
61
+ <a className="k-item__tag" href={tagHref}>
62
+ {tag}
63
+ </a>
64
+ ) : (
65
+ <span className="k-item__tag">{tag}</span>
66
+ )}
67
+ {(pill || rag !== 'none') && (
68
+ <span className="k-item__badges">
69
+ {pill && (
70
+ <span className="k-item__priority" title={`Size ${size}`} style={{ color: pill.color, background: pill.bg, borderColor: `${pill.color}33` }}>
71
+ <span className="k-item__priority-dot" style={{ background: pill.color }}></span>
72
+ {size}
73
+ </span>
74
+ )}
75
+ {rag !== 'none' && <span className="k-item__rag" data-rag={rag} role="img" aria-label={`RAG ${rag}`}></span>}
76
+ </span>
77
+ )}
78
+ </div>
79
+
80
+ <h4 className="k-item__title">
81
+ {href ? (
82
+ <a className="plan-item-link" href={href} data-item={itemId ?? undefined}>
83
+ {title}
84
+ </a>
85
+ ) : (
86
+ <LinkRuns runs={titleRuns} />
87
+ )}
88
+ </h4>
89
+
90
+ <div className="k-item__footer">
91
+ <div className="k-item__meta">
92
+ <div className="k-item__meta-item" title="Due Date">
93
+ <svg {...iconProps}>
94
+ <circle cx="12" cy="12" r="10"></circle>
95
+ <polyline points="12 6 12 12 16 14"></polyline>
96
+ </svg>
97
+ <span>
98
+ <LinkRuns runs={detail} />
99
+ </span>
100
+ </div>
101
+
102
+ {commentsCount > 0 && (
103
+ <div className="k-item__meta-item" title={`${commentsCount} comments`}>
104
+ <svg {...iconProps}>
105
+ <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />
106
+ </svg>
107
+ <span>{commentsCount}</span>
108
+ </div>
109
+ )}
110
+
111
+ {attachmentsCount > 0 && (
112
+ <div className="k-item__meta-item" title={`${attachmentsCount} attachments`}>
113
+ <svg {...iconProps}>
114
+ <path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" />
115
+ </svg>
116
+ <span>{attachmentsCount}</span>
117
+ </div>
118
+ )}
119
+ </div>
120
+
121
+ {assignee && (
122
+ <div className="k-item__assignee" title={`Assigned to ${assignee}`}>
123
+ {assignee}
124
+ </div>
125
+ )}
126
+ </div>
127
+ </div>
128
+ );
129
+ }