fix: Radio の選択ドットが label の padding で位置ずれしないようにする#19
Open
ryoshin0830 wants to merge 1 commit into
Open
Conversation
ドットを ::after の絶対配置(left: calc(...) 固定)で重ねる方式から、 輪(:before)自身の background に radial-gradient で描く方式に変更する。 絶対配置の基準が padding を含まないため、label に padding を当てると 輪だけが動いてドットが取り残されていた。 選択時のアニメーションは transform: scale の代わりに background-size (アニメーション可能)で中心から広がる動きを維持する。 Closes pepabo#18 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Radio コンポーネントで、ルート(label)に padding を付けた際に「選択ドット(内側の●)だけが輪(◯)からずれてしまう」問題を、DOM 構造を変えずに CSS のみで解消するPRです。
Changes:
- 選択ドットの描画を
::afterの絶対配置オーバーレイから、::before(輪)自身のbackground-image(radial-gradient)による描画へ変更 - 選択アニメーションを
transform: scaleからbackground-sizeのトランジションに置き換え
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
概要
Radio のルート(label)に padding を当てると、選択ドットだけが輪から外れて左にずれる問題を修正します。
Closes #18
原因と修正方針
輪(
::before)は flex フロー配置なので padding に押されて動くのに対し、ドット(::after)はposition: absolute; left: calc(...)の固定座標で、基準が padding を含まないため取り残されていました。::afterを廃止し、輪(::before)自身のbackgroundに radial-gradient でドットを描く方式に変更します。ドットは常に輪の中心に描画されるため padding に影響されません。DOM 構造の変更はなく CSS のみです。選択時のアニメーションは
transform: scale(0→1)の代わりにbackground-size: 0→サイズ(アニメーション可能プロパティ)で、従来と同等の「中心から広がる」動きを維持しています。Before / After
padding: 12px 16px確認(Storybook)
data-focus-visibleのフォーカスリング(::beforeの outline)が機能することnpm run lint/npm run build… PASS関連