diff --git a/.specify/feature.json b/.specify/feature.json index 1c5f0ff..9319319 100644 --- a/.specify/feature.json +++ b/.specify/feature.json @@ -1,3 +1,3 @@ { - "feature_directory": "specs/002-cube-render-layer" + "feature_directory": "specs/004-full-ui-options" } diff --git a/CLAUDE.md b/CLAUDE.md index 487d295..96525dc 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ For additional context about technologies to be used, project structure, shell commands, and other important information, read the current plan -at specs/002-cube-render-layer/plan.md +at specs/004-full-ui-options/plan.md ## プロジェクト制約 diff --git a/eslint.config.mjs b/eslint.config.mjs index eae2c8d..3ce9586 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -22,6 +22,12 @@ export default [ }, }, prettierConfig, + { + files: ['tests/**/*.ts'], + rules: { + '@typescript-eslint/no-non-null-assertion': 'off', + }, + }, { ignores: ['dist/', 'node_modules/', 'coverage/'], }, diff --git a/index.html b/index.html index f6f5b3b..f9b5e65 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ Visual Cube Editor 3 +
diff --git a/package.json b/package.json index 9b6f85d..367d8ea 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "index.js", "type": "module", "scripts": { + "dev": "vite", "test": "vitest run", "test:watch": "vitest", "test:coverage": "vitest run --coverage", diff --git a/specs/004-full-ui-options/checklists/requirements.md b/specs/004-full-ui-options/checklists/requirements.md new file mode 100644 index 0000000..996df80 --- /dev/null +++ b/specs/004-full-ui-options/checklists/requirements.md @@ -0,0 +1,36 @@ +# Specification Quality Checklist: Ver.2 相当フル UI オプション + +**Purpose**: Validate specification completeness and quality before proceeding to planning +**Created**: 2026-05-03 +**Feature**: [spec.md](../spec.md) + +## Content Quality + +- [x] No implementation details (languages, frameworks, APIs) +- [x] Focused on user value and business needs +- [x] Written for non-technical stakeholders +- [x] All mandatory sections completed + +## Requirement Completeness + +- [x] No [NEEDS CLARIFICATION] markers remain +- [x] Requirements are testable and unambiguous +- [x] Success criteria are measurable +- [x] Success criteria are technology-agnostic (no implementation details) +- [x] All acceptance scenarios are defined +- [x] Edge cases are identified +- [x] Scope is clearly bounded +- [x] Dependencies and assumptions identified + +## Feature Readiness + +- [x] All functional requirements have clear acceptance criteria +- [x] User scenarios cover primary flows +- [x] Feature meets measurable outcomes defined in Success Criteria +- [x] No implementation details leak into specification + +## Notes + +- FR-015〜FR-017 はやや技術的な記述だが、既存アーキテクチャとの整合性を保つために必要な制約として記載 +- アロー定義 UI は Ver.2 の完全実装より簡略化(テキスト入力のみ)—前提条件に明記済み +- 全項目パス済み:`/speckit-plan` に進める状態 diff --git a/specs/004-full-ui-options/contracts/render-options-api.ts b/specs/004-full-ui-options/contracts/render-options-api.ts new file mode 100644 index 0000000..41a9776 --- /dev/null +++ b/specs/004-full-ui-options/contracts/render-options-api.ts @@ -0,0 +1,94 @@ +/** + * 拡張 RenderOptions 公開 API 契約 + * ファイル: src/render/types.ts の拡張として実装される + * + * このファイルはコントラクト定義のみ(実装なし)。 + */ + +// --------------------------------------------------------------------------- +// 既存定義(変更なし) +// --------------------------------------------------------------------------- + +export declare const ViewAxis: { + readonly X: 'x' + readonly Y: 'y' + readonly Z: 'z' +} +export type ViewAxis = (typeof ViewAxis)[keyof typeof ViewAxis] + +export type ColorScheme = Readonly> + +// --------------------------------------------------------------------------- +// 拡張 RenderOptions +// --------------------------------------------------------------------------- + +/** + * 描画オプション(全フィールド省略可能) + * 004-full-ui-options で新規フィールドを追加 + */ +export interface RenderOptions { + // ---- 既存フィールド ---- + readonly colorScheme?: Partial + readonly backgroundColor?: string + readonly width?: number + readonly height?: number + readonly viewportRotations?: ReadonlyArray + + // ---- 新規フィールド(004) ---- + /** + * 表示モード。'plan' で上面投影図を表示する。 + * 省略または他の値の場合は通常の3D表示。 + */ + readonly view?: string + + /** + * ステージマスク(sr-visualizer Masking 列挙体の文字列値)。 + * 例: 'oll', 'f2l', 'll' + * 省略または空文字の場合はマスクなし。 + */ + readonly mask?: string + + /** + * マスク向き調整アルゴリズム(例: 'y', "x'", 'z2')。 + * mask が指定されている場合のみ有効。 + */ + readonly maskAlg?: string + + /** + * キューブ輪郭色。'#rrggbb' 形式。 + * デフォルト: '#000000'(黒) + */ + readonly cubeColor?: string + + /** + * マスク適用ステッカーの色。'#rrggbb' 形式。 + * デフォルト: '#404040' + */ + readonly maskColor?: string + + /** + * キューブ輪郭の不透明度(0〜100)。 + * sr-visualizer は 0〜100 の整数を受け取る。 + * デフォルト: 100(完全不透明) + */ + readonly cubeOpacity?: number + + /** + * ステッカーの不透明度(0〜100)。 + * デフォルト: 100(完全不透明) + */ + readonly stickerOpacity?: number + + /** + * 投影距離(1〜100)。大きいほど正射影に近くなる。 + * デフォルト: 5 + */ + readonly dist?: number + + /** + * アロー定義文字列(sr-visualizer のアロー書式)。 + * 例: "UFR-UFR,UFL-UBL" (複数はカンマ区切り) + * 省略または空文字の場合はアロー非表示。 + */ + readonly arrows?: string +} diff --git a/specs/004-full-ui-options/contracts/render-options-store-api.ts b/specs/004-full-ui-options/contracts/render-options-store-api.ts new file mode 100644 index 0000000..cb24195 --- /dev/null +++ b/specs/004-full-ui-options/contracts/render-options-store-api.ts @@ -0,0 +1,93 @@ +/** + * useRenderOptionsStore 公開 API 契約 + * ファイル: src/stores/renderOptions.ts として実装される + * + * このファイルはコントラクト定義のみ(実装なし)。 + */ + +import type { RenderOptions, ViewAxis, ColorScheme } from './render-options-api.js' + +// --------------------------------------------------------------------------- +// useRenderOptionsStore — Pinia setup ストア +// --------------------------------------------------------------------------- + +/** + * useRenderOptionsStore() の戻り値型(概念定義)。 + * 実装は defineStore('renderOptions', () => { ... }) で行う。 + */ +export interface RenderOptionsStore { + // ---- ステート ---- + + /** 画像サイズ(幅・高さ共通)。1〜1000。デフォルト: 128 */ + imageSize: number + + /** 表示モード。デフォルト: 'normal' */ + view: 'normal' | 'plan' + + /** ステージマスク値('' = なし)。デフォルト: '' */ + mask: string + + /** マスク向き調整('' = なし)。デフォルト: '' */ + maskAlg: string + + /** 6面カラースキーム。デフォルト: WCA 標準色 */ + colorScheme: Record<0 | 1 | 2 | 3 | 4 | 5, string> + + /** 背景色。デフォルト: '#ffffff' */ + backgroundColor: string + + /** キューブ輪郭色。デフォルト: '#000000' */ + cubeColor: string + + /** マスク色。デフォルト: '#404040' */ + maskColor: string + + /** キューブ不透明度(0〜100)。デフォルト: 100 */ + cubeOpacity: number + + /** ステッカー不透明度(0〜100)。デフォルト: 100 */ + stickerOpacity: number + + /** 投影距離(1〜100)。デフォルト: 5 */ + dist: number + + /** ビューポート回転リスト(3スロット)。デフォルト: y/45, x/-34, z/0 */ + viewportRotations: [ViewAxis, number][] + + /** アロー定義文字列('' = なし)。デフォルト: '' */ + arrows: string + + // ---- computed ---- + + /** + * 全ステートを RenderOptions に変換した computed プロパティ。 + * CubeDisplay が renderSVG() に渡す際に使用する。 + */ + readonly renderOptions: RenderOptions + + // ---- アクション ---- + + /** + * カラースキームを WCA 標準色にリセットする。 + * U=白, D=黄, F=赤, B=橙, R=青, L=緑 + */ + resetColorScheme(): void + + /** + * X 軸回転相当で面の色を1ステップ循環する。 + * U←B, B←D, D←F, F←U + */ + rotateX(): void + + /** + * Y 軸回転相当で面の色を1ステップ循環する。 + * F←R, R←B, B←L, L←F + */ + rotateY(): void + + /** + * Z 軸回転相当で面の色を1ステップ循環する。 + * U←L, L←D, D←R, R←U + */ + rotateZ(): void +} diff --git a/specs/004-full-ui-options/data-model.md b/specs/004-full-ui-options/data-model.md new file mode 100644 index 0000000..242dbfc --- /dev/null +++ b/specs/004-full-ui-options/data-model.md @@ -0,0 +1,171 @@ +# データモデル: Ver.2 相当フル UI オプション(004-full-ui-options) + +**ブランチ**: `004-full-ui-options` | **日付**: 2026-05-03 + +--- + +## エンティティ一覧 + +### 1. `RenderOptions`(拡張) + +既存の `RenderOptions` インターフェースに以下のフィールドを追加する。 + +```typescript +// src/render/types.ts — 既存フィールドはすべて維持 +interface RenderOptions { + // --- 既存フィールド(変更なし) --- + readonly colorScheme?: Partial + readonly backgroundColor?: string + readonly width?: number + readonly height?: number + readonly viewportRotations?: ReadonlyArray + + // --- 新規追加フィールド --- + /** 表示モード。'plan' で上面投影図。省略時は通常の3D表示 */ + readonly view?: string + /** ステージマスク(例: 'oll', 'f2l')。省略時はマスクなし */ + readonly mask?: string + /** マスク向き調整アルゴリズム(例: 'y', "x'")。mask 指定時のみ有効 */ + readonly maskAlg?: string + /** キューブ輪郭色。'#rrggbb' 形式 */ + readonly cubeColor?: string + /** マスク適用ステッカーの色。'#rrggbb' 形式 */ + readonly maskColor?: string + /** キューブ輪郭の不透明度(0〜100)。デフォルト: 100 */ + readonly cubeOpacity?: number + /** ステッカーの不透明度(0〜100)。デフォルト: 100 */ + readonly stickerOpacity?: number + /** 投影距離(1〜100)。デフォルト: 5 */ + readonly dist?: number + /** アロー定義文字列(sr-visualizer のアロー書式) */ + readonly arrows?: string +} +``` + +**バリデーション**: +- `cubeOpacity` / `stickerOpacity`: 0〜100 の整数(ストア側でクランプ) +- `dist`: 1〜100 の整数(ストア側でクランプ) +- `cubeColor` / `maskColor`: `#rrggbb` 形式(カラーピッカーが保証) +- `mask`: `Masking` 列挙体のいずれかの文字列値、または空文字(ストアが保証) + +--- + +### 2. `RenderOptionsState`(永続化スキーマ) + +localStorage に保存されるスキーマ(バージョン付き)。 + +```typescript +// src/stores/renderOptions.ts(内部型) +interface RenderOptionsState { + readonly version: 1 + readonly imageSize: number // 1〜1000、デフォルト: 128 + readonly view: 'normal' | 'plan' // デフォルト: 'normal' + readonly mask: string // '' = なし + readonly maskAlg: string // '' = なし + readonly colorScheme: Record<0 | 1 | 2 | 3 | 4 | 5, string> + readonly backgroundColor: string // '#ffffff' + readonly cubeColor: string // '#000000' + readonly maskColor: string // '#404040' + readonly cubeOpacity: number // 0〜100、デフォルト: 100 + readonly stickerOpacity: number // 0〜100、デフォルト: 100 + readonly dist: number // 1〜100、デフォルト: 5 + readonly viewportRotations: [string, number][] // ViewAxis × 角度 + readonly arrows: string // '' = なし +} +``` + +**localStorage キー**: `vce3-render-options` +**スキーマバージョン**: `1`(将来のマイグレーション用) + +--- + +### 3. `useRenderOptionsStore`(Pinia ストア) + +`src/stores/renderOptions.ts` として実装される setup ストア。 + +**ステート(ref)**: + +| プロパティ | 型 | デフォルト | +|-----------|-----|-----------| +| `imageSize` | `number` | `128` | +| `view` | `'normal' \| 'plan'` | `'normal'` | +| `mask` | `string` | `''` | +| `maskAlg` | `string` | `''` | +| `colorScheme` | `Record<0\|1\|2\|3\|4\|5, string>` | WCA 標準色 | +| `backgroundColor` | `string` | `'#ffffff'` | +| `cubeColor` | `string` | `'#000000'` | +| `maskColor` | `string` | `'#404040'` | +| `cubeOpacity` | `number` | `100` | +| `stickerOpacity` | `number` | `100` | +| `dist` | `number` | `5` | +| `viewportRotations` | `[ViewAxis, number][]` | `[['y',45],['x',-34],['z',0]]` | +| `arrows` | `string` | `''` | + +**computed**: +- `renderOptions: RenderOptions` — 全ステートを `RenderOptions` オブジェクトに変換 + +**アクション**: + +| メソッド | シグネチャ | 説明 | +|---------|-----------|------| +| `resetColorScheme()` | `() => void` | WCA 標準色に戻す | +| `rotateX()` | `() => void` | U/F/D/B を 1 ステップ循環(X 軸回転相当) | +| `rotateY()` | `() => void` | F/R/B/L を 1 ステップ循環(Y 軸回転相当) | +| `rotateZ()` | `() => void` | U/R/D/L を 1 ステップ循環(Z 軸回転相当) | + +**色循環ロジック**(`cycleFaceColors` ヘルパー): + +各回転は `(a, b, c, d)` の 4 面を `a←b, b←c, c←d, d←a` の順で入れ替える。 + +| 回転 | 4 面サイクル(face index)| 意味 | +|------|--------------------------|------| +| rotateX | (0, 5, 3, 2) | U←B←D←F←U | +| rotateY | (2, 1, 5, 4) | F←R←B←L←F | +| rotateZ | (0, 4, 3, 1) | U←L←D←R←U | + +--- + +### 4. Stage Mask 定数一覧 + +sr-visualizer `Masking` 列挙体の全値。`StageMaskControl.vue` で使用。 + +| 表示ラベル | 内部値 | +|-----------|--------| +| FL | `fl` | +| F2L | `f2l` | +| LL | `ll` | +| CLL | `cll` | +| ELL | `ell` | +| OLL | `oll` | +| OCLL | `ocll` | +| OCELL | `ocell` | +| WV | `wv` | +| VH | `vh` | +| ELS | `els` | +| CLS | `cls` | +| CMLL | `cmll` | +| CROSS | `cross` | +| F2L#1 | `f2l_1` | +| F2L#2 | `f2l_2` | +| F2L#3 | `f2l_3` | +| F2L SM | `f2l_sm` | +| F2B | `f2b` | +| LINE | `line` | + +**Mask Alg 選択肢**: `x`, `x'`, `x2`, `y`, `y'`, `y2`, `z`, `z'`, `z2` + +--- + +### 5. ColorScheme キー → 面マッピング + +`RenderOptions.colorScheme` のキーとキューブ面の対応。 +カラーピッカー UI のラベルに使用。 + +| キー | 面 | デフォルト色 | +|-----|----|-------------| +| `0` | U (Up) | `#FFFFFF`(白) | +| `1` | D (Down) | `#FFFF00`(黄) | +| `2` | F (Front) | `#FF0000`(赤) | +| `3` | B (Back) | `#FF8800`(橙) | +| `4` | R (Right) | `#0000FF`(青) | +| `5` | L (Left) | `#00FF00`(緑) | diff --git a/specs/004-full-ui-options/plan.md b/specs/004-full-ui-options/plan.md new file mode 100644 index 0000000..55cec1a --- /dev/null +++ b/specs/004-full-ui-options/plan.md @@ -0,0 +1,283 @@ +# 実装計画: Ver.2 相当フル UI オプション + +**ブランチ**: `004-full-ui-options` | **日付**: 2026-05-03 | **仕様**: [spec.md](spec.md) +**入力**: `specs/004-full-ui-options/spec.md` のフィーチャー仕様 + +## 概要 + +現在の UI(Move ボタン + サイズ選択のみ)に Ver.2 相当のビジュアライズ設定を追加する。 +`RenderOptions` 型を拡張し、`useRenderOptionsStore`(Pinia)で全設定を一元管理する。 +sr-visualizer がすでに持つ機能(mask, view, cubeColor 等)を UI から操作可能にする。 +レイアウトを Bootstrap 5 による二列構成(左: キューブ固定表示、右: 設定パネル)に刷新する。 + +## 技術コンテキスト + +**言語/バージョン**: TypeScript 6.x(strict: true) +**主要依存関係**: Vue 3.5.x, sr-visualizer ^1.0.13, Pinia 3.x, Bootstrap 5.3(CDN) +**ストレージ**: localStorage(既存 `vce3-cube-state` + 新規 `vce3-render-options`) +**テスト**: Vitest 4.x, @vue/test-utils 2.x +**対象プラットフォーム**: モダンブラウザ(Chrome/Firefox/Safari 最新版) +**プロジェクト種別**: Web アプリ(Vue SPA) +**パフォーマンス目標**: 設定変更から 100ms 以内にキューブ表示更新 +**制約**: ランタイム依存追加なし(Bootstrap は CSS のみ、CDN 経由) +**規模/スコープ**: UI レイヤー + 描画レイヤー型拡張。ロジックレイヤーは変更しない。 + +## Constitution Check + +*ゲート: Phase 0 リサーチ開始前に確認必須。Phase 1 設計完了後に再確認。* + +- [x] **I. 目的継承の原則** — Ver.2 のビジュアライズ機能を Ver.3 で再現する実装。 + V2 のユーザー価値(最小手順で高品質キューブ画像生成)を直接強化する。 +- [x] **II. TypeScript Strict Mode** — 全新規コードは strict TypeScript で記述。 + `adapter.ts` での `as Masking` キャストは安全性コメント付きで許容(複雑性トラッキング参照)。 +- [x] **III. レイヤードアーキテクチャ** — 変更範囲は描画レイヤー(型拡張・アダプタ)と + UI レイヤー(ストア・コンポーネント)のみ。ロジックレイヤーは一切変更しない。 +- [x] **IV. Vitest によるテストファースト** — `useRenderOptionsStore` と全新規コンポーネントに + Vitest テストを同時作成する。既存テストは全件パスを維持。 +- [x] **V. NxN キューブ拡張性** — 新規コードにキューブサイズのハードコードなし。 + ビジュアライズオプションはサイズ非依存。 +- [x] **VI. 作成状態の永続化** — `useRenderOptionsStore` が localStorage への自動保存と + 復元を実装する(`vce3-render-options` キー、スキーマバージョン 1)。 + +| 違反内容 | 必要な理由 | 解決期限 | +|----------|------------|----------| +| `adapter.ts` での `options.mask as Masking` 型アサーション | sr-visualizer の `mask` フィールドが `Masking` 列挙体を要求するが、TypeScript はstring → enum の直接割り当てを許容しない。ストアが MASK_LIST 定数から値をセットするため実行時安全 | 次の sr-visualizer アップデート時に型ガードへ移行を検討 | + +## プロジェクト構造 + +### ドキュメント(このフィーチャー) + +```text +specs/004-full-ui-options/ +├── plan.md # このファイル +├── spec.md # フィーチャー仕様 +├── research.md # Phase 0 出力(決定事項まとめ) +├── data-model.md # Phase 1 出力(エンティティ定義) +├── quickstart.md # Phase 1 出力(実装手順) +├── contracts/ +│ ├── render-options-api.ts # RenderOptions 拡張コントラクト +│ └── render-options-store-api.ts # useRenderOptionsStore コントラクト +└── tasks.md # Phase 2 出力(/speckit-tasks コマンドで生成) +``` + +### ソースコード(変更・追加ファイル) + +```text +src/ +├── render/ +│ ├── types.ts # [変更] RenderOptions に新規フィールド追加 +│ └── sr-visualizer/ +│ └── adapter.ts # [変更] 新規オプションを cubeSVG() に渡す +├── stores/ +│ └── renderOptions.ts # [新規] useRenderOptionsStore +├── components/ +│ ├── CubeDisplay.vue # [変更] useRenderOptionsStore を使用 +│ ├── SizeSelector.vue # [変更] +/- ボタン追加 +│ ├── ImageSizeControl.vue # [新規] +│ ├── SpecialViewControl.vue # [新規] +│ ├── StageMaskControl.vue # [新規] +│ ├── ColorSchemeControl.vue # [新規] +│ ├── ViewportRotationControl.vue # [新規] +│ └── AppearanceControl.vue # [新規] +└── App.vue # [変更] Bootstrap 二列レイアウト + +index.html # [変更] Bootstrap 5 CDN リンク追加 +package.json # [変更] "dev": "vite" スクリプト追加 + +tests/ +├── stores/ +│ └── renderOptions.test.ts # [新規] +└── components/ + ├── ImageSizeControl.test.ts # [新規] + ├── SpecialViewControl.test.ts # [新規] + ├── StageMaskControl.test.ts # [新規] + ├── ColorSchemeControl.test.ts # [新規] + ├── ViewportRotationControl.test.ts # [新規] + └── AppearanceControl.test.ts # [新規] +``` + +**構造の決定**: 単一プロジェクト構成を維持。既存 `src/` 以下に追記する形で実装。 + +## 実装設計 + +### 描画レイヤー拡張 + +#### `src/render/types.ts` +`RenderOptions` インターフェースに 9 フィールドを追加(全て省略可能): + +```typescript +readonly view?: string // 'plan' で上面投影図 +readonly mask?: string // ステージマスク値 +readonly maskAlg?: string // マスク向き調整 +readonly cubeColor?: string // キューブ輪郭色 +readonly maskColor?: string // マスク色 +readonly cubeOpacity?: number // 0〜100 +readonly stickerOpacity?: number // 0〜100 +readonly dist?: number // 1〜100 +readonly arrows?: string // アロー定義文字列 +``` + +#### `src/render/sr-visualizer/adapter.ts` +`cubeSVG()` 呼び出しに新規フィールドを条件付きスプレッドで追加: + +```typescript +import { cubeSVG, Axis, Masking } from 'sr-visualizer' + +// ... 既存処理 ... + +cubeSVG(container as unknown as HTMLElement, { + cubeSize: state.size, + stickerColors, + width, + height, + ...(backgroundColor !== undefined && { backgroundColor }), + ...(viewportRotations !== undefined && { viewportRotations }), + ...(options?.view && { view: options.view }), + // sr-visualizer が Masking 列挙体を要求するが、ストアが MASK_LIST から + // 値をセットするため実行時安全。Constitution II 準拠コメント。 + ...(options?.mask && { mask: options.mask as Masking }), + ...(options?.maskAlg && { maskAlg: options.maskAlg }), + ...(options?.cubeColor !== undefined && { cubeColor: options.cubeColor }), + ...(options?.maskColor !== undefined && { maskColor: options.maskColor }), + ...(options?.cubeOpacity !== undefined && { cubeOpacity: options.cubeOpacity }), + ...(options?.stickerOpacity !== undefined && { stickerOpacity: options.stickerOpacity }), + ...(options?.dist !== undefined && { dist: options.dist }), + ...(options?.arrows && { arrows: options.arrows }), +}) +``` + +### `useRenderOptionsStore` 設計 + +```typescript +// src/stores/renderOptions.ts +export const useRenderOptionsStore = defineStore('renderOptions', () => { + const imageSize = ref(128) + const view = ref<'normal' | 'plan'>('normal') + const mask = ref('') + const maskAlg = ref('') + const colorScheme = ref>({ ...DEFAULT_COLOR_SCHEME }) + const backgroundColor = ref('#ffffff') + const cubeColor = ref('#000000') + const maskColor = ref('#404040') + const cubeOpacity = ref(100) + const stickerOpacity = ref(100) + const dist = ref(5) + const viewportRotations = ref<[ViewAxis, number][]>([ + ['y', 45], ['x', -34], ['z', 0], + ]) + const arrows = ref('') + + const renderOptions = computed((): RenderOptions => ({ + width: imageSize.value, + height: imageSize.value, + colorScheme: colorScheme.value, + backgroundColor: backgroundColor.value, + cubeColor: cubeColor.value, + maskColor: maskColor.value, + cubeOpacity: cubeOpacity.value, + stickerOpacity: stickerOpacity.value, + dist: dist.value, + viewportRotations: viewportRotations.value, + ...(view.value === 'plan' && { view: 'plan' }), + ...(mask.value && { mask: mask.value }), + ...(mask.value && maskAlg.value && { maskAlg: maskAlg.value }), + ...(arrows.value && { arrows: arrows.value }), + })) + + function cycleFaceColors( + a: 0|1|2|3|4|5, b: 0|1|2|3|4|5, + c: 0|1|2|3|4|5, d: 0|1|2|3|4|5, + ): void { + const s = { ...colorScheme.value } + const [ca, cb, cc, cd] = [s[a], s[b], s[c], s[d]] + s[a] = cb; s[b] = cc; s[c] = cd; s[d] = ca + colorScheme.value = s + } + + function resetColorScheme(): void { colorScheme.value = { ...DEFAULT_COLOR_SCHEME } } + function rotateX(): void { cycleFaceColors(0, 5, 3, 2) } + function rotateY(): void { cycleFaceColors(2, 1, 5, 4) } + function rotateZ(): void { cycleFaceColors(0, 4, 3, 1) } + + // localStorage 永続化(Constitution VI 準拠) + // ... watch + onMounted で restore/save + + return { + imageSize, view, mask, maskAlg, colorScheme, + backgroundColor, cubeColor, maskColor, cubeOpacity, + stickerOpacity, dist, viewportRotations, arrows, + renderOptions, + resetColorScheme, rotateX, rotateY, rotateZ, + } +}) +``` + +### App.vue レイアウト + +Bootstrap 5 の grid を使用した二列レイアウト: + +``` +┌─ navbar ─────────────────────────────────────────┐ +│ Visual Cube Editor 3 │ +├──────────────────────┬───────────────────────────┤ +│ [sticky] │ [scrollable] │ +│ │ ┌─ パズル設定 ────────┐ │ +│ CubeDisplay │ │ SizeSelector │ │ +│ (SVG) │ └─────────────────────┘ │ +│ │ ┌─ アルゴリズム ──────┐ │ +│ ImageSizeControl │ │ MoveInput │ │ +│ │ └─────────────────────┘ │ +│ │ ┌─ ビジュアライズ ────┐ │ +│ │ │ SpecialViewControl │ │ +│ │ │ StageMaskControl │ │ +│ │ └─────────────────────┘ │ +│ │ ┌─ カラースキーム ────┐ │ +│ │ │ ColorSchemeControl │ │ +│ │ └─────────────────────┘ │ +│ │ ┌─ ビューポート回転 ──┐ │ +│ │ │ ViewportRotation │ │ +│ │ └─────────────────────┘ │ +│ │ ┌─ 外観 ──────────────┐ │ +│ │ │ AppearanceControl │ │ +│ │ └─────────────────────┘ │ +└──────────────────────┴───────────────────────────┘ +``` + +## テスト戦略 + +### 既存テスト(変更なし・全件パス維持) + +| テストファイル | 影響 | 対応 | +|--------------|------|------| +| `tests/App.test.ts` | `select` 要素チェックあり | `SizeSelector` の select を維持 | +| `tests/components/CubeDisplay.test.ts` | `renderSVG` モック済み | 追加引数は検知されない | +| `tests/components/SizeSelector.test.ts` | select 操作テスト | ボタン追加のみ、select 動作不変 | +| `tests/render/render-options.test.ts` | RenderOptions 型変更 | 後方互換(既存フィールド変更なし) | + +### 新規テスト + +#### `tests/stores/renderOptions.test.ts` +``` +- デフォルト値の確認(imageSize=128, view='normal', etc.) +- rotateX/Y/Z の色循環ロジック検証 +- resetColorScheme で WCA 標準色に戻る +- renderOptions computed の出力検証 + - view='plan' のとき { view: 'plan' } が含まれる + - view='normal' のとき view フィールドが含まれない + - mask='' のとき mask フィールドが含まれない + - mask='oll' のとき { mask: 'oll' } が含まれる +- localStorage 保存・復元の動作 +``` + +#### 新規コンポーネントテスト(各コンポーネント) +``` +- ストアの値が UI に正しく反映されている +- UI 操作でストアが更新される +- リセットボタンで初期値に戻る +``` + +## 複雑性トラッキング + +| 違反内容 | 必要な理由 | より単純な代替案を却下した理由 | +|----------|------------|-------------------------------| +| `adapter.ts` での `options.mask as Masking` 型アサーション | TypeScript が `string → Masking enum` の直接代入を禁止するため | 型ガード(20値の列挙)は実装コストが高く、ストアの MASK_LIST による制約で実行時安全が既に保証されている | diff --git a/specs/004-full-ui-options/quickstart.md b/specs/004-full-ui-options/quickstart.md new file mode 100644 index 0000000..1b6ff0e --- /dev/null +++ b/specs/004-full-ui-options/quickstart.md @@ -0,0 +1,136 @@ +# クイックスタート: 004-full-ui-options 実装ガイド + +## 前提確認 + +```bash +# 正しいブランチか確認 +git branch --show-current # → 004-full-ui-options + +# 依存関係インストール済みか確認 +pnpm install + +# 既存テスト全件パス確認 +pnpm test + +# 型チェックパス確認 +pnpm typecheck +``` + +## 開発サーバー起動 + +```bash +# package.json に dev スクリプト追加後 +pnpm dev +# または +npx vite +``` + +## 実装順序 + +依存関係の方向に従い、**下位レイヤーから上位レイヤーへ**実装する。 + +### ステップ 1: 描画レイヤー型拡張(テストなし変更) + +``` +src/render/types.ts ← RenderOptions に新規フィールド追加 +src/render/sr-visualizer/adapter.ts ← 新規フィールドを cubeSVG() に渡す +``` + +変更後 `pnpm typecheck` でエラーなし確認。 + +### ステップ 2: `useRenderOptionsStore` 作成 + +``` +src/stores/renderOptions.ts ← 新規ファイル +tests/stores/renderOptions.test.ts ← 同時作成(TDD) +``` + +テスト項目例: +- デフォルト値が正しく設定されている +- `rotateX/Y/Z` が正しく面色を循環させる +- `resetColorScheme` が WCA 標準色に戻す +- `renderOptions` computed が正しい RenderOptions を返す +- localStorage への自動保存と復元が動作する + +### ステップ 3: CubeDisplay 更新 + +``` +src/components/CubeDisplay.vue ← useRenderOptionsStore を使用 +``` + +`renderSVG(cubeStore.cubeState, renderStore.renderOptions)` に変更。 + +### ステップ 4: 新規 UI コンポーネント + +作成順(依存なし、並列作業可能): + +``` +src/components/ImageSizeControl.vue +src/components/SpecialViewControl.vue +src/components/StageMaskControl.vue +src/components/ColorSchemeControl.vue +src/components/ViewportRotationControl.vue +src/components/AppearanceControl.vue +``` + +各コンポーネントには対応するテストを同時作成: + +``` +tests/components/ImageSizeControl.test.ts +tests/components/SpecialViewControl.test.ts +... +``` + +### ステップ 5: SizeSelector 更新 + +``` +src/components/SizeSelector.vue ← +/- ボタン追加(select 要素維持) +``` + +既存テスト (`tests/components/SizeSelector.test.ts`) が引き続きパスすること。 + +### ステップ 6: Bootstrap 5 + App.vue レイアウト + +``` +index.html ← Bootstrap 5 CSS CDN リンク追加 +src/App.vue ← 二列レイアウト(Bootstrap grid) +``` + +### ステップ 7: package.json dev スクリプト追加 + +```json +"scripts": { + "dev": "vite", + ... +} +``` + +## 検証チェックリスト + +```bash +pnpm test # 全テストパス(新規テスト含む) +pnpm typecheck # TypeScript エラーなし +pnpm lint # ESLint エラーなし +pnpm dev # ブラウザで動作確認 +``` + +ブラウザ確認項目: +- [ ] Special View を "plan" に切り替えるとキューブが平面図に変わる +- [ ] OLL を選択すると非 LL 面がグレーアウトされる +- [ ] 各面のカラーピッカーを変更するとリアルタイムで色が変わる +- [ ] X/Y/Z 回転ボタンで色が循環する +- [ ] ビューポートスライダーを動かすとキューブの向きが変わる +- [ ] 背景色・不透明度・dist を変更すると反映される +- [ ] 画像サイズの +/- ボタンが機能する +- [ ] 右パネルをスクロールしても左のキューブが固定されている +- [ ] ページをリロードしても設定が復元される(localStorage 永続化) + +## 型キャストの注意点(Constitution II 準拠) + +`adapter.ts` で `Masking` 型にキャストする箇所には必ず安全性コメントを付与する: + +```typescript +// sr-visualizer が Masking 列挙体を要求するが、useRenderOptionsStore が +// MASK_LIST 定数からのみ値をセットするため、実行時に無効な値は入らない +...(options?.mask && { mask: options.mask as Masking }), +``` diff --git a/specs/004-full-ui-options/research.md b/specs/004-full-ui-options/research.md new file mode 100644 index 0000000..c220a95 --- /dev/null +++ b/specs/004-full-ui-options/research.md @@ -0,0 +1,109 @@ +# リサーチ: Ver.2 相当フル UI オプション(004-full-ui-options) + +**ブランチ**: `004-full-ui-options` | **日付**: 2026-05-03 + +--- + +## 決定事項 + +### 1. Bootstrap 5 の導入方法 + +**決定**: CDN リンクを `index.html` の `` に追加する(CSS のみ、JS 不要) + +**根拠**: +- Ver.2 が同じ方法を採用している(プロジェクト一貫性) +- Vue の SFC スタイルと競合しない +- Bootstrap JS が提供する機能(Dropdown/Collapse JS)を今回は使わない。 + Vue の `v-show` / `:class` で代替可能 +- `pnpm add bootstrap` による npm 追加は、Vite でのツリーシェイクが効かない限りバンドルサイズを増やす + +**検討した代替案**: +- `pnpm add bootstrap` — ビルド制御は良いが setup overhead +- Tailwind CSS — 既存コードに Tailwind がないため導入コストが高い +- 素の CSS — 時間コストが高い + +--- + +### 2. `Masking` 型キャスト戦略 + +**決定**: sr-visualizer の `Masking` enum をインポートし `options.mask as Masking` でキャストする。 +Constitution II により安全性の説明コメントを付与する。 + +**根拠**: +- `useRenderOptionsStore` がマスク値を `MASK_LIST` 定数から選ばせるため、 + 実行時に無効な文字列が入ることはない(ストアが唯一の更新経路) +- `as unknown as Masking` より `as Masking` の方が読みやすい + (TypeScript が `string → enum` キャストを許容しない場合に限り `as unknown as` を使用) + +**検討した代替案**: +- Runtime validation 関数 — 20 値を網羅する型ガードを書くコストが高い割に既に安全 +- `any` — Constitution II により禁止 + +--- + +### 3. `useRenderOptionsStore` の永続化 + +**決定**: `watch(renderOptions, ...)` で localStorage `vce3-render-options` に自動保存する。 +既存 `useCubePersist` と同じパターン。スキーマバージョン: `1`。 + +**根拠**: +- Constitution VI 「アプリは自動保存しなければならない(MUST)」に準拠 +- `useCubePersist` と同一パターンで実装コストが低い +- spec の前提条件に「既存の `useCubePersist` は変更しない」とあるため分離 + +**検討した代替案**: +- 永続化なし — Constitution VI 違反になるため却下 +- IndexedDB — 非同期になり実装複雑度が上がる。今回のデータ量で不要 + +--- + +### 4. `view` フィールドの型 + +**決定**: `RenderOptions.view?: string`(型は文字列。ストア内は `'normal' | 'plan'`) + +**根拠**: +- sr-visualizer の `ICubeOptions.view?: string` に合わせる +- ストアで union 型を使うことで UI の型安全を確保しつつ、レンダー型を拡張しやすくする + +--- + +### 5. 画像サイズの扱い(正方形統一) + +**決定**: width / height は常に同値。ストアに `imageSize: number` を一本化する。 +`RenderOptions` 生成時に `width: imageSize, height: imageSize` を展開する。 + +**根拠**: +- Ver.2 が正方形のみをサポートしている +- spec の前提条件に「幅・高さ共通の正方形サイズとして扱う」と明記 +- UI がシンプルになる + +--- + +### 6. コンポーネント分割方針 + +**決定**: 機能単位で 1 ファイル 1 コンポーネント。計 6 個の新規コンポーネントを作成。 + +| ファイル | 責務 | +|----------|------| +| `ImageSizeControl.vue` | 画像サイズ(ステップボタン + スライダー) | +| `SpecialViewControl.vue` | Special View ラジオボタン | +| `StageMaskControl.vue` | Stage Mask ドロップダウン + Mask Alg | +| `ColorSchemeControl.vue` | 6 面カラーピッカー + 回転 + リセット | +| `ViewportRotationControl.vue` | 3 軸スライダー + 数値入力 + リセット | +| `AppearanceControl.vue` | 背景色/キューブ色/マスク色/不透明度/dist | + +**根拠**: +- Constitution III: 各コンポーネントが独立テスト可能 +- Constitution IV: @vue/test-utils で個別テストが書きやすい + +--- + +### 7. 既存テストへの影響 + +**決定**: `CubeDisplay.test.ts` はレンダー層をモックしているため、 +`useRenderOptionsStore` を暗黙的に使用するよう `CubeDisplay.vue` を変更しても影響なし。 +`App.test.ts` の `select` 要素チェックは `SizeSelector` の select を残すことで通過。 + +**根拠**: +- `renderSVG` はモック済み → 引数変化を検知しない +- `SizeSelector` の select 要素は残す(+/- ボタン追加のみ) diff --git a/specs/004-full-ui-options/spec.md b/specs/004-full-ui-options/spec.md new file mode 100644 index 0000000..b0a82ec --- /dev/null +++ b/specs/004-full-ui-options/spec.md @@ -0,0 +1,169 @@ +# フィーチャー仕様: Ver.2 相当フル UI オプション + +**フィーチャーブランチ**: `004-full-ui-options` +**作成日**: 2026-05-03 +**ステータス**: 草稿 + +## ユーザーシナリオとテスト *(必須)* + +### ユーザーストーリー 1 - ビジュアライズオプションの設定(優先度: P1) + +ユーザーは、キューブ画像の見た目を細かく制御したい。特定のステップ(OLL, F2L など)を +練習しているとき、関係ない面をグレーアウトしたり、上から見た "plan view" に切り替えたり +することで、アルゴリズムの理解が深まる。 + +**この優先度の理由**: Ver.2 で最も使われているビジュアライズ機能であり、Ver.3 の価値提案の中核。 + +**独立テスト**: Special View・Stage Mask の UI を操作するだけで、すぐに表示が変わることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** アプリを開いた初期状態、**When** Special View を "plan" に切り替えた、**Then** キューブが真上から見た平面図で表示される +2. **Given** 初期状態、**When** Stage Mask に "OLL" を選んだ、**Then** U 面と LL 以外のステッカーがグレーアウトされる +3. **Given** Stage Mask が "OLL" に設定されている、**When** Mask Alg に "y" を選んだ、**Then** マスクの向きが Y 軸方向に 1 回転した状態で表示される +4. **Given** Stage Mask が設定されている、**When** "なし" を選んだ、**Then** 全面が通常色で表示される + +--- + +### ユーザーストーリー 2 - カラースキームの編集(優先度: P1) + +ユーザーは、U/R/F/D/L/B 各面の色を任意に変更したい。配色を変えることで、 +自分のキューブや図解の色に合わせた画像を生成できる。 + +**この優先度の理由**: Ver.2 で日常的に使われる機能であり、カスタマイズの基本。 + +**独立テスト**: 各面のカラーピッカーを変更すると即座にキューブ表示が更新されることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** デフォルト配色の状態、**When** U 面のカラーピッカーで任意の色を選んだ、**Then** Up 面のステッカーが選んだ色で表示される +2. **Given** 任意の配色、**When** x ボタンを押した、**Then** U/F/D/B の色が X 軸回転相当で1ステップ循環する +3. **Given** 任意の配色、**When** y ボタンを押した、**Then** F/R/B/L の色が Y 軸回転相当で1ステップ循環する +4. **Given** 任意の配色、**When** z ボタンを押した、**Then** U/R/D/L の色が Z 軸回転相当で1ステップ循環する +5. **Given** 変更した配色、**When** Reset ボタンを押した、**Then** WCA 標準色(白/赤/青/黄/橙/緑)に戻る + +--- + +### ユーザーストーリー 3 - ビューポート回転の調整(優先度: P1) + +ユーザーは、キューブを見る角度を3軸で細かく調整したい。 +デフォルト(Y=45°、X=−34°)以外の視点でキューブを確認・共有できる。 + +**この優先度の理由**: Ver.2 のコア機能。特定のアルゴリズムを上から・横から見せたいユースケースが多い。 + +**独立テスト**: 各軸スライダーを動かすとリアルタイムにキューブの視点が変わることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** デフォルトビューポート(Y=45°, X=−34°, Z=0°)、**When** Y スライダーを 90° に動かした、**Then** キューブが Y 軸に 90° 回転した角度で表示される +2. **Given** 任意のビューポート設定、**When** 軸ごとの Reset ボタンを押した、**Then** その軸の角度がデフォルト値に戻る +3. **Given** スライダーで角度を変更した、**When** 数値入力フィールドに −180〜180 の値を直接入力した、**Then** その値がスライダーと同期して反映される + +--- + +### ユーザーストーリー 4 - 外観設定(優先度: P2) + +ユーザーは、背景色・キューブの輪郭色・マスク色・不透明度・投影距離を調整したい。 +透明背景や特定の背景色で、ドキュメントや動画に合わせた画像を生成できる。 + +**この優先度の理由**: ビジュアル品質を高める機能だが、なくても基本用途は成立する。 + +**独立テスト**: 各外観設定を変更すると即座にキューブ表示が反映されることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** 初期状態、**When** 背景色を変更した、**Then** キューブ画像の背景が指定色で表示される +2. **Given** 初期状態、**When** キューブ不透明度スライダーを 50% にした、**Then** キューブの枠線が半透明になる +3. **Given** 初期状態、**When** ステッカー不透明度スライダーを 0% にした、**Then** ステッカーが透明になる +4. **Given** 初期状態、**When** 投影距離(dist)を最大値にした、**Then** キューブが正射影に近い見た目になる + +--- + +### ユーザーストーリー 5 - 画像サイズの変更(優先度: P2) + +ユーザーは、生成するキューブ画像のサイズを細かく調整したい。 +SNS 投稿用に大きめ、ドキュメント埋め込み用に小さめ、など用途に合わせてサイズを選べる。 + +**この優先度の理由**: 実用性を高める機能だが、デフォルトサイズでも基本用途は成立する。 + +**独立テスト**: サイズ変更ボタンを押すとキューブ表示領域が即座に変わることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** デフォルトサイズ(128px)、**When** +10 ボタンを 3 回押した、**Then** サイズが 158px になりキューブが大きく表示される +2. **Given** 任意のサイズ、**When** Reset ボタンを押した、**Then** サイズが 128px に戻る +3. **Given** 最小値(1px)付近、**When** −10 ボタンを押した、**Then** 1px 未満には下がらない(下限クランプ) + +--- + +### ユーザーストーリー 6 - レイアウト改善(優先度: P1) + +ユーザーは、キューブ表示と設定パネルを同時に見ながら操作したい。 +設定を変えるたびにスクロールしてキューブを確認するのは非効率。 + +**この優先度の理由**: 操作の流れを根本的に改善するレイアウト変更。他の機能の使いやすさに直結する。 + +**独立テスト**: 設定パネルをスクロールしても左のキューブ表示が常に見える位置に固定されていることを確認できる。 + +**受け入れシナリオ**: + +1. **Given** アプリを開いた状態、**When** 右側の設定パネルをスクロールした、**Then** 左側のキューブ表示は画面内に固定されたまま(sticky) +2. **Given** 任意の設定パネル操作、**When** 設定を変更した、**Then** 左側のキューブがリアルタイムで更新される + +--- + +### エッジケース + +- 画像サイズが 1 未満の値を指定しようとした場合、1px にクランプされる +- Stage Mask を設定した状態でキューブサイズを変更した場合、マスクは引き続き有効に機能する +- 無効なカラーコードがカラーピッカー以外から入力された場合、表示は崩れずデフォルト値にフォールバックする +- ビューポート回転の角度に −180〜180 の範囲外の値が入力された場合、範囲内にクランプされる + +## 要件 *(必須)* + +### 機能要件 + +- **FR-001**: システムは Special View(normal / plan)をラジオボタンで切り替えられなければならない(MUST) +- **FR-002**: システムは 20 種類の Stage Mask をドロップダウンで選択できなければならない(MUST) +- **FR-003**: Stage Mask 選択中は Mask Alg(x/x'/x2/y/y'/y2/z/z'/z2)をドロップダウンで選択できなければならない(MUST) +- **FR-004**: ユーザーは U/R/F/D/L/B 各面の色をカラーピッカーで変更できなければならない(MUST) +- **FR-005**: カラースキームは x/y/z 軸回転ボタン(各1ステップ循環)と Reset ボタンを提供しなければならない(MUST) +- **FR-006**: ビューポート回転は 3 スロット各々で軸(x/y/z)+ 角度(−180〜180°)を設定できなければならない(MUST) +- **FR-007**: ビューポート回転の各スロットにはスライダーと数値入力フィールドが同期して動作しなければならない(MUST) +- **FR-008**: 外観設定として背景色・キューブ色・マスク色のカラーピッカーを提供しなければならない(MUST) +- **FR-009**: キューブ不透明度とステッカー不透明度を 0〜100% のスライダーで調整できなければならない(MUST) +- **FR-010**: 投影距離(dist)を 1〜100 のスライダーで調整できなければならない(MUST) +- **FR-011**: 画像サイズを −10/−1/+1/+10 ボタンとスライダーと Reset ボタンで制御できなければならない(MUST) +- **FR-012**: パズルサイズ選択に +/− ボタンを追加しつつ、既存の select 要素も維持しなければならない(MUST) +- **FR-013**: 左列にキューブ表示・右列に設定パネルの二列レイアウトで、左列は sticky に固定されなければならない(MUST) +- **FR-014**: 全設定変更はキューブ表示にリアルタイムで反映されなければならない(MUST) +- **FR-015**: `RenderOptions` 型に view/mask/maskAlg/cubeColor/maskColor/cubeOpacity/stickerOpacity/dist/arrows フィールドを追加しなければならない(MUST) +- **FR-016**: `SrVisualizerAdapter` は拡張された全オプションを sr-visualizer に渡さなければならない(MUST) +- **FR-017**: `useRenderOptionsStore`(Pinia)が全ビジュアライズ設定を管理しなければならない(MUST) +- **FR-018**: 既存テスト(vitest)が全て引き続き通過しなければならない(MUST) + +### 主要エンティティ + +- **RenderOptions**: ビジュアライズオプション全体を表す型。既存フィールドを維持しつつ新規フィールドを追加。 +- **useRenderOptionsStore**: 全ビジュアライズ設定の状態を保持する Pinia ストア。 +- **SrVisualizerAdapter**: RenderOptions を sr-visualizer ライブラリの ICubeOptions に変換するアダプタ。 + +## 成功基準 *(必須)* + +### 測定可能なアウトカム + +- **SC-001**: ユーザーは5秒以内に Special View・Stage Mask・カラースキーム・ビューポート・外観の全設定にアクセスできる(スクロールのみで到達可能) +- **SC-002**: 全設定変更はユーザー操作から 100ms 以内にキューブ表示に反映される(知覚的なリアルタイム性) +- **SC-003**: Ver.2 が持つビジュアライズオプション(Special View, Stage Mask 20種, カラースキーム, ビューポート3軸, 外観設定6項目, 画像サイズ)が全て操作可能である +- **SC-004**: 既存の vitest テストが全件パスする(テスト件数の減少なし) +- **SC-005**: TypeScript 型チェック(`vue-tsc --noEmit`)がエラーなしで通過する + +## 前提条件 + +- ユーザーはモダンブラウザ(Chrome/Firefox/Safari の最新版)を使用している +- Ver.2 と同様に Bootstrap 5 を CDN 経由で導入してレイアウトに利用する +- sr-visualizer ライブラリ(v1.0.13)が提供する全オプション(mask, view, cubeColor 等)をそのまま利用する +- 既存の `useCubeStore` および `useCubePersist` は変更しない +- アロー定義 UI は Ver.2 の完全な GUI ではなく、テキスト入力(arrows 文字列)のみとする(簡略化) +- 画像サイズは幅・高さ共通の正方形サイズとして扱う +- スタイリングは Bootstrap 5 CSS クラスを主体とし、最小限のカスタム CSS を追加する diff --git a/specs/004-full-ui-options/tasks.md b/specs/004-full-ui-options/tasks.md new file mode 100644 index 0000000..2011e17 --- /dev/null +++ b/specs/004-full-ui-options/tasks.md @@ -0,0 +1,241 @@ +# タスク: Ver.2 相当フル UI オプション + +**入力**: `specs/004-full-ui-options/` の設計ドキュメント +**前提条件**: plan.md(必須)、spec.md(ユーザーストーリー用、必須)、research.md、data-model.md、contracts/ + +**テスト**: 原則IV(Vitest によるテストファースト)に従い、全ストア・コンポーネントのテストタスクは**必須**。 +テストは実装より先に記述し、Red 状態(失敗)を確認してから実装を開始すること。 + +**構成**: タスクはユーザーストーリーごとにグループ化し、各ストーリーを独立して実装・テストできるようにする。 + +## 形式: `[ID] [P?] [Story] 説明` + +- **[P]**: 並列実行可能(異なるファイル、依存関係なし) +- **[Story]**: 対応するユーザーストーリー(US1〜US6) +- 説明には正確なファイルパスを含めること + +--- + +## Phase 1: セットアップ + +**目的**: 開発サーバーと UI スタイリングの基盤整備 + +- [x] T001 `package.json` の `scripts` に `"dev": "vite"` を追加する +- [x] T002 `index.html` の `` に Bootstrap 5.3 CSS CDN リンク(`https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css`)を追加する + +--- + +## Phase 2: 基盤(全ユーザーストーリーのブロッキング前提条件) + +**目的**: `RenderOptions` 型拡張・`SrVisualizerAdapter` 更新・`useRenderOptionsStore` 実装。 +この基盤なしにはいずれの UI コンポーネントも実装できない。 + +**⚠️ 重要**: このフェーズが完了するまでユーザーストーリーの作業を開始してはならない + +### 基盤テスト(TDD: 実装前に作成し FAIL を確認すること) + +- [x] T003 `tests/stores/renderOptions.test.ts` に以下のテストを作成する(実装前に全件 FAIL 確認):デフォルト値の確認(imageSize=128, view='normal', mask='', cubeOpacity=100 等)、rotateX/Y/Z による4面色循環の正確性、resetColorScheme で WCA 標準色への復元、renderOptions computed の出力検証(view='plan'→view フィールド含む、mask=''→mask フィールドなし、mask='oll'→mask:'oll' 含む)、localStorage 保存・復元の動作(`vce3-render-options` キー) + +### 基盤実装 + +- [x] T004 `src/render/types.ts` の `RenderOptions` インターフェースに以下9フィールドを追加する(全て `readonly` かつ省略可能): `view?: string`, `mask?: string`, `maskAlg?: string`, `cubeColor?: string`, `maskColor?: string`, `cubeOpacity?: number`, `stickerOpacity?: number`, `dist?: number`, `arrows?: string` +- [x] T005 `src/render/sr-visualizer/adapter.ts` に `Masking` を sr-visualizer からインポートし、`cubeSVG()` 呼び出しに新規9フィールドを条件付きスプレッドで追加する(`options.mask as Masking` には Constitution II 準拠の安全性コメントを付与する) +- [x] T006 `src/stores/renderOptions.ts` を新規作成し `useRenderOptionsStore` を実装する:全13ステート(imageSize, view, mask, maskAlg, colorScheme, backgroundColor, cubeColor, maskColor, cubeOpacity, stickerOpacity, dist, viewportRotations, arrows)、`renderOptions` computed、`cycleFaceColors` ヘルパー、`rotateX/Y/Z/resetColorScheme` アクション、`watch` + `onMounted` による localStorage 自動保存・復元(Constitution VI 準拠) +- [x] T007 `src/components/CubeDisplay.vue` を `useRenderOptionsStore` をインポートして `renderSVG(cubeStore.cubeState, renderStore.renderOptions)` に更新する(既存テスト `tests/components/CubeDisplay.test.ts` が引き続きパスすること) + +**チェックポイント**: `pnpm test` 全件パス、`pnpm typecheck` エラーなし — ユーザーストーリー実装を開始できる + +--- + +## Phase 3: ユーザーストーリー 6 - レイアウト改善(優先度: P1)🎯 MVP の土台 + +**目標**: 左列キューブ固定表示・右列スクロール設定パネルの二列 Bootstrap レイアウトを実現する + +**独立テスト**: アプリを起動し右パネルをスクロールしても左のキューブが固定されたままであることをブラウザで確認する + +### US6 テスト + +- [x] T008 [US6] `tests/App.test.ts` を読み込み、既存の3つのアサーション(`h1` テキスト、`select` 要素存在、`data-testid="notation-input"` 存在)が引き続きパスすることを確認する(変更不要だが確認としてテストを実行する) + +### US6 実装 + +- [x] T009 [US6] `src/App.vue` を Bootstrap 5 二列レイアウトに全面更新する:`