refactor(patterns): split 7 variant-heavy patterns into framework-specific DemoSection files with shared data#171
Merged
Conversation
…shared demo data Apply the PR #169 framework-split convention to the tabs pattern, plus extract shared variant data (demoTabs / manualTabs / verticalTabs) into a dedicated `tabs-demo-data.ts` to avoid duplicating ~20 lines of data across the four framework files. The shared data rule (per the migration plan): - 4 frameworks reference the data identically (8+ lines, pure data only) - framework-specific prop name differences (e.g. `activationMode` vs `activation`, `label` vs `defaultSelectedId`) stay in each per-framework DemoSection file Verified: - /patterns/tabs/{react,vue,svelte,astro}/ return 200 (en) - /ja/patterns/tabs/{react,vue,svelte,astro}/ return 200 (ja) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The treegrid pattern has the largest shared demo data: 130 lines covering
columnsEn / columnsJa / nodesEn / nodesJa for the Astro Web Component
variant (the React/Vue/Svelte variants use locale-specific wrapper
components TreeGridDemo / TreeGridDemoJa with their own internal data).
Extract the Astro variant's data to treegrid-demo-data.ts and split the
DemoSection into four framework files. Also switch the locale check from
\`Astro.url.pathname.startsWith('/ja/')\` to the \`locale\` prop, matching
the convention established by PR #169.
Verified:
- /patterns/treegrid/{react,vue,svelte,astro}/ return 200 (en)
- /ja/patterns/treegrid/{react,vue,svelte,astro}/ return 200 (ja)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract defaultItems / multipleItems / disabledItems to accordion-demo-data.ts
and split DemoSection into four framework files.
Verified: /patterns/accordion/{react,vue,svelte,astro}/ and the /ja/ variants
all return 200.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract fruitOptions / colorOptions to listbox-demo-data.ts (used by
Vue/Svelte/Astro variants; the React variant has its own wrapper
components with internal data) and split DemoSection into four framework
files.
Verified: /patterns/listbox/{react,vue,svelte,astro}/ and the /ja/ variants
all return 200.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract colorOptions / sizeOptions / planOptions / ratingOptions to
radio-group-demo-data.ts and split DemoSection into four framework files.
Framework prop name differences (e.g. Vue \`ariaLabel\` vs React/Svelte/Astro
\`aria-label\`) are kept in each per-framework file rather than in the
shared data, per the migration convention.
Verified: /patterns/radio-group/{react,vue,svelte,astro}/ and /ja/ variants
all return 200.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract fileSystemNodes / disabledNodes to tree-view-demo-data.ts and split
DemoSection into four framework files. The inline \`<script is:inline>\` that
listens for \`activate\` events on \`<apg-treeview>\` is kept only in
DemoSection.web-component.astro (where the Astro Web Component is rendered),
per the migration plan.
Also switch the locale check from \`Astro.url.pathname.startsWith('/ja/')\` to
the \`locale\` prop, matching the convention.
Verified: /patterns/tree-view/{react,vue,svelte,astro}/ and /ja/ variants
all return 200.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extract pure data (basicColumns/Rows, rowHeaderRows, virtualizedRows,
spanningColumns/Rows) used by the Astro Web Component variant to
table-demo-data.ts. The React / Vue / Svelte variants use wrapper demo
components with their own internal data. The sortable demo, even for the
Astro page, uses the React SortableTableDemo via \`client:load\`.
Note: the previously declared but unused \`sortableColumns\` is dropped,
clearing the existing astro check warning at DemoSection.astro:45.
Verified: /patterns/table/{react,vue,svelte,astro}/ and /ja/ variants
all return 200.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After PR #169 (9 patterns) and PR-A (7 patterns), 16 of 32 patterns now use the framework-split DemoSection format. CLAUDE.md is updated to: - describe the new \`{pattern}-demo-data.ts\` convention (introduced in PR-A for variant-heavy patterns) - list the currently migrated patterns - note that the legacy format and dispatcher fallback will be removed in PR-B once all 32 patterns are split Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Deploying apg-patterns-examples with
|
| Latest commit: |
16f4caf
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6e600875.apg-patterns-examples.pages.dev |
| Branch Preview URL: | https://refactor-demo-section-split.apg-patterns-examples.pages.dev |
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
PR #169 (9 pattern 分割) のフォローアップ第 1 弾。残り 23 pattern のうち、共通 data の切り出しが有効な 7 pattern (accordion / listbox / radio-group / tabs / tree-view / table / treegrid) を framework 別 DemoSection に分割し、新たに
{pattern}-demo-data.ts規約を導入する。本 PR の目的は混在状態 (9 移行 + 23 legacy) の解消ロードマップを進めること。dispatcher の legacy fallback は維持し、残り 16 pattern は後続 PR-B で対応する。なぜ全分割するか
ファイル名/ディレクトリから責務が読めることの認知負荷削減と、将来 Vue SFC を含む pattern を追加した際に legacy 形式由来の
$RefreshSig$regression に巻き込まれない予防策。Issue #170 とは独立な構造一貫性改善。変更内容
{pattern}-demo-data.tsDemoSection.{react,vue,svelte,web-component}.astroDemoSection.astro共通 data 切り出しルール (新規規約)
4 framework で内容が完全に同一かつ概ね 8 行以上 の純 data (配列/オブジェクトリテラル) を
{pattern}-demo-data.tsに切り出す。framework 固有の prop 名変換 (VueariaLabel↔ Reactaria-label等) や関数 (renderCell等) は各 DemoSection に残す。検証
allowlist 付き probe で全 32 pattern × 4 framework × 2 locale のうち、Issue #170 関連の 9 Vue ページのみが期待 500、他は全て 200:
```bash
known_failing_vue=(alert checkbox combobox disclosure menu-button menubar slider slider-multithumb toolbar)
unexpected=0
for d in src/patterns/*/; do
p=$(basename "$d")
for fw in react vue svelte astro; do
expected=200
[ "$fw" = "vue" ] && [[ " ${known_failing_vue[@]} " =~ " $p " ]] && expected=500
actual=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:4336/apg-patterns-examples/patterns/$p/$fw/")
[ "$actual" != "$expected" ] && { echo "UNEXPECTED: $p/$fw expected=$expected got=$actual"; unexpected=$((unexpected+1)); }
done
done
echo "unexpected=$unexpected"
```
結果:
```
unexpected=0
```
npm run lint: 0 errors (table の未使用sortableColumnsdeclaration 1 件減って 28 → 27 hints)npm run build: success (553 pages built)Pattern 別 acceptance
tabstreegridcolumnsEn/Ja,nodesEn/Ja) を data ファイル化 (POC-2、最大ケース)tree-view<script is:inline>(activateevent handler) はDemoSection.web-component.astro1 箇所のみに残したaccordionlistboxradio-grouptablesortableColumnsを data ファイルから除外PR-B 予定 (本 PR merge 後)
frameworkprop を削除.internal/page-template.md等の更新)関連
Test plan
🤖 Generated with Claude Code