@revikornmann/muka-ui 0.45.0 → 0.45.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/dist/styles/fonts/funnel-display-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/funnel-sans-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/ibm-plex-sans-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/lora-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/quicksand-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/red-hat-display-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/red-hat-text-latin-ext-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/yesteryear-latin-ext-400-normal.woff2 +0 -0
- package/dist/styles/fonts-all.css +88 -0
- package/dist/styles/fonts-bouwplan.css +33 -0
- package/dist/styles/fonts-fscl.css +22 -0
- package/dist/styles/fonts-grip.css +22 -0
- package/dist/styles/fonts-muka.css +33 -0
- package/dist/styles/index.css +788 -755
- package/dist/styles/muka-dark.css +788 -755
- package/dist/styles/muka-light.css +788 -755
- package/dist/styles/wireframe-dark.css +1064 -1064
- package/dist/styles/wireframe-light.css +1064 -1064
- package/docs/consumers/brand.md +4 -1
- package/package.json +1 -1
- package/scripts/build-fonts.js +59 -25
package/docs/consumers/brand.md
CHANGED
|
@@ -176,7 +176,10 @@ brand. You have three options:
|
|
|
176
176
|
`system-ui`, and friends need no loading.
|
|
177
177
|
3. **Bring your own** — self-host it with your own `@font-face` under the exact
|
|
178
178
|
family name from `fonts.json`. Don't use a Google Fonts `<link>`: it breaks
|
|
179
|
-
offline and air-gapped installs and adds a render-blocking request.
|
|
179
|
+
offline and air-gapped installs and adds a render-blocking request. Include
|
|
180
|
+
the latin-ext subset as well as latin, as Muka's own fonts files do;
|
|
181
|
+
without it Polish, Turkish and other Central European letters (ą ł ś ğ İ)
|
|
182
|
+
fall back to a system font.
|
|
180
183
|
|
|
181
184
|
## Build and load the CSS
|
|
182
185
|
|
package/package.json
CHANGED
package/scripts/build-fonts.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* but ships no way to *load* them. This script closes that gap: it reads each brand's
|
|
10
10
|
* font source-of-truth (`tokens/t2-alias/brand/<brand>/fonts.json`), and for every web
|
|
11
11
|
* font a brand references it:
|
|
12
|
-
* 1. copies the latin-
|
|
13
|
-
* `styles/fonts/`, plus the family's OFL license file, and
|
|
14
|
-
* 2. emits `styles/fonts-<brand>.css` with
|
|
15
|
-
* literal family name the tokens use (so
|
|
12
|
+
* 1. copies the latin and latin-ext WOFF2 subsets (from the vendored @fontsource
|
|
13
|
+
* packages) into `styles/fonts/`, plus the family's OFL license file, and
|
|
14
|
+
* 2. emits `styles/fonts-<brand>.css` with one `@font-face` per subset, declared under
|
|
15
|
+
* the exact literal family name the tokens use (so `var(--*-fontFamily)` resolves).
|
|
16
|
+
* The browser downloads a subset only when the page uses a character in its
|
|
17
|
+
* unicode-range, so latin-ext costs nothing on pages without accented letters.
|
|
16
18
|
* It also emits an aggregate `styles/fonts-all.css` (every face once) for Storybook and
|
|
17
19
|
* optional multi-brand consumers.
|
|
18
20
|
*
|
|
@@ -33,12 +35,37 @@ const NODE_MODULES = path.join(ROOT_DIR, 'node_modules');
|
|
|
33
35
|
const FONTS_OUT_DIR = path.join(ROOT_DIR, 'styles', 'fonts');
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
|
-
*
|
|
38
|
+
* The Google/Fontsource subsets we ship, with their unicode-ranges. Identical across every
|
|
37
39
|
* @fontsource(-variable) package we bundle.
|
|
40
|
+
*
|
|
41
|
+
* `latin` covers Western European languages. `latin-ext` adds the letters of Polish
|
|
42
|
+
* (ą ę ł ń ś ź ż), Turkish (ğ ş İ), Czech, Romanian, Hungarian and the other Central
|
|
43
|
+
* and Eastern European languages. Without it those letters fall back to a system font
|
|
44
|
+
* and look out of place next to the brand font.
|
|
45
|
+
*
|
|
46
|
+
* The registry names the latin file; the latin-ext file is the same name with
|
|
47
|
+
* `-latin-` replaced by `-latin-ext-` (the fontsource convention).
|
|
38
48
|
*/
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
const SUBSETS = [
|
|
50
|
+
{
|
|
51
|
+
name: 'latin',
|
|
52
|
+
unicodeRange:
|
|
53
|
+
'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,' +
|
|
54
|
+
'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'latin-ext',
|
|
58
|
+
unicodeRange:
|
|
59
|
+
'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,' +
|
|
60
|
+
'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,' +
|
|
61
|
+
'U+2C60-2C7F,U+A720-A7FF',
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/** The WOFF2 file name of a registry entry for one subset. */
|
|
66
|
+
function subsetFile(entry, subset) {
|
|
67
|
+
return subset === 'latin' ? entry.file : entry.file.replace('-latin-', `-${subset}-`);
|
|
68
|
+
}
|
|
42
69
|
|
|
43
70
|
/**
|
|
44
71
|
* Font registry — the single mapping from a token font-family *name* to the WOFF2 source
|
|
@@ -138,14 +165,19 @@ function weightRange(entry) {
|
|
|
138
165
|
return `${wght.min} ${wght.max}`;
|
|
139
166
|
}
|
|
140
167
|
|
|
141
|
-
/** Copy a family's WOFF2 + LICENSE into styles/fonts/.
|
|
168
|
+
/** Copy a family's WOFF2 files (one per subset) + LICENSE into styles/fonts/. */
|
|
142
169
|
function vendorFontFiles(face) {
|
|
143
170
|
const entry = FONT_REGISTRY[face];
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
171
|
+
for (const subset of SUBSETS) {
|
|
172
|
+
const file = subsetFile(entry, subset.name);
|
|
173
|
+
const srcWoff2 = path.join(NODE_MODULES, entry.pkg, 'files', file);
|
|
174
|
+
if (!fs.existsSync(srcWoff2)) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`Missing ${subset.name} WOFF2 for "${face}": ${srcWoff2} (is ${entry.pkg} installed?)`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
fs.copyFileSync(srcWoff2, path.join(FONTS_OUT_DIR, file));
|
|
147
180
|
}
|
|
148
|
-
fs.copyFileSync(srcWoff2, path.join(FONTS_OUT_DIR, entry.file));
|
|
149
181
|
|
|
150
182
|
// Ship the OFL license alongside the font. Name it after the package slug.
|
|
151
183
|
const srcLicense = path.join(NODE_MODULES, entry.pkg, 'LICENSE');
|
|
@@ -155,23 +187,25 @@ function vendorFontFiles(face) {
|
|
|
155
187
|
} else {
|
|
156
188
|
console.warn(` ⚠️ No LICENSE found for ${entry.pkg}`);
|
|
157
189
|
}
|
|
158
|
-
return entry.file;
|
|
159
190
|
}
|
|
160
191
|
|
|
161
|
-
/** Build
|
|
192
|
+
/** Build the `@font-face` blocks for a face: one per subset (relative url, swap). */
|
|
162
193
|
function fontFaceBlock(face) {
|
|
163
194
|
const entry = FONT_REGISTRY[face];
|
|
164
195
|
const weight = entry.variable ? weightRange(entry) : String(entry.weight);
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
196
|
+
return SUBSETS.map((subset) =>
|
|
197
|
+
[
|
|
198
|
+
`/* ${face} — ${subset.name} */`,
|
|
199
|
+
'@font-face {',
|
|
200
|
+
` font-family: '${face}';`,
|
|
201
|
+
` font-style: normal;`,
|
|
202
|
+
` font-weight: ${weight};`,
|
|
203
|
+
` font-display: swap;`,
|
|
204
|
+
` src: url('./fonts/${subsetFile(entry, subset.name)}') format('woff2');`,
|
|
205
|
+
` unicode-range: ${subset.unicodeRange};`,
|
|
206
|
+
'}',
|
|
207
|
+
].join('\n')
|
|
208
|
+
).join('\n\n');
|
|
175
209
|
}
|
|
176
210
|
|
|
177
211
|
function cssHeader(title) {
|