背景
PR #236 (#231) の再レビューで Should-fix #2 として指摘:
src/components/ui/DownloadButton.tsx:55: inline-flex ラッパー span が冗長です。ActionButton 自身が inline-flex items-center を持つため、<DownloadIcon /> {label} を直接 children に置けば 1 段削減できます(gap が必要なら ActionButton 側 className か <span> 区切り文字で代替)。
現状:
<ActionButton ...>
<span style={{ display: 'inline-flex', alignItems: 'center', gap: '0.375rem' }}>
<DownloadIcon />
{label}
</span>
</ActionButton>
ActionButton の button 要素に既に inline-flex items-center が付いているため、children 直下の SVG とテキストは flex item として並ぶ。間隔 (gap: 0.375rem) のためだけに span を 1 段噛ませているのが冗長。
ゴール
DownloadButton から wrapping span を撤廃し、<DownloadIcon /> と label を ActionButton の直接 children にする。アイコンとテキストの間隔は別途確保する。
アプローチ案
案 A: ActionButton 側に gap を追加
ActionButton の className に gap-1.5 (= 0.375rem) を追加。全 variant の見た目に影響するため要確認:
- 現在の各 ActionButton 利用箇所 (
CountInput / ConfigConverter / qr-ticket/VerifyTab / qr-ticket/GenerateTab) は children を 1 つしか渡していないため gap が空回りする → 視覚的に変化なし、安全
- DownloadButton ラッパー経由のみ children 2 個になり、
gap が効く
案 B: ActionButton に className pass-through を追加
ActionButton API を拡張して className マージを許可。<ActionButton className="gap-1.5"> のように呼び側で gap を指定。柔軟だが API 表面が増える。
案 C: DownloadIcon に marginRight を持たせる
marginRight: '0.375rem' を icon の inline style に追加。「icon は常に label を従える」前提を icon に押し付ける形になり、責務漏れがやや気になる。
案 D: 別途仕切り文字 {' '} か で代替
シンプルだが、CSS gap に比べて柔軟性に欠ける。レビュアーも候補として挙げている。
推奨
案 A(ActionButton 側に gap を追加)が最も筋が良い。理由:
- 既存利用箇所への副作用が無い(children 1 個 = gap 空回り)
- DownloadButton から wrapping span を綺麗に除去できる
- 将来別の ActionButton 利用箇所が children 2+ になった場合も自然に動く
- ActionButton API は変えない
ただし docs/ui-conventions.md 2 章「ボタン高さの揃え」など隣接 UI 規約との整合は要確認。
関連
優先度
低。視覚・機能的には問題なく動作している。コード明瞭化のための整理。#238 とまとめて対応するのが効率的。
背景
PR #236 (#231) の再レビューで Should-fix #2 として指摘:
現状:
ActionButton の button 要素に既に
inline-flex items-centerが付いているため、children 直下の SVG とテキストは flex item として並ぶ。間隔 (gap: 0.375rem) のためだけに span を 1 段噛ませているのが冗長。ゴール
DownloadButton から wrapping span を撤廃し、
<DownloadIcon />と label を ActionButton の直接 children にする。アイコンとテキストの間隔は別途確保する。アプローチ案
案 A: ActionButton 側に gap を追加
ActionButton の className に
gap-1.5(= 0.375rem) を追加。全 variant の見た目に影響するため要確認:CountInput/ConfigConverter/qr-ticket/VerifyTab/qr-ticket/GenerateTab) は children を 1 つしか渡していないためgapが空回りする → 視覚的に変化なし、安全gapが効く案 B: ActionButton に className pass-through を追加
ActionButton API を拡張して className マージを許可。
<ActionButton className="gap-1.5">のように呼び側で gap を指定。柔軟だが API 表面が増える。案 C: DownloadIcon に
marginRightを持たせるmarginRight: '0.375rem'を icon の inline style に追加。「icon は常に label を従える」前提を icon に押し付ける形になり、責務漏れがやや気になる。案 D: 別途仕切り文字
{' '}か で代替シンプルだが、CSS gap に比べて柔軟性に欠ける。レビュアーも候補として挙げている。
推奨
案 A(ActionButton 側に
gapを追加)が最も筋が良い。理由:ただし
docs/ui-conventions.md2 章「ボタン高さの揃え」など隣接 UI 規約との整合は要確認。関連
<style>で統合する #238 (ActionButton 全 variant の hover 表現統合) — このとき ActionButton の className を触るので併せて対応するのが効率的優先度
低。視覚・機能的には問題なく動作している。コード明瞭化のための整理。#238 とまとめて対応するのが効率的。