ha-frontend-gallery
GitHub用于管理 Home Assistant 前端画廊的构建、开发及内容维护,涵盖页面生成、TypeScript 演示和静态资源处理。
Trigger Scenarios
Install
npx skills add home-assistant/frontend --skill ha-frontend-gallery -g -y
SKILL.md
Frontmatter
{
"name": "ha-frontend-gallery",
"description": "Home Assistant frontend gallery structure, pages, demos, content, and verification. Use when changing files under gallery\/, including gallery markdown, TypeScript demos, sidebar entries, mock data, page generation, or gallery builds."
}
HA Frontend Gallery
Use this skill for all work under gallery/. Follow the persistent repository guidance in AGENTS.md and load the matching specialist skills alongside this gallery-specific guidance.
Quick Reference
Run commands from the repository root unless noted otherwise:
gallery/script/develop_gallery # Start the gallery development server
gallery/script/build_gallery # Build the static gallery
yarn lint # ESLint, Prettier, TypeScript, and Lit checks
yarn lint:types # TypeScript compiler, without file arguments
Never run yarn lint:types or tsc with file arguments. File arguments make tsc ignore tsconfig.json and can emit .js files into src/.
Purpose
The gallery is a developer and designer reference for Home Assistant frontend UI patterns. It documents component APIs, shows realistic Lovelace and more-info states, captures brand and copy guidance, and provides reproducible demos that are safe to inspect outside a running Home Assistant instance.
- Prefer demonstrating real production components from
src/instead of creating gallery-only replacements. - Keep fake state, sample data, and demo-only helpers inside
gallery/. - Do not move gallery stubs or demo data into production code unless a production feature explicitly needs them.
- Do not hand-edit generated output under
gallery/build/orgallery/dist/.
Structure
gallery/sidebar.js: Defines gallery sections, headers, and explicit page ordering.gallery/script/develop_gallery: Wrapper for thedevelop-gallerygulp task.gallery/script/build_gallery: Wrapper for thebuild-gallerygulp task.gallery/src/entrypoint.js: Creates the<ha-gallery>shell.gallery/src/ha-gallery.ts: Renders the drawer, page routing, markdown descriptions, demos, edit links, and RTL toggle.gallery/src/html/index.html.template: HTML template used by the gallery build.gallery/src/pages/<category>/<page>.markdown: Optional page description and frontmatter.gallery/src/pages/<category>/<page>.ts: Optional live demo module for the same page ID.gallery/src/components/: Gallery-only demo wrappers likedemo-card,demo-cards,demo-more-info, andpage-description.gallery/src/data/: Fakehass, demo states, mock traces, and reusable sample data.gallery/public/: Static assets copied into the gallery output.
Page Model
Gallery pages are generated by gather-gallery-pages in build-scripts/gulp/gallery.js.
- A page ID is the path under
gallery/src/pages/without the extension, likecomponents/ha-button. - A
.markdownfile and a.tsfile with the same page ID become one gallery page. - A page may have only markdown, only a TypeScript demo, or both.
- Markdown can contain YAML frontmatter with
titleand optionalsubtitle. - Markdown that contains only frontmatter contributes metadata without rendering a description block.
- TypeScript demo modules are dynamically imported for side effects when the page is opened.
- A demo module must define a custom element named
demo-${category}-${page}with slashes replaced by hyphens, likedemo-components-ha-buttonforcomponents/ha-button. gallery/src/ha-gallery.tsrenders that element withdynamicElement()based on the current page ID.
Sidebar
Use gallery/sidebar.js when a page needs a visible section, section header, or deterministic ordering.
categorymust match the first directory name undergallery/src/pages/.headeris the section label shown in the drawer.pagesis optional. When present, listed pages keep that exact order.- Pages in a category that are not listed are appended alphabetically after the listed pages.
- New categories without a sidebar entry are appended by the generator with their category name as the header.
- If a listed page does not exist, the generator logs an error during
gather-gallery-pages.
Subsections
A section can group its pages under named subsections instead of one flat list. Use this for large categories where related pages should sit together.
subsectionsis an array of{ header, pages }. It is mutually exclusive with a flatpagesarray on the same group.- Each subsection
headeris a non-collapsible label rendered inside the section's expansion panel; the section stays the only collapsible level. - Listed pages keep their per-subsection order.
- Any pages found in the category but not listed in a subsection are collected into a generated
Othersubsection, appended alphabetically. TheOthersubsection is omitted when there are no leftovers. - A listed page that does not exist still logs an error during
gather-gallery-pages. - Use sentence case for subsection headers and follow the content standards below.
Markdown Pages
Use markdown pages for explanations, design guidance, API notes, and copy standards.
- Start with frontmatter when the page needs a title or subtitle.
- Use sentence case for titles, headings, labels, and UI copy.
- Put the live example before the reference API when that makes the page easier to scan.
- Use fenced code blocks with a language tag for copyable examples.
- Keep examples short and focused on the behavior being documented.
- Prefer real component names and attributes over prose-only descriptions.
- Use Home Assistant terminology from
ha-frontend-user-facing-text. - For remove/delete and add/create wording, follow
gallery/src/pages/misc/remove-delete-add-create.markdown.
Gallery markdown is documentation content and is not localized with localize. If demo code creates production UI strings, follow the localization and copy guidance in ha-frontend-user-facing-text.
Demo Components
Use TypeScript demo pages for interactive or stateful examples.
- Import production components from
src/using the correct relative path from the demo file. - Import reusable gallery helpers from
gallery/src/components/when they already model the pattern. - Use
demo-cardanddemo-cardsfor Lovelace card examples that render YAML card configs. - Use
demo-more-infoanddemo-more-infosfor more-info dialog examples. - Use shared mock data from
gallery/src/data/instead of repeating large fake state objects inline. - Show meaningful states, such as loading, unavailable, empty, error, active, inactive, and disabled when relevant.
- Check responsive behavior and the gallery RTL toggle when layout or direction-sensitive UI changes.
- Keep unavoidable casts or loose demo parsing local to the demo helper or demo page.
The gallery ESLint config allows console for gallery diagnostics. Do not copy that exception into production frontend code.
Content Standards
Follow the detailed copy standards in ha-frontend-user-facing-text: use American English, sentence case, active voice, inclusive language, direct user-focused wording, and consistent Home Assistant terminology.
- Use
Home Assistantin full, notHAorHASS. - Use
integrationinstead ofcomponentfor product concepts. - Use
Removefor reversible disassociation andDeletefor permanent deletion. - Use
Addfor existing items andCreatefor something made from scratch. - Avoid Latin abbreviations like
e.g.andi.e.in prose. - Avoid stitching sentence fragments together in production UI examples.
Verification
- For markdown, sidebar, and page-generation changes, run
gallery/script/build_gallery. - For TypeScript demo or gallery shell changes, run the smallest relevant check plus
yarn lintwhen practical. - For type checking, run
yarn lint:typeswithout file arguments. - For visual changes, run
gallery/script/develop_galleryand check the affected page on desktop, narrow viewport, and RTL when relevant. - If verification is skipped, state which command was skipped and why.
Version History
- 3c7560a Current 2026-08-20 08:57


