feat: Number field で数式入力 (100+20 / 100*2 / 50% / 50vw)#59
Merged
Conversation
Figma の数値入力欄と同じく、PropertyPanel の X/Y/W/H 等で式を書けるように。 - src/utils/evalExpression.ts 新規 - 再帰降下パーサで + - * / ( ) 単項 - を評価 - "50%" (ctx.current ベース) / "50vw" / "50vh" suffix 対応 - eval / Function は使わず、許可文字セット + zod ライクな厳密 validate - NumberField を type="text" + draft state 化 - 数値入力中は即 onChange (スライダー感覚) - "100 + 20" 等の式は blur / Enter で evalExpression 経由で確定 - Esc で draft 破棄 - ArrowUp/Down で ±1 (Shift で ±10) Figma 互換 - 13 件のユニットテスト追加 (合計 263 pass) Co-Authored-By: Claude Opus 4.7 (1M context) <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
Figma と同じく、PropertyPanel の数値入力欄に式を書けるように。
サポート構文
100 + 20100 * 210 + 5 * 2(10 + 5) * 2-1050%current * 0.550vw/50vhUX
123)は入力中も即反映(スライダー感覚を妨げない)実装
src/utils/evalExpression.ts純関数(eval / Function 不使用)PropertyPanel.NumberFieldを type="text" 化、draft state 追加Test plan
100 + 20を width に入れて Enter → 120width*1.5を ... は未対応(識別子不可)、数値のみ🤖 Generated with Claude Code