Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/desktop/src/lib/components/Board.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
moveList,
deleteList
} from '$lib/stores/board';
import { collapsed, toggleCollapsed } from '$lib/stores/collapsed';
import type { List, Ticket } from '$lib/types';

let { onopen, onadd }: { onopen: (t: Ticket) => void; onadd: (id: string, name: string) => void } =
Expand Down Expand Up @@ -158,6 +159,7 @@
{flipMs}
{dragActive}
{overTrash}
collapsed={$collapsed.includes(col.list)}
dragDisabled={$rewinding}
canMoveLeft={i > 0}
canMoveRight={i < cols.length - 1}
Expand All @@ -166,6 +168,7 @@
onmove={handleMove}
onrename={(id, name) => renameList(id, name)}
ondelete={(id) => deleteList(id)}
oncollapse={toggleCollapsed}
onconsider={handleConsider}
onfinalize={handleFinalize}
ondragel={(el) => (draggedEl = el)}
Expand Down
131 changes: 123 additions & 8 deletions apps/desktop/src/lib/components/Column.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
MoreHorizontal,
ChevronLeft,
ChevronRight,
ChevronsLeftRight,
ChevronsRightLeft,
Pencil,
Trash2,
Bell,
Expand All @@ -25,13 +27,15 @@
dragDisabled,
dragActive = false,
overTrash = false,
collapsed = false,
canMoveLeft = false,
canMoveRight = false,
onopen,
onadd,
onmove,
onrename,
ondelete,
oncollapse,
onconsider,
onfinalize,
ondragel
Expand All @@ -43,13 +47,15 @@
dragDisabled: boolean;
dragActive?: boolean;
overTrash?: boolean;
collapsed?: boolean;
canMoveLeft?: boolean;
canMoveRight?: boolean;
onopen: (t: Ticket) => void;
onadd: (listId: string, name: string) => void;
onmove?: (listId: string, dir: -1 | 1) => void;
onrename?: (listId: string, name: string) => void;
ondelete?: (listId: string) => void;
oncollapse?: (listId: string) => void;
onconsider: (listId: string, items: Ticket[]) => void;
onfinalize: (listId: string, items: Ticket[], info: { id: string; trigger: string }) => void;
ondragel?: (el: HTMLElement | null) => void;
Expand Down Expand Up @@ -157,6 +163,18 @@
if (before?.size && zone) play(zone, before);
});

// A collapsed list is a narrow strip: name, count, expand button. It stays a
// drop zone (the strip itself), but shows no cards, so there is no position to
// aim for - a card dropped on it goes to the top of the list, where it is the
// first thing seen when the list is expanded again.
function finalize(items: Ticket[], info: { id: string; trigger: string }) {
if (collapsed && info.trigger === 'droppedIntoZone') {
const dropped = items.find((t) => t.id === info.id);
if (dropped) items = [dropped, ...items.filter((t) => t.id !== info.id)];
}
onfinalize(listId, items, info);
}

let renaming = $state(false);
let renameDraft = $state('');

Expand All @@ -171,7 +189,25 @@
}
</script>

<section class="column" class:target={isTarget}>
<section class="column" class:collapsed class:target={isTarget}>
{#if collapsed}
<!-- The whole strip expands the list. The drop zone below lies over it
without taking pointer events (the drag library works on geometry). -->
<button
class="strip"
aria-expanded="false"
aria-label={`Expand list ${name}`}
title="Expand list"
onclick={() => oncollapse?.(listId)}
>
<span class="strip-icon"><ChevronsLeftRight size={15} /></span>
<span class="count" class:filtered={!!$searchMatches}
>{#if $searchMatches}{shown}/{tickets.length}{:else}{tickets.length}{/if}</span
>
{#if $watches.lists.includes(listId)}<span class="watching"><BellRing size={12} /></span>{/if}
<span class="col-name">{name}</span>
</button>
{/if}
<header class="col-head">
{#if renaming}
<!-- svelte-ignore a11y_autofocus -->
Expand All @@ -194,8 +230,19 @@
>{#if $searchMatches}{shown}/{tickets.length}{:else}{tickets.length}{/if}</span
>
{/if}
{#if !renaming}
<button
class="add"
aria-expanded="true"
aria-label="Collapse list"
title="Collapse list"
onclick={() => oncollapse?.(listId)}
>
<ChevronsRightLeft size={15} />
</button>
{/if}
{#if !dragDisabled}
<button class="add" aria-label="Add card" onclick={() => onadd(listId, name)}>
<button class="add next" aria-label="Add card" onclick={() => onadd(listId, name)}>
<Plus size={15} />
</button>
<Popover align="end" width="180px">
Expand Down Expand Up @@ -276,7 +323,10 @@
// A release over the trash is outside every zone, so the library would
// first animate the card back to its origin and only then let it vanish.
// Over the bin, skip that return trip: the card is being deleted.
dropAnimationDisabled: overTrash,
// Nor is there a slot to fly to in a collapsed list, or a card size to take
// on there: the card keeps its shape over the strip and lands at once.
dropAnimationDisabled: overTrash || collapsed,
morphDisabled: collapsed,
// Disable the library's built-in target styling: it highlights EVERY valid
// zone. We glow just the hovered column ourselves via `isTarget` below.
dropTargetStyle: {},
Expand All @@ -298,16 +348,18 @@
}
}}
onconsider={(e: CustomEvent<DndEvent<Ticket>>) => onconsider(listId, e.detail.items)}
onfinalize={(e: CustomEvent<DndEvent<Ticket>>) =>
onfinalize(listId, e.detail.items, e.detail.info)}
onfinalize={(e: CustomEvent<DndEvent<Ticket>>) => finalize(e.detail.items, e.detail.info)}
>
{#each tickets as ticket (ticket.id)}
<div
class="item"
data-id={ticket.id}
class:hidden={$searchMatches && !(marker in ticket) && !$searchMatches.has(ticket.id)}
>
{#if marker in ticket}
{#if collapsed}
<!-- No cards in a collapsed list: one empty element per ticket keeps the
zone's children in step with its items, which the drag library needs. -->
{:else if marker in ticket}
<!-- The drop slot: render the dragged card hidden so the gap is EXACTLY
its size, with a dashed outline showing where it will land. -->
<div class="slot">
Expand All @@ -323,7 +375,7 @@
<!-- Kept OUTSIDE the dndzone: svelte-dnd-action treats every direct child of
the zone as a draggable item, so an add-card control living inside it
would be grabbable and corrupt the item list on drag. -->
{#if !dragDisabled}
{#if !dragDisabled && !collapsed}
<button class="add-card" onclick={() => onadd(listId, name)}>
<Plus size={14} /> Add a card
</button>
Expand All @@ -332,7 +384,7 @@

<style>
@media (max-width: 700px) {
.column {
.column:not(.collapsed) {
width: 84vw !important;
max-width: 420px;
}
Expand All @@ -353,6 +405,66 @@
box-shadow var(--wp-fast) var(--wp-ease),
background var(--wp-fast) var(--wp-ease);
}
/* Collapsed: a strip as tall as the board - easy to find again, and a tall
target for a card dragged onto it. */
.column.collapsed {
position: relative;
width: 44px;
align-self: stretch;
}
.column.collapsed .col-head {
display: none;
}
.strip {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;
gap: 10px;
padding: 12px 0;
border: none;
border-radius: inherit;
background: none;
cursor: pointer;
overflow: hidden;
}
.strip-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
flex: none;
border-radius: var(--wp-r-sm);
color: var(--wp-text-muted);
transition: all var(--wp-fast) var(--wp-ease);
}
.strip:hover .strip-icon,
.strip:focus-visible .strip-icon {
background: var(--wp-elevated);
color: var(--wp-text);
}
.strip .count,
.strip .watching {
flex: none;
}
/* The name reads top to bottom; a long one is cut at the strip's end. */
.strip .col-name {
writing-mode: vertical-rl;
min-height: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.column.collapsed .col-body {
position: absolute;
inset: 0;
min-height: 0;
padding: 0;
overflow: hidden;
pointer-events: none;
}
/* The single list a release would land in - glow it in the accent color. */
.column.target {
border-color: color-mix(in srgb, var(--wp-accent) 65%, transparent);
Expand Down Expand Up @@ -409,6 +521,9 @@
cursor: pointer;
transition: all var(--wp-fast) var(--wp-ease);
}
.add.next {
margin-left: 0;
}
.add:hover {
background: var(--wp-elevated);
color: var(--wp-text);
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/src/lib/stores/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { writable, derived, get } from 'svelte/store';
import { api, subscribeChanges } from '$lib/api';
import { applyServerDefaults } from '$lib/stores/theme';
import { notifyBoardChanges, notifyForum, useWatchesOf } from '$lib/stores/notify';
import { useCollapsedOf } from '$lib/stores/collapsed';
import type {
Board,
Definitions,
Expand Down Expand Up @@ -52,6 +53,8 @@ currentProject.subscribe((v) => {
lsSet(PROJECT_KEY, v);
// Watches (what to notify about) are per board.
if (typeof localStorage !== 'undefined') useWatchesOf(v);
// So are the lists you collapsed.
if (typeof localStorage !== 'undefined') useCollapsedOf(v);
});

export const definitions = writable<Definitions>({
Expand Down
43 changes: 43 additions & 0 deletions apps/desktop/src/lib/stores/collapsed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Collapsed lists in the board UI.
//
// A list you rarely read (a finished one, say) can be folded to a narrow strip
// that keeps its name and ticket count. That is a view preference, not board
// state: like watches it is kept per board and per browser (localStorage), so it
// changes nothing for teammates or agents and never touches `.wipe/`.
import { writable, get } from 'svelte/store';

function key(project: string | null): string {
return `wipe:collapsed:${project ?? ''}`;
}

function load(project: string | null): string[] {
try {
const raw = JSON.parse(localStorage.getItem(key(project)) ?? '[]');
return Array.isArray(raw) ? raw.filter((x) => typeof x === 'string') : [];
} catch {
return [];
}
}

/** Ids of the current board's collapsed lists. */
export const collapsed = writable<string[]>([]);
let collapsedProject: string | null = null;

/** Switch to (and load) the collapsed lists of `project`. */
export function useCollapsedOf(project: string | null): void {
collapsedProject = project;
collapsed.set(load(project));
}

/** Collapse an expanded list, expand a collapsed one. */
export function toggleCollapsed(listId: string): void {
const now = get(collapsed);
const next = now.includes(listId) ? now.filter((x) => x !== listId) : [...now, listId];
collapsed.set(next);
try {
if (next.length) localStorage.setItem(key(collapsedProject), JSON.stringify(next));
else localStorage.removeItem(key(collapsedProject));
} catch {
/* best-effort */
}
}