@ariaui/typography 0.2.0
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/chunk-F7KWOKBZ.js +428 -0
- package/dist/index.cjs +474 -0
- package/dist/index.d.cts +365 -0
- package/dist/index.d.ts +365 -0
- package/dist/index.js +62 -0
- package/dist/tokens.cjs +579 -0
- package/dist/tokens.d.cts +63 -0
- package/dist/tokens.d.ts +63 -0
- package/dist/tokens.js +159 -0
- package/package.json +45 -0
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BREAKPOINTS,
|
|
3
|
+
FONT_STACKS,
|
|
4
|
+
RATIOS,
|
|
5
|
+
__spreadProps,
|
|
6
|
+
__spreadValues,
|
|
7
|
+
buildFontFamily,
|
|
8
|
+
createFontStack,
|
|
9
|
+
createModularScale,
|
|
10
|
+
createTextStyle,
|
|
11
|
+
extendScale,
|
|
12
|
+
fluidScale,
|
|
13
|
+
fluidSize,
|
|
14
|
+
fluidStyle,
|
|
15
|
+
getStep,
|
|
16
|
+
listSteps,
|
|
17
|
+
measureRange,
|
|
18
|
+
mergeTextStyles,
|
|
19
|
+
monoStack,
|
|
20
|
+
optimalMeasure,
|
|
21
|
+
responsiveStyle,
|
|
22
|
+
rhythmSpacing,
|
|
23
|
+
sansStack,
|
|
24
|
+
serifStack,
|
|
25
|
+
snapToBaseline,
|
|
26
|
+
sortedBreakpoints,
|
|
27
|
+
systemStack,
|
|
28
|
+
toCSSDeclarations,
|
|
29
|
+
toCSSProperties,
|
|
30
|
+
toCSSVars,
|
|
31
|
+
toTailwindClasses,
|
|
32
|
+
verticalRhythm
|
|
33
|
+
} from "./chunk-F7KWOKBZ.js";
|
|
34
|
+
|
|
35
|
+
// src/resolve.ts
|
|
36
|
+
import { typeScale } from "@ariaui/tokens";
|
|
37
|
+
function toScaleStep(step) {
|
|
38
|
+
return {
|
|
39
|
+
size: step.size,
|
|
40
|
+
lineHeight: step.lineHeight,
|
|
41
|
+
letterSpacing: step.letterSpacing,
|
|
42
|
+
fontWeight: step.fontWeight
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function resolveTypeStep(name) {
|
|
46
|
+
const step = typeScale[name];
|
|
47
|
+
if (!step) return void 0;
|
|
48
|
+
return createTextStyle(toScaleStep(step));
|
|
49
|
+
}
|
|
50
|
+
function resolveTypeScale() {
|
|
51
|
+
const result = {};
|
|
52
|
+
for (const [name, step] of Object.entries(typeScale)) {
|
|
53
|
+
result[name] = createTextStyle(toScaleStep(step));
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
function resolveDisplayScale() {
|
|
58
|
+
const result = {};
|
|
59
|
+
for (const [name, step] of Object.entries(typeScale)) {
|
|
60
|
+
if (name.startsWith("display-")) {
|
|
61
|
+
result[name] = createTextStyle(toScaleStep(step));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
function resolveTextScale() {
|
|
67
|
+
const result = {};
|
|
68
|
+
for (const [name, step] of Object.entries(typeScale)) {
|
|
69
|
+
if (name.startsWith("text-")) {
|
|
70
|
+
result[name] = createTextStyle(toScaleStep(step));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
function resolveAsScaleSteps() {
|
|
76
|
+
const result = {};
|
|
77
|
+
for (const [name, step] of Object.entries(typeScale)) {
|
|
78
|
+
result[name] = toScaleStep(step);
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
function resolveFluidScale(mobileMultiplier = 0.75, viewports) {
|
|
83
|
+
const result = {};
|
|
84
|
+
for (const [name, step] of Object.entries(typeScale)) {
|
|
85
|
+
const desktopStep = toScaleStep(step);
|
|
86
|
+
const desktopSize = parseFloat(step.size);
|
|
87
|
+
const desktopLh = parseFloat(step.lineHeight);
|
|
88
|
+
const mobileStep = {
|
|
89
|
+
size: `${round(desktopSize * mobileMultiplier)}rem`,
|
|
90
|
+
lineHeight: `${round(desktopLh * mobileMultiplier)}rem`,
|
|
91
|
+
letterSpacing: step.letterSpacing,
|
|
92
|
+
fontWeight: step.fontWeight
|
|
93
|
+
};
|
|
94
|
+
result[name] = fluidStyle(mobileStep, desktopStep, viewports);
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
function deriveTextPresets() {
|
|
99
|
+
const scale = resolveTypeScale();
|
|
100
|
+
return {
|
|
101
|
+
heading1: __spreadProps(__spreadValues({}, scale["display-2xl"]), { fontWeight: "700" }),
|
|
102
|
+
heading2: __spreadProps(__spreadValues({}, scale["display-xl"]), { fontWeight: "700" }),
|
|
103
|
+
heading3: __spreadProps(__spreadValues({}, scale["display-lg"]), { fontWeight: "600" }),
|
|
104
|
+
heading4: __spreadProps(__spreadValues({}, scale["display-md"]), { fontWeight: "600" }),
|
|
105
|
+
heading5: __spreadProps(__spreadValues({}, scale["display-sm"]), { fontWeight: "600" }),
|
|
106
|
+
heading6: __spreadProps(__spreadValues({}, scale["display-xs"]), { fontWeight: "600" }),
|
|
107
|
+
body: __spreadProps(__spreadValues({}, scale["text-md"]), { fontWeight: "400" }),
|
|
108
|
+
bodyLarge: __spreadProps(__spreadValues({}, scale["text-lg"]), { fontWeight: "400" }),
|
|
109
|
+
bodySmall: __spreadProps(__spreadValues({}, scale["text-sm"]), { fontWeight: "400" }),
|
|
110
|
+
caption: __spreadProps(__spreadValues({}, scale["text-xs"]), { fontWeight: "400" }),
|
|
111
|
+
label: __spreadProps(__spreadValues({}, scale["text-sm"]), { fontWeight: "500" }),
|
|
112
|
+
overline: __spreadProps(__spreadValues({}, scale["text-xs"]), {
|
|
113
|
+
fontWeight: "600",
|
|
114
|
+
letterSpacing: "0.05em"
|
|
115
|
+
})
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function round(value, decimals = 4) {
|
|
119
|
+
const f = Math.pow(10, decimals);
|
|
120
|
+
return Math.round(value * f) / f;
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
BREAKPOINTS,
|
|
124
|
+
FONT_STACKS,
|
|
125
|
+
RATIOS,
|
|
126
|
+
buildFontFamily,
|
|
127
|
+
createFontStack,
|
|
128
|
+
createModularScale,
|
|
129
|
+
createTextStyle,
|
|
130
|
+
deriveTextPresets,
|
|
131
|
+
extendScale,
|
|
132
|
+
fluidScale,
|
|
133
|
+
fluidSize,
|
|
134
|
+
fluidStyle,
|
|
135
|
+
getStep,
|
|
136
|
+
listSteps,
|
|
137
|
+
measureRange,
|
|
138
|
+
mergeTextStyles,
|
|
139
|
+
monoStack,
|
|
140
|
+
optimalMeasure,
|
|
141
|
+
resolveAsScaleSteps,
|
|
142
|
+
resolveDisplayScale,
|
|
143
|
+
resolveFluidScale,
|
|
144
|
+
resolveTextScale,
|
|
145
|
+
resolveTypeScale,
|
|
146
|
+
resolveTypeStep,
|
|
147
|
+
responsiveStyle,
|
|
148
|
+
rhythmSpacing,
|
|
149
|
+
sansStack,
|
|
150
|
+
serifStack,
|
|
151
|
+
snapToBaseline,
|
|
152
|
+
sortedBreakpoints,
|
|
153
|
+
systemStack,
|
|
154
|
+
toCSSDeclarations,
|
|
155
|
+
toCSSProperties,
|
|
156
|
+
toCSSVars,
|
|
157
|
+
toTailwindClasses,
|
|
158
|
+
verticalRhythm
|
|
159
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ariaui/typography",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./tokens": {
|
|
16
|
+
"types": "./dist/tokens.d.ts",
|
|
17
|
+
"import": "./dist/tokens.js",
|
|
18
|
+
"require": "./dist/tokens.cjs",
|
|
19
|
+
"default": "./dist/tokens.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@ariaui/tokens": "0.2.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependenciesMeta": {
|
|
30
|
+
"@ariaui/tokens": {
|
|
31
|
+
"optional": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@ariaui/tokens": "0.2.0"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "rimraf dist && tsup",
|
|
39
|
+
"dev": "rimraf dist && tsup --watch",
|
|
40
|
+
"lint": "eslint \"**/*.ts\"",
|
|
41
|
+
"clean": "rimraf node_modules && rimraf dist",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest watch"
|
|
44
|
+
}
|
|
45
|
+
}
|