port-html-to-react
Skill685 starsChanged 26 days agoMITView on GitHub
Port a component from the HTML reference (digital-go-jp/design-system-example-components-html) to this React + Storybook project.
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- component-rulesSkill
- create-commitSkill
- pre-completion-checkSkill
- reviewSkill
- write-component-docsSkill
- write-testsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 0 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
Not every component has all three.
- Very specific: line 28
Run through component-rules § _Before writing code_ — read a similar existing component's full file set to pick up patterns before writing …
- Very specific: line 43
After Steps 1–2, write src/components/<Name>/component-spec.md (template at the end of this file).
- Very specific: line 53
Start with everything in <Name>.tsx.
- Very specific: line 58
Follow the rules in component-rules (composition, native-prop extension, no logic in body, no cross-component imports, no shared config …
- Very specific: line 62
Follow component-rules § _Storybook conventions_ for the basics (Playground Story, export-name → HTML-file-name mapping).
- Very specific: line 78
Commit scope: component PascalCase, e.g.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context
- HTML reference repo: https://github.com/digital-go-jp/design-system-example-components-html
- Target directory pattern:
src/components/<Name>/ - Read
component-rulesfirst. This skill assumes its rules (component design, file layout, styling, accessibility, Storybook conventions, testing) and only adds the port-specific flow on top.
Steps
- Read the spec and the codebase
Fetch the component's reference files from the HTML repo. Use
curlvia Bash, notWebFetch—WebFetchsummarizes content past a quote limit and will silently truncate the spec/markup/CSS. Example:mkdir -p /tmp/<component>-html && cd /tmp/<component>-html for f in <component>.mdx <component>.html <component>.css <component>.js <component>.stories.ts <component>.test.js <component>.vrt.js <component>.unit.js; do curl -sSL "https://raw.githubusercontent.com/digital-go-jp/design-system-example-components-html/main/src/components/<component>/$f" -o "$f" doneThen read the files locally. Test file roles in the HTML reference:
<component>.test.js— behavior tests (interaction, ARIA wiring, etc.)<component>.vrt.js— visual regression tests for the reset-CSS variant<component>.unit.js— jsdom-based unit tests for any logic split out of the component
Not every component has all three. A 404 from
curljust means that file doesn't exist; ignore it and move on.- Run through
component-rules§ Before writing code — read a similar existing component's full file set to pick up patterns before writing anything.
- Read the HTML reference implementation
- Markup and styles. The HTML reference uses plain CSS with BEM-style class names (
dads-<name>,dads-<name>__<part>) in a sibling<component>.css— not Tailwind. Translate those rules into Tailwind utility classes (with theme-plugin tokens) on the React side; don't carry the BEM class names over. - Read the companion Custom Element JS (e.g.
progress-indicator.js) carefully. Behavior is not inline in the HTML — it lives in aclass Foo extends HTMLElement/customElements.define('dads-foo', Foo)file. That file is where you'll find:- Attribute reactions (
observedAttributes,attributeChangedCallback) — what state changes the component responds to. - Lifecycle work (
connectedCallback/disconnectedCallback) — ARIA wiring (role,aria-valuenow,aria-labelledby), live-region announcers, timers/intervals, validation. - Public properties / methods (
get value(),start(),stop(), etc.) — the imperative API consumers use. [data-js-*]selectors — these are JS-only hooks forquerySelector. The React port doesn't need them; express the same wiring through component structure / props instead.
- Attribute reactions (
- The React port has to reproduce this behavior without
useState/useEffect/useRefin the component body (seecomponent-rules§ No logic in the component body). Plan where each piece goes: Story-side demo state, a separate hook file (useFooAnnouncer.tsetc.), or puredata-*+ CSS. - Note
prefers-reduced-motion: reduceandforced-colorshandling — mirror them as-is. @media (hover: hover)does not need to be ported. The HTML reference wraps hover styles in@media (hover: hover)to prevent sticky-hover on touch devices, but Tailwind'shover:variant is the accepted equivalent in this project. Use plainhover:utilities.- Don't port the reset CSS that the HTML reference uses to normalize elements — Preflight already covers it. See
component-rules§ Don't re-implement Preflight.
- Markup and styles. The HTML reference uses plain CSS with BEM-style class names (
Write a port plan and get user approval before coding — required.
- After Steps 1–2, write
src/components/<Name>/component-spec.md(template at the end of this file). Cover at minimum:- Component design: which sub-components / props /
data-*attributes you'll expose, how children compose, what is intentionally not in the component API (e.g. placeholder icons — see below). - File layout: which files you'll create. Default to one
<Name>.tsxwith Tailwind classes inline in the JSX; only proposetypes.ts/ a hook file when the complexity actually warrants it (seecomponent-rules§ File layout). - Story plan: which Stories to mirror from the HTML version (one per HTML file, plus
Playground). - Test plan: whether tests are needed, with reasoning, and the target cases if any. Decision rule:
write-tests. - Intentional deviations from the HTML reference: anything you plan to do differently from the HTML version (and why).
- Component design: which sub-components / props /
- Present the plan to the user and wait for confirmation before writing component code. The plan exists so the user can redirect file layout, prop shape, and Story/test scope before code is written, not after.
- Commit
component-spec.mdto the repo as a deliverable. It's not a throwaway working doc — it's the artifact reviewers use to evaluate the port on the PR. Commit it as part of the port (typically the first commit on the branch, before the implementation), and keep it in sync if the design changes during implementation. Don't leave it untracked or add it as an after-the-fact follow-up commit.
Defaults to bake into the plan:
- Start with everything in
<Name>.tsx. Do not split files preemptively. - Don't componentize placeholder icons. When the HTML reference shows decorative or example SVGs at icon slots (front/tail/end icons, illustrative glyphs in demos), do not create wrapper components like
<FooFrontIcon>for them. Consumers bring their own icons of unknown shape/size, so the component can't usefully fixwidth/viewBox/fill. Instead, the component contributes only the layout / behavior classes via the slot's container, and the Story renders raw<svg>elements with the required slot classes attached directly. Document the required classes for each slot in the<Name>.mdxdocs page so consumers know what to attach. - Don't create pass-through wrapper components. If an HTML reference element only carries a BEM class for styling (e.g.
<span class="dads-menu-list__label">) and that class is replaced by Tailwind utilities in the React port, the wrapper has nothing left to do. Don't expose it as a sub-component (<MenuListItemLabel>) — apply the Tailwind classes directly on the parent's children, or have consumers pass the inner content as a prop /children. A wrapper is only justified when it owns layout /data-*/ behavior that consumers can't sensibly attach themselves.
- After Steps 1–2, write
- Implement the React component (only after the user approves the plan from Step 3)
- Follow the rules in
component-rules(composition, native-prop extension, no logic in body, no cross-component imports, no shared config additions, styling tokens,data-*+group-data-[...]pattern). - Reproduce HTML markup, classes, and behavior as-is. Do not introduce improvements.
- Follow the rules in
- Build the Storybook entries
- Follow
component-rules§ Storybook conventions for the basics (Playground Story, export-name → HTML-file-name mapping). - Mirror the HTML Storybook layout: one Story per HTML file. Story export names (and the
namefield when set) stay in English — only user-visible UI copy (button labels, captions, etc.) is in Japanese. - Author the
<Name>.mdxdocs file following thewrite-component-docsskill. - Register the component in
.storybook/preview.tsstory sort order, in Japanese 50音順 (gojūon). The list underparameters.options.storySort.order > 'Component'is ordered by each title's kana reading — insert the new title at the right position (e.g.ボタンfalls afterプログレスインジケーター(ぷ) and before見出し(み), not next toパンくずナビゲーション). Re-read the surrounding entries to confirm placement. - Add the component to
src/index.tswithexport * from './components/<Name>';, keeping the list alphabetized.
- Follow
- Tests
- Decide whether tests are needed, and follow the conventions for writing them, per
write-tests(see § When to skip tests entirely for the skip rule).
- Decide whether tests are needed, and follow the conventions for writing them, per
- Run the pre-completion checklist
- Invoke the
pre-completion-checkskill. - Manually verify each Story in Storybook against the HTML reference side-by-side.
- Invoke the
Naming reminders
- Branch:
feature/<component-name>(lowercase, hyphenated). - Commit scope: component PascalCase, e.g.
feat(ProgressIndicator): .... - UI copy: Japanese. Code, types, comments, Story export names, Story
namefields: English.
Checklist
This checklist covers only the port-specific items. The general rules in component-rules (component design, styling, accessibility, Storybook conventions, testing, code style) apply on top — verify against that skill as well, do not assume.
Plan
src/components/<Name>/component-spec.mdwas written after Steps 1–2 and approved by the user before any component code was written.component-spec.mdis committed to the branch (typically the first commit, before the implementation), not left untracked or added as a follow-up.- The implementation matches the approved plan, or any deviation has been re-confirmed with the user and reflected back into
component-spec.md.
HTML reference parity
- Markup matches the HTML reference (element names, structure, ARIA attributes).
- Behavior matches the HTML reference. No "improvements" introduced during the port.
- No wrapper components were created for placeholder icons; the Story renders raw
<svg>with the slot classes documented in the<Name>.mdxdocs page. - No pass-through wrapper components were created for HTML elements that only carried a BEM class (and whose Tailwind classes can sit on the parent or on
children). - Reset CSS from the HTML reference was not ported (Preflight covers it — see
component-rules§ Don't re-implement Preflight). prefers-reduced-motion: reduceandforced-colorshandling mirror the HTML reference.- Reference repo SHA / path noted somewhere (commit message, PR description, or
component-spec.mdif used).
Storybook & registration
- Every HTML file has a matching Story; export name matches the HTML file name (
spinner-loop.html→SpinnerLoop). - The component's Japanese title is added to
.storybook/preview.tsstory sort order in 50音順. src/index.tsre-exports the new component (export * from './components/<Name>';), kept alphabetized.
Tests
- Followed
write-tests, including its § When to skip tests entirely rule.
Pre-completion
- Run the
pre-completion-checkskill (lint / markup lint / build / test). - Visually verify each Story side-by-side with the HTML reference in Storybook.
component-spec.md template (port plan)
Write this at src/components/<Name>/component-spec.md after Steps 1–2 and before writing any component code. The point is to surface design decisions early so the user can redirect them. Keep it brief — bullets, not prose. component-spec.md is a required, committed deliverable (see Step 3) — commit it as part of the port (typically the first commit, before the implementation) and keep it in sync when the design changes during implementation.
# <Component> 移植計画
## HTML reference
- Source: https://github.com/digital-go-jp/design-system-example-components-html/tree/<sha-or-branch>/<path>
- 関連ファイル:
- `<component>.mdx` / `<component>.html` / `<component>.css` / `<component>.js`
- `<component>.stories.ts` (Storybook)
- `<component>.test.js`(機能テスト) / `<component>.vrt.js`(リセット CSS VRT) / `<component>.unit.js`(jsdom ユニット) — 存在するもの
## コンポーネント設計
- 公開する構成要素(例: `Foo`, `FooItem`, `FooLabel`)
- 各要素の props(型・必須/任意・デフォルト)
- ルートで持たせる `data-*` 属性とその役割
- 子要素が反応する `group-data-[...]/name` の対応関係
- コンポーネント API に**入れない**もの(プレースホルダーアイコン、アニメーション一時停止、その他)
## ファイル構成
- `<Name>.tsx`(基本これ1つ。Tailwind クラスは JSX に直書き)
- 分割が必要なら理由とともに(`types.ts` / `useFooXxx.ts` / `<Name>.css`)
## Story 構成
- HTML 版にある Story 一覧 → React 版の export 名と表示名
- 追加で必要な Story(`Playground` など)
- `<Name>.mdx` に載せる項目(仕様表、必要クラス一覧など)
## テスト方針
- テストを書く / 書かない、と理由
- 書く場合は対象ケース(focus、keyboard、event payload など)
## HTML 版との意図的な差異
- 何を / なぜDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

