@salesforce/afv-skills 1.5.2 → 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 +5 -6
- package/package.json +3 -3
- package/skills/generating-apex/SKILL.md +16 -9
- package/skills/generating-apex/assets/abstract.cls +0 -1
- package/skills/generating-apex/assets/batch.cls +0 -1
- package/skills/generating-apex/assets/domain.cls +0 -1
- package/skills/generating-apex/assets/dto.cls +0 -1
- package/skills/generating-apex/assets/exception.cls +0 -1
- package/skills/generating-apex/assets/interface.cls +0 -1
- package/skills/generating-apex/assets/invocable.cls +0 -1
- package/skills/generating-apex/assets/queueable.cls +0 -1
- package/skills/generating-apex/assets/schedulable.cls +0 -1
- package/skills/generating-apex/assets/selector.cls +0 -1
- package/skills/generating-apex/assets/service.cls +0 -1
- package/skills/generating-apex/assets/trigger.cls +1 -1
- package/skills/generating-apex/assets/utility.cls +0 -1
- package/skills/generating-apex/references/AccountDeduplicationBatch.cls +0 -1
- package/skills/generating-apex/references/AccountSelector.cls +0 -1
- package/skills/generating-apex/references/AccountService.cls +0 -1
- package/skills/generating-apex-test/assets/test-class-template.cls +3 -3
- package/skills/generating-apex-test/references/assertion-patterns.md +1 -1
- package/skills/generating-apex-test/references/async-testing.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
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# Color Hooks Decision Guide
|
|
2
|
+
|
|
3
|
+
This guide helps you choose the correct SLDS 2 color hook. Use it when replacing hardcoded colors or when the linter suggests multiple options.
|
|
4
|
+
|
|
5
|
+
> **BEFORE choosing any hook:** Always inspect the element's context in this order:
|
|
6
|
+
> 1. **Markup** (`.html` for LWC, `.cmp` for Aura) — search for the CSS class. Check parent containers, nesting depth, ARIA attributes, interactive role.
|
|
7
|
+
> 2. **JavaScript** — if not in markup, search the JS/TS files for dynamic class insertion (`classList.add`, template literals, conditional class bindings).
|
|
8
|
+
>
|
|
9
|
+
> CSS alone is never enough — always determine context from markup or JS before choosing a hook.
|
|
10
|
+
|
|
11
|
+
## Table of Contents
|
|
12
|
+
|
|
13
|
+
- [Hook Selection Priority](#hook-selection-priority)
|
|
14
|
+
- [Surface Family](#surface-family)
|
|
15
|
+
- [Accent Family](#accent-family)
|
|
16
|
+
- [Feedback Family](#feedback-family)
|
|
17
|
+
- [Palette Family](#palette-family)
|
|
18
|
+
- [System Family](#system-family)
|
|
19
|
+
- [Choosing the Numbered Variant](#choosing-the-numbered-variant)
|
|
20
|
+
- [Background-Foreground Pairing Rules](#background-foreground-pairing-rules)
|
|
21
|
+
- [Applied Examples](#applied-examples--color-context-investigation)
|
|
22
|
+
|
|
23
|
+
## Hook Selection Priority
|
|
24
|
+
|
|
25
|
+
**Always try semantic hooks first.** ~85-90% of color decisions should use semantic hooks. System and palette hooks are last resorts, not alternatives.
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
1. SEMANTIC HOOKS (try first, ~85-90% of decisions)
|
|
29
|
+
surface-*, accent-*, error/warning/success/info/disabled-*
|
|
30
|
+
• Accessibility built-in • Theme-aware • Dark mode ready
|
|
31
|
+
|
|
32
|
+
2. SYSTEM HOOKS (5-10%, only when no semantic family fits)
|
|
33
|
+
*-base-*
|
|
34
|
+
• Manual accessibility required • No semantic meaning
|
|
35
|
+
|
|
36
|
+
3. PALETTE (data viz & decorative only, <5%)
|
|
37
|
+
palette-*
|
|
38
|
+
• Manual accessibility • Non-semantic color only
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If you find yourself reaching for a system hook, re-check whether a semantic hook applies — surface, accent, or feedback families cover most cases.
|
|
42
|
+
|
|
43
|
+
**Decision flow:**
|
|
44
|
+
1. Page/overlay/container background? → Surface hooks
|
|
45
|
+
2. Brand/interactive? → Accent hooks
|
|
46
|
+
3. Error/warning/success/info/disabled state? → Feedback hooks
|
|
47
|
+
4. Edge case with no semantic fit? → System hooks
|
|
48
|
+
5. Data viz or decorative? → Palette hooks
|
|
49
|
+
|
|
50
|
+
> **Visual color density rule (85-5-10):** ~85% of UI surface area should be neutral grays/whites (surface hooks), ~5% accent/feedback colors, ~10% maximum expressive colors.
|
|
51
|
+
|
|
52
|
+
### "Color ≠ Semantic Meaning"
|
|
53
|
+
|
|
54
|
+
| Scenario | Wrong Choice | Right Choice | Why |
|
|
55
|
+
|----------|--------------|--------------|-----|
|
|
56
|
+
| Red text but no error class | `--slds-g-color-error-1` | `--slds-g-color-palette-red-50` | Color for emphasis, not error state |
|
|
57
|
+
| Blue that's not clickable | `--slds-g-color-accent-2` | `--slds-g-color-palette-cloud-blue-50` | Decorative blue, not interactive |
|
|
58
|
+
| Green in data chart | `--slds-g-color-success-1` | `--slds-g-color-palette-green-50` | Data point, not success state |
|
|
59
|
+
| Orange highlight span | `--slds-g-color-warning-1` | `--slds-g-color-palette-orange-90` | Visual emphasis, not warning |
|
|
60
|
+
|
|
61
|
+
Use system hooks if the element matches a semantic meaning. If it explicitly does not, use the palette equivalent (e.g., `--slds-g-color-palette-red-40`). Evaluate background-color first, as it informs the correct foreground color pair.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Surface Family
|
|
66
|
+
|
|
67
|
+
### Core Question
|
|
68
|
+
Is this element a page foundation, an overlay (modal/popover/dropdown), or does it sit within the content flow on an existing surface?
|
|
69
|
+
|
|
70
|
+
| Characteristic | Use `surface-*` | Use `surface-container-*` |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| Creates new stacking context | Yes | No |
|
|
73
|
+
| Elevated/overlays other content | Yes | No |
|
|
74
|
+
| Exists within page's content flow | No | Yes |
|
|
75
|
+
| Sits on top of an existing surface | No | Yes |
|
|
76
|
+
|
|
77
|
+
### Hook Types
|
|
78
|
+
|
|
79
|
+
| Hook Type | Pattern | Use For |
|
|
80
|
+
|---|---|---|
|
|
81
|
+
| Surface | `--slds-g-color-surface-1` / `-2` / `-3` | Pages, modals, popovers, overlays |
|
|
82
|
+
| Container | `--slds-g-color-surface-container-1` / `-2` / `-3` | Cards, buttons, panels on existing surfaces |
|
|
83
|
+
| On Surface | `--slds-g-color-on-surface-1` / `-2` / `-3` | Foreground (text, icons) on any surface or container |
|
|
84
|
+
| Inverse | `--slds-g-color-surface-inverse-1` / `-2` | Dark backgrounds on light themes (hero banners, inverted headers) |
|
|
85
|
+
|
|
86
|
+
### Surface Numbering (Light → Dark, NOT States)
|
|
87
|
+
|
|
88
|
+
Surface variants are an aesthetic progression, not interaction states:
|
|
89
|
+
|
|
90
|
+
| Variant | Description | Typical Use |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| `surface-1` | Lightest (white) | Clean base; cards/containers stand out against it |
|
|
93
|
+
| `surface-2` | Light gray | Softer separation; avoids harsh white backgrounds |
|
|
94
|
+
| `surface-3` | Medium gray | Additional depth; rare in practice |
|
|
95
|
+
|
|
96
|
+
The same numbering applies to `surface-container-*` (1=lightest, 3=darkest).
|
|
97
|
+
|
|
98
|
+
### On-Surface Emphasis Levels
|
|
99
|
+
|
|
100
|
+
On-surface variants represent **content emphasis**, not surface pairing:
|
|
101
|
+
|
|
102
|
+
| Variant | Emphasis | Use For |
|
|
103
|
+
|---|---|---|
|
|
104
|
+
| `on-surface-1` | Low (de-emphasized) | Captions, placeholder text, secondary content |
|
|
105
|
+
| `on-surface-2` | Medium (standard) | Body text, labels, filled input fields |
|
|
106
|
+
| `on-surface-3` | High (maximum weight) | Page titles, component headings, primary content |
|
|
107
|
+
|
|
108
|
+
All three `on-surface` variants can appear on the same surface background. Choose by content importance, not by matching the surface number.
|
|
109
|
+
|
|
110
|
+
### Markup Nesting Depth → Hook Choice
|
|
111
|
+
|
|
112
|
+
| DOM Position | Hook | Why |
|
|
113
|
+
|---|---|---|
|
|
114
|
+
| Page/app wrapper (`<body>` or root) | `surface-1` | Foundation canvas |
|
|
115
|
+
| Card/panel directly on page | `surface-container-1` | First container on a surface |
|
|
116
|
+
| Sub-panel inside a card | `surface-container-2` | Nested container |
|
|
117
|
+
| Modal / popover / dropdown | `surface-1` | Creates NEW stacking context — resets depth |
|
|
118
|
+
|
|
119
|
+
### State Progression
|
|
120
|
+
|
|
121
|
+
The starting variant depends on which one matches the original default color — don't assume `-1`:
|
|
122
|
+
|
|
123
|
+
| Default | Hover | When |
|
|
124
|
+
|---|---|---|
|
|
125
|
+
| `surface-container-1` | `surface-container-2` | Default bg is white/near-white |
|
|
126
|
+
| `surface-container-2` | `surface-container-3` | Default bg is light gray (~#f4f4f4) |
|
|
127
|
+
|
|
128
|
+
### Edge Cases
|
|
129
|
+
|
|
130
|
+
| Scenario | Hook | Why |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| Full-page card (IS the page background) | `surface-*` | Acts as page surface, not a container |
|
|
133
|
+
| Slide-out panel overlaying content | `surface-*` | Creates new stacking context |
|
|
134
|
+
| Slide-out panel in page flow (no overlay) | `surface-container-*` | Sits within existing surface |
|
|
135
|
+
| Nested modals | `surface-1` for each | Each modal creates its own stacking context |
|
|
136
|
+
| Dropdown over page content | `surface-1` | Overlay, not a container |
|
|
137
|
+
|
|
138
|
+
### Inverse Hooks
|
|
139
|
+
|
|
140
|
+
Use when hardcoded dark-blue backgrounds (`#032d60`, `#03234d`) appear on light themes. Pair with `--slds-g-color-on-surface-inverse-*` — do NOT pair with regular `on-surface-*`.
|
|
141
|
+
|
|
142
|
+
### Warning: CSS Class Names Are Irrelevant
|
|
143
|
+
|
|
144
|
+
An element named `.card-container` might use `surface-*` if it's the page-level background, or `surface-container-*` if it's a card. **Always base the decision on structural DOM position, not naming conventions.**
|
|
145
|
+
|
|
146
|
+
Surface variants (1-2-3) are a light-to-dark aesthetic progression, NOT functional states.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Accent Family
|
|
151
|
+
|
|
152
|
+
### Core Question
|
|
153
|
+
Is this element interactive or expressing brand identity?
|
|
154
|
+
|
|
155
|
+
### Hook Types
|
|
156
|
+
|
|
157
|
+
| Hook Type | Pattern | Use For |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| Accent | `accent-1` / `-2` / `-3` | Links, clickable text, interactive icons |
|
|
160
|
+
| Container | `accent-container-1` / `-2` / `-3` | Brand button backgrounds |
|
|
161
|
+
| Border | `border-accent-1` / `-2` / `-3` | High-emphasis brand borders |
|
|
162
|
+
| On Accent | `on-accent-1` / `-2` / `-3` | Text on brand backgrounds |
|
|
163
|
+
|
|
164
|
+
### Why accent-2 is the default for links (not accent-1)
|
|
165
|
+
|
|
166
|
+
`accent-1` may not meet 4.5:1 WCAG contrast on non-white backgrounds. `accent-2` passes on all standard surfaces — use it as the safe default for text links. Go up one for hover: `accent-2` → `accent-3`.
|
|
167
|
+
|
|
168
|
+
### Quick Decision
|
|
169
|
+
|
|
170
|
+
1. Link or clickable text → `accent-2`
|
|
171
|
+
2. Brand button background → `accent-container-1`
|
|
172
|
+
3. Text on brand background → `on-accent-1`
|
|
173
|
+
4. Brand border → `border-accent-1` (use only when design explicitly requires brand-colored outline — default to neutral `border-2` for most borders)
|
|
174
|
+
|
|
175
|
+
### Accent vs Surface
|
|
176
|
+
|
|
177
|
+
| Element Type | Surface | Accent |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| Non-interactive card | `surface-container-*` | Never |
|
|
180
|
+
| Clickable card | `surface-container-*` (bg) | `accent-2` (text) |
|
|
181
|
+
| Primary button | Never | `accent-container-*` |
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Feedback Family
|
|
186
|
+
|
|
187
|
+
### Core Question
|
|
188
|
+
Does the markup/ARIA context indicate a specific state?
|
|
189
|
+
|
|
190
|
+
### Hook Types
|
|
191
|
+
|
|
192
|
+
| Type | Use For |
|
|
193
|
+
|---|---|
|
|
194
|
+
| `error-*` / `error-container-*` / `on-error-*` / `border-error-*` | Invalid inputs, errors, destructive actions |
|
|
195
|
+
| `warning-*` / `warning-container-*` / `on-warning-*` / `border-warning-*` | Cautions, alerts |
|
|
196
|
+
| `success-*` / `success-container-*` / `on-success-*` / `border-success-*` | Confirmations, valid states |
|
|
197
|
+
| `info-*` / `info-container-*` / `on-info-*` | Tips, help badges |
|
|
198
|
+
| `disabled-*` / `disabled-container-*` / `on-disabled-*` / `border-disabled-*` | Inactive elements |
|
|
199
|
+
|
|
200
|
+
### Quick Decision
|
|
201
|
+
|
|
202
|
+
1. `aria-invalid` attribute → `error-*`
|
|
203
|
+
2. Class with "error"/"invalid" → `error-*`
|
|
204
|
+
3. Class with "success"/"valid" → `success-*`
|
|
205
|
+
4. `[disabled]` attribute → `disabled-*`
|
|
206
|
+
5. `role="alert"` → check alert type
|
|
207
|
+
|
|
208
|
+
### Variant Availability
|
|
209
|
+
|
|
210
|
+
| Type | Has -2? | Why |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| Error | Yes | Destructive buttons need hover states |
|
|
213
|
+
| Success | Yes | Success buttons need hover states |
|
|
214
|
+
| Warning | No (only -1) | No warning buttons — only static alerts |
|
|
215
|
+
| Info | No (only -1) | No info buttons — only static badges |
|
|
216
|
+
| Disabled | Yes | Different visual weights |
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Palette Family
|
|
221
|
+
|
|
222
|
+
### Core Question
|
|
223
|
+
Is this color for data visualization or decoration without semantic meaning?
|
|
224
|
+
|
|
225
|
+
Use for: chart data series, decorative gradients, non-semantic colored elements — NOT standard UI.
|
|
226
|
+
|
|
227
|
+
**Hook Pattern:** `--slds-g-color-palette-{color}-{grade}`
|
|
228
|
+
|
|
229
|
+
**Grade Scale:** 0 (darkest) to 100 (lightest). Example: `--slds-g-color-palette-cloud-blue-50`.
|
|
230
|
+
|
|
231
|
+
**Cool Tones (Recommended):** `cloud-blue`, `indigo`, `purple`, `violet`
|
|
232
|
+
**Warm Tones (Use with caution):** `green`, `orange`, `hot-orange`, `red`
|
|
233
|
+
|
|
234
|
+
Warm tones risk confusion with feedback colors — green looks like success, red looks like error, orange looks like warning. Only use palette hooks when the color explicitly does NOT carry semantic meaning.
|
|
235
|
+
|
|
236
|
+
### Palette → Semantic Conversion
|
|
237
|
+
|
|
238
|
+
If existing code uses palette hooks but the element is actually interactive or semantic, convert to the appropriate semantic family:
|
|
239
|
+
|
|
240
|
+
| Element Role | Palette Hook (Before) | Semantic Hook (After) |
|
|
241
|
+
|---|---|---|
|
|
242
|
+
| Clickable icon/link | `palette-*-blue-*` | `accent-*` |
|
|
243
|
+
| Brand button bg | `palette-*-*` | `accent-container-*` |
|
|
244
|
+
| Error indicator | `palette-red-*` | `error-*` |
|
|
245
|
+
| Success indicator | `palette-green-*` | `success-*` |
|
|
246
|
+
| Chart data point | `palette-*` | Keep palette (correct usage) |
|
|
247
|
+
| Decorative element | `palette-*` | Keep palette (correct usage) |
|
|
248
|
+
|
|
249
|
+
Check markup context: if the element has click handlers, `href`, `role="button"`, or brand intent, it belongs in a semantic family.
|
|
250
|
+
|
|
251
|
+
### Accessibility
|
|
252
|
+
|
|
253
|
+
Palette hooks do NOT guarantee accessible contrast. Verify manually:
|
|
254
|
+
- **50-point rule:** 50 grade points between bg and text (4.5:1 WCAG)
|
|
255
|
+
- **40-point rule:** 40 grade points between bg and UI element (3:1 WCAG)
|
|
256
|
+
|
|
257
|
+
**Color vision deficiency:** Never use red+green or blue+purple as sole differentiators. Always pair with patterns, labels, or shapes.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## System Family
|
|
262
|
+
|
|
263
|
+
### Core Question
|
|
264
|
+
Have all semantic and palette options been exhausted?
|
|
265
|
+
|
|
266
|
+
| Need | Try First | System Fallback | Only If |
|
|
267
|
+
|---|---|---|---|
|
|
268
|
+
| Background | `surface-*` | `neutral-base-95` | Custom component, no semantic fit |
|
|
269
|
+
| Interactive | `accent-*` | `brand-base-50` | Legacy exact match required |
|
|
270
|
+
| Error state | `error-*` | `error-base-50` | Special non-standard requirement |
|
|
271
|
+
|
|
272
|
+
System hooks require manual accessibility testing. Never use as a first choice.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Choosing the Numbered Variant
|
|
277
|
+
|
|
278
|
+
**Do not default to `-1`.** Numbered variants represent a light-to-dark progression. Pick the variant whose actual rendered value best matches the original hardcoded value.
|
|
279
|
+
|
|
280
|
+
1. Look at the original hardcoded value
|
|
281
|
+
2. Compare to the rendered values of available variants
|
|
282
|
+
3. Pick the closest match, not the lowest number
|
|
283
|
+
|
|
284
|
+
```css
|
|
285
|
+
/* Original: #014486 — very dark navy */
|
|
286
|
+
/* WRONG: defaulting to -1 */
|
|
287
|
+
border-color: var(--slds-g-color-border-accent-1, #014486);
|
|
288
|
+
/* RIGHT: -3 is darkest, closest to #014486 */
|
|
289
|
+
border-color: var(--slds-g-color-border-accent-3, #014486);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
```css
|
|
293
|
+
/* Original: rgb(243,242,242) — very light gray */
|
|
294
|
+
/* container-1 ≈ #fff, container-2 ≈ #f4f4f4, container-3 ≈ #f3f2f2 */
|
|
295
|
+
/* RIGHT: container-3 is closest */
|
|
296
|
+
background-color: var(--slds-g-color-surface-container-3, rgb(243,242,242));
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
When an element has interactive states, variants progress sequentially from the starting match:
|
|
300
|
+
|
|
301
|
+
| Start At | Hover | Active |
|
|
302
|
+
|---|---|---|
|
|
303
|
+
| `-1` | `-2` | `-3` |
|
|
304
|
+
| `-2` | `-3` | — |
|
|
305
|
+
|
|
306
|
+
---
|
|
307
|
+
|
|
308
|
+
## Background-Foreground Pairing Rules
|
|
309
|
+
|
|
310
|
+
| If background uses... | Then text/fill MUST use... |
|
|
311
|
+
|---|---|
|
|
312
|
+
| `surface-*` or `surface-container-*` | `on-surface-*` |
|
|
313
|
+
| `surface-inverse-*` or `surface-container-inverse-*` | `on-surface-inverse-*` |
|
|
314
|
+
| `accent-container-*` | `on-accent-*` |
|
|
315
|
+
| `error-container-*` | `on-error-*` |
|
|
316
|
+
| `warning-container-*` | `on-warning-*` |
|
|
317
|
+
| `success-container-*` | `on-success-*` |
|
|
318
|
+
| `info-container-*` | `on-info-*` |
|
|
319
|
+
| `disabled-container-*` | `on-disabled-*` |
|
|
320
|
+
|
|
321
|
+
**Never mix families** — e.g., don't use `on-accent-*` on a `surface-container-*` background.
|
|
322
|
+
|
|
323
|
+
### Border Color Decision
|
|
324
|
+
|
|
325
|
+
| Context | Hook |
|
|
326
|
+
|---|---|
|
|
327
|
+
| Interactive element (default) | `border-2` (primary choice for most borders) |
|
|
328
|
+
| Decorative divider | `border-1` |
|
|
329
|
+
| Validation state | `border-[state]-1` |
|
|
330
|
+
| Disabled | `border-disabled-1` |
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## Applied Examples — Color Context Investigation
|
|
335
|
+
|
|
336
|
+
### Context from Class Name
|
|
337
|
+
|
|
338
|
+
```css
|
|
339
|
+
/* Before — recordPage.css */
|
|
340
|
+
.headerBackground {
|
|
341
|
+
background: var(--lwc-colorBackgroundAlt);
|
|
342
|
+
}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Decision:** From class name `headerBackground`, this is a header container on another surface → `surface-container-1`.
|
|
346
|
+
|
|
347
|
+
```css
|
|
348
|
+
/* After */
|
|
349
|
+
.headerBackground {
|
|
350
|
+
background: var(--slds-g-color-surface-container-1, var(--lwc-colorBackgroundAlt));
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Context from Component Name
|
|
355
|
+
|
|
356
|
+
```css
|
|
357
|
+
/* Before — defaultOrgSharingSettingsPanelFooter.css */
|
|
358
|
+
.THIS {
|
|
359
|
+
background-color: t(colorBackground);
|
|
360
|
+
}
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Decision:** `.THIS` alone isn't enough. Component name says panel footer → container on a panel surface → `surface-container-2`.
|
|
364
|
+
|
|
365
|
+
```css
|
|
366
|
+
/* After */
|
|
367
|
+
.THIS {
|
|
368
|
+
background-color: var(--slds-g-color-surface-container-2, var(--lwc-colorBackground));
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Context from Deep Investigation (Markup + JS)
|
|
373
|
+
|
|
374
|
+
```css
|
|
375
|
+
/* Before — floatingPanelContent.css */
|
|
376
|
+
.main-body {
|
|
377
|
+
background-color: var(--lwc-colorBackgroundAlt);
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
**Investigation:**
|
|
382
|
+
- Component name `floatingPanelContent` is ambiguous
|
|
383
|
+
- `.main-body` not found in markup — it's a computed class
|
|
384
|
+
- JS shows the class is applied alongside `slds-popover*` classes
|
|
385
|
+
|
|
386
|
+
**Decision:** Main background of a popover → surface element → `surface-1`.
|
|
387
|
+
|
|
388
|
+
```css
|
|
389
|
+
/* After */
|
|
390
|
+
.main-body {
|
|
391
|
+
background-color: var(--slds-g-color-surface-1, var(--lwc-colorBackgroundAlt));
|
|
392
|
+
}
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
### Border Color — Semantic Fit Over Math
|
|
396
|
+
|
|
397
|
+
```css
|
|
398
|
+
/* Before */
|
|
399
|
+
border: 1px solid #dddbda;
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Decision:** Mathematically closest might be `palette-neutral-90`, but `border-1` is still light grey, fits the design intention, and fits the semantic system better.
|
|
403
|
+
|
|
404
|
+
```css
|
|
405
|
+
/* After */
|
|
406
|
+
border: var(--slds-g-sizing-border-1, 1px) solid var(--slds-g-color-border-1, #dddbda);
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Pairing Examples
|
|
410
|
+
|
|
411
|
+
**Card on page surface:**
|
|
412
|
+
```css
|
|
413
|
+
.product-card {
|
|
414
|
+
background-color: var(--slds-g-color-surface-container-1, #ffffff);
|
|
415
|
+
color: var(--slds-g-color-on-surface-1, #2e2e2e);
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**Brand button:**
|
|
420
|
+
```css
|
|
421
|
+
.primary-action {
|
|
422
|
+
background: var(--slds-g-color-accent-container-1, #066afe);
|
|
423
|
+
color: var(--slds-g-color-on-accent-1, #ffffff);
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
**Error alert (role="alert" + error class):**
|
|
428
|
+
```css
|
|
429
|
+
.error-message {
|
|
430
|
+
background: var(--slds-g-color-error-container-1, #fddde3);
|
|
431
|
+
color: var(--slds-g-color-on-error-1, #b60554);
|
|
432
|
+
border: 1px solid var(--slds-g-color-border-error-1, #b60554);
|
|
433
|
+
}
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Linter vs Agent Decision-Making
|
|
437
|
+
|
|
438
|
+
Linters suggest hooks by **color similarity** — they match hex values regardless of meaning. Agents must choose by **semantic family** — inspect markup (`.html`/`.cmp`), ARIA attributes, and element purpose. Always prioritize semantic correctness over color matching.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Common Patterns
|
|
2
|
+
|
|
3
|
+
Frequently encountered patterns, class lists, and edge cases for SLDS 2 migration.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Deprecated SLDS 2 Classes
|
|
8
|
+
|
|
9
|
+
These classes are removed in SLDS 2. Remove them from markup (`.html` for LWC, `.cmp` for Aura):
|
|
10
|
+
|
|
11
|
+
| Deprecated Class | Action |
|
|
12
|
+
|---|---|
|
|
13
|
+
| `slds-icon-utility-error` | Remove — icon component handles styling |
|
|
14
|
+
| `slds-icon-utility-*` (all variants) | Remove — use icon component variants instead |
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<!-- Before -->
|
|
18
|
+
<span class="slds-icon_container slds-icon-utility-error">
|
|
19
|
+
|
|
20
|
+
<!-- After -->
|
|
21
|
+
<span class="slds-icon_container">
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Color Palette Fallbacks
|
|
27
|
+
|
|
28
|
+
When using palette hooks for data visualization or decorative color, include RGB fallbacks:
|
|
29
|
+
|
|
30
|
+
| SLDS2 Hook | RGB Fallback | Common Use |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `--slds-g-color-palette-red-40` | `rgb(181,54,45)` | Critical indicators, data viz |
|
|
33
|
+
| `--slds-g-color-palette-blue-50` | `rgb(0,112,210)` | Brand colors, primary actions |
|
|
34
|
+
| `--slds-g-color-palette-green-50` | `rgb(4,132,75)` | Positive indicators, data viz |
|
|
35
|
+
|
|
36
|
+
```css
|
|
37
|
+
color: var(--slds-g-color-palette-red-40, rgb(181,54,45));
|
|
38
|
+
background: var(--slds-g-color-palette-blue-50, rgb(0,112,210));
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For transparency with palette hooks, use `color-mix()` — see Advanced Patterns in [SKILL.md](../SKILL.md).
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Tokens with No SLDS 2 Equivalent
|
|
46
|
+
|
|
47
|
+
Some legacy tokens have no direct SLDS 2 hook. Use `--lwc-*` or hardcoded values:
|
|
48
|
+
|
|
49
|
+
| Token | Action | Replacement |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `lineHeightButton` | Use `--lwc-*` directly | `var(--lwc-lineHeightButton)` |
|
|
52
|
+
| `durationInstantly` | Use `--lwc-*` directly | `var(--lwc-durationInstantly)` |
|
|
53
|
+
| `durationPromptly` | Use `--lwc-*` directly | `var(--lwc-durationPromptly)` |
|
|
54
|
+
| `durationSlowly` | Use `--lwc-*` directly | `var(--lwc-durationSlowly)` |
|
|
55
|
+
| `zIndexSticky` | Use hardcoded value | `9000` |
|
|
56
|
+
|
|
57
|
+
**Do not invent `--slds-g-*` hooks** for these tokens. The linter will flag invented hooks with `slds/no-slds-namespace-for-custom-hooks`.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Custom Hook Namespace
|
|
62
|
+
|
|
63
|
+
When no SLDS 2 hook exists for an internal/custom value, use `--lwc-*` directly. Do not use the `--slds-g-*` namespace for custom purposes.
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
/* Bad — inventing SLDS namespace for internal values */
|
|
67
|
+
transition: var(--slds-g-duration-slowly, var(--lwc-durationSlowly));
|
|
68
|
+
|
|
69
|
+
/* Good — use --lwc-* when no official SLDS 2 equivalent */
|
|
70
|
+
transition: var(--lwc-durationSlowly);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Font-Family Post-Linter Cleanup
|
|
76
|
+
|
|
77
|
+
After the linter runs, it may add verbose font-stack fallbacks to `font-family`. For **font-family only**, trim to just the hook tokens — remove the hardcoded font stack:
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
/* Linter output — verbose */
|
|
81
|
+
font-family: var(--slds-g-font-family, var(--lwc-fontFamily, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif));
|
|
82
|
+
|
|
83
|
+
/* Cleaned up — tokens only */
|
|
84
|
+
font-family: var(--slds-g-font-family, var(--lwc-fontFamily));
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For all other properties, **keep** the linter's rgb/rem/px fallbacks.
|