ボード
Jira 風のスプリントボード。スイムレーン、種類・優先度・ストーリーポイント・担当者を表示する課題カード、クイックフィルター、ドラッグ&ドロップ、課題の詳細パネル。
Projects / Surface One
SO Sprint 14
Ship guest-friendly checkout and the mobile push beta.
16 of 60 story points done · 5 of 18 issues
Drag issues between columns, or focus one and press
Board
To Do
6 issuesIn Progress
4 issuesMax 3Over the limitIn Review
3 issuesDone
5 issuesimport {
ChangeDetectionStrategy,
Component,
ElementRef,
Injector,
afterNextRender,
computed,
inject,
signal,
} from "@angular/core";
import { SONE_AVATAR_PARTS } from "@surface-one/angular/avatar";
import { SoneBadgeDirective } from "@surface-one/angular/badge";
import { SoneButtonDirective } from "@surface-one/angular/button";
import { SoneCardDirective } from "@surface-one/angular/card";
import { SoneIconComponent, type ShellIcon } from "@surface-one/angular/icon";
import {
SONE_FIELD_PARTS,
SONE_INPUT_GROUP_PARTS,
} from "@surface-one/angular/input";
import { SoneKbdComponent } from "@surface-one/angular/kbd";
import { SONE_MENU_PARTS } from "@surface-one/angular/menu";
import { SONE_PAGE_HEADER_PARTS } from "@surface-one/angular/page-header";
import { SoneProgressComponent } from "@surface-one/angular/progress";
import { SoneRowMenuComponent } from "@surface-one/angular/row-menu";
import {
SoneSegmentedComponent,
type SegmentOption,
} from "@surface-one/angular/segmented";
import { SoneSelectComponent } from "@surface-one/angular/select";
import { SONE_SIDE_PANEL_PARTS } from "@surface-one/angular/side-panel";
import {
SoneStackedBarComponent,
type SoneStackedBarSegment,
} from "@surface-one/angular/stacked-bar";
import { SONE_TOGGLE_PARTS } from "@surface-one/angular/toggle-group";
type StatusId = "todo" | "progress" | "review" | "done";
type IssueType = "story" | "task" | "bug";
type PriorityId = "highest" | "high" | "medium" | "low" | "lowest";
type GroupBy = "none" | "assignee" | "epic";
interface Status {
readonly id: StatusId;
readonly label: string;
/** Work-in-progress limit: the column turns red above it. */
readonly wip: number | null;
}
interface Person {
readonly id: string;
readonly name: string;
readonly initials: string;
}
interface Epic {
readonly id: string;
readonly name: string;
/** A categorical chart tone: `chart-1` … `chart-8`. */
readonly tone: string;
}
interface Subtask {
readonly id: string;
readonly title: string;
readonly done: boolean;
}
interface Comment {
readonly id: string;
readonly author: string;
readonly when: string;
readonly text: string;
}
interface Issue {
/** The issue key, e.g. `SO-141`. */
readonly id: string;
readonly type: IssueType;
readonly summary: string;
readonly status: StatusId;
readonly assignee: string | null;
readonly reporter: string;
readonly priority: PriorityId;
readonly points: number | null;
readonly epic: string | null;
readonly labels: readonly string[];
readonly flagged: boolean;
/** Days since the last change: 0 is today. */
readonly updated: number;
readonly description: string;
readonly subtasks: readonly Subtask[];
readonly comments: readonly Comment[];
}
/** A drop target or a lane: everything in one row of the board. */
interface Lane {
readonly key: string;
readonly title: string | null;
readonly person: Person | null;
readonly epic: Epic | null;
readonly count: number;
readonly points: number;
readonly cells: readonly {
readonly status: Status;
readonly issues: readonly Issue[];
}[];
}
const STATUSES: readonly Status[] = [
{ id: "todo", label: "To Do", wip: null },
{ id: "progress", label: "In Progress", wip: 3 },
{ id: "review", label: "In Review", wip: null },
{ id: "done", label: "Done", wip: null },
];
const PEOPLE: readonly Person[] = [
{ id: "ms", name: "Mina Sato", initials: "MS" },
{ id: "ap", name: "Ada Park", initials: "AP" },
{ id: "lr", name: "Leo Ruiz", initials: "LR" },
{ id: "tg", name: "Theo Grant", initials: "TG" },
{ id: "nh", name: "Noor Haddad", initials: "NH" },
];
/** The signed-in user: "Only my issues" and "Assign to me". */
const ME = "ms";
const EPICS: readonly Epic[] = [
{ id: "checkout", name: "Checkout v2", tone: "chart-1" },
{ id: "mobile", name: "Mobile app", tone: "chart-3" },
{ id: "tokens", name: "Design tokens", tone: "chart-5" },
];
const POINTS = [1, 2, 3, 5, 8, 13] as const;
/** The sprint, fixed so the screen renders the same on the server and the client. */
const SPRINT = {
name: "SO Sprint 14",
goal: "Ship guest-friendly checkout and the mobile push beta.",
dates: "Oct 1 – Oct 14",
remaining: 4,
};
const task = (id: string, title: string, done = false): Subtask => ({
id,
title,
done,
});
const ISSUES: readonly Issue[] = [
{
id: "SO-148",
type: "story",
summary: "Save cart items for later",
status: "todo",
assignee: "ap",
reporter: "ms",
priority: "high",
points: 5,
epic: "checkout",
labels: ["frontend"],
flagged: false,
updated: 1,
description:
"Shoppers can move an item out of the cart into a saved list and bring it back later, signed in or not.",
subtasks: [
task("t1", "Saved list API"),
task("t2", "Move between cart and list"),
task("t3", "Empty state"),
],
comments: [
{
id: "c1",
author: "ms",
when: "Oct 9",
text: "Guests keep the list in local storage until they sign in.",
},
],
},
{
id: "SO-149",
type: "task",
summary: "Add Apple Pay to the payment step",
status: "todo",
assignee: null,
reporter: "lr",
priority: "medium",
points: 3,
epic: "checkout",
labels: ["payments"],
flagged: false,
updated: 3,
description:
"Offer Apple Pay above the card form on Safari and iOS, behind the payments feature flag.",
subtasks: [],
comments: [],
},
{
id: "SO-150",
type: "bug",
summary: "Date picker closes on the first tap on iOS",
status: "todo",
assignee: "tg",
reporter: "nh",
priority: "high",
points: 2,
epic: "mobile",
labels: ["ios"],
flagged: true,
updated: 0,
description:
"On iOS 18 the delivery date picker opens and closes again on the same tap. Blocks the release candidate.",
subtasks: [task("t1", "Reproduce on a device", true), task("t2", "Fix")],
comments: [
{
id: "c1",
author: "tg",
when: "Oct 10",
text: "Flagged: the release candidate waits on this one.",
},
],
},
{
id: "SO-151",
type: "story",
summary: "Dark mode for the onboarding screens",
status: "todo",
assignee: "ms",
reporter: "ap",
priority: "medium",
points: 3,
epic: "mobile",
labels: ["design"],
flagged: false,
updated: 4,
description: "The three onboarding screens follow the system colour mode.",
subtasks: [],
comments: [],
},
{
id: "SO-152",
type: "task",
summary: "Document the spacing scale",
status: "todo",
assignee: "nh",
reporter: "nh",
priority: "low",
points: 1,
epic: "tokens",
labels: ["docs"],
flagged: false,
updated: 5,
description:
"One page with every spacing token, its value and when to use it.",
subtasks: [],
comments: [],
},
{
id: "SO-153",
type: "story",
summary: "Offline banner when the connection drops",
status: "todo",
assignee: "lr",
reporter: "ms",
priority: "lowest",
points: null,
epic: null,
labels: [],
flagged: false,
updated: 6,
description:
"A banner at the top of every screen while the app is offline.",
subtasks: [],
comments: [],
},
{
id: "SO-141",
type: "story",
summary: "One-page checkout with address autocomplete",
status: "progress",
assignee: "ms",
reporter: "ap",
priority: "highest",
points: 8,
epic: "checkout",
labels: ["frontend", "payments"],
flagged: false,
updated: 0,
description:
"Shipping, delivery and payment on one page. The address field suggests matches after three characters.",
subtasks: [
task("t1", "Address autocomplete", true),
task("t2", "Delivery options", true),
task("t3", "Payment step"),
task("t4", "Order review"),
],
comments: [
{
id: "c1",
author: "ap",
when: "Oct 7",
text: "Designs are final in the checkout file, page 3.",
},
{
id: "c2",
author: "lr",
when: "Oct 8",
text: "The payments API now returns the delivery fee.",
},
{
id: "c3",
author: "ms",
when: "Oct 10",
text: "Autocomplete is in. Starting on the payment step.",
},
],
},
{
id: "SO-143",
type: "bug",
summary: "Promo code field accepts expired codes",
status: "progress",
assignee: "lr",
reporter: "tg",
priority: "high",
points: 3,
epic: "checkout",
labels: ["payments"],
flagged: true,
updated: 1,
description:
"AUTUMN25 expired on Sep 30 but still takes 25% off. The check runs on the client only.",
subtasks: [task("t1", "Validate on the server")],
comments: [
{
id: "c1",
author: "lr",
when: "Oct 9",
text: "Waiting on the pricing service team for the expiry field.",
},
],
},
{
id: "SO-144",
type: "task",
summary: "Migrate the colour tokens to OKLCH",
status: "progress",
assignee: "nh",
reporter: "ms",
priority: "medium",
points: 5,
epic: "tokens",
labels: ["tokens"],
flagged: false,
updated: 2,
description:
"Every colour token in OKLCH, with sRGB fallbacks for older browsers.",
subtasks: [task("t1", "Neutral ramps", true), task("t2", "Accent ramps")],
comments: [],
},
{
id: "SO-145",
type: "story",
summary: "Push notifications for order updates",
status: "progress",
assignee: "tg",
reporter: "ap",
priority: "medium",
points: 5,
epic: "mobile",
labels: ["ios", "android"],
flagged: false,
updated: 1,
description:
"Notify the shopper when the order ships, is out for delivery and arrives.",
subtasks: [],
comments: [],
},
{
id: "SO-138",
type: "story",
summary: "Order summary in the checkout sidebar",
status: "review",
assignee: "ap",
reporter: "ms",
priority: "medium",
points: 3,
epic: "checkout",
labels: ["frontend"],
flagged: false,
updated: 0,
description:
"Items, discounts and the total stay visible beside every step.",
subtasks: [],
comments: [
{
id: "c1",
author: "ms",
when: "Oct 10",
text: "Looks good. One nit on the discount row.",
},
],
},
{
id: "SO-139",
type: "bug",
summary: "Focus ring missing on the segmented control",
status: "review",
assignee: "ms",
reporter: "nh",
priority: "high",
points: 1,
epic: "tokens",
labels: ["a11y"],
flagged: false,
updated: 2,
description:
"Keyboard users lose track of the focused segment in dark mode.",
subtasks: [],
comments: [],
},
{
id: "SO-140",
type: "task",
summary: "Biometric sign-in on Android",
status: "review",
assignee: "lr",
reporter: "tg",
priority: "medium",
points: 5,
epic: "mobile",
labels: ["android"],
flagged: false,
updated: 3,
description: "Fingerprint and face unlock through the BiometricPrompt API.",
subtasks: [],
comments: [],
},
{
id: "SO-131",
type: "story",
summary: "Guest checkout",
status: "done",
assignee: "ap",
reporter: "ms",
priority: "high",
points: 8,
epic: "checkout",
labels: ["frontend"],
flagged: false,
updated: 6,
description: "Buy without an account; offer one after the order is placed.",
subtasks: [],
comments: [],
},
{
id: "SO-132",
type: "task",
summary: "Set up the token build pipeline",
status: "done",
assignee: "nh",
reporter: "nh",
priority: "medium",
points: 3,
epic: "tokens",
labels: ["tokens"],
flagged: false,
updated: 8,
description:
"Build the CSS and the JSON exports from one source on every merge.",
subtasks: [],
comments: [],
},
{
id: "SO-134",
type: "bug",
summary: "Crash when rotating the product gallery",
status: "done",
assignee: "tg",
reporter: "lr",
priority: "highest",
points: 2,
epic: "mobile",
labels: ["android"],
flagged: false,
updated: 5,
description:
"Rotating the device while the gallery animates crashed the app.",
subtasks: [],
comments: [],
},
{
id: "SO-135",
type: "story",
summary: "Type scale for headings",
status: "done",
assignee: "ms",
reporter: "ap",
priority: "low",
points: 2,
epic: "tokens",
labels: ["design"],
flagged: false,
updated: 7,
description: "Six heading sizes on a 1.25 ratio.",
subtasks: [],
comments: [],
},
{
id: "SO-136",
type: "task",
summary: "Track the checkout funnel events",
status: "done",
assignee: "lr",
reporter: "ap",
priority: "low",
points: 1,
epic: "checkout",
labels: ["analytics"],
flagged: false,
updated: 4,
description: "One event per step, with the cart value and the step time.",
subtasks: [],
comments: [],
},
];
const statusOf = (id: StatusId): Status =>
STATUSES.find((s) => s.id === id)!;
const personOf = (id: string | null): Person | null =>
PEOPLE.find((p) => p.id === id) ?? null;
const epicOf = (id: string | null): Epic | null =>
EPICS.find((e) => e.id === id) ?? null;
const pointsOf = (issues: readonly Issue[]): number =>
issues.reduce((sum, i) => sum + (i.points ?? 0), 0);
const keyNumber = (id: string): number =>
Number(id.slice(id.indexOf("-") + 1));
const TYPES: Record<IssueType, { label: string; icon: ShellIcon }> = {
story: { label: "Story", icon: "bookmark" },
task: { label: "Task", icon: "square-check" },
bug: { label: "Bug", icon: "bug" },
};
const PRIORITIES: Record<PriorityId, { label: string; icon: ShellIcon }> = {
highest: { label: "Highest", icon: "chevrons-up" },
high: { label: "High", icon: "arrow-up" },
medium: { label: "Medium", icon: "equal" },
low: { label: "Low", icon: "arrow-down" },
lowest: { label: "Lowest", icon: "chevrons-down" },
};
@Component({
selector: "docs-board-template",
imports: [
...SONE_AVATAR_PARTS,
...SONE_FIELD_PARTS,
...SONE_INPUT_GROUP_PARTS,
...SONE_MENU_PARTS,
...SONE_PAGE_HEADER_PARTS,
...SONE_SIDE_PANEL_PARTS,
...SONE_TOGGLE_PARTS,
SoneBadgeDirective,
SoneButtonDirective,
SoneCardDirective,
SoneIconComponent,
SoneKbdComponent,
SoneProgressComponent,
SoneRowMenuComponent,
SoneSegmentedComponent,
SoneSelectComponent,
SoneStackedBarComponent,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div class="shell">
<div class="body">
<div sonePageHeader>
<div sonePageHeaderContent>
<p sonePageHeaderEyebrow>Projects / Surface One</p>
<h2 sonePageHeaderTitle>{{ sprint.name }}</h2>
<p sonePageHeaderDescription>
{{ sprint.goal }}
<span class="sprint-dates"
><sone-icon icon="clock" />{{ sprint.dates }} ·
{{ sprint.remaining }} days remaining</span
>
</p>
</div>
<div sonePageHeaderActions>
<button
soneBtn
variant="outline"
size="sm"
type="button"
(click)="completeSprint()"
>
Complete sprint
</button>
<sone-row-menu label="Board actions" [prominent]="true">
<button
soneMenuItem
type="button"
(click)="say('Sprint details opened.')"
>
<sone-icon icon="edit" /> Edit sprint
</button>
<button
soneMenuItem
type="button"
(click)="say('Board settings opened.')"
>
<sone-icon icon="sliders" /> Board settings
</button>
<button
soneMenuItem
type="button"
(click)="say('Board link copied.')"
>
<sone-icon icon="link" /> Copy board link
</button>
</sone-row-menu>
</div>
</div>
<div class="toolbar">
<div soneInputGroup class="search">
<span soneInputGroupAddon><sone-icon icon="search" /></span>
<input
soneInputGroupInput
type="search"
aria-label="Search issues"
placeholder="Search this board…"
[value]="query()"
(input)="query.set($any($event.target).value)"
/>
</div>
<div class="people" role="group" aria-label="Filter by assignee">
@for (p of people; track p.id) {
<button
type="button"
class="person-filter"
[attr.aria-pressed]="assignees().includes(p.id)"
[title]="p.name"
(click)="toggleAssignee(p.id)"
>
<sone-avatar size="sm" aria-hidden="true"
><span soneAvatarFallback>{{ p.initials }}</span></sone-avatar
>
<span class="sr-only">{{ p.name }}</span>
</button>
}
</div>
<div
soneToggleGroup
variant="outline"
size="sm"
spacing="1"
role="group"
aria-label="Quick filters"
>
<button
soneToggleGroupItem
type="button"
[pressed]="mine()"
(click)="mine.set(!mine())"
>
Only my issues
</button>
<button
soneToggleGroupItem
type="button"
[pressed]="recent()"
(click)="recent.set(!recent())"
>
Recently updated
</button>
<button
soneToggleGroupItem
type="button"
[pressed]="bugs()"
(click)="bugs.set(!bugs())"
>
Bugs
</button>
</div>
<sone-select
class="epic-filter"
size="sm"
ariaLabel="Epic"
[(value)]="epic"
>
<option value="all">All epics</option>
@for (e of epics; track e.id) {
<option [value]="e.id">{{ e.name }}</option>
}
<option value="none">No epic</option>
</sone-select>
<span class="group-by">
<span class="group-label" aria-hidden="true">Group by</span>
<sone-segmented
size="sm"
ariaLabel="Group by"
[options]="groupOptions"
[value]="groupBy()"
(valueChange)="setGroupBy($event)"
/>
</span>
@if (filtering()) {
<button
soneBtn
variant="ghost"
size="sm"
type="button"
(click)="clearFilters()"
>
Clear filters
</button>
}
</div>
<div class="summary">
<div class="sprint-progress">
<p class="progress-text">
<strong class="num">{{ donePoints() }}</strong> of
<span class="num">{{ totalPoints() }}</span> story points done ·
{{ doneCount() }} of {{ issues().length }} issues
</p>
<sone-stacked-bar
size="sm"
ariaLabel="Sprint progress in story points"
[segments]="progressSegments()"
[max]="totalPoints()"
/>
</div>
<p class="hint" id="board-hint">
Drag issues between columns, or focus one and press
<sone-kbd>Shift</sone-kbd> + <sone-kbd>←</sone-kbd> /
<sone-kbd>→</sone-kbd>.
</p>
</div>
<h3 class="sr-only" id="board-title" tabindex="-1">Board</h3>
<p class="sr-only" role="status">{{ announcement() }}</p>
<div class="board-scroll">
<div class="board">
<div class="board-head">
@for (col of columns(); track col.status.id) {
<div class="col-head" [class.is-over]="col.over">
<h4 class="col-title" [id]="'board-col-' + col.status.id">
{{ col.status.label }}
</h4>
<span
soneBadge
[variant]="col.over ? 'destructive' : 'secondary'"
class="num"
>{{ col.count }}<span class="sr-only"> issues</span></span
>
@if (col.status.wip !== null) {
<span class="wip">Max {{ col.status.wip }}</span>
@if (col.over) {
<span class="sr-only">Over the limit</span>
}
}
</div>
}
</div>
@for (lane of lanes(); track lane.key) {
<div class="lane">
@if (lane.title !== null) {
<h4 class="lane-head">
<button
type="button"
class="lane-toggle"
[attr.aria-expanded]="!collapsed().includes(lane.key)"
[attr.aria-controls]="'board-lane-' + lane.key"
(click)="toggleLane(lane.key)"
>
<sone-icon icon="chevron-right" class="lane-caret" />
@if (lane.person) {
<sone-avatar size="sm" aria-hidden="true"
><span soneAvatarFallback>{{
lane.person.initials
}}</span></sone-avatar
>
} @else if (lane.epic) {
<span class="epic-dot" [style.--tone]="tone(lane.epic)"
><sone-icon icon="zap"
/></span>
}
<span
class="lane-name"
[id]="'board-lane-name-' + lane.key"
>{{ lane.title }}</span
>
<span class="lane-meta"
>{{ lane.count }}
{{ lane.count === 1 ? "issue" : "issues" }} ·
{{ lane.points }} points</span
>
</button>
</h4>
}
@if (!collapsed().includes(lane.key)) {
<div class="cells" [id]="'board-lane-' + lane.key">
@for (cell of lane.cells; track cell.status.id) {
<ul
class="cell"
[class.is-drop]="
dropTarget() === lane.key + ':' + cell.status.id
"
[attr.aria-labelledby]="cellLabel(lane, cell.status)"
(dragover)="
onDragOver($event, lane.key, cell.status.id)
"
(dragleave)="
onDragLeave($event, lane.key, cell.status.id)
"
(drop)="onDrop($event, lane.key, cell.status.id)"
>
@for (i of cell.issues; track i.id) {
@let assignee = personOf(i.assignee);
@let epic = epicOf(i.epic);
<li
soneCard
size="sm"
class="issue"
draggable="true"
[attr.data-status]="i.status"
[class.is-flagged]="i.flagged"
[class.is-selected]="selectedId() === i.id"
[class.is-dragging]="dragId() === i.id"
(dragstart)="onDragStart($event, i.id)"
(dragend)="onDragEnd()"
>
<div class="issue-head">
<button
type="button"
class="issue-open"
[id]="'board-open-' + i.id"
[attr.aria-describedby]="'board-meta-' + i.id"
[attr.aria-controls]="
selected() ? 'board-detail' : null
"
aria-keyshortcuts="Shift+ArrowLeft Shift+ArrowRight"
(click)="open(i.id)"
(keydown)="onCardKeydown($event, i)"
>
{{ i.summary }}
</button>
<sone-row-menu
class="issue-menu"
[label]="'Actions for ' + i.id"
>
<div soneMenuGroup aria-label="Move to">
<p soneMenuLabel>Move to</p>
@for (s of statuses; track s.id) {
<button
soneMenuRadioItem
type="button"
[checked]="i.status === s.id"
(click)="moveFromMenu(i.id, s.id)"
>
{{ s.label }}
</button>
}
</div>
<div soneMenuSeparator></div>
<button
soneMenuItem
type="button"
(click)="open(i.id)"
>
<sone-icon icon="eye" /> Open issue
</button>
<button
soneMenuItem
type="button"
[disabled]="i.assignee === me"
(click)="assign(i.id, me)"
>
<sone-icon icon="user" /> Assign to me
</button>
<button
soneMenuItem
type="button"
(click)="toggleFlag(i.id)"
>
<sone-icon icon="alert-circle" />
{{ i.flagged ? "Remove flag" : "Add flag" }}
</button>
<div soneMenuSeparator></div>
<button
soneMenuItem
variant="destructive"
type="button"
(click)="remove(i.id)"
>
<sone-icon icon="trash" /> Delete
</button>
</sone-row-menu>
</div>
@if (epic || i.labels.length) {
<p class="issue-tags">
@if (epic) {
<span
class="epic-tag"
[style.--tone]="tone(epic)"
>{{ epic.name }}</span
>
}
@for (l of i.labels; track l) {
<span soneBadge variant="outline">{{
l
}}</span>
}
</p>
}
<div class="issue-meta" [id]="'board-meta-' + i.id">
<span class="type-icon" [attr.data-type]="i.type"
><sone-icon
[icon]="typeIcon(i)"
[label]="typeLabel(i)"
/></span>
<span class="issue-key">{{ i.id }}</span>
@if (i.flagged) {
<span class="flag"
><sone-icon
icon="alert-circle"
label="Flagged"
/></span>
}
@if (i.subtasks.length) {
<span class="meta-count num"
><sone-icon icon="list-checks" />{{
subtasksDone(i)
}}/{{ i.subtasks.length
}}<span class="sr-only">
subtasks done</span
></span
>
}
@if (i.comments.length) {
<span class="meta-count num"
><sone-icon icon="message-square" />{{
i.comments.length
}}<span class="sr-only">
{{
i.comments.length === 1
? "comment"
: "comments"
}}</span
></span
>
}
<span class="meta-end">
@if (i.points !== null) {
<span
soneBadge
variant="secondary"
class="points num"
>{{ i.points
}}<span class="sr-only">
story points</span
></span
>
}
<span
class="priority"
[attr.data-priority]="i.priority"
><sone-icon
[icon]="priorityIcon(i)"
[label]="priorityLabel(i) + ' priority'"
/></span>
@if (assignee) {
<sone-avatar
size="sm"
aria-hidden="true"
[title]="assignee.name"
><span soneAvatarFallback>{{
assignee.initials
}}</span></sone-avatar
>
<span class="sr-only"
>Assigned to {{ assignee.name }}</span
>
} @else {
<span class="unassigned" title="Unassigned"
><sone-icon icon="user" label="Unassigned"
/></span>
}
</span>
</div>
</li>
}
</ul>
}
</div>
}
</div>
}
<div class="board-foot">
@if (creating()) {
<form class="create-form" (submit)="create($event)">
<sone-select
size="sm"
ariaLabel="Issue type"
[(value)]="newType"
>
@for (t of typeOptions; track t.value) {
<option [value]="t.value">{{ t.label }}</option>
}
</sone-select>
<input
id="board-new-summary"
type="text"
aria-label="Summary of the new issue"
placeholder="What needs to be done?"
autocomplete="off"
[value]="newSummary()"
(input)="newSummary.set($any($event.target).value)"
(keydown.escape)="cancelCreate()"
/>
<div class="create-actions">
<button
soneBtn
variant="ghost"
size="sm"
type="button"
(click)="cancelCreate()"
>
Cancel
</button>
<button
soneBtn
size="sm"
type="submit"
[disabled]="!newSummary().trim()"
>
Create
</button>
</div>
</form>
} @else {
<button
soneBtn
variant="ghost"
size="sm"
type="button"
id="board-create"
class="create-btn"
(click)="startCreate()"
>
<sone-icon icon="plus" /><span>Create issue</span>
</button>
}
</div>
</div>
</div>
@if (!visible().length) {
<p class="no-results">No issues match these filters.</p>
}
</div>
@if (selected(); as issue) {
<div
soneSidePanel
id="board-detail"
role="region"
aria-labelledby="board-detail-title"
class="details"
(keydown.escape)="close()"
>
<div soneSidePanelHeader>
<h3 soneSidePanelTitle id="board-detail-title" tabindex="-1">
<span class="type-icon" [attr.data-type]="issue.type"
><sone-icon [icon]="typeIcon(issue)" [label]="typeLabel(issue)"
/></span>
{{ issue.id }}
</h3>
<div soneSidePanelActions>
<button
soneBtn
variant="ghost"
size="icon-sm"
type="button"
[attr.aria-pressed]="issue.flagged"
aria-label="Flagged"
title="Flagged"
(click)="toggleFlag(issue.id)"
>
<sone-icon icon="alert-circle" />
</button>
<button
soneBtn
variant="ghost"
size="icon-sm"
type="button"
aria-label="Close issue details"
(click)="close()"
>
<sone-icon icon="close" />
</button>
</div>
</div>
<div soneSidePanelContent>
@if (issue.flagged) {
<p class="flag-note">
<sone-icon icon="alert-circle" /> Flagged as an impediment
</p>
}
<div soneField>
<label soneFieldLabel for="board-summary">Summary</label>
<textarea
id="board-summary"
class="summary-input"
rows="2"
[value]="issue.summary"
(change)="rename(issue.id, $any($event.target).value)"
(keydown.enter)="
$event.preventDefault(); $any($event.target).blur()
"
></textarea>
</div>
<div class="fields">
<div soneField>
<label soneFieldLabel for="board-status">Status</label>
<sone-select
size="sm"
selectId="board-status"
[value]="issue.status"
(selectionChange)="moveTo(issue.id, $any($event))"
>
@for (s of statuses; track s.id) {
<option [value]="s.id">{{ s.label }}</option>
}
</sone-select>
</div>
<div soneField>
<label soneFieldLabel for="board-assignee">Assignee</label>
<sone-select
size="sm"
selectId="board-assignee"
[value]="issue.assignee ?? ''"
(selectionChange)="assign(issue.id, $event || null)"
>
<option value="">Unassigned</option>
@for (p of people; track p.id) {
<option [value]="p.id">{{ p.name }}</option>
}
</sone-select>
</div>
<div soneField>
<label soneFieldLabel for="board-priority">Priority</label>
<sone-select
size="sm"
selectId="board-priority"
[value]="issue.priority"
(selectionChange)="
patch(issue.id, { priority: $any($event) })
"
>
@for (p of priorityOptions; track p.value) {
<option [value]="p.value">{{ p.label }}</option>
}
</sone-select>
</div>
<div soneField>
<label soneFieldLabel for="board-points">Story points</label>
<sone-select
size="sm"
selectId="board-points"
[value]="issue.points === null ? '' : '' + issue.points"
(selectionChange)="setPoints(issue.id, $event)"
>
<option value="">None</option>
@for (n of points; track n) {
<option [value]="'' + n">{{ n }}</option>
}
</sone-select>
</div>
<div soneField class="wide">
<label soneFieldLabel for="board-epic">Epic</label>
<sone-select
size="sm"
selectId="board-epic"
[value]="issue.epic ?? ''"
(selectionChange)="patch(issue.id, { epic: $event || null })"
>
<option value="">No epic</option>
@for (e of epics; track e.id) {
<option [value]="e.id">{{ e.name }}</option>
}
</sone-select>
</div>
</div>
<dl class="props">
<div>
<dt>Reporter</dt>
<dd class="person">
@let reporter = personOf(issue.reporter);
@if (reporter) {
<sone-avatar size="sm" aria-hidden="true"
><span soneAvatarFallback>{{
reporter.initials
}}</span></sone-avatar
>
{{ reporter.name }}
}
</dd>
</div>
<div>
<dt>Labels</dt>
<dd class="tags">
@for (l of issue.labels; track l) {
<span soneBadge variant="outline">{{ l }}</span>
} @empty {
None
}
</dd>
</div>
<div>
<dt>Sprint</dt>
<dd>{{ sprint.name }}</dd>
</div>
<div>
<dt>Updated</dt>
<dd>{{ updatedLabel(issue) }}</dd>
</div>
</dl>
<h4 class="section-title">Description</h4>
<p class="text">{{ issue.description }}</p>
<h4 class="section-title" id="board-subtasks-title">
Subtasks
@if (issue.subtasks.length) {
<span class="section-count num"
>{{ subtasksDone(issue) }} of
{{ issue.subtasks.length }} done</span
>
}
</h4>
@if (issue.subtasks.length) {
<sone-progress
ariaLabel="Subtasks done"
[value]="subtasksDone(issue)"
[max]="issue.subtasks.length"
/>
<ul class="subtasks" aria-labelledby="board-subtasks-title">
@for (t of issue.subtasks; track t.id) {
<li>
<input
type="checkbox"
[id]="'board-subtask-' + t.id"
[checked]="t.done"
(change)="toggleSubtask(issue.id, t.id)"
/>
<label
[for]="'board-subtask-' + t.id"
[class.is-done]="t.done"
>{{ t.title }}</label
>
</li>
}
</ul>
} @else {
<p class="text muted">No subtasks yet.</p>
}
<h4 class="section-title">Activity</h4>
<form class="comment-form" (submit)="addComment($event, issue.id)">
<div soneField>
<label soneFieldLabel for="board-comment">Add a comment</label>
<textarea
id="board-comment"
rows="2"
placeholder="Ask a question or post an update…"
[value]="draft()"
(input)="draft.set($any($event.target).value)"
></textarea>
</div>
<button
soneBtn
size="sm"
type="submit"
[disabled]="!draft().trim()"
>
Save
</button>
</form>
@if (issue.comments.length) {
<ol class="comments" aria-label="Comments, newest first">
@for (c of commentsOf(issue); track c.id) {
@let author = personOf(c.author);
<li>
<sone-avatar size="sm" aria-hidden="true"
><span soneAvatarFallback>{{
author?.initials
}}</span></sone-avatar
>
<span class="comment-body">
<span class="comment-meta"
><strong>{{ author?.name }}</strong> ·
{{ c.when }}</span
>
<span class="comment-text">{{ c.text }}</span>
</span>
</li>
}
</ol>
}
</div>
</div>
}
</div>
`,
styles: `
:host {
display: block;
}
.shell {
position: relative;
display: flex;
/* The frame: the board and its details are islands on the skin's backdrop (flush panes in a
flat skin). */
gap: var(--island-inset);
height: 720px;
overflow: hidden;
padding: var(--island-inset);
background: var(--app-backdrop);
}
.body {
flex: 1 1 auto;
min-width: 0;
overflow-y: auto;
padding: var(--space-6);
border-radius: var(--island-radius);
background: var(--surface-base);
box-shadow: var(--island-shadow);
}
.num {
font-variant-numeric: tabular-nums;
}
.sprint-dates {
display: inline-flex;
align-items: center;
gap: var(--space-1);
margin-left: var(--space-2);
color: var(--text-muted);
white-space: nowrap;
}
.toolbar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-2);
margin: var(--space-5) 0 var(--space-3);
}
.search {
flex: 0 1 14rem;
min-width: 10rem;
}
.people {
display: inline-flex;
align-items: center;
gap: var(--space-0_5);
}
.person-filter {
display: inline-flex;
margin: 0;
padding: 0;
border: 2px solid var(--surface-base);
border-radius: var(--radius-pill);
background: var(--surface-base);
cursor: pointer;
transition: transform var(--transition-fast);
}
.person-filter:hover {
z-index: var(--z-raised);
transform: translateY(-2px);
}
.person-filter[aria-pressed="true"] {
z-index: var(--z-raised);
border-color: var(--accent);
}
.person-filter:focus-visible {
z-index: calc(var(--z-raised) + 1);
outline: none;
box-shadow: var(--focus-ring);
}
.epic-filter {
flex: 0 1 10rem;
}
.group-by {
display: inline-flex;
align-items: center;
gap: var(--space-2);
}
.group-label {
color: var(--text-secondary);
font-size: var(--font-size-sm);
}
.summary {
display: flex;
flex-wrap: wrap;
align-items: flex-end;
justify-content: space-between;
gap: var(--space-2) var(--space-6);
margin-bottom: var(--space-4);
}
.sprint-progress {
display: grid;
flex: 0 1 22rem;
gap: var(--space-1);
}
.progress-text,
.hint {
margin: 0;
color: var(--text-secondary);
font-size: var(--font-size-xs);
}
.progress-text strong {
color: var(--text-primary);
}
.board-scroll {
overflow-x: auto;
padding-bottom: var(--space-2);
}
.board {
--_col: minmax(15rem, 1fr);
display: grid;
gap: var(--space-2);
min-width: calc(4 * 15rem + 3 * var(--space-3));
}
.board-head,
.cells,
.board-foot {
display: grid;
grid-template-columns: repeat(4, var(--_col));
gap: var(--space-3);
}
.col-head {
display: flex;
align-items: center;
gap: var(--space-2);
padding: var(--space-2) var(--space-3);
border-radius: var(--radius);
background: var(--surface-hover);
}
.col-head.is-over {
background: var(--danger-soft);
}
.col-title {
margin: 0;
color: var(--text-secondary);
font-size: var(--font-size-xs);
font-weight: var(--font-weight-semibold);
letter-spacing: var(--tracking-caps);
text-transform: uppercase;
}
.wip {
margin-left: auto;
color: var(--text-secondary);
font-size: var(--font-size-xs);
}
.is-over .wip {
color: var(--danger-text);
font-weight: var(--font-weight-semibold);
}
.lane {
display: grid;
gap: var(--space-2);
}
.lane-head {
margin: var(--space-2) 0 0;
font-size: var(--font-size-sm);
}
.lane-toggle {
display: inline-flex;
align-items: center;
gap: var(--space-2);
margin: 0;
padding: var(--space-1) var(--space-2);
border: 0;
border-radius: var(--radius-control);
background: none;
color: var(--text-primary);
font: inherit;
font-weight: var(--font-weight-semibold);
cursor: pointer;
}
.lane-toggle:hover {
background: var(--surface-hover);
}
.lane-toggle:focus-visible {
outline: none;
box-shadow: var(--focus-ring);
}
.lane-caret {
transition: transform var(--transition-fast);
}
.lane-toggle[aria-expanded="true"] .lane-caret {
transform: rotate(90deg);
}
.lane-meta {
color: var(--text-muted);
font-size: var(--font-size-xs);
font-weight: var(--font-weight-normal);
}
.epic-dot {
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--control-h-xs);
height: var(--control-h-xs);
border-radius: var(--radius-sm);
background: color-mix(in srgb, var(--tone) 16%, transparent);
color: color-mix(in oklab, var(--tone) 70%, var(--text-primary));
}
.cell {
display: flex;
flex-direction: column;
gap: var(--space-2);
min-width: 0;
min-height: 4.5rem;
margin: 0;
padding: var(--space-2);
border: var(--border-width-thin) dashed transparent;
border-radius: var(--radius);
background: var(--surface-hover);
list-style: none;
transition:
background var(--transition-fast),
border-color var(--transition-fast);
}
.cell.is-drop {
border-color: var(--accent);
background: var(--accent-soft);
}
.issue {
position: relative;
gap: var(--space-2);
border: var(--border-width-thin) solid var(--border);
background: var(--surface-raised);
box-shadow: var(--shadow-sm);
cursor: grab;
transition:
border-color var(--transition-fast),
box-shadow var(--transition-fast),
opacity var(--transition-fast);
}
.issue:hover {
border-color: var(--border-strong);
box-shadow: var(--shadow-md);
}
.issue:has(.issue-open:focus-visible) {
box-shadow: var(--focus-ring);
}
.issue.is-selected {
border-color: var(--accent);
}
.issue.is-flagged {
border-color: var(--warning);
/* stylelint-disable declaration-property-unit-disallowed-list -- the flag stripe is 3px so it reads apart from the 2px selection ring */
box-shadow:
inset 3px 0 0 var(--warning),
var(--shadow-sm);
/* stylelint-enable declaration-property-unit-disallowed-list */
}
.issue.is-dragging {
opacity: 0.5;
}
.issue-head {
display: flex;
align-items: flex-start;
gap: var(--space-1);
}
.issue-open {
flex: 1 1 auto;
min-width: 0;
margin: 0;
padding: 0;
border: 0;
background: none;
color: var(--text-primary);
font: inherit;
font-size: var(--font-size-sm);
line-height: var(--leading-snug);
text-align: start;
cursor: pointer;
overflow-wrap: anywhere;
}
/* The whole card opens the issue; the menu sits above the stretched target. */
.issue-open::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
}
.issue-open:focus-visible {
outline: none;
}
.issue-menu {
position: relative;
z-index: var(--z-raised);
margin: calc(var(--space-1) * -1) calc(var(--space-1) * -1) 0 0;
}
.issue-tags {
display: flex;
flex-wrap: wrap;
gap: var(--space-1);
margin: 0;
}
.epic-tag {
display: inline-flex;
align-items: center;
height: var(--badge-h);
padding: 0 var(--space-2);
border-radius: var(--radius-sm);
background: color-mix(in srgb, var(--tone) 16%, transparent);
color: color-mix(in oklab, var(--tone) 55%, var(--text-primary));
font-size: var(--font-size-xs);
font-weight: var(--font-weight-semibold);
}
.issue-meta {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--space-1) var(--space-2);
color: var(--text-secondary);
font-size: var(--font-size-xs);
}
.type-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--control-h-xs);
height: var(--control-h-xs);
flex: none;
border-radius: var(--radius-sm);
background: color-mix(in srgb, var(--_type) 16%, transparent);
color: var(--_type);
}
.type-icon[data-type="story"] {
--_type: var(--success-text);
}
.type-icon[data-type="task"] {
--_type: var(--chart-2);
}
.type-icon[data-type="bug"] {
--_type: var(--danger-text);
}
.issue-key {
color: var(--text-secondary);
font-weight: var(--font-weight-medium);
white-space: nowrap;
}
.issue[data-status="done"] .issue-key {
text-decoration: line-through;
}
.flag {
display: inline-flex;
color: var(--warning-text);
}
.meta-count {
display: inline-flex;
align-items: center;
gap: var(--space-0_5);
}
.meta-end {
display: inline-flex;
align-items: center;
gap: var(--space-2);
margin-left: auto;
}
.points {
min-width: 1.5rem;
justify-content: center;
}
.priority {
display: inline-flex;
}
.priority[data-priority="highest"],
.priority[data-priority="high"] {
color: var(--danger-text);
}
.priority[data-priority="medium"] {
color: var(--warning-text);
}
.priority[data-priority="low"],
.priority[data-priority="lowest"] {
color: var(--chart-2);
}
.unassigned {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border: var(--border-width-thin) dashed var(--border-strong);
border-radius: var(--radius-pill);
color: var(--text-muted);
}
.create-btn {
justify-self: start;
}
.create-form {
display: grid;
gap: var(--space-2);
padding: var(--space-2);
border: var(--border-width-thin) solid var(--border);
border-radius: var(--radius);
background: var(--surface-raised);
}
.create-actions {
display: flex;
justify-content: flex-end;
gap: var(--space-2);
}
.no-results {
margin: var(--space-4) 0 0;
color: var(--text-muted);
font-size: var(--font-size-sm);
text-align: center;
}
.details {
flex: none;
width: 24rem;
border-left-width: var(--island-divider);
border-radius: var(--island-radius);
box-shadow: var(--island-shadow);
}
.details h3 {
display: inline-flex;
align-items: center;
gap: var(--space-2);
}
.details h3:focus {
outline: none;
}
.flag-note {
display: flex;
align-items: center;
gap: var(--space-2);
margin: 0 0 var(--space-3);
padding: var(--space-2) var(--space-3);
border-radius: var(--radius);
background: var(--warning-soft);
color: var(--warning-text);
font-size: var(--font-size-sm);
}
.summary-input {
font-size: var(--font-size-md);
font-weight: var(--font-weight-semibold);
}
.fields {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--space-3);
margin-top: var(--space-4);
}
.fields .wide {
grid-column: 1 / -1;
}
.props {
display: grid;
gap: var(--space-3);
margin: var(--space-4) 0 0;
}
.props div {
display: grid;
grid-template-columns: 5.5rem minmax(0, 1fr);
align-items: center;
gap: var(--space-2);
}
.props dt {
color: var(--text-muted);
font-size: var(--font-size-sm);
}
.props dd {
margin: 0;
color: var(--text-primary);
font-size: var(--font-size-sm);
}
.person,
.tags {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--space-2);
}
.section-title {
display: flex;
align-items: baseline;
gap: var(--space-2);
margin: var(--space-6) 0 var(--space-3);
color: var(--text-primary);
font-size: var(--font-size-sm);
font-weight: var(--font-weight-semibold);
}
.section-count {
color: var(--text-muted);
font-size: var(--font-size-xs);
font-weight: var(--font-weight-normal);
}
.text {
margin: 0;
color: var(--text-secondary);
font-size: var(--font-size-sm);
}
.muted {
color: var(--text-muted);
}
.subtasks {
display: grid;
gap: var(--space-2);
margin: var(--space-3) 0 0;
padding: 0;
list-style: none;
}
.subtasks li {
display: flex;
align-items: center;
gap: var(--space-2);
color: var(--text-primary);
font-size: var(--font-size-sm);
}
.subtasks .is-done {
color: var(--text-muted);
text-decoration: line-through;
}
.comment-form {
display: grid;
gap: var(--space-3);
}
.comment-form button {
justify-self: end;
}
.comments {
display: grid;
gap: var(--space-4);
margin: var(--space-4) 0 0;
padding: 0;
list-style: none;
}
.comments li {
display: flex;
gap: var(--space-3);
}
.comment-body {
display: grid;
gap: var(--space-0_5);
min-width: 0;
}
.comment-meta {
color: var(--text-muted);
font-size: var(--font-size-xs);
}
.comment-meta strong {
color: var(--text-primary);
font-weight: var(--font-weight-semibold);
}
.comment-text {
color: var(--text-secondary);
font-size: var(--font-size-sm);
}
@media (prefers-reduced-motion: reduce) {
.person-filter,
.lane-caret,
.cell,
.issue {
transition: none;
}
.person-filter:hover {
transform: none;
}
}
@media (max-width: 900px) {
.details {
position: absolute;
top: var(--island-inset);
right: var(--island-inset);
bottom: var(--island-inset);
z-index: var(--z-drawer);
width: min(100%, 24rem);
box-shadow: var(--menu-shadow);
}
}
@media (max-width: 640px) {
.body {
padding: var(--space-4);
}
.search,
.epic-filter {
flex: 1 1 10rem;
}
.board {
--_col: minmax(15rem, 80vw);
}
.sprint-dates {
display: flex;
margin: var(--space-1) 0 0;
}
}
`,
})
export default class BoardTemplate {
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
private readonly injector = inject(Injector);
protected readonly sprint = SPRINT;
protected readonly statuses = STATUSES;
protected readonly people = PEOPLE;
protected readonly epics = EPICS;
protected readonly points = POINTS;
protected readonly me = ME;
protected readonly groupOptions: readonly SegmentOption[] = [
{ value: "none", label: "None" },
{ value: "assignee", label: "Assignee" },
{ value: "epic", label: "Epic" },
];
protected readonly typeOptions = (Object.keys(TYPES) as IssueType[]).map(
(value) => ({ value, label: TYPES[value].label }),
);
protected readonly priorityOptions = (
Object.keys(PRIORITIES) as PriorityId[]
).map((value) => ({ value, label: PRIORITIES[value].label }));
protected readonly issues = signal<readonly Issue[]>(ISSUES);
protected readonly query = signal("");
protected readonly assignees = signal<readonly string[]>([]);
protected readonly mine = signal(false);
protected readonly recent = signal(false);
protected readonly bugs = signal(false);
protected readonly epic = signal("all");
protected readonly groupBy = signal<GroupBy>("none");
protected readonly collapsed = signal<readonly string[]>([]);
protected readonly selectedId = signal<string | null>(null);
protected readonly dragId = signal<string | null>(null);
/** `<lane>:<status>` under the dragged card. */
protected readonly dropTarget = signal<string | null>(null);
protected readonly creating = signal(false);
protected readonly newType = signal<string>("story");
protected readonly newSummary = signal("");
protected readonly draft = signal("");
protected readonly announcement = signal("");
protected readonly filtering = computed(
() =>
!!this.query().trim() ||
this.assignees().length > 0 ||
this.mine() ||
this.recent() ||
this.bugs() ||
this.epic() !== "all",
);
protected readonly visible = computed(() => {
const q = this.query().trim().toLowerCase();
const people = this.assignees();
const epic = this.epic();
return this.issues().filter(
(i) =>
(!q ||
i.summary.toLowerCase().includes(q) ||
i.id.toLowerCase().includes(q)) &&
(!people.length || people.includes(i.assignee ?? "")) &&
(!this.mine() || i.assignee === ME) &&
(!this.recent() || i.updated <= 1) &&
(!this.bugs() || i.type === "bug") &&
(epic === "all" || (i.epic ?? "none") === epic),
);
});
protected readonly columns = computed(() =>
STATUSES.map((status) => ({
status,
count: this.visible().filter((i) => i.status === status.id).length,
// The limit counts every issue in the column, filtered out or not.
over:
status.wip !== null &&
this.issues().filter((i) => i.status === status.id).length > status.wip,
})),
);
protected readonly lanes = computed<readonly Lane[]>(() => {
const issues = this.visible();
const lane = (
key: string,
title: string | null,
list: readonly Issue[],
person: Person | null = null,
epic: Epic | null = null,
): Lane => ({
key,
title,
person,
epic,
count: list.length,
points: pointsOf(list),
cells: STATUSES.map((status) => ({
status,
issues: list.filter((i) => i.status === status.id),
})),
});
const group = this.groupBy();
if (group === "none") return [lane("all", null, issues)];
if (group === "assignee") {
return [
...PEOPLE.map((p) =>
lane(
p.id,
p.id === ME ? `${p.name} (you)` : p.name,
issues.filter((i) => i.assignee === p.id),
p,
),
),
lane(
"none",
"Unassigned",
issues.filter((i) => !i.assignee),
),
].filter((l) => l.count > 0);
}
return [
...EPICS.map((e) =>
lane(
e.id,
e.name,
issues.filter((i) => i.epic === e.id),
null,
e,
),
),
lane(
"none",
"No epic",
issues.filter((i) => !i.epic),
),
].filter((l) => l.count > 0);
});
protected readonly totalPoints = computed(() => pointsOf(this.issues()));
protected readonly donePoints = computed(() =>
pointsOf(this.issues().filter((i) => i.status === "done")),
);
protected readonly doneCount = computed(
() => this.issues().filter((i) => i.status === "done").length,
);
protected readonly progressSegments = computed<SoneStackedBarSegment[]>(
() => {
const sum = (status: StatusId) =>
pointsOf(this.issues().filter((i) => i.status === status));
return [
{ key: "done", label: "Done", value: sum("done"), tone: "success" },
{
key: "review",
label: "In review",
value: sum("review"),
tone: "chart-6",
},
{
key: "progress",
label: "In progress",
value: sum("progress"),
tone: "accent",
},
];
},
);
protected readonly selected = computed(
() => this.issues().find((i) => i.id === this.selectedId()) ?? null,
);
protected readonly personOf = personOf;
protected readonly epicOf = epicOf;
protected tone(epic: Epic): string {
return `var(--${epic.tone})`;
}
protected typeIcon(i: Issue): ShellIcon {
return TYPES[i.type].icon;
}
protected typeLabel(i: Issue): string {
return TYPES[i.type].label;
}
protected priorityIcon(i: Issue): ShellIcon {
return PRIORITIES[i.priority].icon;
}
protected priorityLabel(i: Issue): string {
return PRIORITIES[i.priority].label;
}
protected subtasksDone(i: Issue): number {
return i.subtasks.filter((t) => t.done).length;
}
protected commentsOf(i: Issue): readonly Comment[] {
return [...i.comments].reverse();
}
protected updatedLabel(i: Issue): string {
if (i.updated === 0) return "Today";
return i.updated === 1 ? "Yesterday" : `${i.updated} days ago`;
}
/** The column heading, prefixed by the lane name when the board is grouped. */
protected cellLabel(lane: Lane, status: Status): string {
const column = `board-col-${status.id}`;
return lane.title === null
? column
: `board-lane-name-${lane.key} ${column}`;
}
protected say(message: string): void {
this.announcement.set(message);
}
protected completeSprint(): void {
const open = this.issues().filter((i) => i.status !== "done").length;
this.say(
`${SPRINT.name} completed: ${this.doneCount()} issues done, ${open} moved to the next sprint.`,
);
}
protected toggleAssignee(id: string): void {
this.assignees.update((list) =>
list.includes(id) ? list.filter((p) => p !== id) : [...list, id],
);
}
protected setGroupBy(value: string): void {
this.groupBy.set(value as GroupBy);
this.collapsed.set([]);
}
protected toggleLane(key: string): void {
this.collapsed.update((list) =>
list.includes(key) ? list.filter((k) => k !== key) : [...list, key],
);
}
protected clearFilters(): void {
this.query.set("");
this.assignees.set([]);
this.mine.set(false);
this.recent.set(false);
this.bugs.set(false);
this.epic.set("all");
}
protected open(id: string): void {
this.selectedId.set(id);
this.draft.set("");
afterNextRender(() => this.focus("#board-detail-title"), {
injector: this.injector,
});
}
protected close(): void {
const id = this.selectedId();
this.selectedId.set(null);
if (id) this.focusLater(`#board-open-${id}`);
}
// ---- Moving issues: drag and drop, the card menu, the keyboard, the panel.
protected onDragStart(event: DragEvent, id: string): void {
this.dragId.set(id);
event.dataTransfer?.setData("text/plain", id);
if (event.dataTransfer) event.dataTransfer.effectAllowed = "move";
}
protected onDragEnd(): void {
this.dragId.set(null);
this.dropTarget.set(null);
}
protected onDragOver(event: DragEvent, lane: string, status: StatusId): void {
if (!this.dragId()) return;
event.preventDefault();
if (event.dataTransfer) event.dataTransfer.dropEffect = "move";
this.dropTarget.set(`${lane}:${status}`);
}
protected onDragLeave(
event: DragEvent,
lane: string,
status: StatusId,
): void {
const into = event.relatedTarget as Node | null;
if (into && (event.currentTarget as Node).contains(into)) return;
if (this.dropTarget() === `${lane}:${status}`) this.dropTarget.set(null);
}
protected onDrop(event: DragEvent, lane: string, status: StatusId): void {
event.preventDefault();
const id = this.dragId() ?? event.dataTransfer?.getData("text/plain");
this.onDragEnd();
if (!id) return;
// Dropped in another swimlane: the card takes that lane's assignee or epic.
const group = this.groupBy();
const value = lane === "none" ? null : lane;
if (group === "assignee") this.assign(id, value, false);
if (group === "epic") this.patch(id, { epic: value });
this.moveTo(id, status);
}
/** Shift + ← / → moves the focused card one column; focus follows it. */
protected onCardKeydown(event: KeyboardEvent, issue: Issue): void {
if (!event.shiftKey) return;
const delta =
event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
if (!delta) return;
event.preventDefault();
const index = STATUSES.findIndex((s) => s.id === issue.status) + delta;
const target = STATUSES[index];
if (!target) return;
this.moveTo(issue.id, target.id);
this.focusLater(`#board-open-${issue.id}`);
}
protected moveTo(id: string, status: StatusId): void {
const issue = this.issues().find((i) => i.id === id);
if (!issue || issue.status === status) return;
// A moved card goes to the bottom of its new column.
this.issues.update((all) => [
...all.filter((i) => i.id !== id),
{ ...issue, status, updated: 0 },
]);
const target = statusOf(status);
const over =
target.wip !== null &&
this.issues().filter((i) => i.status === status).length > target.wip;
this.say(
`${id} moved to ${target.label}.` +
(over ? ` ${target.label} is over its limit of ${target.wip}.` : ""),
);
}
/** From the card menu: focus follows the card to its new column. */
protected moveFromMenu(id: string, status: StatusId): void {
this.moveTo(id, status);
this.focusLater(`#board-open-${id}`);
}
protected assign(id: string, person: string | null, announce = true): void {
this.patch(id, { assignee: person });
if (announce) {
this.say(
person
? `${id} assigned to ${personOf(person)?.name}.`
: `${id} unassigned.`,
);
}
}
protected toggleFlag(id: string): void {
const issue = this.issues().find((i) => i.id === id);
if (!issue) return;
this.patch(id, { flagged: !issue.flagged });
this.say(issue.flagged ? `Flag removed from ${id}.` : `${id} flagged.`);
}
protected remove(id: string): void {
// Focus moves to the next card in the same list, else to the board.
const order = this.lanes().flatMap((l) =>
l.cells.flatMap((c) => c.issues.map((i) => i.id)),
);
const at = order.indexOf(id);
const next = order[at + 1] ?? order[at - 1];
this.issues.update((all) => all.filter((i) => i.id !== id));
if (this.selectedId() === id) this.selectedId.set(null);
this.say(`${id} deleted.`);
afterNextRender(
() =>
(next && this.focus(`#board-open-${next}`)) ||
this.focus("#board-title"),
{ injector: this.injector },
);
}
protected setPoints(id: string, value: string): void {
this.patch(id, { points: value ? Number(value) : null });
}
protected rename(id: string, summary: string): void {
const text = summary.trim();
if (text) this.patch(id, { summary: text });
}
protected toggleSubtask(id: string, subtask: string): void {
this.update(id, (i) => ({
...i,
subtasks: i.subtasks.map((t) =>
t.id === subtask ? { ...t, done: !t.done } : t,
),
}));
}
protected addComment(event: Event, id: string): void {
event.preventDefault();
const text = this.draft().trim();
if (!text) return;
this.update(id, (i) => ({
...i,
comments: [
...i.comments,
{ id: `c${i.comments.length + 1}`, author: ME, when: "Just now", text },
],
}));
this.draft.set("");
this.say("Comment saved.");
}
// ---- Creating an issue inline, at the bottom of To Do.
protected startCreate(): void {
this.creating.set(true);
this.focusLater("#board-new-summary");
}
protected cancelCreate(): void {
this.creating.set(false);
this.newSummary.set("");
this.focusLater("#board-create");
}
protected create(event: Event): void {
event.preventDefault();
const summary = this.newSummary().trim();
if (!summary) return;
const id = `SO-${Math.max(...this.issues().map((i) => keyNumber(i.id)), 153) + 1}`;
const epic = this.epic();
this.issues.update((all) => [
...all,
{
id,
type: this.newType() as IssueType,
summary,
status: "todo",
assignee: null,
reporter: ME,
priority: "medium",
points: null,
epic: epic === "all" || epic === "none" ? null : epic,
labels: [],
flagged: false,
updated: 0,
description: "No description yet.",
subtasks: [],
comments: [],
},
]);
this.newSummary.set("");
this.say(`${id} created in To Do.`);
}
protected patch(id: string, changes: Partial<Issue>): void {
this.update(id, (i) => ({ ...i, ...changes, updated: 0 }));
}
private update(id: string, fn: (issue: Issue) => Issue): void {
this.issues.update((all) => all.map((i) => (i.id === id ? fn(i) : i)));
}
private focusLater(selector: string): void {
afterNextRender(() => this.focus(selector), { injector: this.injector });
}
private focus(selector: string): boolean {
const el = this.host.nativeElement.querySelector<HTMLElement>(selector);
el?.focus();
return !!el;
}
}