Skip to content

Commit 93881db

Browse files
committed
chore: update theme docs
1 parent 2397212 commit 93881db

File tree

3 files changed

+191
-285
lines changed

3 files changed

+191
-285
lines changed

tools/reactive-controllers/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
### Reactive controllers
66

7-
- [ColorController](../color-controller)
8-
- [ElementResolutionController](../element-resolution)
9-
- FocusGroupController
10-
- LanguageResolutionController
11-
- [MatchMediaController](../match-media)
12-
- [RovingTabindexController](../roving-tab-index)
13-
- [PendingStateController](../pending-state)
14-
- SystemContextResolutionController
7+
- [ColorController](../color-controller)
8+
- [ElementResolutionController](../element-resolution)
9+
- FocusGroupController
10+
- LanguageResolutionController
11+
- [MatchMediaController](../match-media)
12+
- [RovingTabindexController](../roving-tab-index)
13+
- [PendingStateController](../pending-state)
14+
- [SystemContextResolutionController](../system-context-resolution)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
## Description
2+
3+
System context (private beta API — subject to change)
4+
5+
The `<sp-theme>` element provides a private beta “system” context. Components can consume it via a controller that resolves the current system (e.g. `spectrum`, `express`, `spectrum-two`) and notifies on change.
6+
7+
### Usage
8+
9+
[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/reactive-controllers?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/reactive-controllers)
10+
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/reactive-controllers?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/reactive-controllers)
11+
12+
```
13+
yarn add @spectrum-web-components/reactive-controllers
14+
```
15+
16+
Import the controller and symbol via:
17+
18+
```
19+
import {
20+
SystemResolutionController,
21+
systemResolverUpdatedSymbol,
22+
} from '@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js';
23+
import type { SystemVariant } from '@spectrum-web-components/theme';
24+
```
25+
26+
## Example
27+
28+
Consume the system context and respond to updates in a LitElement host:
29+
30+
```js
31+
import { html, LitElement } from 'lit';
32+
import {
33+
SystemResolutionController,
34+
systemResolverUpdatedSymbol,
35+
} from '@spectrum-web-components/reactive-controllers/src/SystemContextResolution.js';
36+
37+
class MyComponent extends LitElement {
38+
systemResolver = new SystemResolutionController(this);
39+
40+
protected update(changes) {
41+
super.update(changes);
42+
if (changes.has(systemResolverUpdatedSymbol)) {
43+
this.handleSystemChange();
44+
}
45+
}
46+
47+
handleSystemChange() {
48+
const currentSystem = this.systemResolver.system; // "spectrum" | "express" | "spectrum-two"
49+
// react to system updates: adjust styles, state, or rendering
50+
}
51+
52+
render() {
53+
return html`Current system: ${this.systemResolver.system}`;
54+
}
55+
}
56+
```
57+
58+
## Notes
59+
60+
- This is a private beta API and may change.
61+
- If no `<sp-theme>` is present, `system` remains `"spectrum"` until a provider appears.
62+
- Pair with explicit `<sp-theme system="…" color="…" scale="…">` to avoid fallback behavior and ensure predictable theming.

0 commit comments

Comments
 (0)