Skip to content

Commit 20d488c

Browse files
committed
feat: naming change
1 parent 556c238 commit 20d488c

File tree

7 files changed

+1337
-1373
lines changed

7 files changed

+1337
-1373
lines changed

packages/container/src/build.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { fontFaceToString } from './font/font-face-to-string'
4040
import { fontFamilyJoin } from './font/font-family-join'
4141
import { fontInspect } from './font/font-inspect'
4242
import { fontLoaderScript } from './font/font-loader-script'
43+
import { fontName } from './font/font-name'
4344
import { fontNames } from './font/font-names'
4445
import { fontResourceHints } from './font/font-resource-hints'
4546
import { fontSort } from './font/font-sort'
@@ -53,7 +54,6 @@ import { optimizeAst } from './utilities/optimize-ast'
5354
import { reduceGraph } from './utilities/reduce-graph'
5455
import { round } from './utilities/round'
5556
import { toposort } from './utilities/toposort'
56-
import { fontName } from './font/font-name'
5757

5858
const findNode = (node: AstNode): AstNode[] => {
5959
assert(node.kind === 'at-rule')
@@ -88,7 +88,7 @@ const toLang = (locale: string, configuration: Configuration): string => {
8888
}
8989

9090
const toWebFontLocale = (styles: Style[], configuration: Configuration): Locale => {
91-
const prefixes = uniq(styles.map((value) => value.prefix))
91+
const stacks = uniq(styles.map((value) => value.stack))
9292

9393
const style = minifyCss(
9494
toCss(
@@ -160,7 +160,7 @@ const toWebFontLocale = (styles: Style[], configuration: Configuration): Locale
160160
fontFace,
161161
fonts: outputFont,
162162
order,
163-
prefixes,
163+
stacks,
164164
style,
165165
}
166166

@@ -340,22 +340,22 @@ export const build = async () => {
340340
}
341341

342342
style.propertiesMetrics = {
343-
[`--${style.prefix}-ascent`]: round(
343+
[`--${style.stack}-ascent`]: round(
344344
fontPrimaryInformation.ascent / fontPrimaryInformation.unitsPerEm,
345345
),
346-
[`--${style.prefix}-cap-height`]: round(
346+
[`--${style.stack}-cap-height`]: round(
347347
fontPrimaryInformation.capHeight / fontPrimaryInformation.unitsPerEm,
348348
),
349-
[`--${style.prefix}-descent`]: round(
349+
[`--${style.stack}-descent`]: round(
350350
Math.abs(fontPrimaryInformation.descent / fontPrimaryInformation.unitsPerEm),
351351
),
352-
[`--${style.prefix}-line-gap`]: round(
352+
[`--${style.stack}-line-gap`]: round(
353353
fontPrimaryInformation.lineGap / fontPrimaryInformation.unitsPerEm,
354354
),
355-
[`--${style.prefix}-x-height`]: round(
355+
[`--${style.stack}-x-height`]: round(
356356
Math.abs(fontPrimaryInformation.xHeight / fontPrimaryInformation.unitsPerEm),
357357
),
358-
[`--${style.prefix}-x-width-average`]: round(
358+
[`--${style.stack}-x-width-average`]: round(
359359
xWidthAverage(locales, ...requiredFontInformation),
360360
),
361361
}
@@ -380,7 +380,7 @@ export const build = async () => {
380380

381381
style.propertiesNoScript = pickBy(
382382
{
383-
[`--${style.prefix}-font-family`]: fontFamilyJoin([
383+
[`--${style.stack}-font-family`]: fontFamilyJoin([
384384
...userFontFamilies.map((value) => value.fontFamily),
385385
...localFontFamilies,
386386
...genericFontFamilies,
@@ -391,15 +391,15 @@ export const build = async () => {
391391

392392
style.propertiesLocal = pickBy(
393393
{
394-
[`--${style.prefix}-font-family`]: fontFamilyJoin([
394+
[`--${style.stack}-font-family`]: fontFamilyJoin([
395395
...localFontFamilies,
396396
...genericFontFamilies,
397397
]),
398-
[`--${style.prefix}-font-stretch`]:
398+
[`--${style.stack}-font-stretch`]:
399399
propertiesUser?.fontStretch === undefined ? undefined : `${propertiesUser.fontStretch}%`,
400-
[`--${style.prefix}-font-style`]: propertiesUser?.fontStyle,
401-
[`--${style.prefix}-font-variation-settings`]: selectorFontVariationSettings(style),
402-
[`--${style.prefix}-font-weight`]: propertiesUser?.fontWeight,
400+
[`--${style.stack}-font-style`]: propertiesUser?.fontStyle,
401+
[`--${style.stack}-font-variation-settings`]: selectorFontVariationSettings(style),
402+
[`--${style.stack}-font-weight`]: propertiesUser?.fontWeight,
403403
},
404404
(value) => value !== undefined,
405405
)
@@ -457,7 +457,7 @@ export const build = async () => {
457457
return styleRule(selector, [
458458
styleRule(
459459
toLang(style.locale, configuration),
460-
applyStyleAtRules(style, [decl(`--${style.prefix}-font-family`, fontFamily)]),
460+
applyStyleAtRules(style, [decl(`--${style.stack}-font-family`, fontFamily)]),
461461
),
462462
])
463463
}),

packages/container/src/configuration/normalize-styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const normalizeStyles = (locales: ConfigurationLocales, state: StateParti
1212
return []
1313
}
1414

15-
return flatMap(value, (styleRule, prefix) =>
15+
return flatMap(value, (styleRule, stack) =>
1616
normalizeStyleRule(styleRule).map((value): Style => {
1717
const properties = normalizeProperties(value.properties, state)
1818

@@ -23,9 +23,9 @@ export const normalizeStyles = (locales: ConfigurationLocales, state: StateParti
2323
id: value.id,
2424
locale,
2525
parent: value.parent,
26-
prefix: escape(kebabCase(prefix)),
2726
properties:
2827
properties?.id === undefined ? undefined : state.properties.get(properties.id),
28+
stack: escape(kebabCase(stack)),
2929
} satisfies Style
3030
}),
3131
)

packages/container/src/configuration/user-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ export const schemaLocales = z
314314
export interface Locale {
315315
fontFace: string
316316
fonts: Font[]
317-
prefixes: string[]
317+
stacks: string[]
318318
style: string
319319
order?: string[]
320320
}

packages/container/src/font/font-sort.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const fontSort = (
1818
// }
1919

2020
if (hasFontOverlap(initial)) {
21-
throw new Error('One of the prefixes has font overlaps.')
21+
throw new Error('One of the stacks has font overlaps.')
2222
}
2323

2424
const graph = new Map<string, string[]>()

packages/container/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export interface Style {
6868
atRules: AtRule[]
6969
id: string
7070
locale: string
71-
prefix: string
71+
stack: string
7272
graph?: Map<string, string[]>
7373
parent?: string
7474
properties?: Required<Properties>

packages/pangram/src/parse-manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const schemaManifestLocale = z.object({
3737
fontFace: z.string(),
3838
fonts: z.array(schemaFont),
3939
order: z.array(z.string()).optional(),
40-
prefixes: z.array(z.string()),
40+
stacks: z.array(z.string()),
4141
style: z.string(),
4242
})
4343

0 commit comments

Comments
 (0)