一键导入
create-usage-example
Automatically identify and add missing usage examples for a component in the styleguide. Usage: /create-usage-example {ComponentName}
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Automatically identify and add missing usage examples for a component in the styleguide. Usage: /create-usage-example {ComponentName}
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Migrate a component SCSS file from raw var_default variables to the design token mixin pattern, then verify visually with Playwright. Usage: /implement-design-tokens {ComponentScssName} {PreviewUrl}
Remove the $extras parameter from tokens.create() in a component SCSS file, moving the extra tokens into the component selector as CSS custom properties. Usage: /remove-tokens-extras {ComponentPath}
Get a report on CSS class usage by classname (prefix or full name) across the helsingborg-stad GitHub org, including counts and file locations.
基于 SOC 职业分类
| name | create-usage-example |
| description | Automatically identify and add missing usage examples for a component in the styleguide. Usage: /create-usage-example {ComponentName} |
Analyse a component's documentation coverage and add every missing usage example that has meaningful documentation value.
Parse $ARGUMENTS as: {ComponentName}
ComponentName — Identifies the component. Accept any of these formats and normalise to the PascalCase PHP directory name:
Nav, Hero, Buttonsource/sass/component/_nav.scss or @source/sass/component/_nav → Navhttp://localhost:.../components/molecules/nav → Navnav, hero → NavLocate the component directory:
vendor/helsingborg-stad/component-library/source/php/Component/{ComponentName}/
Read these files (all may not exist — skip gracefully):
{ComponentName}.json (or the json file in that directory) — defines all accepted parameters, their types, defaults, and descriptions. The "slug" field gives the URL/directory slug used in usage examples.{ComponentName}.php — the PHP controller. Read it carefully to understand:
$this->data[...] assignments)buttonArgs becoming $buttons for multi-button cases)normalizeItems() (e.g. active, ancestor, style, icon, classList)heroView-style selectors workviews/ — list all view blade files and read each one to understand what variants exist.partials/ — skim available partials; read any that are referenced by views.After reading the component source, also check the styleguide's own SCSS for the component:
source/sass/component/_{slug}.scss
This file often defines modifier classes (e.g. --align-left, --bordered, --gap) that are not listed in the component JSON but can be applied via the base controller's classList parameter. Scan all &-- selectors and note any modifiers that represent distinct visual variants.
The full modifier class name is constructed as {baseClass}--{modifier} (e.g. c-nav--bordered) and is passed via 'classList' => ['c-nav--bordered'].
Also look for context-dependent rules such as a > .c-{slug} or .some-parent .c-{slug}. These indicate the component has a distinct visual state when placed inside a specific HTML element. Demonstrate these by wrapping the @{slug}([...]) @end{slug} call in the relevant HTML in the blade file — the component itself may have no corresponding parameter.
The component examples live at:
source/components/{slug}/examples/
where {slug} comes from the "slug" field in the component JSON (usually the lowercase component name).
Read:
.blade.php files in that directory — to understand the argument style, formatting conventions, and what is already covered.Build a complete inventory of what could be demonstrated, then subtract what already is demonstrated.
Sources of candidates:
compressed, indentSubLevels), enum-like string parameters (height: sm/md/lg), optional object/array parameters not shown.active, ancestor, icon items, items with classList, multi-level nesting.callToActions.blade.php, split.blade.php) should have at least one example.&--{modifier} selector that produces a meaningfully different visual result.For each candidate, judge its documentation value:
Compile a prioritised list of all high-value gaps. You will create examples for all of them, starting with the highest-value gap first.
Good gap candidates:
active, ancestor (current-page highlighting)height: sm/md/lg) if not shown in isolationc-nav--gap, c-nav--drawer, etc.)indentSubLevels, compressed, icon-only items, or other boolean flagsBefore writing each example, reason through:
buttonArgs as an array-of-arrays routes to $buttons in the view rather than a single $buttonArgs). Always trace the PHP controller logic.@component/@slot or content slots. Check the blade view for {!! $slot !!}, $content, or @slot directives.customHeroData or equivalent? Some views have a secondary data bag passed via a dedicated parameter.active, ancestor, style, icon, classList — these are item-level, not top-level parameters. Use them to demonstrate states like the current-page trail.https://picsum.photos for images).horizontal-dropdown.blade.php).For each gap identified in Step 3, write the file to:
source/components/{slug}/examples/{exampleName}.blade.php
Follow the exact formatting of existing examples:
@{slug}([...]) @end{slug} Blade component syntax.Create all files before moving on to registration.
Edit source/components/{slug}/examples/examples.json to add an entry for each new example:
"{exampleName}": {
"heading": "...",
"description": "..."
}
heading: A short, human-readable label for the example (e.g. "Hero with call to actions").description: One sentence describing what the example renders and what it demonstrates.Add all new entries in a single edit pass.
https://picsum.photos/id/{id}/{width}/{height} with realistic dimensions.normalizeItems().heroView-style variant selector, always include that parameter.