fix: examples のライトモード視認性改善と英数字混在ワード対応#54
Merged
Conversation
ライトモードで黄色系の色(枠線・ハイライト・ミスキー列)が白背景に埋もれて 見えづらかったため、グレーや赤などコントラストの取れる色へ変更した。 react-stroke-graph はカラースキームを監視してテーマに追従させる。 また英字・記号混在ワード "aから@" を扱う react-backspace / react-roman-or-kana で、ローマ字・かなルール単体では automaton 化できずエラーになっていたため、 createDirectInputRule をマージするよう修正した。 react-roman-or-kana では activate を打鍵ごとに再登録しており、その内部 KeyboardState がリセットされて Shift 押しっぱなしの状態が失われ、 "を"(Shift+0)が修飾なし入力として failed になっていた。ハンドラを マウント時に一度だけ登録し、最新 state は ref 経由で参照するよう修正した。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prefers-color-schemeを監視し、ノード背景・ボーダー・edge ラベル色をテーマに追従させるaから@を扱う react-backspace / react-roman-or-kana で、createDirectInputRuleをマージして automaton 構築エラーを解消activate再登録による Shift 押しっぱなし状態の喪失バグを修正設計の背景
ライトモード対応では、ミスキー列に使われていた
yellowや枠線のyellowが白背景でほぼ視認できなかった。ミス表示は赤系(#e5484d)、枠線・キー押下ハイライトはグレー基調へ寄せ、両モードで成立する色に統一した。react-stroke-graph はノード背景が固定whiteでライトモードの白背景と同化していたため、テーマ追従させる必要があった。aから@のような英数字混在ワードは、ローマ字/JIS かなルール単体では@やaを automaton 化できずビルド時に例外を投げる。README に記載のとおりcreateDirectInputRule(layout)をルールにmergeすることで対応した。react-roman-or-kana では
useEffectの依存配列に打鍵ごとに変化するselectorsが含まれており、打鍵のたびにactivateが破棄・再登録されていた。activateは呼び出しごとに内部KeyboardStateを新規生成するため、「Shift 押下 → effect 再実行で再登録 → 0 押下」の流れで Shift の押下状態が失われ、を(Shift+0)が修飾なし入力扱いとなり failed になっていた。最新 state をuseRef経由で参照し、ハンドラ登録をマウント時の1回だけにすることで解消した。検討した代替案
react-roman-or-kana の修正では、
useEffectの依存配列からselectorsのみ外す案も考えられたが、ハンドラが古いselectorsをクロージャに閉じ込めてしまうため不適切。ref で最新値を参照する方式にした。Test plan
aから@を含む全ワードがエラーなく入力できるおをひくをかな入力し、を(Shift+0)が failed にならないaから@がエラーなく表示・入力できる🤖 Generated with Claude Code