From ca877c716210ad4a8906750dedc03b7f04c2175d Mon Sep 17 00:00:00 2001 From: Arumino Date: Wed, 23 Sep 2026 17:48:58 +0900 Subject: [PATCH 1/9] =?UTF-8?q?chore(devenv):=20Nix=20flake=20=E3=81=A8=20?= =?UTF-8?q?direnv=20=E3=81=A7=E9=96=8B=E7=99=BA=E7=92=B0=E5=A2=83=E3=82=92?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nix develop で Node 22 / pnpm / psql / OpenSSL が揃うようにし、 pnpm は package.json の packageManager と同じ 9.12.0 を nix/pnpm.nix で固定する。 README の環境構築を Nix / Docker / 素の pnpm の3通りに整理した。 Co-Authored-By: Claude Opus 5 (1M context) --- .envrc | 3 +++ README.md | 18 ++++++++++++++++++ flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ nix/pnpm.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 141 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 nix/pnpm.nix 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..92dde82 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 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..631dde9 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1790046670, + "narHash": "sha256-MYiI+CzL0tuWgRPjGsKCDHqYs2T3OzMlMQWOYWG0qso=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6774f7bc253789b113a4f39285dc0fa100abeacc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..1237d1c --- /dev/null +++ b/flake.nix @@ -0,0 +1,45 @@ +{ + description = "CHroS (CHaserProgressionControlSystem) 開発環境"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { nixpkgs, ... }: + let + # x86_64-darwin (Intel Mac) は nixpkgs 26.11 以降サポート対象外のため含めない + systems = [ + "aarch64-darwin" + "aarch64-linux" + "x86_64-linux" + ]; + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + in + { + devShells = forAllSystems ( + pkgs: + let + nodejs = pkgs.nodejs_22; # package.json engines: node >= 22 / Dockerfile: node:22-slim + pnpm = pkgs.callPackage ./nix/pnpm.nix { inherit nodejs; }; + in + { + default = pkgs.mkShell { + name = "chros"; + packages = [ + nodejs + pnpm + pkgs.postgresql_17 # psql / pg_isready(docker-compose.yaml の db と同じメジャー) + pkgs.openssl # Prisma query engine が参照する + ]; + }; + } + ); + + packages = forAllSystems (pkgs: { + pnpm = pkgs.callPackage ./nix/pnpm.nix { nodejs = pkgs.nodejs_22; }; + }); + + formatter = forAllSystems (pkgs: pkgs.nixfmt-tree); + }; +} diff --git a/nix/pnpm.nix b/nix/pnpm.nix new file mode 100644 index 0000000..7d09a8b --- /dev/null +++ b/nix/pnpm.nix @@ -0,0 +1,48 @@ +# package.json の packageManager フィールドと同じ pnpm を固定で提供する。 +# nixpkgs の pnpm は 10.x 系のため、バージョンを揃える目的で npm registry から取得する。 +# 更新手順: +# 1. package.json の packageManager を書き換える +# 2. version を同じ値にする +# 3. nix store prefetch-file https://registry.npmjs.org/pnpm/-/pnpm-.tgz +{ + lib, + stdenvNoCC, + fetchurl, + makeBinaryWrapper, + nodejs, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "pnpm"; + version = "9.12.0"; + + src = fetchurl { + url = "https://registry.npmjs.org/pnpm/-/pnpm-${finalAttrs.version}.tgz"; + hash = "sha256-phtn/2zJevhkVk9EQlVsIqBPLlp3FPvudqEBE2HZtyY="; + }; + + nativeBuildInputs = [ makeBinaryWrapper ]; + + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p "$out/lib/pnpm" + cp -r . "$out/lib/pnpm" + + for cmd in pnpm pnpx; do + makeBinaryWrapper ${lib.getExe nodejs} "$out/bin/$cmd" \ + --add-flags "$out/lib/pnpm/bin/$cmd.cjs" + done + + runHook postInstall + ''; + + meta = { + description = "Fast, disk space efficient package manager (${finalAttrs.version} pinned for this repo)"; + homepage = "https://pnpm.io"; + license = lib.licenses.mit; + mainProgram = "pnpm"; + }; +}) From 175d38ae289d9d2bf11b1380ecb9ecf3f338dce3 Mon Sep 17 00:00:00 2001 From: Arumino Date: Wed, 23 Sep 2026 17:49:04 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix(shared):=20=E5=8B=9D=E5=9B=A0=E3=83=A9?= =?UTF-8?q?=E3=83=99=E3=83=AB=E3=82=92=E7=AB=B6=E6=8A=80=E3=81=AE=E5=91=BC?= =?UTF-8?q?=E7=A7=B0=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit illegal-move の表示を「相手の移動違反」から「相手の壁埋まり」に変更する。 CHaser では壁に埋まった状態を指す呼称が使われており、記録者の認識と一致させる。 Co-Authored-By: Claude Opus 5 (1M context) --- packages/shared/src/control.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared/src/control.ts b/packages/shared/src/control.ts index ba67be3..ff7f281 100644 --- a/packages/shared/src/control.ts +++ b/packages/shared/src/control.ts @@ -33,7 +33,7 @@ export const reasonLabels: Record = { put: 'PUT', surround: '相手を包囲', disconnect: '相手の通信切断', - 'illegal-move': '相手の移動違反', + 'illegal-move': '相手の壁埋まり', 'self-surround': '相手の自己包囲', }; const id = z.string().min(1).max(100); From 6fd79b3bb568c1b1c212bc9f0599d32378c2d05a Mon Sep 17 00:00:00 2001 From: Arumino Date: Wed, 23 Sep 2026 17:49:13 +0900 Subject: [PATCH 3/9] =?UTF-8?q?feat(ui):=20=E9=81=B8=E6=8A=9E=E8=82=A2?= =?UTF-8?q?=E3=82=92=E4=B8=A6=E3=81=B9=E3=81=A6=E7=A4=BA=E3=81=99=20Choice?= =?UTF-8?q?Group=20=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit select は開くまで選択肢が見えず、進行中に素早く選ぶ操作に向かない。 ラジオボタンを視覚的に隠した label をカード状に並べ、 選択肢とその状態を常に画面上に出す共通部品を用意する。 Co-Authored-By: Claude Opus 5 (1M context) --- chros/app/globals.css | 82 ++++++++++++++++++++++++++++++++ chros/components/ChoiceGroup.tsx | 54 +++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 chros/components/ChoiceGroup.tsx diff --git a/chros/app/globals.css b/chros/app/globals.css index df5ce95..0b2fb96 100644 --- a/chros/app/globals.css +++ b/chros/app/globals.css @@ -164,6 +164,88 @@ small { .full-width { width: 100%; } +.choice-group > legend { + padding: 0; + margin-bottom: 9px; + font-size: 12px; + font-weight: 600; +} +.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 { + 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); diff --git a/chros/components/ChoiceGroup.tsx b/chros/components/ChoiceGroup.tsx new file mode 100644 index 0000000..950e5b6 --- /dev/null +++ b/chros/components/ChoiceGroup.tsx @@ -0,0 +1,54 @@ +'use client'; + +import type { ReactNode } from 'react'; + +export type Choice = { + value: Value; + label: string; + icon?: ReactNode; + note?: ReactNode; +}; + +export default function ChoiceGroup({ + legend, + name, + choices, + selected, + required = false, + disabled = false, + onSelect, +}: { + legend: ReactNode; + name: string; + choices: readonly Choice[]; + selected: Value | null; + required?: boolean; + disabled?: boolean; + onSelect: (value: Value) => void; +}) { + return ( +
+ {legend} +
+ {choices.map((choice) => ( + + ))} +
+
+ ); +} From 2fc87a4560ba80824414a90e4d82350c0980eecd Mon Sep 17 00:00:00 2001 From: Arumino Date: Wed, 23 Sep 2026 17:49:24 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat(matches):=20=E8=A8=98=E9=8C=B2?= =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=A0=E3=81=AE=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E3=82=92=20ChoiceGroup=20=E3=81=AB=E7=BD=AE=E3=81=8D=E6=8F=9B?= =?UTF-8?q?=E3=81=88=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 勝因・勝利した参加者・第1戦の先攻を select から選択肢の並びに変える。 勝因には図形アイコンを添えて一覧から目的の項目を探しやすくし、 得点比較のときは勝者の選択を disabled にして自動判定であることを示す。 仕切り直しの開閉は text-button では押せる箇所が分かりにくいため button subtle にし、aria-expanded で開閉状態を伝える。 Co-Authored-By: Claude Opus 5 (1M context) --- chros/app/globals.css | 13 ++-- chros/components/matches/GameForm.tsx | 85 +++++++++++----------- chros/components/matches/MatchControls.tsx | 33 ++++++--- chros/components/matches/ReasonIcon.tsx | 74 +++++++++++++++++++ 4 files changed, 147 insertions(+), 58 deletions(-) create mode 100644 chros/components/matches/ReasonIcon.tsx diff --git a/chros/app/globals.css b/chros/app/globals.css index 0b2fb96..40eb72a 100644 --- a/chros/app/globals.css +++ b/chros/app/globals.css @@ -946,7 +946,8 @@ small { font-size: 8px; letter-spacing: 1px; } -.score-input-b .side-badge { +.score-input-b .side-badge, +.side-badge-b { color: #b58268; } .score-input strong { @@ -1013,18 +1014,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; diff --git a/chros/components/matches/GameForm.tsx b/chros/components/matches/GameForm.tsx index bb46965..899bbe7 100644 --- a/chros/components/matches/GameForm.tsx +++ b/chros/components/matches/GameForm.tsx @@ -5,6 +5,8 @@ import type { SendCommand } from '@/lib/control-types'; import { evaluateGame, playerName } from '@chros/scoring'; import { reasonLabels, reasons, type ControlState, type Game, type Match } from '@chros/shared'; import { useState } from 'react'; +import ChoiceGroup from '../ChoiceGroup'; +import ReasonIcon from './ReasonIcon'; export default function GameForm({ state, @@ -42,6 +44,8 @@ export default function GameForm({ const updateGame = (patch: Partial) => setGame((current) => ({ ...current, ...patch })); const needsRemainingTurns = state.profile === 'asahikawa' && !['points', 'put', 'surround'].includes(game.reason); + const decidedByScore = game.reason === 'points'; + const sideBadge = (side: 'a' | 'b') => (match[side] === cool ? 'COOL · 先攻' : 'HOT · 後攻'); let resultLabel = '勝者を選択してください'; if (!scoreInputs.a || !scoreInputs.b) { @@ -66,9 +70,7 @@ export default function GameForm({
{(['a', 'b'] as const).map((side) => (