@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,447 +0,0 @@
|
|
|
1
|
-
import type { Variable } from "@styleframe/core";
|
|
2
|
-
import { styleframe } from "@styleframe/core";
|
|
3
|
-
import { consume } from "@styleframe/transpiler";
|
|
4
|
-
import { useBreakpoint } from "./useBreakpoint";
|
|
5
|
-
|
|
6
|
-
describe("useBreakpoint", () => {
|
|
7
|
-
it("should create a single breakpoint variable with 'default' key", () => {
|
|
8
|
-
const s = styleframe();
|
|
9
|
-
const { breakpoint } = useBreakpoint(s, {
|
|
10
|
-
default: 768,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
expect(breakpoint).toEqual({
|
|
14
|
-
type: "variable",
|
|
15
|
-
name: "breakpoint",
|
|
16
|
-
value: 768,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const css = consume(breakpoint, s.options);
|
|
20
|
-
expect(css).toBe(`--breakpoint: 768;`);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("should create breakpoint variable with modifier for non-default keys", () => {
|
|
24
|
-
const s = styleframe();
|
|
25
|
-
const { breakpointSm } = useBreakpoint(s, {
|
|
26
|
-
sm: 576,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
expect(breakpointSm).toEqual({
|
|
30
|
-
type: "variable",
|
|
31
|
-
name: "breakpoint--sm",
|
|
32
|
-
value: 576,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const css = consume(breakpointSm, s.options);
|
|
36
|
-
expect(css).toBe(`--breakpoint--sm: 576;`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should create multiple breakpoint variables", () => {
|
|
40
|
-
const s = styleframe();
|
|
41
|
-
const { breakpointXs, breakpointSm, breakpointMd, breakpointLg } =
|
|
42
|
-
useBreakpoint(s, {
|
|
43
|
-
xs: 0,
|
|
44
|
-
sm: 576,
|
|
45
|
-
md: 768,
|
|
46
|
-
lg: 992,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
expect(breakpointXs).toEqual({
|
|
50
|
-
type: "variable",
|
|
51
|
-
name: "breakpoint--xs",
|
|
52
|
-
value: 0,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(breakpointSm).toEqual({
|
|
56
|
-
type: "variable",
|
|
57
|
-
name: "breakpoint--sm",
|
|
58
|
-
value: 576,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
expect(breakpointMd).toEqual({
|
|
62
|
-
type: "variable",
|
|
63
|
-
name: "breakpoint--md",
|
|
64
|
-
value: 768,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
expect(breakpointLg).toEqual({
|
|
68
|
-
type: "variable",
|
|
69
|
-
name: "breakpoint--lg",
|
|
70
|
-
value: 992,
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should add variables to root", () => {
|
|
75
|
-
const s = styleframe();
|
|
76
|
-
useBreakpoint(s, {
|
|
77
|
-
sm: 576,
|
|
78
|
-
md: 768,
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
expect(s.root.variables).toHaveLength(2);
|
|
82
|
-
expect(s.root.variables[0]?.name).toBe("breakpoint--sm");
|
|
83
|
-
expect(s.root.variables[1]?.name).toBe("breakpoint--md");
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it("should handle kebab-case breakpoint names", () => {
|
|
87
|
-
const s = styleframe();
|
|
88
|
-
const { breakpointExtraLarge } = useBreakpoint(s, {
|
|
89
|
-
"extra-large": 1440,
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
expect(breakpointExtraLarge).toEqual({
|
|
93
|
-
type: "variable",
|
|
94
|
-
name: "breakpoint--extra-large",
|
|
95
|
-
value: 1440,
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("should handle snake_case breakpoint names", () => {
|
|
100
|
-
const s = styleframe();
|
|
101
|
-
const { breakpointTabletPortrait } = useBreakpoint(s, {
|
|
102
|
-
tablet_portrait: 768,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
expect(breakpointTabletPortrait).toEqual({
|
|
106
|
-
type: "variable",
|
|
107
|
-
name: "breakpoint--tablet_portrait",
|
|
108
|
-
value: 768,
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("should handle numeric breakpoint names", () => {
|
|
113
|
-
const s = styleframe();
|
|
114
|
-
const { breakpoint1024 } = useBreakpoint(s, {
|
|
115
|
-
"1024": 1024,
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
expect(breakpoint1024).toEqual({
|
|
119
|
-
type: "variable",
|
|
120
|
-
name: "breakpoint--1024",
|
|
121
|
-
value: 1024,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("should handle numeric pixel values", () => {
|
|
126
|
-
const s = styleframe();
|
|
127
|
-
const { breakpointMd } = useBreakpoint(s, {
|
|
128
|
-
md: 768,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
expect(breakpointMd).toEqual({
|
|
132
|
-
type: "variable",
|
|
133
|
-
name: "breakpoint--md",
|
|
134
|
-
value: 768,
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it("should handle string pixel values", () => {
|
|
139
|
-
const s = styleframe();
|
|
140
|
-
const { breakpointLg } = useBreakpoint(s, {
|
|
141
|
-
lg: "992px",
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(breakpointLg).toEqual({
|
|
145
|
-
type: "variable",
|
|
146
|
-
name: "breakpoint--lg",
|
|
147
|
-
value: "992px",
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("should handle em values", () => {
|
|
152
|
-
const s = styleframe();
|
|
153
|
-
const { breakpointBase } = useBreakpoint(s, {
|
|
154
|
-
base: "48em",
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
expect(breakpointBase).toEqual({
|
|
158
|
-
type: "variable",
|
|
159
|
-
name: "breakpoint--base",
|
|
160
|
-
value: "48em",
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
it("should handle rem values", () => {
|
|
165
|
-
const s = styleframe();
|
|
166
|
-
const { breakpointFluid } = useBreakpoint(s, {
|
|
167
|
-
fluid: "60rem",
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
expect(breakpointFluid).toEqual({
|
|
171
|
-
type: "variable",
|
|
172
|
-
name: "breakpoint--fluid",
|
|
173
|
-
value: "60rem",
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("should handle zero values", () => {
|
|
178
|
-
const s = styleframe();
|
|
179
|
-
const { breakpointXs } = useBreakpoint(s, {
|
|
180
|
-
xs: 0,
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
expect(breakpointXs).toEqual({
|
|
184
|
-
type: "variable",
|
|
185
|
-
name: "breakpoint--xs",
|
|
186
|
-
value: 0,
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("should handle viewport width units", () => {
|
|
191
|
-
const s = styleframe();
|
|
192
|
-
const { breakpointVw } = useBreakpoint(s, {
|
|
193
|
-
vw: "50vw",
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
expect(breakpointVw.value).toBe("50vw");
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("should handle calc() expressions", () => {
|
|
200
|
-
const s = styleframe();
|
|
201
|
-
const { breakpointDynamic } = useBreakpoint(s, {
|
|
202
|
-
dynamic: "calc(768px + 2rem)",
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
expect(breakpointDynamic.value).toBe("calc(768px + 2rem)");
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it("should handle empty breakpoint object", () => {
|
|
209
|
-
const s = styleframe();
|
|
210
|
-
const result = useBreakpoint(s, {});
|
|
211
|
-
|
|
212
|
-
expect(result).toEqual({});
|
|
213
|
-
expect(s.root.variables).toHaveLength(0);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("should handle breakpoint references", () => {
|
|
217
|
-
const s = styleframe();
|
|
218
|
-
const baseBreakpoint = s.variable("base-breakpoint", 768);
|
|
219
|
-
const { breakpoint } = useBreakpoint(s, {
|
|
220
|
-
default: s.ref(baseBreakpoint),
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
expect(breakpoint.value).toEqual({
|
|
224
|
-
type: "reference",
|
|
225
|
-
name: "base-breakpoint",
|
|
226
|
-
fallback: undefined,
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it("should compile to correct CSS output using consume", () => {
|
|
231
|
-
const s = styleframe();
|
|
232
|
-
useBreakpoint(s, {
|
|
233
|
-
xs: 0,
|
|
234
|
-
sm: 576,
|
|
235
|
-
md: 768,
|
|
236
|
-
lg: 992,
|
|
237
|
-
xl: 1200,
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
const css = consume(s.root, s.options);
|
|
241
|
-
|
|
242
|
-
expect(css).toBe(`:root {
|
|
243
|
-
--breakpoint--xs: 0;
|
|
244
|
-
--breakpoint--sm: 576;
|
|
245
|
-
--breakpoint--md: 768;
|
|
246
|
-
--breakpoint--lg: 992;
|
|
247
|
-
--breakpoint--xl: 1200;
|
|
248
|
-
}`);
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
it("should handle a complete breakpoint scale", () => {
|
|
252
|
-
const s = styleframe();
|
|
253
|
-
const breakpoints = useBreakpoint(s, {
|
|
254
|
-
xs: 0,
|
|
255
|
-
sm: 576,
|
|
256
|
-
md: 768,
|
|
257
|
-
lg: 992,
|
|
258
|
-
xl: 1200,
|
|
259
|
-
"2xl": 1440,
|
|
260
|
-
"3xl": 1920,
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
expect(breakpoints.breakpointXs.value).toBe(0);
|
|
264
|
-
expect(breakpoints.breakpointSm.value).toBe(576);
|
|
265
|
-
expect(breakpoints.breakpointMd.value).toBe(768);
|
|
266
|
-
expect(breakpoints.breakpointLg.value).toBe(992);
|
|
267
|
-
expect(breakpoints.breakpointXl.value).toBe(1200);
|
|
268
|
-
expect(breakpoints.breakpoint2xl.value).toBe(1440);
|
|
269
|
-
expect(breakpoints.breakpoint3xl.value).toBe(1920);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
it("should handle Bootstrap-style breakpoints", () => {
|
|
273
|
-
const s = styleframe();
|
|
274
|
-
const breakpoints = useBreakpoint(s, {
|
|
275
|
-
xs: 0,
|
|
276
|
-
sm: 576,
|
|
277
|
-
md: 768,
|
|
278
|
-
lg: 992,
|
|
279
|
-
xl: 1200,
|
|
280
|
-
xxl: 1400,
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
expect(breakpoints.breakpointXs.value).toBe(0);
|
|
284
|
-
expect(breakpoints.breakpointSm.value).toBe(576);
|
|
285
|
-
expect(breakpoints.breakpointMd.value).toBe(768);
|
|
286
|
-
expect(breakpoints.breakpointLg.value).toBe(992);
|
|
287
|
-
expect(breakpoints.breakpointXl.value).toBe(1200);
|
|
288
|
-
expect(breakpoints.breakpointXxl.value).toBe(1400);
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
it("should handle Tailwind-style breakpoints", () => {
|
|
292
|
-
const s = styleframe();
|
|
293
|
-
const breakpoints = useBreakpoint(s, {
|
|
294
|
-
sm: 640,
|
|
295
|
-
md: 768,
|
|
296
|
-
lg: 1024,
|
|
297
|
-
xl: 1280,
|
|
298
|
-
"2xl": 1536,
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
expect(breakpoints.breakpointSm.value).toBe(640);
|
|
302
|
-
expect(breakpoints.breakpointMd.value).toBe(768);
|
|
303
|
-
expect(breakpoints.breakpointLg.value).toBe(1024);
|
|
304
|
-
expect(breakpoints.breakpointXl.value).toBe(1280);
|
|
305
|
-
expect(breakpoints.breakpoint2xl.value).toBe(1536);
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
it("should handle semantic device-based breakpoints", () => {
|
|
309
|
-
const s = styleframe();
|
|
310
|
-
const breakpoints = useBreakpoint(s, {
|
|
311
|
-
mobile: 0,
|
|
312
|
-
tablet: 768,
|
|
313
|
-
desktop: 1024,
|
|
314
|
-
wide: 1440,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
expect(breakpoints.breakpointMobile.value).toBe(0);
|
|
318
|
-
expect(breakpoints.breakpointTablet.value).toBe(768);
|
|
319
|
-
expect(breakpoints.breakpointDesktop.value).toBe(1024);
|
|
320
|
-
expect(breakpoints.breakpointWide.value).toBe(1440);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
it("should handle Material Design breakpoints", () => {
|
|
324
|
-
const s = styleframe();
|
|
325
|
-
const breakpoints = useBreakpoint(s, {
|
|
326
|
-
xs: 0,
|
|
327
|
-
sm: 600,
|
|
328
|
-
md: 960,
|
|
329
|
-
lg: 1280,
|
|
330
|
-
xl: 1920,
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
expect(breakpoints.breakpointXs.value).toBe(0);
|
|
334
|
-
expect(breakpoints.breakpointSm.value).toBe(600);
|
|
335
|
-
expect(breakpoints.breakpointMd.value).toBe(960);
|
|
336
|
-
expect(breakpoints.breakpointLg.value).toBe(1280);
|
|
337
|
-
expect(breakpoints.breakpointXl.value).toBe(1920);
|
|
338
|
-
});
|
|
339
|
-
|
|
340
|
-
describe("type safety", () => {
|
|
341
|
-
it("should preserve exact breakpoint names in return type", () => {
|
|
342
|
-
const s = styleframe();
|
|
343
|
-
const breakpoints = useBreakpoint(s, {
|
|
344
|
-
sm: 576,
|
|
345
|
-
md: 768,
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
// Type assertions to verify the generic types are preserved
|
|
349
|
-
const smBreakpoint: Variable<"breakpoint--sm"> = breakpoints.breakpointSm;
|
|
350
|
-
const mdBreakpoint: Variable<"breakpoint--md"> = breakpoints.breakpointMd;
|
|
351
|
-
|
|
352
|
-
expect(smBreakpoint.name).toBe("breakpoint--sm");
|
|
353
|
-
expect(mdBreakpoint.name).toBe("breakpoint--md");
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
it("should maintain type information for kebab-case names", () => {
|
|
357
|
-
const s = styleframe();
|
|
358
|
-
const { breakpointExtraLarge } = useBreakpoint(s, {
|
|
359
|
-
"extra-large": 1440,
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
const typed: Variable<"breakpoint--extra-large"> = breakpointExtraLarge;
|
|
363
|
-
expect(typed.name).toBe("breakpoint--extra-large");
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
it("should work with const assertion", () => {
|
|
367
|
-
const s = styleframe();
|
|
368
|
-
const breakpointConfig = {
|
|
369
|
-
sm: 576,
|
|
370
|
-
md: 768,
|
|
371
|
-
} as const;
|
|
372
|
-
|
|
373
|
-
const breakpoints = useBreakpoint(s, breakpointConfig);
|
|
374
|
-
|
|
375
|
-
expect(breakpoints.breakpointSm.name).toBe("breakpoint--sm");
|
|
376
|
-
expect(breakpoints.breakpointMd.name).toBe("breakpoint--md");
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
describe("practical usage", () => {
|
|
381
|
-
it("should work with media queries", () => {
|
|
382
|
-
const s = styleframe();
|
|
383
|
-
const { breakpointMd, breakpointLg } = useBreakpoint(s, {
|
|
384
|
-
md: 768,
|
|
385
|
-
lg: 992,
|
|
386
|
-
});
|
|
387
|
-
|
|
388
|
-
s.selector(
|
|
389
|
-
`@media (min-width: ${breakpointMd.value}px)`,
|
|
390
|
-
({ selector }) => {
|
|
391
|
-
selector(".container", {
|
|
392
|
-
maxWidth: "720px",
|
|
393
|
-
});
|
|
394
|
-
},
|
|
395
|
-
);
|
|
396
|
-
|
|
397
|
-
s.selector(
|
|
398
|
-
`@media (min-width: ${breakpointLg.value}px)`,
|
|
399
|
-
({ selector }) => {
|
|
400
|
-
selector(".container", {
|
|
401
|
-
maxWidth: "960px",
|
|
402
|
-
});
|
|
403
|
-
},
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
const css = consume(s.root, s.options);
|
|
407
|
-
expect(css).toContain("--breakpoint--md: 768;");
|
|
408
|
-
expect(css).toContain("--breakpoint--lg: 992;");
|
|
409
|
-
expect(css).toContain("@media (min-width: 768px)");
|
|
410
|
-
expect(css).toContain("@media (min-width: 992px)");
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
it("should support container queries", () => {
|
|
414
|
-
const s = styleframe();
|
|
415
|
-
const { breakpointSm } = useBreakpoint(s, {
|
|
416
|
-
sm: 576,
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
expect(breakpointSm.value).toBe(576);
|
|
420
|
-
expect(breakpointSm.name).toBe("breakpoint--sm");
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
it("should handle ascending breakpoint order", () => {
|
|
424
|
-
const s = styleframe();
|
|
425
|
-
const breakpoints = useBreakpoint(s, {
|
|
426
|
-
xs: 0,
|
|
427
|
-
sm: 576,
|
|
428
|
-
md: 768,
|
|
429
|
-
lg: 992,
|
|
430
|
-
xl: 1200,
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
const values = [
|
|
434
|
-
breakpoints.breakpointXs.value,
|
|
435
|
-
breakpoints.breakpointSm.value,
|
|
436
|
-
breakpoints.breakpointMd.value,
|
|
437
|
-
breakpoints.breakpointLg.value,
|
|
438
|
-
breakpoints.breakpointXl.value,
|
|
439
|
-
];
|
|
440
|
-
|
|
441
|
-
// Verify ascending order
|
|
442
|
-
for (let i = 1; i < values.length; i++) {
|
|
443
|
-
expect(Number(values[i])).toBeGreaterThan(Number(values[i - 1]));
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createUseVariable } from "../utils";
|
|
2
|
-
|
|
3
|
-
export const defaultBreakpointValues = {
|
|
4
|
-
xs: 0,
|
|
5
|
-
sm: 576,
|
|
6
|
-
md: 992,
|
|
7
|
-
lg: 1200,
|
|
8
|
-
xl: 1440,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a set of breakpoint variables for use in a Styleframe instance.
|
|
13
|
-
*
|
|
14
|
-
* @usage
|
|
15
|
-
* ```typescript
|
|
16
|
-
* import { styleframe } from "styleframe";
|
|
17
|
-
* import { useBreakpoint } from "styleframe/theme";
|
|
18
|
-
*
|
|
19
|
-
* const s = styleframe();
|
|
20
|
-
*
|
|
21
|
-
* const {
|
|
22
|
-
* breakpointXs, // Variable<'breakpoint--xs'>
|
|
23
|
-
* breakpointSm, // Variable<'breakpoint--sm'>
|
|
24
|
-
* breakpointMd, // Variable<'breakpoint--md'>
|
|
25
|
-
* breakpointLg, // Variable<'breakpoint--lg'>
|
|
26
|
-
* breakpointXl, // Variable<'breakpoint--xl'>
|
|
27
|
-
* } = useBreakpoint(s, {
|
|
28
|
-
* xs: 0,
|
|
29
|
-
* sm: 576,
|
|
30
|
-
* md: 992,
|
|
31
|
-
* lg: 1200,
|
|
32
|
-
* xl: 1440,
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export const useBreakpoint = createUseVariable("breakpoint", {
|
|
37
|
-
defaults: defaultBreakpointValues,
|
|
38
|
-
});
|