Merge pull request 'Give the phone its own harbour UI instead of a squeezed desktop.' (#1) from cursor/mobile-harbour-sheet into main

Reviewed-on: #1
This commit is contained in:
2026-11-08 03:02:45 +08:00
4 changed files with 335 additions and 67 deletions

View File

@@ -7,7 +7,7 @@
--buoy: #E8A33D; --buoy: #E8A33D;
/* Boat slots on the water: a boat's width and one slot row's height. */ /* Boat slots on the water: a boat's width and one slot row's height. */
--boat-w: 120px; --boat-w: 120px;
--slot-h: 152px; --slot-h: 176px;
--paper: #F6F2EA; --paper: #F6F2EA;
--sand: #E8D9BB; --sand: #E8D9BB;
--quay: #B98B5E; --quay: #B98B5E;
@@ -58,7 +58,9 @@ button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px soli
.brand span { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.5px; } .brand span { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
h1 { position: relative; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 46px; line-height: 1.05; letter-spacing: -1px; } h1 { position: relative; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 46px; line-height: 1.05; letter-spacing: -1px; }
.empty { position: relative; margin: 0; max-width: 520px; font-size: 17px; line-height: 1.5; } .empty { position: relative; margin: 0; max-width: 520px; font-size: 17px; line-height: 1.5; }
.legend { position: relative; margin: -8px 0 0; max-width: 520px; font-size: 13px; line-height: 1.4; color: #1E4A51; opacity: .78; }
.stale { position: relative; margin: 0; align-self: flex-start; font-size: 14px; background: rgba(255,253,248,.85); border-radius: 999px; padding: 6px 14px; } .stale { position: relative; margin: 0; align-self: flex-start; font-size: 14px; background: rgba(255,253,248,.85); border-radius: 999px; padding: 6px 14px; }
.scrim { display: none; }
main { position: relative; display: flex; flex-direction: column; } main { position: relative; display: flex; flex-direction: column; }
.lane { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 34px 0 12px; } .lane { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 34px 0 12px; }
@@ -83,7 +85,8 @@ main { position: relative; display: flex; flex-direction: column; }
/* Boats */ /* Boats */
.boat { position: relative; background: transparent; border: 0; border-radius: 18px; padding: 4px 2px 8px; width: var(--boat-w); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; } .boat { position: relative; background: transparent; border: 0; border-radius: 18px; padding: 4px 2px 8px; width: var(--boat-w); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.boat.dim { opacity: .3; } .boat.dim { opacity: .42; }
.boat.needs:not(.dim) .chip { box-shadow: 0 0 0 2px var(--buoy); }
.boat.done { opacity: .8; } .boat.done { opacity: .8; }
.boat .hull { display: block; position: relative; width: 96px; height: 72px; animation: float 4.6s ease-in-out infinite; transform-origin: 50% 85%; transition: filter .2s ease; } .boat .hull { display: block; position: relative; width: 96px; height: 72px; animation: float 4.6s ease-in-out infinite; transform-origin: 50% 85%; transition: filter .2s ease; }
.boat.done .hull { animation-name: calm; animation-duration: 6s; } .boat.done .hull { animation-name: calm; animation-duration: 6s; }
@@ -92,7 +95,9 @@ main { position: relative; display: flex; flex-direction: column; }
.boat.picked .shade { background: rgba(255,255,255,.95); } .boat.picked .shade { background: rgba(255,255,255,.95); }
.boat:hover .hull { filter: brightness(1.06); animation-duration: 2.2s; } .boat:hover .hull { filter: brightness(1.06); animation-duration: 2.2s; }
.boat .chip { font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; padding: 4px 10px; border-radius: 10px; background: rgba(255,253,248,.82); overflow-wrap: anywhere; } .boat .chip { font-size: 13px; font-weight: 700; line-height: 1.2; text-align: center; padding: 4px 10px; border-radius: 10px; background: rgba(255,253,248,.82); overflow-wrap: anywhere; }
.boat.picked .chip { background: var(--teal); color: #fff; } .boat.picked .chip { background: var(--teal); color: #fff; box-shadow: none; }
.boat .boat-title { max-width: 100%; font-size: 11px; line-height: 1.25; text-align: center; color: #1E4A51; opacity: .9; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.boat.picked .boat-title { color: var(--ink); opacity: 1; }
.boat .marks { display: flex; align-items: center; justify-content: center; gap: 8px; height: 16px; } .boat .marks { display: flex; align-items: center; justify-content: center; gap: 8px; height: 16px; }
.boat .anchor { position: absolute; left: -10px; top: 40px; animation: sway 3s ease-in-out infinite; transform-origin: 18px 0; } .boat .anchor { position: absolute; left: -10px; top: 40px; animation: sway 3s ease-in-out infinite; transform-origin: 18px 0; }
.boat .buoy { position: absolute; right: -6px; top: 46px; width: 18px; height: 22px; animation: float 3.4s ease-in-out infinite; } .boat .buoy { position: absolute; right: -6px; top: 46px; width: 18px; height: 22px; animation: float 3.4s ease-in-out infinite; }
@@ -160,8 +165,7 @@ aside { min-width: 0; }
.stamp { margin: -8px 0 0; font-size: 12px; color: var(--ink-soft); } .stamp { margin: -8px 0 0; font-size: 12px; color: var(--ink-soft); }
.todo-list { display: flex; flex-direction: column; gap: 12px; } .todo-list { display: flex; flex-direction: column; gap: 12px; }
.todo-item { text-align: left; border: 0; cursor: pointer; background: #FBEBD0; border-radius: 18px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; } .todo-item { text-align: left; border: 0; cursor: pointer; background: #FBEBD0; border-radius: 18px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.todo-item strong { flex: 1; font-size: 15px; } .todo-item .age { flex: none; font-size: 13px; color: #5C4310; }
.todo-item .age { font-size: 13px; color: #5C4310; }
.todo-item .dot { position: relative; flex: none; width: 12px; height: 12px; } .todo-item .dot { position: relative; flex: none; width: 12px; height: 12px; }
.todo-item .dot i { position: absolute; inset: 0; border-radius: 50%; background: var(--buoy); } .todo-item .dot i { position: absolute; inset: 0; border-radius: 50%; background: var(--buoy); }
.todo-item .dot i:first-child { animation: pulse 1.8s ease-out infinite; } .todo-item .dot i:first-child { animation: pulse 1.8s ease-out infinite; }
@@ -176,34 +180,203 @@ aside { min-width: 0; }
:root { --boat-w: 104px; } :root { --boat-w: 104px; }
} }
/* Phone: the shore becomes a sheet rising from the bottom. */ /* Phone: full harbour + floating dock + bottom sheet for detail. */
@media (max-width: 899px) { @media (max-width: 899px) {
.harbour { display: block; min-height: 100vh; background: linear-gradient(180deg, var(--water-a) 0%, var(--water-b) 60%, var(--water-c) 100%); } .harbour {
.water { padding: 22px 20px 50vh; gap: 18px; } display: block;
min-height: 100vh;
min-height: 100dvh;
background: linear-gradient(180deg, var(--water-a) 0%, var(--water-b) 55%, var(--water-c) 100%);
overflow: visible;
}
.water {
padding: 18px 16px calc(88px + env(safe-area-inset-bottom));
gap: 14px;
min-height: 100vh;
min-height: 100dvh;
}
.brand span { font-size: 22px; } .brand span { font-size: 22px; }
h1 { font-size: 32px; letter-spacing: -.5px; } h1 { font-size: 28px; letter-spacing: -.5px; }
.zones { grid-template-columns: 1fr; gap: 14px; height: auto; transition: none; } .legend { margin-top: -4px; font-size: 12px; }
.boats { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.zone.beres .boats { justify-content: flex-start; }
.zones { padding-right: 0; }
aside, .shore-top { position: static; }
.zone .floats, .quay, .pilings { display: none; } .zone .floats, .quay, .pilings { display: none; }
.lane, .lane.has-break { padding: 14px 0 22px; }
.lane h2 { font-size: 20px; }
.breakwater {
left: 0; right: 0; bottom: -6px; height: 10px;
border-radius: 999px;
background-image: none;
background-color: rgba(168, 158, 140, .55);
box-shadow: none;
}
.breakwater svg { display: none; }
/* One strip per zone; boats scroll sideways. */
.zones {
display: flex;
flex-direction: column;
gap: 12px;
height: auto;
padding-right: 0;
transition: none;
}
.zone {
background: rgba(255, 253, 248, .34);
border-radius: 18px;
padding: 10px 10px 8px;
}
.zone-label { margin-bottom: 2px; }
.boats {
display: flex;
flex-wrap: nowrap;
gap: 4px 8px;
overflow-x: auto;
overscroll-behavior-x: contain;
scroll-snap-type: x mandatory;
-webkit-overflow-scrolling: touch;
padding: 2px 4px 6px;
margin: 0 -2px;
scrollbar-width: none;
}
.boats::-webkit-scrollbar { display: none; }
.zone.beres .boats { justify-content: flex-start; } .zone.beres .boats { justify-content: flex-start; }
.lane, .lane.has-break { padding: 18px 0 28px; } .boat {
.breakwater { left: 40px; } flex: 0 0 auto;
.boat { width: 104px; } width: 112px;
.shore { position: fixed; z-index: 10; top: auto; left: 0; right: 0; bottom: 0; height: auto; max-height: 72vh; overflow-y: auto; padding: 16px 18px calc(24px + env(safe-area-inset-bottom)); border-radius: 0; box-shadow: 0 -6px 0 rgba(23,43,51,.05); } scroll-snap-align: start;
.shore-inner { height: auto; gap: 16px; padding: 0; } min-height: 148px;
.shore-inner aside { overflow: visible; padding: 0; scrollbar-gutter: auto; } padding-top: 6px;
.shore-top { padding-right: 0; } }
.boat .hull { width: 88px; height: 66px; }
.boat .hull svg { width: 88px; height: 66px; }
.boat .boat-title { font-size: 12px; -webkit-line-clamp: 2; }
/* Dock + sheet share .shore so the scrim can never paint over #detail.
Shore must be a full-viewport layer: its children are all out-of-flow, so
height:auto collapses to 0 and the sheet ends up above the screen. */
.shore {
position: fixed;
z-index: 20;
inset: 0;
width: 100%;
height: 100%;
height: 100dvh;
max-height: none;
flex: none;
background: transparent;
background-image: none;
box-shadow: none;
padding: 0;
pointer-events: none;
}
.shore-inner {
position: absolute;
inset: 0;
gap: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: flex-end;
pointer-events: none;
}
.shore .edge { display: none; } .shore .edge { display: none; }
.shore::before { content: ''; position: sticky; top: -16px; display: block; height: 0; } .shore-top {
.card { padding: 18px; gap: 18px; border-radius: 24px; } position: relative;
z-index: 3;
pointer-events: auto;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin: 0 12px calc(12px + env(safe-area-inset-bottom));
padding: 8px;
background: rgba(246, 242, 234, .96);
border: 1px solid rgba(23, 43, 51, .06);
border-radius: 22px;
box-shadow: 0 10px 28px rgba(23, 43, 51, .14);
backdrop-filter: blur(10px);
transition: opacity .2s ease, transform .2s ease;
}
.harbour[data-sheet="detail"] .shore-top,
.harbour[data-sheet="list"] .shore-top {
opacity: 0;
transform: translateY(12px);
pointer-events: none;
}
.seg { flex: 1 1 auto; min-width: 0; }
.seg button { flex: 1 1 auto; justify-content: center; min-height: 44px; padding: 6px 12px; font-size: 14px; }
.seg #show-mine { padding-right: 8px; }
.avatar { width: 40px; height: 40px; }
.scrim {
display: block;
position: absolute;
inset: 0;
z-index: 1;
border: 0;
padding: 0;
margin: 0;
background: rgba(23, 43, 51, .28);
opacity: 0;
pointer-events: none;
transition: opacity .22s ease;
}
.harbour[data-sheet="detail"] .scrim,
.harbour[data-sheet="list"] .scrim {
opacity: 1;
pointer-events: auto;
}
.scrim[hidden] { display: none !important; }
#detail {
position: absolute;
z-index: 2;
left: 0;
right: 0;
bottom: 0;
max-height: min(92dvh, 860px);
overflow-y: auto;
overscroll-behavior: contain;
pointer-events: auto;
padding: 0 14px calc(18px + env(safe-area-inset-bottom));
background: var(--paper);
background-image: radial-gradient(#E2D8C6 1.2px, transparent 1.4px);
background-size: 24px 24px;
border-radius: 28px 28px 0 0;
box-shadow: 0 -12px 40px rgba(23, 43, 51, .18);
transform: translateY(110%);
transition: transform .28s cubic-bezier(.2, .8, .2, 1);
scrollbar-gutter: auto;
}
#detail::before {
content: '';
display: block;
width: 44px;
height: 5px;
margin: 10px auto 14px;
border-radius: 999px;
background: #D5CBB8;
}
.harbour[data-sheet="detail"] #detail,
.harbour[data-sheet="list"] #detail {
transform: translateY(0);
}
.harbour[data-sheet="closed"] #detail {
pointer-events: none;
}
body.sheet-open { overflow: hidden; }
.card { padding: 4px 4px 18px; gap: 18px; border-radius: 0; box-shadow: none; background: transparent; }
.card h2 { font-size: 22px; } .card h2 { font-size: 22px; }
.tone { padding: 16px; } .tone { padding: 16px; }
.tone .icon { width: 44px; height: 44px; } .tone .icon { width: 44px; height: 44px; }
.tone .word { font-size: 24px; } .tone .word { font-size: 24px; }
.seg button { padding: 6px 14px; }
.actions .buttons.main { display: flex; flex-direction: column; gap: 10px; }
.actions .buttons.main .act { width: 100%; min-height: 52px; }
.actions .buttons.side { display: flex; gap: 10px; }
.actions .buttons.side .act { flex: 1 1 0; min-height: 48px; }
.release-row { flex-direction: column; }
.release-row .act { width: 100%; min-height: 52px; }
} }
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
@@ -211,11 +384,14 @@ aside { min-width: 0; }
} }
/* Gate and rubric pages */ /* Gate and rubric pages */
.page-gate, .page-rubric { background: var(--paper); min-height: 100vh; } .page-gate, .page-rubric { background: var(--paper); min-height: 100vh; color: var(--ink); font-family: var(--sans); }
.page-gate main { max-width: 440px; margin: 0 auto; padding: 18vh 20px 40px; display: flex; flex-direction: column; gap: 18px; } .page-gate main { max-width: 440px; margin: 0 auto; padding: 16vh 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.page-gate h1 { font-size: 40px; } .page-gate .brand { margin-bottom: 8px; }
.page-gate p { margin: 0; font-size: 17px; line-height: 1.5; } .page-gate .brand span { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
.page-gate h1 { font-family: var(--serif); font-weight: 600; font-size: 40px; line-height: 1.1; letter-spacing: -1px; margin: 0; }
.page-gate p { margin: 0; font-size: 17px; line-height: 1.5; color: var(--ink-soft); }
.btn { align-self: flex-start; display: inline-flex; align-items: center; min-height: 52px; padding: 0 26px; border-radius: 999px; background: var(--teal); color: #fff !important; font-weight: 700; text-decoration: none; } .btn { align-self: flex-start; display: inline-flex; align-items: center; min-height: 52px; padding: 0 26px; border-radius: 999px; background: var(--teal); color: #fff !important; font-weight: 700; text-decoration: none; }
.btn:hover { background: var(--teal-deep); }
.page-rubric main { max-width: 760px; margin: 0 auto; padding: 40px 20px 80px; line-height: 1.55; } .page-rubric main { max-width: 760px; margin: 0 auto; padding: 40px 20px 80px; line-height: 1.55; }
.page-rubric h1, .page-rubric h2, .page-rubric h3 { font-family: var(--serif); scroll-margin-top: 20px; } .page-rubric h1, .page-rubric h2, .page-rubric h3 { font-family: var(--serif); scroll-margin-top: 20px; }
.page-rubric h2:target { background: #FBEBD0; border-radius: 10px; padding: 4px 10px; margin-left: -10px; } .page-rubric h2:target { background: #FBEBD0; border-radius: 10px; padding: 4px 10px; margin-left: -10px; }
@@ -223,6 +399,8 @@ aside { min-width: 0; }
/* Approver actions (M3) */ /* Approver actions (M3) */
.actions { display: flex; flex-direction: column; gap: 12px; } .actions { display: flex; flex-direction: column; gap: 12px; }
.actions .buttons { display: flex; flex-wrap: wrap; gap: 10px; } .actions .buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .buttons.main,
.actions .buttons.side { display: flex; flex-wrap: wrap; gap: 10px; }
.act { min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; } .act { min-height: 48px; padding: 0 22px; border-radius: 999px; border: 0; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.act:disabled { opacity: .5; cursor: progress; } .act:disabled { opacity: .5; cursor: progress; }
.act.primary { background: var(--teal); color: #fff; min-width: 120px; } .act.primary { background: var(--teal); color: #fff; min-width: 120px; }
@@ -231,7 +409,7 @@ aside { min-width: 0; }
.act.danger { background: #F8DDD5; color: #9A2E1A; } .act.danger { background: #F8DDD5; color: #9A2E1A; }
.countdown { margin: 0; font-size: 15px; font-weight: 700; color: #6B4206; } .countdown { margin: 0; font-size: 15px; font-weight: 700; color: #6B4206; }
.note-label { font-size: 14px; font-weight: 700; color: #24525A; } .note-label { font-size: 14px; font-weight: 700; color: #24525A; }
.actions textarea { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 2px solid #E2D8C6; resize: vertical; } .actions textarea { font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 16px; border: 2px solid #E2D8C6; resize: vertical; width: 100%; }
.actions textarea:focus-visible { outline: 3px solid var(--buoy); outline-offset: 1px; } .actions textarea:focus-visible { outline: 3px solid var(--buoy); outline-offset: 1px; }
.act-error { margin: 0; font-size: 14px; color: #9A2E1A; } .act-error { margin: 0; font-size: 14px; color: #9A2E1A; }
@@ -248,4 +426,6 @@ aside { min-width: 0; }
.changelog .by { color: var(--ink-soft); font-size: 14px; } .changelog .by { color: var(--ink-soft); font-size: 14px; }
.boat.sailing .hull { animation-name: sail; animation-duration: 2.6s; } .boat.sailing .hull { animation-name: sail; animation-duration: 2.6s; }
@keyframes sail { 0%, 100% { transform: translate(0, 0) rotate(-1deg); } 50% { transform: translate(6px, -3px) rotate(1.5deg); } } @keyframes sail { 0%, 100% { transform: translate(0, 0) rotate(-1deg); } 50% { transform: translate(6px, -3px) rotate(1.5deg); } }
@media (max-width: 899px) { .act { flex: 1 1 auto; } } .todo-item .todo-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.todo-item .todo-copy strong { font-size: 15px; }
.todo-item .todo-copy span { font-size: 13px; color: #5C4310; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

View File

@@ -41,8 +41,14 @@
todo: '<svg width="12" height="12" viewBox="0 0 12 12"><path d="M3 6h6M6.5 3.5L9 6l-2.5 2.5" fill="none" stroke="#6B4206" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>', todo: '<svg width="12" height="12" viewBox="0 0 12 12"><path d="M3 6h6M6.5 3.5L9 6l-2.5 2.5" fill="none" stroke="#6B4206" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',
}; };
const state = { cols: null, data: null, sel: null, filter: 'all', seen: new Set(), first: true, failedAt: null, shown: null, composing: null, busy: false, error: null, releaseTag: null }; const state = { cols: null, data: null, sel: null, filter: 'all', listOpen: false, seen: new Set(), first: true, failedAt: null, shown: null, composing: null, busy: false, error: null, releaseTag: null };
const $ = (id) => document.getElementById(id); const $ = (id) => document.getElementById(id);
const phone = window.matchMedia('(max-width: 899px)');
const shortTitle = (t, n = 28) => {
const s = String(t || '').trim().replace(/\s+/g, ' ');
if (!s) return '';
return s.length <= n ? s : `${s.slice(0, n - 1).trimEnd()}…`;
};
function el(tag, attrs, ...children) { function el(tag, attrs, ...children) {
const n = document.createElement(tag); const n = document.createElement(tag);
@@ -113,7 +119,7 @@
const m = META[a.status]; const m = META[a.status];
const picked = state.sel === a.id; const picked = state.sel === a.id;
const dim = state.filter === 'mine' && !a.needsYou; const dim = state.filter === 'mine' && !a.needsYou;
const cls = ['boat', picked && 'picked', dim && 'dim', (a.status === 'done' || a.status === 'rejected') && 'done', a.status === 'sailing' && 'sailing', !state.first && !state.seen.has(a.id) && 'new'].filter(Boolean).join(' '); const cls = ['boat', picked && 'picked', dim && 'dim', a.needsYou && 'needs', (a.status === 'done' || a.status === 'rejected') && 'done', a.status === 'sailing' && 'sailing', !state.first && !state.seen.has(a.id) && 'new'].filter(Boolean).join(' ');
// The bobbing phase comes from the clock and the boat, not its place in the list, so a boat // The bobbing phase comes from the clock and the boat, not its place in the list, so a boat
// drawn again carries on mid-swell instead of jumping back to the start of its loop. // drawn again carries on mid-swell instead of jumping back to the start of its loop.
const seed = hash(`${a.repo}${a.iid}`); const seed = hash(`${a.repo}${a.iid}`);
@@ -122,7 +128,8 @@
const delay = `-${(now % secs).toFixed(2)}s`; const delay = `-${(now % secs).toFixed(2)}s`;
const flagDelay = `-${(now % 2.2).toFixed(2)}s`; const flagDelay = `-${(now % 2.2).toFixed(2)}s`;
const dur = `${secs.toFixed(1)}s`; const dur = `${secs.toFixed(1)}s`;
const b = el('button', { type: 'button', class: cls, 'data-id': a.id, 'aria-label': `${a.label}, ${m.aria}`, 'aria-pressed': picked ? 'true' : 'false', onclick: () => pick(a.id) }); const title = shortTitle(a.title, phone.matches ? 24 : 28);
const b = el('button', { type: 'button', class: cls, 'data-id': a.id, 'aria-label': `${a.label}${a.title ? `, ${a.title}` : ''}, ${m.aria}`, 'aria-pressed': picked ? 'true' : 'false', onclick: () => pick(a.id) });
const hull = el('span', { class: 'hull', style: { animationDelay: delay, animationDuration: dur } }); const hull = el('span', { class: 'hull', style: { animationDelay: delay, animationDuration: dur } });
const h = hullOf(a); const h = hullOf(a);
hull.innerHTML = `<svg width="96" height="72" viewBox="0 0 96 72" aria-hidden="true" style="overflow:visible"><line x1="48" y1="5" x2="48" y2="44" stroke="#172B33" stroke-width="2.5" stroke-linecap="round"/><g class="flag" style="animation-delay:${flagDelay}"><path d="M50 6 Q60 8 72 7 Q67 12.5 72 18 Q60 17 50 19 Z" fill="${m.flag}"/></g><rect x="34" y="29" width="28" height="16" rx="4" fill="#FFFDF8"/><circle cx="42" cy="37" r="2.6" fill="${h}"/><circle cx="54" cy="37" r="2.6" fill="${h}"/><path d="M6 44 H90 L81 61 Q79 65 73 65 H23 Q17 65 15 61 Z" fill="${h}"/><path d="M13 51 H83" stroke="#FFFDF8" stroke-opacity="0.45" stroke-width="2" stroke-linecap="round"/></svg>`; hull.innerHTML = `<svg width="96" height="72" viewBox="0 0 96 72" aria-hidden="true" style="overflow:visible"><line x1="48" y1="5" x2="48" y2="44" stroke="#172B33" stroke-width="2.5" stroke-linecap="round"/><g class="flag" style="animation-delay:${flagDelay}"><path d="M50 6 Q60 8 72 7 Q67 12.5 72 18 Q60 17 50 19 Z" fill="${m.flag}"/></g><rect x="34" y="29" width="28" height="16" rx="4" fill="#FFFDF8"/><circle cx="42" cy="37" r="2.6" fill="${h}"/><circle cx="54" cy="37" r="2.6" fill="${h}"/><path d="M6 44 H90 L81 61 Q79 65 73 65 H23 Q17 65 15 61 Z" fill="${h}"/><path d="M13 51 H83" stroke="#FFFDF8" stroke-opacity="0.45" stroke-width="2" stroke-linecap="round"/></svg>`;
@@ -134,6 +141,7 @@
if (a.status === 'done') if (a.status === 'done')
b.append(el('span', { class: 'rope', 'aria-hidden': 'true', html: '<svg width="20" height="12" viewBox="0 0 20 12"><path d="M0 2 Q10 12 20 4" fill="none" stroke="#7A5A33" stroke-width="1.8" stroke-linecap="round"/></svg>' })); b.append(el('span', { class: 'rope', 'aria-hidden': 'true', html: '<svg width="20" height="12" viewBox="0 0 20 12"><path d="M0 2 Q10 12 20 4" fill="none" stroke="#7A5A33" stroke-width="1.8" stroke-linecap="round"/></svg>' }));
b.append(el('span', { class: 'chip' }, a.label)); b.append(el('span', { class: 'chip' }, a.label));
if (title) b.append(el('span', { class: 'boat-title' }, title));
const marks = el('span', { class: 'marks', 'aria-hidden': 'true' }); const marks = el('span', { class: 'marks', 'aria-hidden': 'true' });
if (a.status === 'checking' || a.status === 'sailing' || a.status === 'gas') marks.innerHTML = ICON.dots; if (a.status === 'checking' || a.status === 'sailing' || a.status === 'gas') marks.innerHTML = ICON.dots;
if (a.status === 'blocked') marks.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M7 9.5l2-2M5.5 11.5l-1 1a2.1 2.1 0 0 1-3-3l2-2a2.1 2.1 0 0 1 3 0M10.5 4.5l1-1a2.1 2.1 0 0 1 3 3l-2 2a2.1 2.1 0 0 1-3 0" fill="none" stroke="#3E4E53" stroke-width="1.8" stroke-linecap="round"/></svg>'; if (a.status === 'blocked') marks.innerHTML = '<svg width="16" height="16" viewBox="0 0 16 16"><path d="M7 9.5l2-2M5.5 11.5l-1 1a2.1 2.1 0 0 1-3-3l2-2a2.1 2.1 0 0 1 3 0M10.5 4.5l1-1a2.1 2.1 0 0 1 3 3l-2 2a2.1 2.1 0 0 1-3 0" fill="none" stroke="#3E4E53" stroke-width="1.8" stroke-linecap="round"/></svg>';
@@ -184,7 +192,6 @@
const SHARE = { cek: 3, siap: 2 }; const SHARE = { cek: 3, siap: 2 };
// Beres is a fixed berth: two boats per row, so four boats in all. // Beres is a fixed berth: two boats per row, so four boats in all.
const BERES_PER_ROW = 2; const BERES_PER_ROW = 2;
const phone = window.matchMedia('(max-width: 899px)');
// Dicek and Siap gas share what Beres leaves: each its share, or what its boats need if more. // Dicek and Siap gas share what Beres leaves: each its share, or what its boats need if more.
function splitWidth(total, needs, least, weights) { function splitWidth(total, needs, least, weights) {
@@ -289,7 +296,7 @@
const lanes = data.lanes.filter((l, i) => used.has(l) || (l !== 'Lainnya' && i < 2)); const lanes = data.lanes.filter((l, i) => used.has(l) || (l !== 'Lainnya' && i < 2));
const main = $('lanes'); const main = $('lanes');
// A refresh that changes nothing on the water leaves the boats alone, so none restarts mid-glide. // A refresh that changes nothing on the water leaves the boats alone, so none restarts mid-glide.
const key = JSON.stringify([lanes, state.sel, state.filter, data.ajuan.map((a) => [a.id, a.lane, a.status, a.label, a.needsYou, state.seen.has(a.id)])]); const key = JSON.stringify([lanes, state.sel, state.filter, data.ajuan.map((a) => [a.id, a.lane, a.status, a.label, a.title, a.needsYou, state.seen.has(a.id)])]);
if (key === drawnLanes && main.childElementCount) return; if (key === drawnLanes && main.childElementCount) return;
drawnLanes = key; drawnLanes = key;
const before = new Map([...main.querySelectorAll('.boat[data-id]')].map((b) => [b.dataset.id, { rect: b.getBoundingClientRect(), node: b }])); const before = new Map([...main.querySelectorAll('.boat[data-id]')].map((b) => [b.dataset.id, { rect: b.getBoundingClientRect(), node: b }]));
@@ -376,6 +383,24 @@
await load(); await load();
} }
function actionLabel(a, k) {
if (k === 'undo' && a.status === 'gas') return 'Batalkan gas';
if (k === 'undo' && a.closeAt) return 'Batal tutup';
if (k === 'undo' && a.status === 'rejected') return 'Batalkan tolak';
if (k === 'gas' && a.dry) return 'Gas (uji coba)';
if (k === 'close' && a.dry) return 'Tutup MR (uji coba)';
return ACTION_LABEL[k];
}
function actionButton(a, k) {
return el('button', {
type: 'button',
class: `act ${k === 'gas' ? 'primary' : k === 'tolak' || k === 'close' ? 'danger' : 'quiet'}`,
disabled: state.busy,
onclick: () => (k === 'tunda' || k === 'tolak' ? (state.composing = { id: a.id, action: k, note: '' }, draw()) : act(a, k)),
}, actionLabel(a, k));
}
function actions(a) { function actions(a) {
const box = el('div', { class: 'actions' }); const box = el('div', { class: 'actions' });
if (a.gasAt || a.closeAt) box.append(el('p', { class: 'countdown', role: 'status', 'data-id': a.id }, countdownText(a))); if (a.gasAt || a.closeAt) box.append(el('p', { class: 'countdown', role: 'status', 'data-id': a.id }, countdownText(a)));
@@ -387,19 +412,17 @@
box.append( box.append(
el('label', { class: 'note-label', for: 'decision-note' }, compose.action === 'tolak' ? 'Tolak ajuan ini' : 'Tunda ajuan ini'), el('label', { class: 'note-label', for: 'decision-note' }, compose.action === 'tolak' ? 'Tolak ajuan ini' : 'Tunda ajuan ini'),
input, input,
el('div', { class: 'buttons' }, el('div', { class: 'buttons main' },
el('button', { type: 'button', class: `act ${compose.action === 'tolak' ? 'danger' : 'quiet'}`, disabled: state.busy, onclick: () => act(a, compose.action, compose.note) }, compose.action === 'tolak' ? 'Tolak' : 'Tunda'), el('button', { type: 'button', class: `act ${compose.action === 'tolak' ? 'danger' : 'quiet'}`, disabled: state.busy, onclick: () => act(a, compose.action, compose.note) }, compose.action === 'tolak' ? 'Tolak' : 'Tunda'),
el('button', { type: 'button', class: 'act quiet', onclick: () => { state.composing = null; draw(); } }, 'Batal'), el('button', { type: 'button', class: 'act quiet', onclick: () => { state.composing = null; draw(); } }, 'Batal'),
), ),
); );
} else { } else {
box.append(el('div', { class: 'buttons' }, a.actions.map((k) => // Gas / undo / close first and full-width on a phone; Tunda and Tolak sit apart so a thumb misses Gas less often.
el('button', { const main = a.actions.filter((k) => k === 'gas' || k === 'undo' || k === 'close');
type: 'button', const side = a.actions.filter((k) => k === 'tunda' || k === 'tolak');
class: `act ${k === 'gas' ? 'primary' : k === 'tolak' || k === 'close' ? 'danger' : 'quiet'}`, if (main.length) box.append(el('div', { class: 'buttons main' }, main.map((k) => actionButton(a, k))));
disabled: state.busy, if (side.length) box.append(el('div', { class: 'buttons side' }, side.map((k) => actionButton(a, k))));
onclick: () => (k === 'tunda' || k === 'tolak' ? (state.composing = { id: a.id, action: k, note: '' }, draw()) : act(a, k)),
}, k === 'undo' && a.status === 'gas' ? 'Batalkan gas' : k === 'undo' && a.closeAt ? 'Batal tutup' : k === 'undo' && a.status === 'rejected' ? 'Batalkan tolak' : k === 'gas' && a.dry ? 'Gas (uji coba)' : k === 'close' && a.dry ? 'Tutup MR (uji coba)' : ACTION_LABEL[k]))));
} }
if (state.error) box.append(el('p', { class: 'act-error', role: 'alert' }, state.error)); if (state.error) box.append(el('p', { class: 'act-error', role: 'alert' }, state.error));
return box; return box;
@@ -517,18 +540,32 @@
function needsYouCard() { function needsYouCard() {
const list = state.data.ajuan.filter((a) => a.needsYou); const list = state.data.ajuan.filter((a) => a.needsYou);
const card = el('div', { class: 'card' }, el('h2', {}, 'Perlu kamu')); const card = el('div', { class: 'card' });
const head = el('div', { class: 'card-head' }, el('h2', {}, 'Perlu kamu'));
if (phone.matches)
head.append(el('button', { type: 'button', class: 'close', 'aria-label': 'Tutup', onclick: () => closeSheet(), html: '<svg width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 3l10 10M13 3L3 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>' }));
card.append(head);
if (!list.length) card.append(el('p', { class: 'note' }, state.data.viewer.approver ? 'Belum ada. Santai dulu.' : 'Nggak ada ajuanmu yang ditahan.')); if (!list.length) card.append(el('p', { class: 'note' }, state.data.viewer.approver ? 'Belum ada. Santai dulu.' : 'Nggak ada ajuanmu yang ditahan.'));
else else
card.append(el('div', { class: 'todo-list' }, list.map((a) => card.append(el('div', { class: 'todo-list' }, list.map((a) =>
el('button', { type: 'button', class: 'todo-item', onclick: () => pick(a.id) }, el('button', { type: 'button', class: 'todo-item', onclick: () => pick(a.id) },
el('span', { class: 'dot', 'aria-hidden': 'true' }, el('i'), el('i')), el('span', { class: 'dot', 'aria-hidden': 'true' }, el('i'), el('i')),
el('span', { class: 'todo-copy' },
el('strong', {}, a.label), el('strong', {}, a.label),
a.title ? el('span', {}, shortTitle(a.title, 42)) : null,
),
el('span', { class: 'age' }, age(a.since)), el('span', { class: 'age' }, age(a.since)),
)))); ))));
return card; return card;
} }
function sheetMode(a) {
if (!phone.matches) return '';
if (a) return 'detail';
if (state.listOpen) return 'list';
return 'closed';
}
function drawShore() { function drawShore() {
const { data } = state; const { data } = state;
const a = data.ajuan.find((x) => x.id === state.sel); const a = data.ajuan.find((x) => x.id === state.sel);
@@ -536,12 +573,27 @@
// Keep a half-written Tunda or Tolak note across refreshes. // Keep a half-written Tunda or Tolak note across refreshes.
if (a && state.composing && state.composing.id === a.id && document.activeElement && document.activeElement.id === 'decision-note') return; if (a && state.composing && state.composing.id === a.id && document.activeElement && document.activeElement.id === 'decision-note') return;
if (a && document.activeElement && document.activeElement.id === 'release-tag') return; if (a && document.activeElement && document.activeElement.id === 'release-tag') return;
const card = a ? detail(a) : needsYouCard();
// Animate only when what the shore shows changes, not on every refresh. const mode = sheetMode(a);
const key = a ? `a${a.id}` : 'todo'; const harbour = $('harbour');
harbour.dataset.sheet = mode || 'closed';
document.body.classList.toggle('sheet-open', mode === 'detail' || mode === 'list');
const scrim = $('scrim');
scrim.hidden = !(mode === 'detail' || mode === 'list');
let card = null;
if (a) card = detail(a);
else if (!phone.matches || state.listOpen) card = needsYouCard();
const key = a ? `a${a.id}` : state.listOpen || !phone.matches ? 'todo' : 'closed';
if (card) {
if (key === state.shown) card.classList.add('still'); if (key === state.shown) card.classList.add('still');
state.shown = key;
$('detail').replaceChildren(card); $('detail').replaceChildren(card);
} else {
$('detail').replaceChildren();
}
state.shown = key;
const mine = data.ajuan.filter((x) => x.needsYou).length; const mine = data.ajuan.filter((x) => x.needsYou).length;
$('mine-count').textContent = mine; $('mine-count').textContent = mine;
$('show-all').setAttribute('aria-pressed', String(state.filter === 'all')); $('show-all').setAttribute('aria-pressed', String(state.filter === 'all'));
@@ -583,6 +635,12 @@
state.first = false; state.first = false;
} }
function closeSheet() {
state.listOpen = false;
if (state.sel) pick(null);
else draw();
}
function pick(id) { function pick(id) {
if (id !== state.sel) { if (id !== state.sel) {
state.composing = null; state.composing = null;
@@ -590,10 +648,11 @@
state.releaseTag = null; state.releaseTag = null;
} }
state.sel = id; state.sel = id;
if (id) state.listOpen = false;
history.replaceState(null, '', id ? `#a${id}` : location.pathname); history.replaceState(null, '', id ? `#a${id}` : location.pathname);
draw(); draw();
// A new ajuan opens at its top: the sheet scrolls on a phone, the detail column on a laptop. // A new ajuan opens at its top: the sheet scrolls on a phone, the detail column on a laptop.
if (id) (window.matchMedia('(max-width: 899px)').matches ? $('shore') : $('detail')).scrollTop = 0; if (id) $('detail').scrollTop = 0;
} }
async function load() { async function load() {
@@ -618,9 +677,27 @@
drawSea(); drawSea();
const m = location.hash.match(/^#a(\d+)$/); const m = location.hash.match(/^#a(\d+)$/);
if (m) state.sel = Number(m[1]); if (m) state.sel = Number(m[1]);
$('show-all').addEventListener('click', () => { state.filter = 'all'; draw(); }); $('show-all').addEventListener('click', () => {
$('show-mine').addEventListener('click', () => { state.filter = 'mine'; draw(); }); state.filter = 'all';
document.addEventListener('keydown', (e) => { if (e.key === 'Escape' && state.sel) pick(null); }); state.listOpen = false;
draw();
});
$('show-mine').addEventListener('click', () => {
state.filter = 'mine';
// On a phone the list is a sheet; on a laptop it lives in the shore panel.
if (phone.matches) {
state.sel = null;
state.listOpen = true;
history.replaceState(null, '', location.pathname);
}
draw();
});
$('scrim').addEventListener('click', () => closeSheet());
document.addEventListener('keydown', (e) => {
if (e.key !== 'Escape') return;
if (state.sel) pick(null);
else if (state.listOpen) closeSheet();
});
load(); load();
// Faster while a Gas waits or a boat is sailing, so the harbour follows it. // Faster while a Gas waits or a boat is sailing, so the harbour follows it.
let last = 0; let last = 0;
@@ -641,6 +718,12 @@
} }
}, 1000); }, 1000);
document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); }); document.addEventListener('visibilitychange', () => { if (!document.hidden) load(); });
window.addEventListener('resize', () => { drawnLanes = ''; if (state.data) drawLanes(); }); window.addEventListener('resize', () => {
drawnLanes = '';
if (state.data) {
if (!phone.matches) state.listOpen = false;
draw();
}
});
}); });
})(); })();

View File

@@ -13,7 +13,7 @@
<script src="/board.js" defer></script> <script src="/board.js" defer></script>
</head> </head>
<body> <body>
<div class="harbour"> <div class="harbour" id="harbour" data-sheet="closed">
<div class="water"> <div class="water">
<div class="sea" aria-hidden="true"></div> <div class="sea" aria-hidden="true"></div>
<header class="brand"> <header class="brand">
@@ -22,14 +22,16 @@
</header> </header>
<h1 id="headline">Membaca antrean…</h1> <h1 id="headline">Membaca antrean…</h1>
<p id="empty" class="empty" hidden></p> <p id="empty" class="empty" hidden></p>
<p id="legend" class="legend">Pelampung = siap gas · Jangkar = ditahan · Tali = berlabuh</p>
<main id="lanes"></main> <main id="lanes"></main>
<p id="stale" class="stale" role="status" hidden></p> <p id="stale" class="stale" role="status" hidden></p>
</div> </div>
<div class="shore" id="shore"> <div class="shore" id="shore">
<svg class="edge" aria-hidden="true" preserveAspectRatio="none"><path class="foam"/><path class="sand"/><path class="land"/></svg> <svg class="edge" aria-hidden="true" preserveAspectRatio="none"><path class="foam"/><path class="sand"/><path class="land"/></svg>
<button type="button" id="scrim" class="scrim" hidden aria-label="Tutup lembar"></button>
<div class="shore-inner"> <div class="shore-inner">
<div class="shore-top"> <div class="shore-top" id="dock">
<div class="seg" role="group" aria-label="Tampilkan"> <div class="seg" role="group" aria-label="Tampilkan">
<button type="button" id="show-all" aria-pressed="true">Semua</button> <button type="button" id="show-all" aria-pressed="true">Semua</button>
<button type="button" id="show-mine" aria-pressed="false">Perlu kamu <span class="count" id="mine-count">0</span></button> <button type="button" id="show-mine" aria-pressed="false">Perlu kamu <span class="count" id="mine-count">0</span></button>

View File

@@ -86,6 +86,9 @@ const TYPES: Record<string, string> = { '.html': 'text/html; charset=utf-8', '.j
const escapeHtml = (s: string) => s.replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]!); const escapeHtml = (s: string) => s.replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]!);
const PAGE_HEAD = `<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="theme-color" content="#9DCAC3"><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=Atkinson+Hyperlegible:wght@400;700&display=swap"><link rel="stylesheet" href="/board.css"><link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='16' fill='%23172B33'/%3E%3Cpath d='M22 14V42H44' fill='none' stroke='%23F6F2EA' stroke-width='8' stroke-linecap='round' stroke-linejoin='round'/%3E%3Ccircle cx='44' cy='26' r='5.5' fill='%23E8A33D'/%3E%3C/svg%3E">`;
const BRAND_MARK = `<header class="brand"><svg width="36" height="36" viewBox="0 0 64 64" aria-hidden="true"><rect width="64" height="64" rx="16" fill="#172B33"/><path d="M22 14V42H44" fill="none" stroke="#F6F2EA" stroke-width="8" stroke-linecap="round" stroke-linejoin="round"/><circle cx="44" cy="26" r="5.5" fill="#E8A33D"/></svg><span>labuh</span></header>`;
// The rubric as a plain page with an anchor per rule (`## R9 · …` → #r9). // The rubric as a plain page with an anchor per rule (`## R9 · …` → #r9).
function rubricPage(md: string): string { function rubricPage(md: string): string {
const body = md const body = md
@@ -97,7 +100,7 @@ function rubricPage(md: string): string {
return `<h${h[1].length}${id ? ` id="${id}"` : ''}>${escapeHtml(h[2])}</h${h[1].length}>`; return `<h${h[1].length}${id ? ` id="${id}"` : ''}>${escapeHtml(h[2])}</h${h[1].length}>`;
}) })
.join('\n'); .join('\n');
return `<!doctype html><html lang="id"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Rubrik Labuh</title><link rel="stylesheet" href="/board.css"></head><body class="page-rubric"><main>${body}</main></body></html>`; return `<!doctype html><html lang="id"><head>${PAGE_HEAD}<title>Rubrik Labuh</title></head><body class="page-rubric"><main>${body}</main></body></html>`;
} }
const ACTIONS: Action[] = ['gas', 'tunda', 'tolak', 'close', 'undo']; const ACTIONS: Action[] = ['gas', 'tunda', 'tolak', 'close', 'undo'];
@@ -144,7 +147,7 @@ export function createBoard(store: Store, cfg: BoardConfig, projects: string[],
}; };
const json = (res: http.ServerResponse, status: number, data: unknown) => send(res, status, 'application/json; charset=utf-8', JSON.stringify(data)); const json = (res: http.ServerResponse, status: number, data: unknown) => send(res, status, 'application/json; charset=utf-8', JSON.stringify(data));
const page = (res: http.ServerResponse, status: number, title: string, text: string, action = '') => const page = (res: http.ServerResponse, status: number, title: string, text: string, action = '') =>
send(res, status, TYPES['.html'], `<!doctype html><html lang="id"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Labuh</title><link rel="stylesheet" href="/board.css"></head><body class="page-gate"><main><h1>${escapeHtml(title)}</h1><p>${escapeHtml(text)}</p>${action}</main></body></html>`); send(res, status, TYPES['.html'], `<!doctype html><html lang="id"><head>${PAGE_HEAD}<title>Labuh</title></head><body class="page-gate"><main>${BRAND_MARK}<h1>${escapeHtml(title)}</h1><p>${escapeHtml(text)}</p>${action}</main></body></html>`);
const viewerOf = (req: http.IncomingMessage): Viewer | null => { const viewerOf = (req: http.IncomingMessage): Viewer | null => {
// Approver rights follow board.json on every request, so adding or removing one needs no new sign-in. // Approver rights follow board.json on every request, so adding or removing one needs no new sign-in.