@styleframe/theme 1.0.1 → 1.0.3
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 +12 -0
- package/LICENSE +21 -0
- package/dist/theme.d.ts +772 -0
- package/dist/theme.js +2507 -0
- package/dist/theme.umd.cjs +4 -0
- package/package.json +14 -4
- package/.tsbuildinfo +0 -1
- package/src/constants/border.ts +0 -0
- package/src/constants/breakpoint.ts +0 -0
- package/src/constants/color.ts +0 -0
- package/src/constants/index.ts +0 -4
- package/src/constants/scale.ts +0 -3
- package/src/constants/typography.ts +0 -0
- package/src/index.ts +0 -4
- package/src/shims.d.ts +0 -8
- package/src/types.ts +0 -32
- package/src/utils/createUseVariable.test.ts +0 -928
- package/src/utils/createUseVariable.ts +0 -107
- package/src/utils/index.ts +0 -1
- package/src/variables/index.ts +0 -20
- package/src/variables/useBorderColor.ts +0 -27
- package/src/variables/useBorderRadius.test.ts +0 -335
- package/src/variables/useBorderRadius.ts +0 -26
- package/src/variables/useBorderStyle.test.ts +0 -569
- package/src/variables/useBorderStyle.ts +0 -49
- package/src/variables/useBorderWidth.test.ts +0 -535
- package/src/variables/useBorderWidth.ts +0 -38
- package/src/variables/useBoxShadow.test.ts +0 -336
- package/src/variables/useBoxShadow.ts +0 -54
- package/src/variables/useBreakpoint.test.ts +0 -447
- package/src/variables/useBreakpoint.ts +0 -38
- package/src/variables/useColor.test.ts +0 -360
- package/src/variables/useColor.ts +0 -35
- package/src/variables/useColorLightness.test.ts +0 -168
- package/src/variables/useColorLightness.ts +0 -59
- package/src/variables/useColorShade.test.ts +0 -166
- package/src/variables/useColorShade.ts +0 -52
- package/src/variables/useColorTint.test.ts +0 -164
- package/src/variables/useColorTint.ts +0 -52
- package/src/variables/useEasing.ts +0 -0
- package/src/variables/useFontFamily.test.ts +0 -228
- package/src/variables/useFontFamily.ts +0 -33
- package/src/variables/useFontSize.test.ts +0 -299
- package/src/variables/useFontSize.ts +0 -32
- package/src/variables/useFontStyle.test.ts +0 -555
- package/src/variables/useFontStyle.ts +0 -37
- package/src/variables/useFontWeight.test.ts +0 -650
- package/src/variables/useFontWeight.ts +0 -55
- package/src/variables/useLetterSpacing.test.ts +0 -455
- package/src/variables/useLetterSpacing.ts +0 -41
- package/src/variables/useLineHeight.test.ts +0 -410
- package/src/variables/useLineHeight.ts +0 -41
- package/src/variables/useMultiplier.test.ts +0 -722
- package/src/variables/useMultiplier.ts +0 -44
- package/src/variables/useScale.test.ts +0 -393
- package/src/variables/useScale.ts +0 -52
- package/src/variables/useScalePowers.test.ts +0 -412
- package/src/variables/useScalePowers.ts +0 -35
- package/src/variables/useSpacing.test.ts +0 -309
- package/src/variables/useSpacing.ts +0 -26
- package/src/vite-env.d.ts +0 -1
- package/test-scale.js +0 -22
- package/tsconfig.json +0 -7
- package/vite.config.ts +0 -5
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
import type { Variable } from "@styleframe/core";
|
|
2
|
-
import { styleframe } from "@styleframe/core";
|
|
3
|
-
import { consume } from "@styleframe/transpiler";
|
|
4
|
-
import { defaultLineHeightValues, useLineHeight } from "./useLineHeight";
|
|
5
|
-
|
|
6
|
-
describe("useLineHeight", () => {
|
|
7
|
-
it("should create all line height variables with correct names and values", () => {
|
|
8
|
-
const s = styleframe();
|
|
9
|
-
const {
|
|
10
|
-
lineHeightTight,
|
|
11
|
-
lineHeightSnug,
|
|
12
|
-
lineHeightNormal,
|
|
13
|
-
lineHeightRelaxed,
|
|
14
|
-
lineHeightLoose,
|
|
15
|
-
lineHeight,
|
|
16
|
-
} = useLineHeight(s);
|
|
17
|
-
|
|
18
|
-
expect(lineHeightTight).toEqual({
|
|
19
|
-
type: "variable",
|
|
20
|
-
name: "line-height--tight",
|
|
21
|
-
value: 1.2,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
expect(lineHeightSnug).toEqual({
|
|
25
|
-
type: "variable",
|
|
26
|
-
name: "line-height--snug",
|
|
27
|
-
value: 1.35,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
expect(lineHeightNormal).toEqual({
|
|
31
|
-
type: "variable",
|
|
32
|
-
name: "line-height--normal",
|
|
33
|
-
value: 1.5,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
expect(lineHeightRelaxed).toEqual({
|
|
37
|
-
type: "variable",
|
|
38
|
-
name: "line-height--relaxed",
|
|
39
|
-
value: 1.65,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
expect(lineHeightLoose).toEqual({
|
|
43
|
-
type: "variable",
|
|
44
|
-
name: "line-height--loose",
|
|
45
|
-
value: 1.9,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
expect(lineHeight).toEqual({
|
|
49
|
-
type: "variable",
|
|
50
|
-
name: "line-height",
|
|
51
|
-
value: {
|
|
52
|
-
type: "reference",
|
|
53
|
-
name: "line-height--normal",
|
|
54
|
-
fallback: undefined,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should add all line height variables to root", () => {
|
|
60
|
-
const s = styleframe();
|
|
61
|
-
useLineHeight(s);
|
|
62
|
-
|
|
63
|
-
expect(s.root.variables).toHaveLength(6);
|
|
64
|
-
expect(s.root.variables[0]?.name).toBe("line-height--tight");
|
|
65
|
-
expect(s.root.variables[1]?.name).toBe("line-height--snug");
|
|
66
|
-
expect(s.root.variables[2]?.name).toBe("line-height--normal");
|
|
67
|
-
expect(s.root.variables[3]?.name).toBe("line-height--relaxed");
|
|
68
|
-
expect(s.root.variables[4]?.name).toBe("line-height--loose");
|
|
69
|
-
expect(s.root.variables[5]?.name).toBe("line-height");
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it("should return all line height variables in an object", () => {
|
|
73
|
-
const s = styleframe();
|
|
74
|
-
const lineHeights = useLineHeight(s);
|
|
75
|
-
|
|
76
|
-
expect(Object.keys(lineHeights)).toEqual([
|
|
77
|
-
"lineHeightTight",
|
|
78
|
-
"lineHeightSnug",
|
|
79
|
-
"lineHeightNormal",
|
|
80
|
-
"lineHeightRelaxed",
|
|
81
|
-
"lineHeightLoose",
|
|
82
|
-
"lineHeight",
|
|
83
|
-
]);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should compile to correct CSS output using consume", () => {
|
|
87
|
-
const s = styleframe();
|
|
88
|
-
useLineHeight(s);
|
|
89
|
-
|
|
90
|
-
const css = consume(s.root, s.options);
|
|
91
|
-
|
|
92
|
-
expect(css).toBe(`:root {
|
|
93
|
-
--line-height--tight: 1.2;
|
|
94
|
-
--line-height--snug: 1.35;
|
|
95
|
-
--line-height--normal: 1.5;
|
|
96
|
-
--line-height--relaxed: 1.65;
|
|
97
|
-
--line-height--loose: 1.9;
|
|
98
|
-
--line-height: var(--line-height--normal);
|
|
99
|
-
}`);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it("should compile individual line height variable to correct CSS", () => {
|
|
103
|
-
const s = styleframe();
|
|
104
|
-
const { lineHeightRelaxed } = useLineHeight(s);
|
|
105
|
-
|
|
106
|
-
const css = consume(lineHeightRelaxed, s.options);
|
|
107
|
-
|
|
108
|
-
expect(css).toBe("--line-height--relaxed: 1.65;");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("should not create duplicate variables when called multiple times", () => {
|
|
112
|
-
const s = styleframe();
|
|
113
|
-
const lineHeights1 = useLineHeight(s);
|
|
114
|
-
const lineHeights2 = useLineHeight(s);
|
|
115
|
-
|
|
116
|
-
// Should return the same variables (default: true behavior)
|
|
117
|
-
expect(lineHeights1.lineHeightTight).toBe(lineHeights2.lineHeightTight);
|
|
118
|
-
expect(lineHeights1.lineHeight).toBe(lineHeights2.lineHeight);
|
|
119
|
-
expect(s.root.variables).toHaveLength(6);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("should allow line height variables to be used as references", () => {
|
|
123
|
-
const s = styleframe();
|
|
124
|
-
const { lineHeightLoose } = useLineHeight(s);
|
|
125
|
-
|
|
126
|
-
const customLineHeight = s.variable(
|
|
127
|
-
"custom-line-height",
|
|
128
|
-
s.ref(lineHeightLoose),
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
expect(customLineHeight.value).toEqual({
|
|
132
|
-
type: "reference",
|
|
133
|
-
name: "line-height--loose",
|
|
134
|
-
fallback: undefined,
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const css = consume(s.root, s.options);
|
|
138
|
-
expect(css).toEqual(`:root {
|
|
139
|
-
--line-height--tight: 1.2;
|
|
140
|
-
--line-height--snug: 1.35;
|
|
141
|
-
--line-height--normal: 1.5;
|
|
142
|
-
--line-height--relaxed: 1.65;
|
|
143
|
-
--line-height--loose: 1.9;
|
|
144
|
-
--line-height: var(--line-height--normal);
|
|
145
|
-
--custom-line-height: var(--line-height--loose);
|
|
146
|
-
}`);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it("should work with selector overrides", () => {
|
|
150
|
-
const s = styleframe();
|
|
151
|
-
const { lineHeightNormal } = useLineHeight(s);
|
|
152
|
-
|
|
153
|
-
s.selector(".custom-line-height", ({ variable }) => {
|
|
154
|
-
variable(lineHeightNormal, 1.8);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
const css = consume(s.root, s.options);
|
|
158
|
-
|
|
159
|
-
expect(css).toEqual(`:root {
|
|
160
|
-
--line-height--tight: 1.2;
|
|
161
|
-
--line-height--snug: 1.35;
|
|
162
|
-
--line-height--normal: 1.5;
|
|
163
|
-
--line-height--relaxed: 1.65;
|
|
164
|
-
--line-height--loose: 1.9;
|
|
165
|
-
--line-height: var(--line-height--normal);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
.custom-line-height {
|
|
169
|
-
--line-height--normal: 1.8;
|
|
170
|
-
}`);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
describe("type safety", () => {
|
|
174
|
-
it("should preserve exact line height variable names in return type", () => {
|
|
175
|
-
const s = styleframe();
|
|
176
|
-
const lineHeights = useLineHeight(s);
|
|
177
|
-
|
|
178
|
-
// Type assertions to verify the generic types are preserved
|
|
179
|
-
const tight: Variable<"line-height--tight"> = lineHeights.lineHeightTight;
|
|
180
|
-
const snug: Variable<"line-height--snug"> = lineHeights.lineHeightSnug;
|
|
181
|
-
const normal: Variable<"line-height--normal"> =
|
|
182
|
-
lineHeights.lineHeightNormal;
|
|
183
|
-
const relaxed: Variable<"line-height--relaxed"> =
|
|
184
|
-
lineHeights.lineHeightRelaxed;
|
|
185
|
-
const loose: Variable<"line-height--loose"> = lineHeights.lineHeightLoose;
|
|
186
|
-
const lineHeight: Variable<"line-height"> = lineHeights.lineHeight;
|
|
187
|
-
|
|
188
|
-
expect(tight.name).toBe("line-height--tight");
|
|
189
|
-
expect(snug.name).toBe("line-height--snug");
|
|
190
|
-
expect(normal.name).toBe("line-height--normal");
|
|
191
|
-
expect(relaxed.name).toBe("line-height--relaxed");
|
|
192
|
-
expect(loose.name).toBe("line-height--loose");
|
|
193
|
-
expect(lineHeight.name).toBe("line-height");
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it("should have correct numeric value types", () => {
|
|
197
|
-
const s = styleframe();
|
|
198
|
-
const lineHeights = useLineHeight(s);
|
|
199
|
-
|
|
200
|
-
expect(typeof lineHeights.lineHeightTight.value).toBe("number");
|
|
201
|
-
expect(typeof lineHeights.lineHeightSnug.value).toBe("number");
|
|
202
|
-
expect(typeof lineHeights.lineHeightNormal.value).toBe("number");
|
|
203
|
-
expect(typeof lineHeights.lineHeightRelaxed.value).toBe("number");
|
|
204
|
-
expect(typeof lineHeights.lineHeightLoose.value).toBe("number");
|
|
205
|
-
expect(typeof lineHeights.lineHeight.value).toBe("object");
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
describe("default line height", () => {
|
|
210
|
-
it("should create a default line height variable referencing normal by default", () => {
|
|
211
|
-
const s = styleframe();
|
|
212
|
-
const { lineHeight } = useLineHeight(s);
|
|
213
|
-
|
|
214
|
-
expect(lineHeight).toEqual({
|
|
215
|
-
type: "variable",
|
|
216
|
-
name: "line-height",
|
|
217
|
-
value: {
|
|
218
|
-
type: "reference",
|
|
219
|
-
name: "line-height--normal",
|
|
220
|
-
fallback: undefined,
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it("should allow customizing the default line height", () => {
|
|
226
|
-
const s = styleframe();
|
|
227
|
-
const { lineHeight } = useLineHeight(s, {
|
|
228
|
-
default: "@relaxed",
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
expect(lineHeight.value).toEqual({
|
|
232
|
-
type: "reference",
|
|
233
|
-
name: "line-height--relaxed",
|
|
234
|
-
fallback: undefined,
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("should compile default line height to CSS correctly", () => {
|
|
239
|
-
const s = styleframe();
|
|
240
|
-
useLineHeight(s, {
|
|
241
|
-
...defaultLineHeightValues,
|
|
242
|
-
default: "@loose",
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
const css = consume(s.root, s.options);
|
|
246
|
-
|
|
247
|
-
expect(css).toEqual(`:root {
|
|
248
|
-
--line-height--tight: 1.2;
|
|
249
|
-
--line-height--snug: 1.35;
|
|
250
|
-
--line-height--normal: 1.5;
|
|
251
|
-
--line-height--relaxed: 1.65;
|
|
252
|
-
--line-height--loose: 1.9;
|
|
253
|
-
--line-height: var(--line-height--loose);
|
|
254
|
-
}`);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it("should work with different default line heights", () => {
|
|
258
|
-
const lineHeights = ["tight", "snug", "normal", "relaxed", "loose"];
|
|
259
|
-
|
|
260
|
-
for (const lineHeightName of lineHeights) {
|
|
261
|
-
const s = styleframe();
|
|
262
|
-
const { lineHeight } = useLineHeight(s, {
|
|
263
|
-
...defaultLineHeightValues,
|
|
264
|
-
default: `@${lineHeightName}`,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
expect(lineHeight.value).toEqual({
|
|
268
|
-
type: "reference",
|
|
269
|
-
name: `line-height--${lineHeightName}`,
|
|
270
|
-
fallback: undefined,
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
describe("line height value relationships", () => {
|
|
277
|
-
it("should have line heights in ascending order", () => {
|
|
278
|
-
const s = styleframe();
|
|
279
|
-
const {
|
|
280
|
-
lineHeightTight,
|
|
281
|
-
lineHeightSnug,
|
|
282
|
-
lineHeightNormal,
|
|
283
|
-
lineHeightRelaxed,
|
|
284
|
-
lineHeightLoose,
|
|
285
|
-
} = useLineHeight(s);
|
|
286
|
-
|
|
287
|
-
expect(lineHeightTight.value).toBeLessThan(
|
|
288
|
-
lineHeightSnug.value as number,
|
|
289
|
-
);
|
|
290
|
-
expect(lineHeightSnug.value).toBeLessThan(
|
|
291
|
-
lineHeightNormal.value as number,
|
|
292
|
-
);
|
|
293
|
-
expect(lineHeightNormal.value).toBeLessThan(
|
|
294
|
-
lineHeightRelaxed.value as number,
|
|
295
|
-
);
|
|
296
|
-
expect(lineHeightRelaxed.value).toBeLessThan(
|
|
297
|
-
lineHeightLoose.value as number,
|
|
298
|
-
);
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it("should have loose as the largest line height", () => {
|
|
302
|
-
const s = styleframe();
|
|
303
|
-
const lineHeights = useLineHeight(s);
|
|
304
|
-
const values = Object.values(lineHeights)
|
|
305
|
-
.filter((v) => typeof v.value === "number")
|
|
306
|
-
.map((v) => v.value as number);
|
|
307
|
-
const maxValue = Math.max(...values);
|
|
308
|
-
|
|
309
|
-
expect(lineHeights.lineHeightLoose.value).toBe(maxValue);
|
|
310
|
-
expect(lineHeights.lineHeightLoose.value).toBe(1.9);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it("should have tight as the smallest line height", () => {
|
|
314
|
-
const s = styleframe();
|
|
315
|
-
const lineHeights = useLineHeight(s);
|
|
316
|
-
const values = Object.values(lineHeights)
|
|
317
|
-
.filter((v) => typeof v.value === "number")
|
|
318
|
-
.map((v) => v.value as number);
|
|
319
|
-
const minValue = Math.min(...values);
|
|
320
|
-
|
|
321
|
-
expect(lineHeights.lineHeightTight.value).toBe(minValue);
|
|
322
|
-
expect(lineHeights.lineHeightTight.value).toBe(1.2);
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
describe("practical usage", () => {
|
|
327
|
-
it("should work for creating typography with different line heights", () => {
|
|
328
|
-
const s = styleframe();
|
|
329
|
-
const { lineHeightTight, lineHeightRelaxed } = useLineHeight(s);
|
|
330
|
-
|
|
331
|
-
s.selector("h1, h2, h3", ({ variable }) => {
|
|
332
|
-
variable("line-height", s.ref(lineHeightTight));
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
s.selector("p, li", ({ variable }) => {
|
|
336
|
-
variable("line-height", s.ref(lineHeightRelaxed));
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
const css = consume(s.root, s.options);
|
|
340
|
-
expect(css).toEqual(`:root {
|
|
341
|
-
--line-height--tight: 1.2;
|
|
342
|
-
--line-height--snug: 1.35;
|
|
343
|
-
--line-height--normal: 1.5;
|
|
344
|
-
--line-height--relaxed: 1.65;
|
|
345
|
-
--line-height--loose: 1.9;
|
|
346
|
-
--line-height: var(--line-height--normal);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
h1, h2, h3 {
|
|
350
|
-
--line-height: var(--line-height--tight);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
p, li {
|
|
354
|
-
--line-height: var(--line-height--relaxed);
|
|
355
|
-
}`);
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
it("should work for responsive line height adjustments", () => {
|
|
359
|
-
const s = styleframe();
|
|
360
|
-
const { lineHeightNormal, lineHeightRelaxed } = useLineHeight(s);
|
|
361
|
-
|
|
362
|
-
const bodyLineHeight = s.variable(
|
|
363
|
-
"body-line-height",
|
|
364
|
-
s.ref(lineHeightNormal),
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
s.selector("@media (min-width: 768px)", ({ variable }) => {
|
|
368
|
-
variable(bodyLineHeight, s.ref(lineHeightRelaxed));
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
const css = consume(s.root, s.options);
|
|
372
|
-
expect(css).toEqual(`:root {
|
|
373
|
-
--line-height--tight: 1.2;
|
|
374
|
-
--line-height--snug: 1.35;
|
|
375
|
-
--line-height--normal: 1.5;
|
|
376
|
-
--line-height--relaxed: 1.65;
|
|
377
|
-
--line-height--loose: 1.9;
|
|
378
|
-
--line-height: var(--line-height--normal);
|
|
379
|
-
--body-line-height: var(--line-height--normal);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
@media (min-width: 768px) {
|
|
383
|
-
--body-line-height: var(--line-height--relaxed);
|
|
384
|
-
}`);
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
it("should work for theme-specific line height overrides", () => {
|
|
388
|
-
const s = styleframe();
|
|
389
|
-
const { lineHeightNormal, lineHeightLoose } = useLineHeight(s);
|
|
390
|
-
|
|
391
|
-
s.selector(".theme-readable", ({ variable }) => {
|
|
392
|
-
variable(lineHeightNormal, s.ref(lineHeightLoose));
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
const css = consume(s.root, s.options);
|
|
396
|
-
expect(css).toEqual(`:root {
|
|
397
|
-
--line-height--tight: 1.2;
|
|
398
|
-
--line-height--snug: 1.35;
|
|
399
|
-
--line-height--normal: 1.5;
|
|
400
|
-
--line-height--relaxed: 1.65;
|
|
401
|
-
--line-height--loose: 1.9;
|
|
402
|
-
--line-height: var(--line-height--normal);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
.theme-readable {
|
|
406
|
-
--line-height--normal: var(--line-height--loose);
|
|
407
|
-
}`);
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createUseVariable } from "../utils";
|
|
2
|
-
|
|
3
|
-
export const defaultLineHeightValues = {
|
|
4
|
-
default: "@normal",
|
|
5
|
-
tight: 1.2,
|
|
6
|
-
snug: 1.35,
|
|
7
|
-
normal: 1.5,
|
|
8
|
-
relaxed: 1.65,
|
|
9
|
-
loose: 1.9,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create a set of line-height variables for use in a Styleframe instance.
|
|
14
|
-
*
|
|
15
|
-
* @usage
|
|
16
|
-
* ```typescript
|
|
17
|
-
* import { styleframe } from "styleframe";
|
|
18
|
-
* import { useLineHeight } from "styleframe/theme";
|
|
19
|
-
*
|
|
20
|
-
* const s = styleframe();
|
|
21
|
-
*
|
|
22
|
-
* const {
|
|
23
|
-
* lineHeightTight,
|
|
24
|
-
* lineHeightSnug,
|
|
25
|
-
* lineHeightNormal,
|
|
26
|
-
* lineHeightRelaxed,
|
|
27
|
-
* lineHeightLoose,
|
|
28
|
-
* lineHeight,
|
|
29
|
-
* } = useLineHeight(s, {
|
|
30
|
-
* default: "normal",
|
|
31
|
-
* tight: 1.2,
|
|
32
|
-
* snug: 1.35,
|
|
33
|
-
* normal: 1.5,
|
|
34
|
-
* relaxed: 1.65,
|
|
35
|
-
* loose: 1.9,
|
|
36
|
-
* });
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export const useLineHeight = createUseVariable("line-height", {
|
|
40
|
-
defaults: defaultLineHeightValues,
|
|
41
|
-
});
|