Creating LWC Components from Design
Orchestrate the end-to-end creation of a new Lightning Web Component from a design input (Figma, PRD, Aura source, or user description). This is the top-level workflow skill — it sequences the specialized sibling skills that own each stage. Org-aware data (LDS schema introspection, design-frame inspection) is resolved by handing off to experience-lds-data-requirements-generate or via design-tool URLs the user provides.
When to Use
- Building a brand-new LWC from a Figma frame, PRD, or written spec.
- Migrating an Aura component to LWC as a fresh build (in-place Aura → LWC porting is out of scope for this skill).
- Creating a component whose requirements are still partly implicit and need distillation into a PRD before coding.
Do NOT use this skill for:
- Refactoring an existing LWC (use
experience-lwc-generate).
- Aura → LWC in-place migration (out of scope for this skill).
- Pure styling or data-layer work (use the specialized skills directly).
Prerequisites
- At least one design input: Figma URL, PRD markdown, Aura component source, or a textual spec.
- Target path (module folder) for the new LWC.
- For data-backed components: access to the org so
experience-lds-data-requirements-generate and experience-lds-best-practices-apply can resolve the schema and adapter shapes.
Knowledge Bases
- references/prd-analysis-template.md — PRD section skeleton (copy it verbatim when producing a PRD).
- references/figma-to-prd-blueprint.md — Figma-specific guidance for translating a frame into PRD sections (componentName/tagName, contentRequirements, dataRequirements, interactions, componentCommunication, states, accessibility/responsiveness/styling/localization/security). Read this before Phase 1.2 when the input is a Figma design.
Workflow (mandatory five phases)
Phase 1 — Gather PRD & requirements
Goal: produce a consolidated PRD that every later phase consumes.
Obtain raw requirements — collect the PRD, design spec, Figma URL, Aura source, or user text.
Figma → PRD (if applicable): follow references/figma-to-prd-blueprint.md for the full Figma-frame analysis and PRD section guidelines. Inputs you need from the user: the Figma URL, a screenshot of the target frame, and (if Dev Mode is available) the metadata export for the node. Translate into the PRD skeleton from references/prd-analysis-template.md using the section-by-section guidance in the blueprint.
Aura → PRD (if migrating): enumerate the Aura component's functionality that must be preserved — markup, controller/helper actions, events, attributes, and wired data — and feed that inventory into the PRD as explicit requirements. (In-place Aura → LWC porting is out of scope; this step only captures behavior for a fresh build.)
Data requirements (if the component reads/writes data): hand off to experience-lds-data-requirements-generate. That skill produces a validated data specification (object/field API names, recommended LDS API, implementation approach). Paste its output verbatim into the PRD.
Adapter exploration: hand off to experience-lds-best-practices-apply for the adapter selection rules (UI API vs GraphQL vs Apex) and the recommended wiring for the chosen approach.
Naming: componentName must be camelCase (e.g., productCard) and tagName must be its kebab-case form (e.g., product-card). Validate both with the bundled script — do not eyeball the check:
"<skill_dir>/scripts/check-component-name.sh" <componentName> <tagName>
The script exits nonzero (with an actionable stderr message) if either name is malformed or if the kebab form of componentName does not equal tagName.
Deliverable: a comprehensive PRD covering purpose, content, data, interactions, states, a11y, responsiveness, styling direction, localization, and security. Keep it checked into the workspace (e.g., packages/skills/<skill>-workspace/<iteration>/PRD.md).
Phase 2 — Generate component code
Goal: initial .html, .js, .css, .js-meta.xml that strictly reflect the PRD.
- Hand off to
experience-lwc-generate with the PRD content as the spec. That skill owns PRD → code translation (events, getters, @api, .js-meta.xml, AI metadata) and is the authoring source of truth.
- Use the SLDS decision hierarchy from
design-systems-slds-apply:
- Prefer a matching Lightning Base Component (
experience-lwc-base-components-integrate).
- Otherwise pick an SLDS Blueprint or utility class (per
design-systems-slds-apply).
- Otherwise write custom CSS using SLDS styling hooks (also covered in
design-systems-slds-apply).
- Re-confirm the authoring baseline by walking the
experience-lwc-generate checklist before proceeding.
- Translate every PRD data requirement to either a wire adapter (UIAPI / GraphQL) or an explicit TODO.
- Adhere strictly to the PRD:
- Only include features and behaviors the PRD describes.
- Mark uncertain areas with
// TODO: comments that quote the PRD language raising the ambiguity.
- Add extensive code comments explaining intent.
- Do not split the component into more sub-components than the PRD implies.
Deliverable: a first-pass LWC bundle in the target path.
Phase 3 — Optimize component
Goal: apply performance, maintainability, and best-practice fixes.
- Walk the optimization checklist below before any other review:
- Single responsibility, encapsulation, reusability.
- Minimize DOM operations; batch updates via properties.
- Audit event handlers and lifecycle hook usage (
renderedCallback guards).
- Consider lazy loading for heavy children.
- Hand off to
experience-lwc-generate for the LWC best-practices review pass (anti-patterns, reactivity, composition).
- Hand off to the compliance suite for the pre-ship review —
experience-accessibility-validate (a11y), experience-lwc-security-validate (LWS + Product Security), and experience-lwc-rtl-validate (RTL i18n). Run them together for the full quality pass.
- If the component touches data, hand off to
experience-lds-best-practices-apply for cache/consistency and referential-integrity checks.
- Apply every accepted finding. Keep the PRD as the source of truth — do not add scope under the guise of optimization.
Phase 4 — Lint, format, compile-check
Condition: only run steps whose tooling is configured in the project.
Detect project tooling — invoke the bundled detection script from the project root and read its <tool>=yes|no lines. Do NOT eyeball package.json / dotfiles in prose:
"<skill_dir>/scripts/detect-project-tools.sh" <projectRoot>
Sample output:
eslint=yes
prettier=yes
cursor-rules=no
lwc-compiler=yes
Run the substeps below only for tools reported yes; skip the rest.
ESLint (if eslint=yes) — run and fix all violations.
Prettier (if prettier=yes) — run for consistent formatting.
Cursor rules (if cursor-rules=yes) — apply every rule the project ships.
LWC compiler (if lwc-compiler=yes) — run via local dev server or SFDX; resolve every syntax/template error before moving on.
Deliverable: clean, validated component code.
Phase 5 — Create tests
Hand off to experience-lwc-accessibility-jest-run for automated accessibility Jest coverage; add general-purpose Jest coverage in the same pass following the experience-lwc-generate test guidance, plus UTAM page object generation if the team requires it.
Deliverable: the LWC bundle with a passing test suite at or above the project's coverage threshold.
Definition of Done
A new component built from this workflow is "done" only when every item below is true. Treat this as the canonical readiness checklist — copy it into the PR description so reviewers can confirm each line.
Code completion — no implementation gaps:
- Every PRD requirement is either implemented or explicitly annotated with a
TODO: and a linked tracking item. No silent gaps.
- No
TODO, FIXME, or console.log / console.table / alert() left in production paths.
- No commented-out code blocks, no empty function bodies, no placeholder values, no dummy data, no unreferenced imports.
- No
lwc:dom="manual" regions or third-party-library escape hatches without a comment explaining why a native LWC pattern wasn't used.
Compliance and quality:
.js-meta.xml AI metadata passes the audit in experience-lwc-generate (component-wide <ai><description> set, plus an <ai><property name="…" aiDescription="…"/></ai> entry for every @api member exposed through <targetConfig>; no marketing language).
- SLDS styling passes
design-systems-slds-apply verification — no raw hex / px values, only styling hooks and SLDS utility classes.
- Accessibility pass complete:
experience-accessibility-validate for source review + experience-lwc-accessibility-jest-run for automated tests, both green.
- Security + RTL pass complete:
experience-lwc-security-validate + experience-lwc-rtl-validate, both green.
Data + tests:
- Data layer verified against the referenced LDS adapters (every wire / imperative call is documented in the PRD's data section and matches one of the adapters from
experience-lds-best-practices-apply or experience-lds-data-requirements-generate).
- Jest tests green at the required coverage level for the project. New tests cover every
@api surface, every dispatched event, and every error path (failed wire, failed apex, validation rejection).
- UTAM page objects produced for any UI flow that needs cross-component browser-level testing (skip if not needed).
Cross-References
- Skills chained by this workflow (in phase order):
experience-lds-data-requirements-generate — Phase 1.4 data spec (and Phase 1.5 adapter exploration alongside experience-lds-best-practices-apply).
design-systems-slds-apply, experience-lwc-base-components-integrate — Phase 2 styling decisions.
experience-lwc-generate — Phase 2 authoring baseline + Phase 3 best-practices review + Phase 5 AI-metadata audit.
experience-lds-best-practices-apply — Phase 2/3 data-layer adapter selection and consistency review.
experience-accessibility-validate, experience-lwc-security-validate, experience-lwc-rtl-validate — Phase 3 a11y/security/RTL review.
experience-lwc-accessibility-jest-run — Phase 5 automated a11y test generation.
- Optional: add o11y instrumentation as a separate pass once the component stabilizes.
experience-lwc-typescript-migrate — optional once JS is green.
- When the new component ships behind a flag, gate it with a feature flag during rollout.
experience-lwc-api-docs-generate — once the public API surface is stable.
- Org-aware inputs used by this workflow:
- Figma URL + screenshot (and, if available, the developer's Dev Mode metadata export) — Phase 1.2 Figma input.
experience-lds-data-requirements-generate owns the org-schema introspection and data-spec validation used in Phase 1 when the component needs org-backed data — hand off to that skill rather than duplicating its work here.
Examples
Phase 1 PRD skeleton (fill from the Figma/PRD/Aura input)
Component: productCard (<product-card>)
Purpose: Render a compact summary of a product with quick actions.
Content requirements
- Hero image (Product.HeroImage__c)
- Title (Product.Name)
- Subtitle (Product.Tagline__c)
- Primary CTA button ("Add to cart")
- Secondary CTA icon button ("Favorite")
Data requirements
- Input: @api recordId (Product Id)
- Adapter: getRecord (UIAPI) with fields Name, Tagline__c, HeroImage__c
- Events out: addtocart{detail.recordId}, favorite{detail.recordId, detail.value}
States
- Loading (data not yet resolved)
- Error (adapter error)
- Empty (no record found)
- Default
Accessibility
- Title uses <h3>
- Icon-only button carries aria-label="Favorite"
- Card is a labelled region (role="group", aria-labelledby)
Responsiveness
- Full width < 480px
- Side-by-side image + text >= 480px
Styling
- Uses lightning-card wrapper
- Surface color: --slds-g-color-surface-container-1
- Shadow: --slds-g-shadow-1
Phase 2 skeleton
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import NAME from '@salesforce/schema/Product__c.Name';
import TAGLINE from '@salesforce/schema/Product__c.Tagline__c';
import HERO from '@salesforce/schema/Product__c.HeroImage__c';
const FIELDS = [NAME, TAGLINE, HERO];
export default class ProductCard extends LightningElement {
@api recordId;
@wire(getRecord, { recordId: '$recordId', fields: FIELDS })
record;
get hasRecord() { return this.record?.data != null; }
get isLoading() { return !this.record; }
get hasError() { return !!this.record?.error; }
get name() { return this.record?.data?.fields?.Name?.value ?? ''; }
get tagline() { return this.record?.data?.fields?.Tagline__c?.value ?? ''; }
get heroUrl() { return this.record?.data?.fields?.HeroImage__c?.value ?? ''; }
handleAddToCart() {
this.dispatchEvent(new CustomEvent('addtocart', { detail: { recordId: this.recordId }, bubbles: true, composed: true }));
}
handleFavorite(event) {
this.dispatchEvent(new CustomEvent('favorite', { detail: { recordId: this.recordId, value: event.detail.value }, bubbles: true, composed: true }));
}
}
Verification
- Every PRD section is traceable to at least one block of code or an explicit TODO.
- Phases 1–5 were executed in order; no step was skipped.
- Accessibility, SLDS, data-layer, and AI metadata reviews all pass.
- Coverage meets or exceeds the project's threshold.
- The component renders correctly in
experience-lwc-runtime-observe across the responsive breakpoints enumerated in the PRD.
1---
2name: experience-lwc-design-generate
3description: "Use when you need to create a brand new Lightning Web Component from a Figma design, a Product Requirements Document, or another design artifact — orchestrating the five-phase workflow (gather requirements → generate code → optimize → lint/format/compile → test) and stitching together the specialized skills for SLDS, LDS, base components, optimization, and testing. Use this skill whenever the user mentions building a new LWC from Figma, building an LWC from a PRD, generating an LWC from a design or screenshot, or migrating an Aura component as a fresh LWC build. DO NOT TRIGGER when refactoring an existing LWC (use experience-lwc-generate), for Aura → LWC in-place migration (out of scope for this skill), for standalone SLDS token or styling work (use design-systems-slds-apply), or for standalone data-layer work (use experience-lds-best-practices-apply or experience-lds-data-requirements-generate)."
4metadata:
5 version: "1.0"
6 domains: ["Experience", "Design Systems"]
7 cliTools:
8 - tool: ["eslint"]
9 semver: ">=8.0"
10 - tool: ["prettier"]
11 semver: ">=2.0"
12 - tool: ["python3"]
13 semver: ">=3.8"
14 relatedSkills:
15 - design-systems-slds-apply
16 - experience-lds-best-practices-apply
17 - experience-lds-data-requirements-generate
18 - experience-lwc-accessibility-jest-run
19 - experience-accessibility-validate
20 - experience-lwc-base-components-integrate
21 - experience-lwc-generate
22 - experience-lwc-rtl-validate
23 - experience-lwc-runtime-observe
24 - experience-lwc-security-validate
25 - experience-lwc-typescript-migrate
26---
27
28<!-- adk-managed-skill -->
29
30# Creating LWC Components from Design
31
32Orchestrate the end-to-end creation of a new Lightning Web Component from a design input (Figma, PRD, Aura source, or user description). This is the top-level workflow skill — it sequences the specialized sibling skills that own each stage. Org-aware data (LDS schema introspection, design-frame inspection) is resolved by handing off to `experience-lds-data-requirements-generate` or via design-tool URLs the user provides.
33
34## When to Use
35
36- Building a brand-new LWC from a Figma frame, PRD, or written spec.
37- Migrating an Aura component to LWC as a fresh build (in-place Aura → LWC porting is out of scope for this skill).
38- Creating a component whose requirements are still partly implicit and need distillation into a PRD before coding.
39
40Do NOT use this skill for:
41- Refactoring an existing LWC (use `experience-lwc-generate`).
42- Aura → LWC in-place migration (out of scope for this skill).
43- Pure styling or data-layer work (use the specialized skills directly).
44
45## Prerequisites
46
47- At least one design input: Figma URL, PRD markdown, Aura component source, or a textual spec.
48- Target path (module folder) for the new LWC.
49- For data-backed components: access to the org so `experience-lds-data-requirements-generate` and `experience-lds-best-practices-apply` can resolve the schema and adapter shapes.
50
51## Knowledge Bases
52
53- [references/prd-analysis-template.md](references/prd-analysis-template.md) — PRD section skeleton (copy it verbatim when producing a PRD).
54- [references/figma-to-prd-blueprint.md](references/figma-to-prd-blueprint.md) — Figma-specific guidance for translating a frame into PRD sections (componentName/tagName, contentRequirements, dataRequirements, interactions, componentCommunication, states, accessibility/responsiveness/styling/localization/security). Read this before Phase 1.2 when the input is a Figma design.
55
56## Workflow (mandatory five phases)
57
58### Phase 1 — Gather PRD & requirements
59
60**Goal:** produce a consolidated PRD that every later phase consumes.
61
621. **Obtain raw requirements** — collect the PRD, design spec, Figma URL, Aura source, or user text.
632. **Figma → PRD** (if applicable): follow [references/figma-to-prd-blueprint.md](references/figma-to-prd-blueprint.md) for the full Figma-frame analysis and PRD section guidelines. Inputs you need from the user: the Figma URL, a screenshot of the target frame, and (if Dev Mode is available) the metadata export for the node. Translate into the PRD skeleton from [references/prd-analysis-template.md](references/prd-analysis-template.md) using the section-by-section guidance in the blueprint.
643. **Aura → PRD** (if migrating): enumerate the Aura component's functionality that must be preserved — markup, controller/helper actions, events, attributes, and wired data — and feed that inventory into the PRD as explicit requirements. (In-place Aura → LWC porting is out of scope; this step only captures behavior for a fresh build.)
654. **Data requirements** (if the component reads/writes data): hand off to `experience-lds-data-requirements-generate`. That skill produces a validated data specification (object/field API names, recommended LDS API, implementation approach). Paste its output verbatim into the PRD.
665. **Adapter exploration**: hand off to `experience-lds-best-practices-apply` for the adapter selection rules (UI API vs GraphQL vs Apex) and the recommended wiring for the chosen approach.
676. **Naming**: `componentName` must be camelCase (e.g., `productCard`) and `tagName` must be its kebab-case form (e.g., `product-card`). Validate both with the bundled script — do not eyeball the check:
68
69 ```bash
70 "<skill_dir>/scripts/check-component-name.sh" <componentName> <tagName>
71 ```
72
73 The script exits nonzero (with an actionable stderr message) if either name is malformed or if the kebab form of `componentName` does not equal `tagName`.
74
75**Deliverable:** a comprehensive PRD covering purpose, content, data, interactions, states, a11y, responsiveness, styling direction, localization, and security. Keep it checked into the workspace (e.g., `packages/skills/<skill>-workspace/<iteration>/PRD.md`).
76
77### Phase 2 — Generate component code
78
79**Goal:** initial `.html`, `.js`, `.css`, `.js-meta.xml` that strictly reflect the PRD.
80
811. Hand off to `experience-lwc-generate` with the PRD content as the spec. That skill owns PRD → code translation (events, getters, `@api`, `.js-meta.xml`, AI metadata) and is the authoring source of truth.
822. Use the SLDS decision hierarchy from `design-systems-slds-apply`:
83 1. Prefer a matching Lightning Base Component (`experience-lwc-base-components-integrate`).
84 2. Otherwise pick an SLDS Blueprint or utility class (per `design-systems-slds-apply`).
85 3. Otherwise write custom CSS using SLDS styling hooks (also covered in `design-systems-slds-apply`).
863. Re-confirm the authoring baseline by walking the `experience-lwc-generate` checklist before proceeding.
874. Translate every PRD data requirement to either a wire adapter (UIAPI / GraphQL) or an explicit TODO.
885. Adhere strictly to the PRD:
89 - Only include features and behaviors the PRD describes.
90 - Mark uncertain areas with `// TODO:` comments that quote the PRD language raising the ambiguity.
91 - Add extensive code comments explaining intent.
92 - Do not split the component into more sub-components than the PRD implies.
93
94**Deliverable:** a first-pass LWC bundle in the target path.
95
96### Phase 3 — Optimize component
97
98**Goal:** apply performance, maintainability, and best-practice fixes.
99
1001. Walk the optimization checklist below before any other review:
101 - Single responsibility, encapsulation, reusability.
102 - Minimize DOM operations; batch updates via properties.
103 - Audit event handlers and lifecycle hook usage (`renderedCallback` guards).
104 - Consider lazy loading for heavy children.
1052. Hand off to `experience-lwc-generate` for the LWC best-practices review pass (anti-patterns, reactivity, composition).
1063. Hand off to the compliance suite for the pre-ship review — `experience-accessibility-validate` (a11y), `experience-lwc-security-validate` (LWS + Product Security), and `experience-lwc-rtl-validate` (RTL i18n). Run them together for the full quality pass.
1074. If the component touches data, hand off to `experience-lds-best-practices-apply` for cache/consistency and referential-integrity checks.
1085. Apply every accepted finding. Keep the PRD as the source of truth — do not add scope under the guise of optimization.
109
110### Phase 4 — Lint, format, compile-check
111
112Condition: only run steps whose tooling is configured in the project.
113
1141. **Detect project tooling** — invoke the bundled detection script from the project root and read its `<tool>=yes|no` lines. Do NOT eyeball `package.json` / dotfiles in prose:
115
116 ```bash
117 "<skill_dir>/scripts/detect-project-tools.sh" <projectRoot>
118 ```
119
120 Sample output:
121
122 ```text
123 eslint=yes
124 prettier=yes
125 cursor-rules=no
126 lwc-compiler=yes
127 ```
128
129 Run the substeps below only for tools reported `yes`; skip the rest.
1302. **ESLint** (if `eslint=yes`) — run and fix all violations.
1313. **Prettier** (if `prettier=yes`) — run for consistent formatting.
1324. **Cursor rules** (if `cursor-rules=yes`) — apply every rule the project ships.
1335. **LWC compiler** (if `lwc-compiler=yes`) — run via local dev server or SFDX; resolve every syntax/template error before moving on.
134
135**Deliverable:** clean, validated component code.
136
137### Phase 5 — Create tests
138
139Hand off to `experience-lwc-accessibility-jest-run` for automated accessibility Jest coverage; add general-purpose Jest coverage in the same pass following the `experience-lwc-generate` test guidance, plus UTAM page object generation if the team requires it.
140
141**Deliverable:** the LWC bundle with a passing test suite at or above the project's coverage threshold.
142
143## Definition of Done
144
145A new component built from this workflow is "done" only when **every** item below is true. Treat this as the canonical readiness checklist — copy it into the PR description so reviewers can confirm each line.
146
147**Code completion** — no implementation gaps:
148
1491. Every PRD requirement is either implemented or explicitly annotated with a `TODO:` and a linked tracking item. No silent gaps.
1502. No `TODO`, `FIXME`, or `console.log` / `console.table` / `alert()` left in production paths.
1513. No commented-out code blocks, no empty function bodies, no placeholder values, no dummy data, no unreferenced imports.
1524. No `lwc:dom="manual"` regions or third-party-library escape hatches without a comment explaining why a native LWC pattern wasn't used.
153
154**Compliance and quality:**
155
1565. `.js-meta.xml` AI metadata passes the audit in `experience-lwc-generate` (component-wide `<ai><description>` set, plus an `<ai><property name="…" aiDescription="…"/></ai>` entry for every `@api` member exposed through `<targetConfig>`; no marketing language).
1576. SLDS styling passes `design-systems-slds-apply` verification — no raw hex / px values, only styling hooks and SLDS utility classes.
1587. Accessibility pass complete: `experience-accessibility-validate` for source review + `experience-lwc-accessibility-jest-run` for automated tests, both green.
1598. Security + RTL pass complete: `experience-lwc-security-validate` + `experience-lwc-rtl-validate`, both green.
160
161**Data + tests:**
162
1639. Data layer verified against the referenced LDS adapters (every wire / imperative call is documented in the PRD's data section and matches one of the adapters from `experience-lds-best-practices-apply` or `experience-lds-data-requirements-generate`).
16410. Jest tests green at the required coverage level for the project. New tests cover every `@api` surface, every dispatched event, and every error path (failed wire, failed apex, validation rejection).
16511. UTAM page objects produced for any UI flow that needs cross-component browser-level testing (skip if not needed).
166
167## Cross-References
168
169- Skills chained by this workflow (in phase order):
170 - `experience-lds-data-requirements-generate` — Phase 1.4 data spec (and Phase 1.5 adapter exploration alongside `experience-lds-best-practices-apply`).
171 - `design-systems-slds-apply`, `experience-lwc-base-components-integrate` — Phase 2 styling decisions.
172 - `experience-lwc-generate` — Phase 2 authoring baseline + Phase 3 best-practices review + Phase 5 AI-metadata audit.
173 - `experience-lds-best-practices-apply` — Phase 2/3 data-layer adapter selection and consistency review.
174 - `experience-accessibility-validate`, `experience-lwc-security-validate`, `experience-lwc-rtl-validate` — Phase 3 a11y/security/RTL review.
175 - `experience-lwc-accessibility-jest-run` — Phase 5 automated a11y test generation.
176 - Optional: add o11y instrumentation as a separate pass once the component stabilizes.
177 - `experience-lwc-typescript-migrate` — optional once JS is green.
178 - When the new component ships behind a flag, gate it with a feature flag during rollout.
179 - `experience-lwc-api-docs-generate` — once the public API surface is stable.
180- Org-aware inputs used by this workflow:
181 - Figma URL + screenshot (and, if available, the developer's Dev Mode metadata export) — Phase 1.2 Figma input.
182 - `experience-lds-data-requirements-generate` owns the org-schema introspection and data-spec validation used in Phase 1 when the component needs org-backed data — hand off to that skill rather than duplicating its work here.
183
184## Examples
185
186**Phase 1 PRD skeleton (fill from the Figma/PRD/Aura input)**
187
188```text
189Component: productCard (<product-card>)
190Purpose: Render a compact summary of a product with quick actions.
191
192Content requirements
193- Hero image (Product.HeroImage__c)
194- Title (Product.Name)
195- Subtitle (Product.Tagline__c)
196- Primary CTA button ("Add to cart")
197- Secondary CTA icon button ("Favorite")
198
199Data requirements
200- Input: @api recordId (Product Id)
201- Adapter: getRecord (UIAPI) with fields Name, Tagline__c, HeroImage__c
202- Events out: addtocart{detail.recordId}, favorite{detail.recordId, detail.value}
203
204States
205- Loading (data not yet resolved)
206- Error (adapter error)
207- Empty (no record found)
208- Default
209
210Accessibility
211- Title uses <h3>
212- Icon-only button carries aria-label="Favorite"
213- Card is a labelled region (role="group", aria-labelledby)
214
215Responsiveness
216- Full width < 480px
217- Side-by-side image + text >= 480px
218
219Styling
220- Uses lightning-card wrapper
221- Surface color: --slds-g-color-surface-container-1
222- Shadow: --slds-g-shadow-1
223```
224
225**Phase 2 skeleton**
226
227```javascript
228import { LightningElement, api, wire } from 'lwc';
229import { getRecord } from 'lightning/uiRecordApi';
230import NAME from '@salesforce/schema/Product__c.Name';
231import TAGLINE from '@salesforce/schema/Product__c.Tagline__c';
232import HERO from '@salesforce/schema/Product__c.HeroImage__c';
233
234const FIELDS = [NAME, TAGLINE, HERO];
235
236export default class ProductCard extends LightningElement {
237 @api recordId;
238
239 @wire(getRecord, { recordId: '$recordId', fields: FIELDS })
240 record;
241
242 get hasRecord() { return this.record?.data != null; }
243 get isLoading() { return !this.record; }
244 get hasError() { return !!this.record?.error; }
245 get name() { return this.record?.data?.fields?.Name?.value ?? ''; }
246 get tagline() { return this.record?.data?.fields?.Tagline__c?.value ?? ''; }
247 get heroUrl() { return this.record?.data?.fields?.HeroImage__c?.value ?? ''; }
248
249 handleAddToCart() {
250 this.dispatchEvent(new CustomEvent('addtocart', { detail: { recordId: this.recordId }, bubbles: true, composed: true }));
251 }
252 handleFavorite(event) {
253 this.dispatchEvent(new CustomEvent('favorite', { detail: { recordId: this.recordId, value: event.detail.value }, bubbles: true, composed: true }));
254 }
255}
256```
257
258## Verification
259
260- Every PRD section is traceable to at least one block of code or an explicit TODO.
261- Phases 1–5 were executed in order; no step was skipped.
262- Accessibility, SLDS, data-layer, and AI metadata reviews all pass.
263- Coverage meets or exceeds the project's threshold.
264- The component renders correctly in `experience-lwc-runtime-observe` across the responsive breakpoints enumerated in the PRD.