agents/projects/chrome-design-system/skills/figma-to-webui/SKILL.md
//src/).If prerequisites are not met, STOP execution and inform the user.
When given a Figma design URL (e.g., https://www.figma.com/design/:fileKey/:fileName?node-id=:nodeId):
fileKey and the nodeId (replace hyphens with colons, e.g. 54800-5491 becomes 54800:5491).get_design_context with fileKey and nodeId to fetch the metadata, layout hierarchy, layer styles, and a screenshot of the node.project-knowledge skill to map Figma components to Chromium WebUI components.project-knowledge skill to translate Figma variables to equivalent Chromium CSS variables (e.g., desktop/sys/surface-colors/surface-2 to --color-sys-surface2), and translate Figma typography styles to equivalent Chromium font families, sizes, weights, and line heights.Before writing any code, first check if the user already did an audit of this Figma design against production coding standards within the current chat session's recent history (past 5 commands). If not, perform the audit. Incorporate the feedback from this audit into the following code implementation.
get_design_context). Ensure outer and inner containers maintain their exact nesting relationships. Exception: if a frame contains only one other frame, these frames can be combined; merge their properties.@click, @selected-changed, @value-changed, @change, etc.). Bind properties declaratively to pre-populated mock values without mutation handlers.<component_name>.tsThe main TypeScript file defining the element class. It must:
CrLitElement.is getter (returning the kebab-case tag name).import { getCss } from './<component_name>.css.js';
import { getHtml } from './<component_name>.html.js';
Example Boilerplate:
// other imports go here...
import { CrLitElement } from '//resources/lit/v3_0/lit.rollup.js';
import { getCss } from './my_component.css.js';
import { getHtml } from './my_component.html.js';
export interface MyComponentElement {
$: {
dialog: CrDialogElement,
};
}
export class MyComponentElement extends CrLitElement {
static get is() {
return 'my-component';
}
static override get styles() {
return getCss();
}
override render() {
return getHtml.bind(this)();
}
static override get properties() {
return {
value_: {type: String},
};
}
protected accessor value_: string = 'Default Mock Value';
}
customElements.define(MyComponentElement.is, MyComponentElement);
<component_name>.html.tsThe HTML template containing the Lit markup.
html literal.slot="title", slot="body", slot="footer").Example Boilerplate:
import {html} from '//resources/lit/v3_0/lit.rollup.js';
import type {MyComponentElement} from './my_component.js';
export function getHtml(this: MyComponentElement) {
return html`
<!-- HTML goes here... -->
`;
}
<component_name>.cssStylesheet guidelines:
python3 ui/webui/resources/tools/stylelint.py --config ui/webui/resources/tools/stylelint.config_base.mjs --in_folder <relative_folder_path> --in_files <file_name>.css --out_file /tmp/stylelint.out
fill container (filling the remaining space in a flex row or column), use standard CSS flex shorthand (flex: 1) instead of computing or hardcoding static pixel flex-basis or fixed width. This ensures responsive layouts that cleanly adapt to parent padding, gap, and sibling sizes.width property instead of flex-basis.var(--color-sys-<token>, var(--cr-fallback-color-<token>))):
/* Preferred: Dynamic Material 3 token with Chromium fallback */
background-color: var(--color-sys-surface2, var(--cr-fallback-color-surface2));
color: var(--color-sys-on-surface, var(--cr-fallback-color-on-surface));
--cr-button-background-color: var(--color-sys-tonal-container, var(--cr-fallback-color-tonal-container));
/* Anti-pattern: Hardcoded hex fallbacks */
background-color: var(--color-sys-surface2, #f3f6fc);
Example Boilerplate:
/* #css_wrapper_metadata_start
* #type=style-lit
* #import=//resources/cr_elements/cr_shared_vars.css.js
* #scheme=relative
* #css_wrapper_metadata_end */
:host {
background-color: var(--color-sys-surface2, var(--cr-fallback-color-surface2));
color: var(--color-sys-on-surface, var(--cr-fallback-color-on-surface));
display: block;
}
/* Styles go here... */
Whenever creating or integrating a WebUI component into a host HTML page (e.g. an internal diagnostics page, a feature page, or webui_gallery.html):
<link rel="stylesheet" href="chrome://theme/colors.css?sets=ui,chrome"> is included in the host HTML <head> or <body>.
ThemeSource (ui::ColorProvider) to the DOM, defining dynamic Material 3 --color-sys-* variables at runtime for both light and dark mode.chrome://resources/css/text_defaults_md.css and chrome://resources/css/md_colors.css are imported if text and focus defaults are required.Create an artifact that summarizes the work performed. Explain rationale for the following: