diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..91e0e79 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +# direnv (https://direnv.net) を使う場合はこのファイルを `direnv allow` する。 +# nix-direnv を入れておくと devShell がキャッシュされて高速になる。 +use flake diff --git a/README.md b/README.md index 903b7fa..7d7b63d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,24 @@ packages/scoring/ スコア計算の純粋ロジック(I/O を持たない) ## 環境構築 Node.js 22以降とpnpmで起動できます。今回の試作はファイル保存のためDBを必要としません。 +### Nix + +[Nix](https://nixos.org/download/) と flakes が有効なら、`nix develop` で +Node 22 / pnpm 9.12.0 / PostgreSQL クライアント 17 / OpenSSL が揃ったシェルに入れます。 +ツールを用意するだけなので、以降の手順は下の「Docker」「素の pnpm」と同じです。 + +pnpm は `package.json` の `packageManager` と同じバージョンを固定しています。 +更新する場合は [nix/pnpm.nix](./nix/pnpm.nix) 冒頭の手順を参照してください。 + +[direnv](https://direnv.net) を入れている場合は `direnv allow` でディレクトリに入るだけで +シェルが有効になります(`.envrc` 同梱)。 + +### Docker + +リポジトリのルートで `docker compose up -d` を実行してください。 +`app` (Next.js, :3000) と `db` (PostgreSQL 17, :5432) が立ち上がります。 + +### 素の pnpm ```sh pnpm install @@ -41,4 +59,4 @@ Dockerでは `docker compose up -d --build` でアプリと永続化用volumeを Viewer は `GET /api/stream` の SSE を購読します。接続直後に全状態のスナップショットが 1件届き、以降も保存のたびに最新の全状態が流れます。WebSocketは使用しません。 -これは掲示状態の即時反映であり、試合の得点入力は各戦終了後に行います。 +これは掲示状態の即時反映であり、試合のスコア入力は各戦終了後に行います。 diff --git a/chros/app/globals.css b/chros/app/globals.css index df5ce95..c950da4 100644 --- a/chros/app/globals.css +++ b/chros/app/globals.css @@ -164,6 +164,107 @@ small { .full-width { width: 100%; } +.choice-group > legend { + display: flex; + align-items: center; + gap: 8px; + width: 100%; + padding: 0; + margin-bottom: 9px; + font-size: 12px; + font-weight: 600; +} +.choice-clear { + margin-left: auto; + padding: 2px 4px; + font-size: 10px; + white-space: nowrap; +} +.choice-group > legend small { + margin-left: 6px; + color: var(--muted); + font-size: 10px; + font-weight: 400; +} +.choice-options { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); + gap: 8px; +} +.choice-sections { + display: grid; + gap: 8px; +} +.choice-sections > .choice-options:not(:only-child) { + grid-auto-flow: column; + grid-auto-columns: minmax(0, 1fr); + grid-template-columns: none; +} +.choice { + position: relative; + align-items: center; + justify-content: center; + gap: 2px; + min-height: 43px; + padding: 8px 12px; + border: 1px solid #d8e0d8; + border-radius: 7px; + background: white; + text-align: center; + cursor: pointer; + transition: background 0.15s; +} +.choice:hover { + background: #f0f5ec; +} +.choice.selected { + border-color: #8cab5d; + background: #edf5df; + box-shadow: 0 0 0 1px #8cab5d; +} +.choice strong { + font-size: 12px; + font-weight: 650; + line-height: 1.3; +} +.choice small { + font-size: 9px; +} +.choice-icon { + width: 25px; + height: 25px; + color: #6c8a5f; +} +.choice.selected .choice-icon { + color: #5a7a36; +} +.choice-group:disabled .choice, +.choice-group:disabled .choice:hover { + background: white; + opacity: 0.5; + cursor: not-allowed; +} +.choice input, +.scene-button input { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + min-height: 0; + margin: 0; + padding: 0; + border: 0; + border-radius: inherit; + background: none; + opacity: 0; + appearance: none; + cursor: pointer; +} +.choice:has(input:focus-visible), +.scene-button:has(input:focus-visible) { + outline: 3px solid #64b7ad; + outline-offset: 3px; +} .text-button { font-size: 11px; color: var(--green); @@ -527,6 +628,9 @@ small { font-size: 9px; } .scene-controls { + display: flex; + flex-direction: column; + gap: 16px; padding: 17px 20px 20px; border-top: 1px solid var(--line); } @@ -534,24 +638,14 @@ small { display: flex; align-items: center; justify-content: space-between; - margin-bottom: 14px; + gap: 10px; } .scene-toolbar > b { font-size: 11px; } -.scene-toolbar label { - flex-direction: row; - align-items: center; - gap: 8px; +.scene-toolbar > small { color: var(--muted); font-size: 10px; - font-weight: 400; -} -.scene-toolbar select { - min-height: 30px; - padding: 4px 7px; - font-size: 10px; - width: 105px; } .scene-grid { display: grid; @@ -560,6 +654,7 @@ small { } .scene-button { position: relative; + cursor: pointer; border: 1px solid #e0e7db; background: #fcfdfb; border-radius: 6px; @@ -831,6 +926,9 @@ small { flex-direction: column; gap: 17px; } +.game-form .notice { + margin-bottom: 0; +} .game-form-top { display: flex; justify-content: space-between; @@ -849,23 +947,31 @@ small { gap: 15px; } .score-input { - background: #f2f7f2; - border: 1px solid #dfe9dc; + border: 1px solid var(--line); border-radius: 7px; padding: 14px; gap: 9px; } -.score-input-b { - background: #fcf4ee; - border-color: #eee2d9; +.score-input-cool { + background: #eef4fb; + border-color: #d2e0f0; +} +.score-input-hot { + background: #fdf2ef; + border-color: #f0d7d0; } .side-badge { - color: #518a81; + color: var(--muted); font-size: 8px; letter-spacing: 1px; } -.score-input-b .side-badge { - color: #b58268; +.score-input-cool .side-badge, +.side-badge-cool { + color: #2f6099; +} +.score-input-hot .side-badge, +.side-badge-hot { + color: #b0453a; } .score-input strong { font-size: 13px; @@ -931,18 +1037,18 @@ small { .replay-area { border-top: 1px solid var(--line); margin-top: 22px; - padding-top: 10px; -} -.replay-area > .text-button { - font-size: 10px; - color: #929d88; + padding-top: 16px; } .replay-area form { display: flex; flex-direction: column; + align-items: stretch; gap: 12px; padding-top: 10px; } +.replay-area form > .button { + align-self: flex-end; +} .replay-area p { color: #947457; font-size: 11px; @@ -2149,6 +2255,12 @@ small { .game-tabs { gap: 13px; } + .choice-sections > .choice-options:not(:only-child) .choice { + padding: 8px 6px; + } + .choice-sections > .choice-options:not(:only-child) .choice strong { + font-size: 11px; + } .score-input { padding: 12px; } diff --git a/chros/components/Board.tsx b/chros/components/Board.tsx index 26be7f0..a93e704 100644 --- a/chros/components/Board.tsx +++ b/chros/components/Board.tsx @@ -50,7 +50,7 @@ export default function Board({ state }: { state: ControlState }) { ? 'SAMPLE TOURNAMENT · 架空の参加者によるデモ' : 'CHASER PROGRESSION CONTROL SYSTEM'} - 得点は各戦の終了後に更新 + スコアは各戦の終了後に更新 CHroS / {String(state.revision).padStart(3, '0')} diff --git a/chros/components/ChoiceGroup.tsx b/chros/components/ChoiceGroup.tsx new file mode 100644 index 0000000..abbc641 --- /dev/null +++ b/chros/components/ChoiceGroup.tsx @@ -0,0 +1,78 @@ +'use client'; + +import type { ReactNode } from 'react'; + +export type Choice = { + value: Value; + label: string; + icon?: ReactNode; + note?: ReactNode; +}; + +type Common = { + legend: ReactNode; + name: string; + selected: Value | null; + required?: boolean; + disabled?: boolean; + onSelect: (value: Value) => void; + onClear?: () => void; +}; +type Grouping = + | { choices: readonly Choice[]; sections?: never } + | { sections: readonly (readonly Choice[])[]; choices?: never }; + +export default function ChoiceGroup({ + legend, + name, + selected, + required = false, + disabled = false, + onSelect, + onClear, + ...grouping +}: Common & Grouping) { + const sections = grouping.sections ?? [grouping.choices ?? []]; + return ( +
+ + {legend} + {onClear && ( + + )} + +
+ {sections.map((section) => ( +
choice.value).join('-')}> + {section.map((choice) => ( + + ))} +
+ ))} +
+
+ ); +} diff --git a/chros/components/MatchEditor.tsx b/chros/components/MatchEditor.tsx index ee00335..024c4eb 100644 --- a/chros/components/MatchEditor.tsx +++ b/chros/components/MatchEditor.tsx @@ -45,7 +45,7 @@ export default function MatchEditor({ MATCH WINNER {playerName(state, result.winnerId)} - {result.decidedBy}で勝利 · 特殊P {result.a.special}–{result.b.special} / 合計得点{' '} + {result.decidedBy}で勝利 · 特殊P {result.a.special}–{result.b.special} / 合計スコア{' '} {result.a.points}–{result.b.points} diff --git a/chros/components/board/MatchScene.tsx b/chros/components/board/MatchScene.tsx index 5b6d375..598d827 100644 --- a/chros/components/board/MatchScene.tsx +++ b/chros/components/board/MatchScene.tsx @@ -55,7 +55,7 @@ export function MatchScene({ state, match }: { state: ControlState; match: Match
{match.games.length ? result[side].points : '–'}
- {state.profile === 'asahikawa' ? '換算得点' : '合計得点'} + {state.profile === 'asahikawa' ? '換算スコア' : '合計スコア'} {state.profile === 'kushiro' ? `特殊P ${result[side].special}` diff --git a/chros/components/board/StandingsTable.tsx b/chros/components/board/StandingsTable.tsx index 860c7e2..b7a7d5c 100644 --- a/chros/components/board/StandingsTable.tsx +++ b/chros/components/board/StandingsTable.tsx @@ -30,7 +30,7 @@ export function StandingsTable({ 参加者 勝–敗 特殊P - {state.profile === 'asahikawa' ? '換算得点' : '得点'} + {state.profile === 'asahikawa' ? '換算スコア' : 'スコア'} diff --git a/chros/components/console/BroadcastPanel.tsx b/chros/components/console/BroadcastPanel.tsx index 10bfafb..54956d8 100644 --- a/chros/components/console/BroadcastPanel.tsx +++ b/chros/components/console/BroadcastPanel.tsx @@ -2,15 +2,9 @@ import { boardPages } from '@/lib/board-pages'; import type { ControlProps } from '@/lib/control-types'; -import { - phaseLabels, - phases, - sceneLabels, - scenes, - type ControlState, - type Scene, -} from '@chros/shared'; +import { phaseLabels, phases, sceneLabels, scenes, type Scene } from '@chros/shared'; import Board from '../Board'; +import ChoiceGroup from '../ChoiceGroup'; const sceneSymbols: Record = { ceremony: '◷', @@ -43,49 +37,55 @@ export function BroadcastPanel({ state, send }: ControlProps) {
- {sceneLabels[state.scene]} を掲示中 + {phaseLabels[state.phase]} · {sceneLabels[state.scene]} を掲示中 - 各戦の記録後に得点を更新 + 各戦の記録後にスコアを更新
画面を切り替え - -
-
- {scenes.map((scene, index) => ( - - ))} + 掲示する画面と進行区分を選びます
+
+ + 画面表示 会場スクリーンに映す内容 + +
+ {scenes.map((scene, index) => ( + + ))} +
+
+ + 進行区分 掲示画面の上部に出る現在の進行 + + } + name="board-phase" + choices={phases.map((phase) => ({ value: phase, label: phaseLabels[phase] }))} + selected={state.phase} + onSelect={(phase) => send({ type: 'show', scene: state.scene, phase })} + />
{pages.count > 1 && (
diff --git a/chros/components/console/ControlDesk.tsx b/chros/components/console/ControlDesk.tsx index 499dd6f..3ace15f 100644 --- a/chros/components/console/ControlDesk.tsx +++ b/chros/components/console/ControlDesk.tsx @@ -32,7 +32,7 @@ export default function ControlDesk({

記録して、伝える。

第1戦を保存したら、先攻・後攻を交代。第2戦の保存で試合結果と順位が確定します。

- 01 得点・勝因 + 01 スコア・勝因 → 02 自動集計 → diff --git a/chros/components/console/CurrentMatchPanel.tsx b/chros/components/console/CurrentMatchPanel.tsx index 7086fee..ee73f8d 100644 --- a/chros/components/console/CurrentMatchPanel.tsx +++ b/chros/components/console/CurrentMatchPanel.tsx @@ -20,7 +20,7 @@ export function CurrentMatchPanel({
NOW PLAYING -

掲示する試合・得点入力

+

掲示する試合・スコア入力

- {(['a', 'b'] as const).map((side) => ( -