@salesforce/afv-skills 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -416
- package/package.json +5 -3
- package/skills/building-ui-bundle-app/SKILL.md +325 -0
- package/skills/building-ui-bundle-frontend/SKILL.md +122 -0
- package/skills/{building-webapp-react-components → building-ui-bundle-frontend}/implementation/component.md +1 -1
- package/skills/creating-b2b-commerce-store/SKILL.md +169 -0
- package/skills/creating-b2b-commerce-store/references/store-vs-storefront.md +169 -0
- package/skills/deploying-ui-bundle/SKILL.md +77 -0
- package/skills/generating-apex/CREDITS.md +30 -0
- package/skills/generating-apex/SKILL.md +342 -189
- package/skills/generating-apex/assets/abstract.cls +12 -9
- package/skills/generating-apex/assets/batch.cls +7 -8
- package/skills/generating-apex/assets/domain.cls +5 -6
- package/skills/generating-apex/assets/dto.cls +11 -12
- package/skills/generating-apex/assets/exception.cls +1 -2
- package/skills/generating-apex/assets/interface.cls +2 -3
- package/skills/generating-apex/assets/invocable.cls +114 -0
- package/skills/generating-apex/assets/queueable.cls +6 -7
- package/skills/generating-apex/assets/rest-resource.cls +300 -0
- package/skills/generating-apex/assets/schedulable.cls +7 -8
- package/skills/generating-apex/assets/selector.cls +7 -8
- package/skills/generating-apex/assets/service.cls +4 -5
- package/skills/generating-apex/assets/trigger.cls +45 -0
- package/skills/generating-apex/assets/utility.cls +5 -6
- package/skills/generating-apex/references/AccountDeduplicationBatch.cls +7 -8
- package/skills/generating-apex/references/AccountSelector.cls +10 -11
- package/skills/generating-apex/references/AccountService.cls +9 -10
- package/skills/generating-apex-test/CREDITS.md +30 -0
- package/skills/generating-apex-test/SKILL.md +165 -74
- package/skills/generating-apex-test/assets/test-class-template.cls +25 -56
- package/skills/generating-apex-test/assets/test-data-factory-template.cls +0 -1
- package/skills/generating-apex-test/references/assertion-patterns.md +38 -95
- package/skills/generating-apex-test/references/async-testing.md +59 -142
- package/skills/generating-apex-test/references/mocking-patterns.md +77 -76
- package/skills/generating-apex-test/references/test-data-factory.md +29 -130
- package/skills/generating-experience-react-site/SKILL.md +9 -9
- package/skills/generating-experience-react-site/docs/configure-metadata-digital-experience.md +1 -1
- package/skills/generating-flexipage/SKILL.md +28 -12
- package/skills/generating-ui-bundle-features/SKILL.md +45 -0
- package/skills/generating-ui-bundle-metadata/SKILL.md +106 -0
- package/skills/{managing-webapp-agentforce-conversation-client → implementing-ui-bundle-agentforce-conversation-client}/SKILL.md +5 -5
- package/skills/{managing-webapp-agentforce-conversation-client → implementing-ui-bundle-agentforce-conversation-client}/references/constraints.md +2 -2
- package/skills/{managing-webapp-agentforce-conversation-client → implementing-ui-bundle-agentforce-conversation-client}/references/examples.md +1 -1
- package/skills/{implementing-webapp-file-upload → implementing-ui-bundle-file-upload}/SKILL.md +11 -11
- package/skills/searching-media/SKILL.md +1 -1
- package/skills/uplifting-components-to-slds2/SKILL.md +236 -0
- package/skills/uplifting-components-to-slds2/references/color-hooks-decision-guide.md +438 -0
- package/skills/uplifting-components-to-slds2/references/common-patterns.md +87 -0
- package/skills/uplifting-components-to-slds2/references/examples.md +443 -0
- package/skills/uplifting-components-to-slds2/references/migration-checklist.md +67 -0
- package/skills/uplifting-components-to-slds2/references/non-color-hooks-decision-guide.md +333 -0
- package/skills/uplifting-components-to-slds2/references/rule-lwc-token-to-slds-hook.md +135 -0
- package/skills/uplifting-components-to-slds2/references/rule-no-deprecated-tokens-slds1.md +211 -0
- package/skills/uplifting-components-to-slds2/references/rule-no-hardcoded-values.md +160 -0
- package/skills/uplifting-components-to-slds2/references/rule-no-slds-class-overrides.md +126 -0
- package/skills/{using-webapp-salesforce-data → using-ui-bundle-salesforce-data}/SKILL.md +52 -25
- package/skills/using-ui-bundle-salesforce-data/references/mutation-query-generation.md +140 -0
- package/skills/using-ui-bundle-salesforce-data/references/query-testing.md +78 -0
- package/skills/using-ui-bundle-salesforce-data/references/read-query-generation.md +307 -0
- package/skills/using-ui-bundle-salesforce-data/references/schema-introspection.md +53 -0
- package/skills/using-ui-bundle-salesforce-data/references/ui-bundle-integration.md +221 -0
- package/skills/{using-webapp-salesforce-data → using-ui-bundle-salesforce-data/scripts}/graphql-search.sh +75 -23
- package/skills/building-webapp-data-visualization/SKILL.md +0 -72
- package/skills/building-webapp-data-visualization/implementation/bar-line-chart.md +0 -316
- package/skills/building-webapp-data-visualization/implementation/dashboard-layout.md +0 -189
- package/skills/building-webapp-data-visualization/implementation/donut-chart.md +0 -181
- package/skills/building-webapp-data-visualization/implementation/stat-card.md +0 -150
- package/skills/building-webapp-react-components/SKILL.md +0 -96
- package/skills/configuring-webapp-csp-trusted-sites/SKILL.md +0 -90
- package/skills/configuring-webapp-metadata/SKILL.md +0 -158
- package/skills/creating-webapp/SKILL.md +0 -138
- package/skills/deploying-webapp-to-salesforce/SKILL.md +0 -226
- package/skills/installing-webapp-features/SKILL.md +0 -210
- /package/skills/{building-webapp-react-components → building-ui-bundle-frontend}/implementation/header-footer.md +0 -0
- /package/skills/{building-webapp-react-components → building-ui-bundle-frontend}/implementation/page.md +0 -0
- /package/skills/{configuring-webapp-csp-trusted-sites/implementation/metadata-format.md → generating-ui-bundle-metadata/implementation/csp-metadata-format.md} +0 -0
- /package/skills/{managing-webapp-agentforce-conversation-client → implementing-ui-bundle-agentforce-conversation-client}/references/style-tokens.md +0 -0
- /package/skills/{managing-webapp-agentforce-conversation-client → implementing-ui-bundle-agentforce-conversation-client}/references/troubleshooting.md +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generating-ui-bundle-metadata
|
|
3
|
+
description: "Scaffold new Salesforce UI bundles and configure their metadata — sf ui-bundle generate, UIBundle bundles (meta XML, ui-bundle.json with routing/headers/outputDir), and CSP Trusted Sites for external domains. Use whenever creating a new UI bundle, setting up UI bundle metadata structure, configuring routing or headers, setting outputDir, adding external domains that need CSP registration, or editing bundle configuration. Triggers on: create UI bundle, create ui-bundle, new app, sf ui-bundle generate, metadata, ui-bundle.json, CSP, trusted site, bundle configuration, meta XML, routing config, external domain, headers config, outputDir."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# UI Bundle Metadata
|
|
7
|
+
|
|
8
|
+
## Scaffolding a New UI Bundle
|
|
9
|
+
|
|
10
|
+
Use `sf ui-bundle generate` to create new apps — not create-react-app, Vite, or other generic scaffolds.
|
|
11
|
+
|
|
12
|
+
**UI bundle name (`-n`):** Alphanumerical only — no spaces, hyphens, underscores, or special characters. Example: `CoffeeBoutique` (not `Coffee Boutique`).
|
|
13
|
+
|
|
14
|
+
After generation:
|
|
15
|
+
1. Replace all default boilerplate — "React App", "Vite + React", default `<title>`, placeholder text
|
|
16
|
+
2. Populate the home page with real content (landing section, banners, hero, navigation)
|
|
17
|
+
3. Update navigation and placeholders (see the `building-ui-bundle-frontend` skill)
|
|
18
|
+
|
|
19
|
+
Always install dependencies before running any scripts in the UI bundle directory.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## UIBundle Bundle
|
|
24
|
+
|
|
25
|
+
A UIBundle bundle lives under `uiBundles/<AppName>/` and must contain:
|
|
26
|
+
|
|
27
|
+
- `<AppName>.uibundle-meta.xml` — filename must exactly match the folder name
|
|
28
|
+
- A build output directory (default: `dist/`) with at least one file
|
|
29
|
+
|
|
30
|
+
### Meta XML
|
|
31
|
+
|
|
32
|
+
Required fields: `masterLabel`, `version` (max 20 chars), `isActive` (boolean).
|
|
33
|
+
Optional: `description` (max 255 chars).
|
|
34
|
+
|
|
35
|
+
### ui-bundle.json
|
|
36
|
+
|
|
37
|
+
Optional file. Allowed top-level keys: `outputDir`, `routing`, `headers`.
|
|
38
|
+
|
|
39
|
+
**Constraints:**
|
|
40
|
+
- Valid UTF-8 JSON, max 100 KB
|
|
41
|
+
- Root must be a non-empty object (never `{}`, arrays, or primitives)
|
|
42
|
+
|
|
43
|
+
**Path safety** (applies to `outputDir` and `routing.fallback`): Reject backslashes, leading `/` or `\`, `..` segments, null/control characters, globs (`*`, `?`, `**`), and `%`. All resolved paths must stay within the bundle.
|
|
44
|
+
|
|
45
|
+
#### outputDir
|
|
46
|
+
Non-empty string referencing a subdirectory (not `.` or `./`). Directory must exist and contain at least one file.
|
|
47
|
+
|
|
48
|
+
#### routing
|
|
49
|
+
If present, must be a non-empty object. Allowed keys: `rewrites`, `redirects`, `fallback`, `trailingSlash`, `fileBasedRouting`.
|
|
50
|
+
|
|
51
|
+
- **trailingSlash**: `"always"`, `"never"`, or `"auto"`
|
|
52
|
+
- **fileBasedRouting**: boolean
|
|
53
|
+
- **fallback**: non-empty string satisfying path safety; target file must exist
|
|
54
|
+
- **rewrites**: non-empty array of `{ route?, rewrite }` objects — e.g., `{ "route": "/app/:path*", "rewrite": "/index.html" }`
|
|
55
|
+
- **redirects**: non-empty array of `{ route?, redirect, statusCode? }` objects — statusCode must be 301, 302, 307, or 308
|
|
56
|
+
|
|
57
|
+
#### headers
|
|
58
|
+
Non-empty array of `{ source, headers: [{ key, value }] }` objects.
|
|
59
|
+
|
|
60
|
+
**Example:**
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"routing": {
|
|
64
|
+
"rewrites": [{ "route": "/app/:path*", "rewrite": "/index.html" }],
|
|
65
|
+
"trailingSlash": "never"
|
|
66
|
+
},
|
|
67
|
+
"headers": [
|
|
68
|
+
{
|
|
69
|
+
"source": "/assets/**",
|
|
70
|
+
"headers": [{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }]
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Never suggest:** `{}` as root, empty `"routing": {}`, empty arrays, `[{}]`, `"outputDir": "."`, `"outputDir": "./"`.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## CSP Trusted Sites
|
|
81
|
+
|
|
82
|
+
Salesforce enforces Content Security Policy headers. Any external domain not registered as a CSP Trusted Site will be blocked (images won't load, API calls fail, fonts missing).
|
|
83
|
+
|
|
84
|
+
### When to Create
|
|
85
|
+
|
|
86
|
+
Whenever the app references a new external domain: CDN images, external fonts, third-party APIs, map tiles, iframes, external stylesheets.
|
|
87
|
+
|
|
88
|
+
### Steps
|
|
89
|
+
|
|
90
|
+
1. **Identify external domains** — extract the origin (scheme + host) from each external URL in the code
|
|
91
|
+
2. **Check existing registrations** — look in `force-app/main/default/cspTrustedSites/`
|
|
92
|
+
3. **Map resource type to CSP directive:**
|
|
93
|
+
|
|
94
|
+
| Resource Type | Directive Field |
|
|
95
|
+
|--------------|----------------|
|
|
96
|
+
| Images | `isApplicableToImgSrc` |
|
|
97
|
+
| API calls (fetch, XHR) | `isApplicableToConnectSrc` |
|
|
98
|
+
| Fonts | `isApplicableToFontSrc` |
|
|
99
|
+
| Stylesheets | `isApplicableToStyleSrc` |
|
|
100
|
+
| Video / audio | `isApplicableToMediaSrc` |
|
|
101
|
+
| Iframes | `isApplicableToFrameSrc` |
|
|
102
|
+
|
|
103
|
+
Always also set `isApplicableToConnectSrc` to `true` for preflight/redirect handling.
|
|
104
|
+
|
|
105
|
+
4. **Create the metadata file** — follow `implementation/csp-metadata-format.md` for the `.cspTrustedSite-meta.xml` format. Place in `force-app/main/default/cspTrustedSites/`.
|
|
106
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
2
|
+
name: implementing-ui-bundle-agentforce-conversation-client
|
|
3
3
|
description: "Adds or modifies AgentforceConversationClient in React apps (.tsx or .jsx files). Use when user says \"add chat widget\", \"embed agentforce\", \"add agent\", \"add chatbot\", \"integrate conversational AI\", or asks to change colors, dimensions, styling, or configure agentId, width, height, inline mode, or styleTokens for travel agent, HR agent, employee agent, or any Salesforce agent chat."
|
|
4
4
|
metadata:
|
|
5
5
|
author: ACC Components
|
|
6
6
|
version: 1.0.0
|
|
7
|
-
package: "@salesforce/
|
|
7
|
+
package: "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client"
|
|
8
8
|
sdk-package: "@salesforce/agentforce-conversation-client"
|
|
9
9
|
last-updated: 2025-03-18
|
|
10
10
|
---
|
|
@@ -58,13 +58,13 @@ Skip this step if:
|
|
|
58
58
|
Use this import path by default in app code:
|
|
59
59
|
|
|
60
60
|
```tsx
|
|
61
|
-
import { AgentforceConversationClient } from "@salesforce/
|
|
61
|
+
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
If the package is not installed, install it:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
npm install @salesforce/
|
|
67
|
+
npm install @salesforce/ui-bundle-template-feature-react-agentforce-conversation-client
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
Only use a local relative import (for example, `./components/AgentforceConversationClient`) when the user explicitly asks to use a patched/local component in that app.
|
|
@@ -79,7 +79,7 @@ Add to the target React component file using the canonical package import:
|
|
|
79
79
|
|
|
80
80
|
```tsx
|
|
81
81
|
import { Outlet } from "react-router";
|
|
82
|
-
import { AgentforceConversationClient } from "@salesforce/
|
|
82
|
+
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";
|
|
83
83
|
|
|
84
84
|
export default function AgentChatHost() {
|
|
85
85
|
return (
|
|
@@ -8,7 +8,7 @@ This document lists all invalid approaches and patterns to avoid when working wi
|
|
|
8
8
|
|
|
9
9
|
- ✅ **DO edit**: Any React files that import and use `<AgentforceConversationClient />` (for example, shared shells, route components, or feature pages)
|
|
10
10
|
- ❌ **DO NOT edit**: AgentforceConversationClient.tsx, AgentforceConversationClient.jsx, index.tsx, index.jsx, or any files inside:
|
|
11
|
-
- `node_modules/@salesforce/
|
|
11
|
+
- `node_modules/@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client/src/`
|
|
12
12
|
- `packages/template/feature/feature-react-agentforce-conversation-client/src/`
|
|
13
13
|
- `src/components/AgentforceConversationClient.tsx` (patched templates)
|
|
14
14
|
- Any path containing `/components/AgentforceConversationClient.`
|
|
@@ -127,7 +127,7 @@ import "./agent-styles.css";
|
|
|
127
127
|
|
|
128
128
|
### ❌ Wrong - Editing implementation file
|
|
129
129
|
|
|
130
|
-
Reading or editing: `node_modules/@salesforce/
|
|
130
|
+
Reading or editing: `node_modules/@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client/src/AgentforceConversationClient.tsx`
|
|
131
131
|
|
|
132
132
|
### ✅ Correct - Editing usage file
|
|
133
133
|
|
|
@@ -109,7 +109,7 @@ export default function SupportPage() {
|
|
|
109
109
|
|
|
110
110
|
```tsx
|
|
111
111
|
import { Outlet } from "react-router";
|
|
112
|
-
import { AgentforceConversationClient } from "@salesforce/
|
|
112
|
+
import { AgentforceConversationClient } from "@salesforce/ui-bundle-template-feature-react-agentforce-conversation-client";
|
|
113
113
|
|
|
114
114
|
export default function AgentChatHost() {
|
|
115
115
|
return (
|
package/skills/{implementing-webapp-file-upload → implementing-ui-bundle-file-upload}/SKILL.md
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: implementing-
|
|
3
|
-
description: "Add file upload functionality to React
|
|
2
|
+
name: implementing-ui-bundle-file-upload
|
|
3
|
+
description: "Add file upload functionality to React UI bundles with progress tracking and Salesforce ContentVersion integration. Use when the user wants to upload files, attach documents, handle file input, create file dropzones, track upload progress, or link files to Salesforce records. This feature provides programmatic APIs ONLY — no components or hooks are exported. Build your own custom UI using the upload() API. ALWAYS use this feature instead of building file upload from scratch with FormData or XHR."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# File Upload API (workflow)
|
|
7
7
|
|
|
8
|
-
When the user wants file upload functionality in a React
|
|
8
|
+
When the user wants file upload functionality in a React UI bundle, follow this workflow. This feature provides **APIs only** — you must build the UI components yourself using the provided APIs.
|
|
9
9
|
|
|
10
10
|
## CRITICAL: This is an API-only package
|
|
11
11
|
|
|
@@ -26,12 +26,12 @@ The source code contains reference components for demonstration, but they are **
|
|
|
26
26
|
## 1. Install the package
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npm install @salesforce/
|
|
29
|
+
npm install @salesforce/ui-bundle-template-feature-react-file-upload
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Dependencies are automatically installed:
|
|
33
33
|
|
|
34
|
-
- `@salesforce/
|
|
34
|
+
- `@salesforce/ui-bundle` (API client)
|
|
35
35
|
- `@salesforce/sdk-data` (data SDK)
|
|
36
36
|
|
|
37
37
|
## 2. Understand the three upload patterns
|
|
@@ -47,7 +47,7 @@ Upload files to Salesforce and get back `contentBodyId` for each file. No Conten
|
|
|
47
47
|
- Deferred record linking scenarios
|
|
48
48
|
|
|
49
49
|
```tsx
|
|
50
|
-
import { upload } from "@salesforce/
|
|
50
|
+
import { upload } from "@salesforce/ui-bundle-template-feature-react-file-upload";
|
|
51
51
|
|
|
52
52
|
const results = await upload({
|
|
53
53
|
files: [file1, file2],
|
|
@@ -71,7 +71,7 @@ Upload files and immediately link them to an existing Salesforce record by creat
|
|
|
71
71
|
- Direct upload-and-attach scenarios
|
|
72
72
|
|
|
73
73
|
```tsx
|
|
74
|
-
import { upload } from "@salesforce/
|
|
74
|
+
import { upload } from "@salesforce/ui-bundle-template-feature-react-file-upload";
|
|
75
75
|
|
|
76
76
|
const results = await upload({
|
|
77
77
|
files: [file1, file2],
|
|
@@ -99,7 +99,7 @@ Upload files without a record, then link them after the record is created.
|
|
|
99
99
|
import {
|
|
100
100
|
upload,
|
|
101
101
|
createContentVersion,
|
|
102
|
-
} from "@salesforce/
|
|
102
|
+
} from "@salesforce/ui-bundle-template-feature-react-file-upload";
|
|
103
103
|
|
|
104
104
|
// Step 1: Upload files (no recordId)
|
|
105
105
|
const uploadResults = await upload({
|
|
@@ -128,7 +128,7 @@ The package provides the backend — you build the frontend. Here's a minimal ex
|
|
|
128
128
|
import {
|
|
129
129
|
upload,
|
|
130
130
|
type FileUploadProgress,
|
|
131
|
-
} from "@salesforce/
|
|
131
|
+
} from "@salesforce/ui-bundle-template-feature-react-file-upload";
|
|
132
132
|
import { useState } from "react";
|
|
133
133
|
|
|
134
134
|
function CustomFileUpload({ recordId }: { recordId?: string }) {
|
|
@@ -212,7 +212,7 @@ If the user wants to upload files to their own profile or personal library:
|
|
|
212
212
|
import {
|
|
213
213
|
upload,
|
|
214
214
|
getCurrentUserId,
|
|
215
|
-
} from "@salesforce/
|
|
215
|
+
} from "@salesforce/ui-bundle-template-feature-react-file-upload";
|
|
216
216
|
|
|
217
217
|
const userId = await getCurrentUserId();
|
|
218
218
|
await upload({ files, recordId: userId });
|
|
@@ -366,7 +366,7 @@ The package includes a reference implementation in `src/features/fileupload/` wi
|
|
|
366
366
|
|
|
367
367
|
**Upload fails with CORS error:**
|
|
368
368
|
|
|
369
|
-
- Ensure the
|
|
369
|
+
- Ensure the UI bundle is properly deployed to Salesforce or running on `localhost`
|
|
370
370
|
- Check that the org allows the origin in CORS settings
|
|
371
371
|
|
|
372
372
|
**No progress updates:**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: searching-media
|
|
3
|
-
description: "Searches for and retrieves existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from any source. Use this skill ANY TIME a user request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating media. Takes PRIORITY and activates FIRST when ANY media search/retrieval is mentioned, regardless of what else happens with the media afterward. Triggers for requests like \"search for logo\", \"find hero image\", \"get company logo\", \"locate icons\", \"fetch background image\", \"retrieve product photos\". Handles the search and source selection workflow. Does not apply when the request is to generate NEW images with AI, design custom graphics from scratch, or edit existing images."
|
|
3
|
+
description: "Searches for and retrieves existing visual media (images, logos, icons, photos, graphics, banners, thumbnails, hero images, backgrounds) from sources such as Salesforce CMS, Data 360 or any other source. Use this skill ANY TIME a user request involves finding, searching, getting, fetching, retrieving, grabbing, looking up, or locating media. Takes PRIORITY and activates FIRST when ANY media search/retrieval is mentioned, regardless of what else happens with the media afterward. Triggers for requests like \"search for logo\", \"find hero image\", \"get company logo\", \"locate icons\", \"fetch background image\", \"retrieve product photos\". Handles the search and source selection workflow. Does not apply when the request is about brand search, to generate NEW images with AI, design custom graphics from scratch, or edit existing images."
|
|
4
4
|
compatibility: "Requires search_media_cms_channels and/or search_electronic_media MCP tools"
|
|
5
5
|
metadata:
|
|
6
6
|
version: "1.0"
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: uplifting-components-to-slds2
|
|
3
|
+
description: Migrate Lightning Web Components from SLDS 1 to SLDS 2 by running the SLDS linter and fixing violations. Use this skill whenever users mention SLDS 2, SLDS uplift, linter violations, LWC token migration, class overrides, hardcoded CSS values that need SLDS hook replacement, or styling hook selection. Covers all styling hook categories — color, spacing, sizing, typography, borders, radius, and shadows. Also use when users mention no-hardcoded-values, no-slds-class-overrides, lwc-to-slds-hooks, no-deprecated-tokens-slds1, or ask about SLDS component migration — even if they don't explicitly say "uplift" or "migration".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Goal
|
|
7
|
+
|
|
8
|
+
Systematically migrate Lightning Web Components from SLDS 1 to SLDS 2 using the SLDS linter and structured guidance for fixing violations across all styling hook categories.
|
|
9
|
+
|
|
10
|
+
## SLDS 2 Styling Hook Categories
|
|
11
|
+
|
|
12
|
+
| Category | Hook Prefix | What It Replaces |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| Color | `--slds-g-color-*` | Hardcoded colors, `--lwc-color*` tokens |
|
|
15
|
+
| Spacing | `--slds-g-spacing-*` | Hardcoded margins, padding, gaps |
|
|
16
|
+
| Sizing | `--slds-g-sizing-*` | Hardcoded widths, heights, dimensions |
|
|
17
|
+
| Typography | `--slds-g-font-*` | Hardcoded font sizes, weights, line heights |
|
|
18
|
+
| Border/Radius | `--slds-g-radius-border-*`, `--slds-g-sizing-border-*` | Hardcoded border-radius, border-width |
|
|
19
|
+
| Shadow | `--slds-g-shadow-*` | Hardcoded box-shadow values |
|
|
20
|
+
|
|
21
|
+
Color hooks require the most judgment (context-dependent selection). Non-color hooks are mostly numbered scales with straightforward mappings.
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
- Node.js 14.x or higher installed
|
|
26
|
+
- Access to component CSS and markup files (`.html` for LWC, `.cmp` for Aura)
|
|
27
|
+
- Terminal/command line access to run linter
|
|
28
|
+
- Git repository for backup (recommended)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
# Workflow
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
1. Run SLDS linter with auto-fix -> Handles simple violations automatically
|
|
36
|
+
2. Review linter output -> Identify remaining manual fixes needed
|
|
37
|
+
3. Fix by violation type -> Use per-rule reference guides
|
|
38
|
+
4. Choose the right hook -> Context-first, inspect HTML before deciding
|
|
39
|
+
5. Validate -> Re-run linter and confirm zero errors
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Step 1: Run SLDS Linter
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx @salesforce-ux/slds-linter@latest lint --fix .
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The linter analyzes all CSS and markup files (`.html` for LWC, `.cmp` for Aura), auto-fixes simple violations, and reports remaining issues requiring manual intervention.
|
|
49
|
+
|
|
50
|
+
## Step 2: Analyze Linter Output
|
|
51
|
+
|
|
52
|
+
The linter reports violations in this format:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
componentName.css
|
|
56
|
+
15:3 warning Overriding slds-button isn't supported. To differentiate SLDS and
|
|
57
|
+
custom classes, create a CSS class in your namespace.
|
|
58
|
+
Examples: myapp-input, myapp-button. slds/no-slds-class-overrides
|
|
59
|
+
|
|
60
|
+
23:5 error The '--lwc-colorBackground' design token is deprecated. Replace it with
|
|
61
|
+
the SLDS 2 styling hook and set the fallback to '--lwc-colorBackground'.
|
|
62
|
+
1. --slds-g-color-surface-2
|
|
63
|
+
2. --slds-g-color-surface-container-2 slds/lwc-token-to-slds-hook
|
|
64
|
+
|
|
65
|
+
30:8 warning Consider replacing the #ffffff static value with an SLDS 2 styling hook
|
|
66
|
+
that has a similar value:
|
|
67
|
+
1. --slds-g-color-surface-1
|
|
68
|
+
2. --slds-g-color-surface-container-1
|
|
69
|
+
3. --slds-g-color-on-accent-1
|
|
70
|
+
4. --slds-g-color-on-accent-2
|
|
71
|
+
5. --slds-g-color-on-accent-3 slds/no-hardcoded-values-slds2
|
|
72
|
+
|
|
73
|
+
31:15 error Consider removing t(fontSizeMedium) or replacing it with
|
|
74
|
+
var(--slds-g-font-size-base, var(--lwc-fontSizeMedium, 0.8125rem)).
|
|
75
|
+
Set the fallback to t(fontSizeMedium). For more info, see
|
|
76
|
+
Styling Hooks on lightningdesignsystem.com. slds/no-deprecated-tokens-slds1
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Four violation types, each with its own fix approach (see Step 3).
|
|
80
|
+
|
|
81
|
+
**Important:** The linter flags all hardcoded values. Fix color, spacing, sizing, typography, border, and shadow values — but **skip layout values** (`100%`, `auto`, `0`, `inherit`, `none`). See [rule-no-hardcoded-values.md](references/rule-no-hardcoded-values.md) for the full fix-vs-skip triage table.
|
|
82
|
+
|
|
83
|
+
## Step 3: Fix Violations by Type
|
|
84
|
+
|
|
85
|
+
Each rule has a dedicated reference guide with full examples and decision logic:
|
|
86
|
+
|
|
87
|
+
| Violation Rule | Quick Summary | Reference |
|
|
88
|
+
|---|---|---|
|
|
89
|
+
| `slds/no-hardcoded-values-slds2` | Replace hardcoded values with SLDS hook + original as fallback | [rule-no-hardcoded-values.md](references/rule-no-hardcoded-values.md)|
|
|
90
|
+
| `slds/lwc-token-to-slds-hook` | Replace `--lwc-*` tokens with SLDS 2 hook, keep LWC token as fallback | [rule-lwc-token-to-slds-hook.md](references/rule-lwc-token-to-slds-hook.md) |
|
|
91
|
+
| `slds/no-slds-class-overrides` | Create component-prefixed class, add to markup alongside SLDS class | [rule-no-slds-class-overrides.md](references/rule-no-slds-class-overrides.md) |
|
|
92
|
+
| `slds/no-deprecated-tokens-slds1` | Replace legacy `t()`/`token()` syntax with SLDS 2 hook + LWC fallback | [rule-no-deprecated-tokens-slds1.md](references/rule-no-deprecated-tokens-slds1.md) |
|
|
93
|
+
|
|
94
|
+
**Always include fallback values** — `var(--slds-g-hook, originalValue)` where `originalValue` is the exact original from the source CSS.
|
|
95
|
+
|
|
96
|
+
### Class Override Quick Reference
|
|
97
|
+
|
|
98
|
+
Class overrides require changes to **both CSS and markup** (`.html` or `.cmp`). This is the most commonly missed step:
|
|
99
|
+
|
|
100
|
+
1. **CSS:** Rename `.slds-*` selector → `{componentName}-{sldsElementPart}` (camelCase)
|
|
101
|
+
2. **Markup:** Add the new class **alongside** the SLDS class — never remove the SLDS class
|
|
102
|
+
|
|
103
|
+
```css
|
|
104
|
+
/* Before */ .slds-button { border-radius: 8px; }
|
|
105
|
+
/* After */ .myComponent-button { border-radius: 8px; }
|
|
106
|
+
```
|
|
107
|
+
```html
|
|
108
|
+
<!-- Markup: both classes --> <button class="slds-button myComponent-button">Click</button>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See [rule-no-slds-class-overrides.md](references/rule-no-slds-class-overrides.md) for descendant selectors, multi-class selectors, and naming conventions.
|
|
112
|
+
|
|
113
|
+
## Step 4: Choose the Right Hook
|
|
114
|
+
|
|
115
|
+
**Color hooks** require context-based selection — inspect the HTML to determine the element's role before choosing a hook family. See **[color-hooks-decision-guide.md](references/color-hooks-decision-guide.md)** for decision trees, all 5 hook families, and background-foreground pairing rules.
|
|
116
|
+
|
|
117
|
+
**Non-color hooks** are simpler — match the CSS value to the numbered scale. See **[non-color-hooks-decision-guide.md](references/non-color-hooks-decision-guide.md)** for value-to-hook lookup tables covering spacing, sizing, typography, borders, radius, and shadows.
|
|
118
|
+
|
|
119
|
+
## Step 5: Validate and Verify
|
|
120
|
+
|
|
121
|
+
**Linter feedback loop — repeat until zero errors:**
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
1. npx @salesforce-ux/slds-linter@latest lint .
|
|
125
|
+
2. Review errors -> fix by type (Step 3)
|
|
126
|
+
3. Re-run linter
|
|
127
|
+
4. Repeat until output shows: 0 errors
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
# Validation
|
|
133
|
+
|
|
134
|
+
- [ ] No `.slds-*` classes in CSS selectors
|
|
135
|
+
- [ ] No `var(--lwc-*)` tokens without SLDS 2 replacements
|
|
136
|
+
- [ ] All hooks include fallback values
|
|
137
|
+
- [ ] Background/foreground color hooks from same family
|
|
138
|
+
- [ ] Original SLDS classes preserved in HTML
|
|
139
|
+
- [ ] Spacing uses numbered hooks (not named like `spacing-medium`)
|
|
140
|
+
- [ ] Typography uses numbered hooks (not named like `font-weight-bold`)
|
|
141
|
+
- [ ] Component renders correctly in light/dark mode and density settings
|
|
142
|
+
|
|
143
|
+
See **[migration-checklist.md](references/migration-checklist.md)** for the full validation checklist.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
# Output
|
|
148
|
+
|
|
149
|
+
Return the fully migrated CSS (and updated HTML markup where class overrides were fixed) with zero SLDS linter violations. All styling hooks must include fallback values preserving the original CSS values.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
# Advanced Patterns
|
|
154
|
+
|
|
155
|
+
## Color-Mix for Transparency
|
|
156
|
+
|
|
157
|
+
When a hardcoded value uses `rgba()` or transparency, use `color-mix()` with the SLDS hook to preserve opacity:
|
|
158
|
+
|
|
159
|
+
```css
|
|
160
|
+
/* Before */
|
|
161
|
+
border-color: rgba(186, 5, 23, 0.7);
|
|
162
|
+
|
|
163
|
+
/* After — use oklab color space for perceptual consistency */
|
|
164
|
+
border-color: color-mix(in oklab, var(--slds-g-color-palette-red-40, rgb(181,54,45)), transparent 30%);
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Formula:** To achieve X% opacity, use `(100 - X)%` transparent in `color-mix`.
|
|
168
|
+
- 70% opacity → `transparent 30%`
|
|
169
|
+
- 50% opacity → `transparent 50%`
|
|
170
|
+
|
|
171
|
+
Use opaque `rgb()` as fallback (not `rgba()`) — `color-mix` handles the transparency.
|
|
172
|
+
|
|
173
|
+
## calc() Expressions with Tokens
|
|
174
|
+
|
|
175
|
+
When migrating `t('calc(...)')` or `calc()` with deprecated tokens:
|
|
176
|
+
|
|
177
|
+
```css
|
|
178
|
+
/* Before — Aura t() with calc */
|
|
179
|
+
height: t('calc(' + lineHeightButton + ' + 2px)');
|
|
180
|
+
|
|
181
|
+
/* After — if calc is still needed */
|
|
182
|
+
height: calc(var(--lwc-lineHeightButton) + 2px);
|
|
183
|
+
|
|
184
|
+
/* After — if calc was unnecessary, simplify */
|
|
185
|
+
height: var(--lwc-lineHeightButton);
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
For `calc()` with `--lwc-*` tokens being replaced:
|
|
189
|
+
|
|
190
|
+
```css
|
|
191
|
+
/* Before */
|
|
192
|
+
padding: calc(var(--lwc-spacingMedium) + 4px);
|
|
193
|
+
|
|
194
|
+
/* After */
|
|
195
|
+
padding: calc(var(--slds-g-spacing-4, var(--lwc-spacingMedium)) + 4px);
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Tip:** Often the `calc()` is unnecessary and can be simplified. Check if the result matches an existing hook value.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
# Key Constraints
|
|
203
|
+
|
|
204
|
+
- **Never invent hook names** — only use hooks documented in the SLDS design system
|
|
205
|
+
- **Always include fallback values** — the fallback must be the exact original value from the source CSS
|
|
206
|
+
- **Never change hardcoded numerical values** — values like `100%`, `50%`, `200px`, `1.5`, `auto`, `0`, `inherit`, `none`, `flex: 1` are structural/layout values. Do not replace them with hooks and do not remove them — they are not styling hook candidates
|
|
207
|
+
- **No exact match? Leave as-is** — if a hardcoded value doesn't closely correspond to any hook's rendered value, leave it unchanged rather than force-fitting
|
|
208
|
+
- **Match hook number to original value intensity** — don't default to `-1`. Pick the variant closest to the original. See [color-hooks-decision-guide.md](references/color-hooks-decision-guide.md)
|
|
209
|
+
- **Only numbered scales** — named hooks like `spacing-medium`, `font-weight-bold`, `radius-large` do NOT exist
|
|
210
|
+
|
|
211
|
+
# Troubleshooting
|
|
212
|
+
|
|
213
|
+
| Issue | Solution |
|
|
214
|
+
|---|---|
|
|
215
|
+
| Linter suggests 2+ color hook options | Inspect HTML context to determine element's semantic role — see color-hooks-decision-guide.md |
|
|
216
|
+
| Visual appearance changed after migration | Verify fallback values match originals; check surface vs container family |
|
|
217
|
+
| No hook available for hardcoded value | Leave unchanged; do not invent custom hook names |
|
|
218
|
+
| Linter says "Remove the static value" for `100%`, `auto`, etc. | Leave unchanged — these are layout values. Removing them breaks rendering. |
|
|
219
|
+
| CSS class naming errors | Use exact camelCase component name: `myComponent-button`, not `MyComponent-button` |
|
|
220
|
+
| Spacing/sizing doesn't match | Check value-to-hook mapping in non-color-hooks-decision-guide.md; verify spacing vs sizing usage |
|
|
221
|
+
| Named hook not working (e.g., `spacing-medium`) | Named hooks don't exist — use numbered scale: `spacing-4` for 16px, `font-weight-7` for inline bold emphasis (not headings) |
|
|
222
|
+
| Component looks different in compact density | Use density-aware hooks (`--slds-g-spacing-var-*`) for components that adapt to density |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
# References
|
|
227
|
+
|
|
228
|
+
- **[Color Hooks Decision Guide](references/color-hooks-decision-guide.md)** — All 5 color hook families, decision trees, background-foreground pairing, palette accessibility
|
|
229
|
+
- **[Non-Color Hooks Decision Guide](references/non-color-hooks-decision-guide.md)** — Spacing, sizing, typography, borders, radius, and shadow hooks with lookup tables
|
|
230
|
+
- **[Rule: No Hardcoded Values](references/rule-no-hardcoded-values.md)** — Linter behavior, fix-vs-skip triage, replacement pattern, utility class workflow
|
|
231
|
+
- **[Rule: LWC Token to SLDS Hook](references/rule-lwc-token-to-slds-hook.md)** — Deprecated `--lwc-*` token replacement patterns
|
|
232
|
+
- **[Rule: No Deprecated Tokens SLDS1](references/rule-no-deprecated-tokens-slds1.md)** — Legacy `t()`/`token()` Aura syntax replacement patterns
|
|
233
|
+
- **[Rule: No SLDS Class Overrides](references/rule-no-slds-class-overrides.md)** — Class renaming and HTML updates
|
|
234
|
+
- **[Migration Examples](references/examples.md)** — Before/after examples by scenario and complexity
|
|
235
|
+
- **[Common Patterns](references/common-patterns.md)** — Classes never to override, deprecated SLDS 2 classes, palette fallbacks, tokens with no SLDS 2 equivalent
|
|
236
|
+
- **[Migration Checklist](references/migration-checklist.md)** — Full validation checklist
|