@motion-proto/live-tokens 0.65.0 → 0.65.1
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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/editor/core/fonts/fontLoader.ts +18 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.65.1 — applyFontStacks returns what it wrote
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **`applyFontStacks` returns the variables it wrote.** It writes the `--font-*`
|
|
8
|
+
stacks from a list it kept to itself, so a consumer tracking what it had
|
|
9
|
+
applied — to tear those vars down when switching looks — had to hand-maintain
|
|
10
|
+
a copy of that list. A copy falls behind silently the moment a stack is added
|
|
11
|
+
here, and the missed variable stays stuck at the outgoing look's value:
|
|
12
|
+
`--font-editorial` did exactly that to a site that had listed the original
|
|
13
|
+
four. The return value is additive, so existing calls keep working.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
applied = [...applied, ...applyFontStacks(theme.fontStacks, theme.fontSources)];
|
|
17
|
+
```
|
|
18
|
+
|
|
3
19
|
## 0.65.0 — A link the router cannot serve is the browser's
|
|
4
20
|
|
|
5
21
|
### Fixed
|
package/package.json
CHANGED
|
@@ -129,12 +129,27 @@ export function resolveFontStackValues(
|
|
|
129
129
|
* Compose each stack into its resolved "family1, family2, ..." string and
|
|
130
130
|
* write it to the matching --font-* variable on :root (and parent :root when
|
|
131
131
|
* in an iframe) via the same pipeline used for color variables.
|
|
132
|
+
*
|
|
133
|
+
* Returns the variables it set, so a caller tracking what it has applied — to
|
|
134
|
+
* tear those vars down when switching looks — can record them without keeping
|
|
135
|
+
* its own copy of the stack list. A hand-maintained copy silently falls behind
|
|
136
|
+
* whenever a stack is added here, leaving the missed variable stuck at the
|
|
137
|
+
* outgoing look's value; `--font-editorial` did exactly that.
|
|
132
138
|
*/
|
|
133
|
-
export function applyFontStacks(
|
|
139
|
+
export function applyFontStacks(
|
|
140
|
+
stacks: FontStack[],
|
|
141
|
+
sources: FontSource[],
|
|
142
|
+
): FontStackVariable[] {
|
|
134
143
|
const resolved = resolveFontStackValues(stacks, sources);
|
|
144
|
+
const applied: FontStackVariable[] = [];
|
|
135
145
|
for (const name of FONT_STACK_VARIABLES) {
|
|
136
146
|
const value = resolved[name];
|
|
137
|
-
if (value)
|
|
138
|
-
|
|
147
|
+
if (value) {
|
|
148
|
+
setCssVar(name, value);
|
|
149
|
+
applied.push(name);
|
|
150
|
+
} else {
|
|
151
|
+
removeCssVar(name);
|
|
152
|
+
}
|
|
139
153
|
}
|
|
154
|
+
return applied;
|
|
140
155
|
}
|