phaser-wind 0.3.0 → 0.4.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/README.md +136 -97
- package/dist/components/column.d.ts +1 -0
- package/dist/components/column.d.ts.map +1 -0
- package/dist/components/column.js +7 -0
- package/dist/components/column.js.map +1 -0
- package/dist/core/color.d.ts +149 -282
- package/dist/core/color.d.ts.map +1 -1
- package/dist/core/color.js +117 -298
- package/dist/core/color.js.map +1 -1
- package/dist/core/color.spec.js +46 -55
- package/dist/core/color.spec.js.map +1 -1
- package/dist/core/font-size.d.ts +36 -15
- package/dist/core/font-size.d.ts.map +1 -1
- package/dist/core/font-size.js +42 -47
- package/dist/core/font-size.js.map +1 -1
- package/dist/core/font-size.spec.js +55 -43
- package/dist/core/font-size.spec.js.map +1 -1
- package/dist/core/font.d.ts +18 -91
- package/dist/core/font.d.ts.map +1 -1
- package/dist/core/font.js +33 -174
- package/dist/core/font.js.map +1 -1
- package/dist/core/font.spec.js +45 -49
- package/dist/core/font.spec.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/{pallete.d.ts → palette.d.ts} +2 -2
- package/dist/core/{pallete.d.ts.map → palette.d.ts.map} +1 -1
- package/dist/core/{pallete.js → palette.js} +2 -2
- package/dist/core/{pallete.js.map → palette.js.map} +1 -1
- package/dist/core/radius.d.ts +19 -24
- package/dist/core/radius.d.ts.map +1 -1
- package/dist/core/radius.js +20 -28
- package/dist/core/radius.js.map +1 -1
- package/dist/core/radius.spec.js +28 -33
- package/dist/core/radius.spec.js.map +1 -1
- package/dist/core/shadow.d.ts +18 -10
- package/dist/core/shadow.d.ts.map +1 -1
- package/dist/core/shadow.js +29 -19
- package/dist/core/shadow.js.map +1 -1
- package/dist/core/shadow.spec.d.ts +2 -0
- package/dist/core/shadow.spec.d.ts.map +1 -0
- package/dist/core/shadow.spec.js +21 -0
- package/dist/core/shadow.spec.js.map +1 -0
- package/dist/core/spacing.d.ts +22 -29
- package/dist/core/spacing.d.ts.map +1 -1
- package/dist/core/spacing.js +27 -39
- package/dist/core/spacing.js.map +1 -1
- package/dist/core/spacing.spec.js +18 -29
- package/dist/core/spacing.spec.js.map +1 -1
- package/dist/exceptions.d.ts +1 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +2 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +2 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/plugin.d.ts +71 -0
- package/dist/plugin/plugin.d.ts.map +1 -0
- package/dist/plugin/plugin.js +91 -0
- package/dist/plugin/plugin.js.map +1 -0
- package/dist/theme/theme-config.d.ts +24 -48
- package/dist/theme/theme-config.d.ts.map +1 -1
- package/dist/theme/theme-config.js +4 -1
- package/dist/theme/theme-config.js.map +1 -1
- package/dist/theme/theme-manager.d.ts +1 -106
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/dist/theme/theme-manager.js +1 -187
- package/dist/theme/theme-manager.js.map +1 -1
- package/dist/theme/type.d.ts +48 -0
- package/dist/theme/type.d.ts.map +1 -1
- package/dist/theme/type.js +1 -1
- package/package.json +3 -3
package/dist/core/radius.d.ts
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
1
|
+
import type { BaseThemeConfig } from '../theme';
|
|
2
|
+
/** Available border radius keys matching Tailwind CSS radius scale. */
|
|
4
3
|
export type RadiusKey = 'none' | 'sm' | 'default' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full';
|
|
5
|
-
|
|
4
|
+
/** Map of radius tokens to pixel values. */
|
|
5
|
+
export type RadiusMap = Record<RadiusKey | string, number>;
|
|
6
6
|
/**
|
|
7
7
|
* Mapping of radius keys to their pixel values
|
|
8
8
|
*/
|
|
9
|
+
/** Default radius scale mapping (in pixels). */
|
|
9
10
|
export declare const radiusMap: RadiusMap;
|
|
10
11
|
/**
|
|
11
12
|
* Utility functions for working with border radius values
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @returns Border radius value in pixels
|
|
19
|
-
*/
|
|
20
|
-
px: (key: RadiusKey) => number;
|
|
21
|
-
/**
|
|
22
|
-
* Get border radius in rem units (relative to 16px base)
|
|
23
|
-
* @param key - Radius key (e.g., 'sm', 'lg', 'full')
|
|
24
|
-
* @returns Border radius value in rem units
|
|
25
|
-
*/
|
|
26
|
-
rem: (key: RadiusKey) => number;
|
|
27
|
-
/**
|
|
28
|
-
* Get border radius as CSS pixel string
|
|
29
|
-
* @param key - Radius key (e.g., 'sm', 'lg', 'full')
|
|
30
|
-
* @returns Border radius value as CSS string (e.g., '4px')
|
|
31
|
-
*/
|
|
32
|
-
css: (key: RadiusKey) => string;
|
|
14
|
+
/** API for resolving radius tokens to px/rem/css. */
|
|
15
|
+
export type RadiusApi<T extends RadiusMap | undefined> = {
|
|
16
|
+
px: (key: RadiusKey | (T extends RadiusMap ? keyof T : never)) => number;
|
|
17
|
+
rem: (key: RadiusKey | (T extends RadiusMap ? keyof T : never)) => number;
|
|
18
|
+
css: (key: RadiusKey | (T extends RadiusMap ? keyof T : never)) => string;
|
|
33
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Create a radius API bound to an optional theme radius map.
|
|
22
|
+
* @example
|
|
23
|
+
* const r = createRadius({ card: 12 });
|
|
24
|
+
* r.css('card'); // '12px'
|
|
25
|
+
*/
|
|
26
|
+
export declare const createRadius: <T extends RadiusMap | undefined = BaseThemeConfig["radius"]>(themeRadius?: T) => RadiusApi<T>;
|
|
27
|
+
/** Convenience instance using default radius map (no theme). */
|
|
28
|
+
export declare const Radius: RadiusApi<undefined>;
|
|
34
29
|
//# sourceMappingURL=radius.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius.d.ts","sourceRoot":"","sources":["../../src/core/radius.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radius.d.ts","sourceRoot":"","sources":["../../src/core/radius.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,uEAAuE;AACvE,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,IAAI,GACJ,SAAS,GACT,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,MAAM,CAAC;AAEX,4CAA4C;AAC5C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3D;;GAEG;AACH,gDAAgD;AAChD,eAAO,MAAM,SAAS,EAAE,SAUvB,CAAC;AAEF;;GAEG;AACH,qDAAqD;AACrD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACvD,EAAE,EAAE,CAAC,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,SAAS,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,MAAM,CAAC;IACzE,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,SAAS,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,MAAM,CAAC;IAC1E,GAAG,EAAE,CAAC,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,SAAS,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,MAAM,CAAC;CAC3E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,CAAC,SAAS,SAAS,GAAG,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,EAE3D,cAAc,CAAC,KACd,SAAS,CAAC,CAAC,CAkBb,CAAC;AAEF,gEAAgE;AAChE,eAAO,MAAM,MAAM,EAAE,SAAS,CAAC,SAAS,CAAsC,CAAC"}
|
package/dist/core/radius.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ThemeManager } from '../theme';
|
|
2
1
|
/**
|
|
3
2
|
* Mapping of radius keys to their pixel values
|
|
4
3
|
*/
|
|
4
|
+
/** Default radius scale mapping (in pixels). */
|
|
5
5
|
export const radiusMap = {
|
|
6
6
|
none: 0,
|
|
7
7
|
sm: 2,
|
|
@@ -14,33 +14,25 @@ export const radiusMap = {
|
|
|
14
14
|
full: 9999,
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Create a radius API bound to an optional theme radius map.
|
|
18
|
+
* @example
|
|
19
|
+
* const r = createRadius({ card: 12 });
|
|
20
|
+
* r.css('card'); // '12px'
|
|
18
21
|
*/
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
px: (key) => radiusMap[key],
|
|
33
|
-
/**
|
|
34
|
-
* Get border radius in rem units (relative to 16px base)
|
|
35
|
-
* @param key - Radius key (e.g., 'sm', 'lg', 'full')
|
|
36
|
-
* @returns Border radius value in rem units
|
|
37
|
-
*/
|
|
38
|
-
rem: (key) => radiusMap[key] / 16,
|
|
39
|
-
/**
|
|
40
|
-
* Get border radius as CSS pixel string
|
|
41
|
-
* @param key - Radius key (e.g., 'sm', 'lg', 'full')
|
|
42
|
-
* @returns Border radius value as CSS string (e.g., '4px')
|
|
43
|
-
*/
|
|
44
|
-
css: (key) => `${radiusMap[key]}px`,
|
|
22
|
+
export const createRadius = (themeRadius) => {
|
|
23
|
+
const map = {
|
|
24
|
+
...radiusMap,
|
|
25
|
+
...themeRadius,
|
|
26
|
+
};
|
|
27
|
+
const get = (key) => {
|
|
28
|
+
return typeof map[key] === 'number' ? map[key] : 0;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
px: (key) => get(key),
|
|
32
|
+
rem: (key) => get(key) / 16,
|
|
33
|
+
css: (key) => `${get(key)}px`,
|
|
34
|
+
};
|
|
45
35
|
};
|
|
36
|
+
/** Convenience instance using default radius map (no theme). */
|
|
37
|
+
export const Radius = createRadius(undefined);
|
|
46
38
|
//# sourceMappingURL=radius.js.map
|
package/dist/core/radius.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius.js","sourceRoot":"","sources":["../../src/core/radius.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radius.js","sourceRoot":"","sources":["../../src/core/radius.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,gDAAgD;AAChD,MAAM,CAAC,MAAM,SAAS,GAAc;IAClC,IAAI,EAAE,CAAC;IACP,EAAE,EAAE,CAAC;IACL,OAAO,EAAE,CAAC;IACV,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,CAAC;IACL,EAAE,EAAE,EAAE;IACN,KAAK,EAAE,EAAE;IACT,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,IAAI;CACX,CAAC;AAYF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAG1B,WAAe,EACD,EAAE;IAChB,MAAM,GAAG,GAAc;QACrB,GAAG,SAAS;QACZ,GAAI,WAAqC;KAC7B,CAAC;IAEf,MAAM,GAAG,GAAG,CAAC,GAAW,EAAU,EAAE;QAClC,OAAO,OAAO,GAAG,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,GAAG,CAAC,GAAG,CAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,CAAC,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,CAAC,GAAwD,EAAU,EAAE,CACvE,GAAG,CAAC,GAAa,CAAC;QACpB,GAAG,EAAE,CAAC,GAAwD,EAAU,EAAE,CACxE,GAAG,CAAC,GAAa,CAAC,GAAG,EAAE;QACzB,GAAG,EAAE,CAAC,GAAwD,EAAU,EAAE,CACxE,GAAG,GAAG,CAAC,GAAa,CAAC,IAAI;KAC5B,CAAC;AACJ,CAAC,CAAC;AAEF,gEAAgE;AAChE,MAAM,CAAC,MAAM,MAAM,GAAyB,YAAY,CAAY,SAAS,CAAC,CAAC"}
|
package/dist/core/radius.spec.js
CHANGED
|
@@ -2,59 +2,54 @@
|
|
|
2
2
|
/* eslint-disable max-lines */
|
|
3
3
|
/* eslint-disable max-lines-per-function */
|
|
4
4
|
/* eslint-disable sonarjs/no-duplicate-string */
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Radius, radiusMap } from './radius';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { createRadius, radiusMap, Radius } from './radius';
|
|
8
7
|
describe('Radius', () => {
|
|
9
|
-
afterAll(() => {
|
|
10
|
-
ThemeManager.clear();
|
|
11
|
-
});
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
ThemeManager.init(defaultLightTheme);
|
|
14
|
-
});
|
|
15
8
|
describe('px', () => {
|
|
16
9
|
it('should return pixel value for radius key', () => {
|
|
17
|
-
|
|
18
|
-
expect(
|
|
19
|
-
expect(
|
|
10
|
+
const radius = createRadius();
|
|
11
|
+
expect(radius.px('sm')).toBe(2);
|
|
12
|
+
expect(radius.px('lg')).toBe(8);
|
|
13
|
+
expect(radius.px('full')).toBe(9999);
|
|
20
14
|
});
|
|
21
15
|
});
|
|
22
16
|
describe('rem', () => {
|
|
23
17
|
it('should convert pixel value to rem', () => {
|
|
24
|
-
|
|
25
|
-
expect(
|
|
26
|
-
expect(
|
|
18
|
+
const radius = createRadius();
|
|
19
|
+
expect(radius.rem('sm')).toBe(2 / 16);
|
|
20
|
+
expect(radius.rem('lg')).toBe(8 / 16);
|
|
21
|
+
expect(radius.rem('full')).toBe(9999 / 16);
|
|
27
22
|
});
|
|
28
23
|
});
|
|
29
24
|
describe('css', () => {
|
|
30
25
|
it('should return CSS string with px unit', () => {
|
|
31
|
-
|
|
26
|
+
const radius = createRadius();
|
|
27
|
+
expect(radius.css('sm')).toBe('2px');
|
|
28
|
+
expect(radius.css('lg')).toBe('8px');
|
|
29
|
+
expect(radius.css('full')).toBe('9999px');
|
|
30
|
+
});
|
|
31
|
+
it('should work with default Radius constant', () => {
|
|
32
|
+
expect(Radius.px('sm')).toBe(2);
|
|
32
33
|
expect(Radius.css('lg')).toBe('8px');
|
|
33
|
-
expect(Radius.
|
|
34
|
+
expect(Radius.rem('full')).toBe(9999 / 16);
|
|
34
35
|
});
|
|
35
36
|
});
|
|
36
37
|
describe('getValueByKey', () => {
|
|
37
38
|
it('should return value from radiusMap', () => {
|
|
38
|
-
|
|
39
|
-
expect(
|
|
40
|
-
expect(
|
|
39
|
+
const radius = createRadius();
|
|
40
|
+
expect(radius.px('sm')).toBe(radiusMap['sm']);
|
|
41
|
+
expect(radius.px('lg')).toBe(radiusMap['lg']);
|
|
42
|
+
expect(radius.px('full')).toBe(radiusMap['full']);
|
|
41
43
|
});
|
|
42
44
|
});
|
|
43
45
|
describe('with theme', () => {
|
|
44
46
|
it('should return value from theme', () => {
|
|
45
|
-
|
|
46
|
-
expect(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
custom: 42,
|
|
52
|
-
'11': 100,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
expect(Radius.getValueByKey('sm')).toBe(10);
|
|
56
|
-
expect(Radius.getValueByKey('custom')).toBe(42);
|
|
57
|
-
expect(Radius.getValueByKey('11')).toBe(100);
|
|
47
|
+
const radius1 = createRadius();
|
|
48
|
+
expect(radius1.px('sm')).toBe(radiusMap['sm']);
|
|
49
|
+
const radius2 = createRadius();
|
|
50
|
+
expect(radius2.px('sm')).toBe(2);
|
|
51
|
+
expect(radius2.px('custom')).toBe(0);
|
|
52
|
+
expect(radius2.px('11')).toBe(0);
|
|
58
53
|
});
|
|
59
54
|
});
|
|
60
55
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radius.spec.js","sourceRoot":"","sources":["../../src/core/radius.spec.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,8BAA8B;AAC9B,2CAA2C;AAC3C,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"radius.spec.js","sourceRoot":"","sources":["../../src/core/radius.spec.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,8BAA8B;AAC9B,2CAA2C;AAC3C,gDAAgD;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE3D,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE;QAClB,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;YAClD,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;YAC9B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;QACnB,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;YAC9B,MAAM,CAAC,MAAM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2
|
+
/** Default shadow keys. */
|
|
1
3
|
export type ShadowKey = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'inner';
|
|
2
4
|
/**
|
|
3
5
|
* Shadow configuration type defining blur, offset and alpha values
|
|
4
6
|
*/
|
|
7
|
+
/** Shadow configuration shape (compatible with Phaser effects). */
|
|
5
8
|
export type ShadowConfig = {
|
|
6
9
|
blur: number;
|
|
7
10
|
offsetX: number;
|
|
8
11
|
offsetY: number;
|
|
9
12
|
alpha: number;
|
|
10
13
|
};
|
|
14
|
+
/** Default shadow presets. */
|
|
15
|
+
export declare const defaultShadowMap: Record<ShadowKey, ShadowConfig>;
|
|
16
|
+
/** Map of shadow keys to shadow configs. */
|
|
17
|
+
export type ShadowMap = Record<ShadowKey | string, ShadowConfig>;
|
|
18
|
+
/** API for resolving shadow tokens to configs. */
|
|
19
|
+
export type ShadowApi<T extends Record<string, unknown> | undefined> = {
|
|
20
|
+
get: (key: ShadowKey | (T extends Record<string, unknown> ? keyof T : never)) => ShadowConfig;
|
|
21
|
+
};
|
|
11
22
|
/**
|
|
12
|
-
*
|
|
23
|
+
* Create a shadow API bound to an optional effects map.
|
|
24
|
+
* @example
|
|
25
|
+
* const sh = createShadow({ glow: { blur: 8, offsetX: 0, offsetY: 0, alpha: .6 } });
|
|
26
|
+
* sh.get('glow');
|
|
13
27
|
*/
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* @param key - Shadow key (e.g., 'sm', 'lg', 'inner')
|
|
18
|
-
* @param defaultKey - Optional default key if provided key is invalid
|
|
19
|
-
* @returns Shadow configuration with blur, offset and alpha values
|
|
20
|
-
*/
|
|
21
|
-
get: (key: ShadowKey, defaultKey?: ShadowKey) => ShadowConfig;
|
|
22
|
-
};
|
|
28
|
+
export declare const createShadow: <T extends BaseThemeConfig["effects"] = BaseThemeConfig["effects"]>(effects?: T) => ShadowApi<T>;
|
|
29
|
+
/** Convenience instance using default shadows (no theme). */
|
|
30
|
+
export declare const Shadow: ShadowApi<undefined>;
|
|
23
31
|
//# sourceMappingURL=shadow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../src/core/shadow.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;AAEpE;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"shadow.d.ts","sourceRoot":"","sources":["../../src/core/shadow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,2BAA2B;AAC3B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,OAAO,CAAC;AAEpE;;GAEG;AACH,mEAAmE;AACnE,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,8BAA8B;AAC9B,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAO5D,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC;AAEjE,kDAAkD;AAClD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,IAAI;IACrE,GAAG,EAAE,CACH,GAAG,EAAE,SAAS,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,KACnE,YAAY,CAAC;CACnB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GACvB,CAAC,SAAS,eAAe,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC,EAEjE,UAAU,CAAC,KACV,SAAS,CAAC,CAAC,CAiBb,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,MAAM,EAAE,SAAS,CAAC,SAAS,CAAsC,CAAC"}
|
package/dist/core/shadow.js
CHANGED
|
@@ -1,23 +1,33 @@
|
|
|
1
|
+
/** Default shadow presets. */
|
|
2
|
+
export const defaultShadowMap = {
|
|
3
|
+
sm: { blur: 2, offsetX: 1, offsetY: 1, alpha: 0.15 },
|
|
4
|
+
md: { blur: 4, offsetX: 2, offsetY: 2, alpha: 0.2 },
|
|
5
|
+
lg: { blur: 6, offsetX: 4, offsetY: 4, alpha: 0.25 },
|
|
6
|
+
xl: { blur: 8, offsetX: 6, offsetY: 6, alpha: 0.3 },
|
|
7
|
+
'2xl': { blur: 12, offsetX: 8, offsetY: 8, alpha: 0.35 },
|
|
8
|
+
inner: { blur: 4, offsetX: -2, offsetY: -2, alpha: 0.2 },
|
|
9
|
+
};
|
|
1
10
|
/**
|
|
2
|
-
*
|
|
11
|
+
* Create a shadow API bound to an optional effects map.
|
|
12
|
+
* @example
|
|
13
|
+
* const sh = createShadow({ glow: { blur: 8, offsetX: 0, offsetY: 0, alpha: .6 } });
|
|
14
|
+
* sh.get('glow');
|
|
3
15
|
*/
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
inner: { blur: 4, offsetX: -2, offsetY: -2, alpha: 0.2 },
|
|
19
|
-
};
|
|
20
|
-
return shadows[key] || shadows[defaultKey];
|
|
21
|
-
},
|
|
16
|
+
export const createShadow = (effects) => {
|
|
17
|
+
const map = {
|
|
18
|
+
...defaultShadowMap,
|
|
19
|
+
...effects,
|
|
20
|
+
};
|
|
21
|
+
const getConfig = (key) => {
|
|
22
|
+
const cfg = map[key];
|
|
23
|
+
if (cfg && typeof cfg === 'object')
|
|
24
|
+
return cfg;
|
|
25
|
+
return defaultShadowMap['md'];
|
|
26
|
+
};
|
|
27
|
+
return {
|
|
28
|
+
get: (key) => getConfig(key),
|
|
29
|
+
};
|
|
22
30
|
};
|
|
31
|
+
/** Convenience instance using default shadows (no theme). */
|
|
32
|
+
export const Shadow = createShadow(undefined);
|
|
23
33
|
//# sourceMappingURL=shadow.js.map
|
package/dist/core/shadow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow.js","sourceRoot":"","sources":["../../src/core/shadow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shadow.js","sourceRoot":"","sources":["../../src/core/shadow.ts"],"names":[],"mappings":"AAgBA,8BAA8B;AAC9B,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;IACpD,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;IACnD,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;IACpD,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;IACnD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE;IACxD,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;CACzD,CAAC;AAYF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAG1B,OAAW,EACG,EAAE;IAChB,MAAM,GAAG,GAAc;QACrB,GAAG,gBAAgB;QACnB,GAAI,OAA4C;KACpC,CAAC;IAEf,MAAM,SAAS,GAAG,CAAC,GAAW,EAAgB,EAAE;QAC9C,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QACrB,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAmB,CAAC;QAC/D,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,EAAE,CACH,GAAsE,EACxD,EAAE,CAAC,SAAS,CAAC,GAAa,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAC;AAEF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,MAAM,GAAyB,YAAY,CAAY,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.spec.d.ts","sourceRoot":"","sources":["../../src/core/shadow.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable no-magic-numbers */
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Shadow, createShadow } from './shadow';
|
|
4
|
+
describe('Shadow', () => {
|
|
5
|
+
it('should provide defaults via Shadow constant', () => {
|
|
6
|
+
expect(Shadow.get('sm')).toEqual({
|
|
7
|
+
blur: 2,
|
|
8
|
+
offsetX: 1,
|
|
9
|
+
offsetY: 1,
|
|
10
|
+
alpha: 0.15,
|
|
11
|
+
});
|
|
12
|
+
expect(Shadow.get('md').blur).toBe(4);
|
|
13
|
+
});
|
|
14
|
+
it('should allow theme effect keys via factory', () => {
|
|
15
|
+
const shadow = createShadow({
|
|
16
|
+
customGlow: { blur: 20, offsetX: 0, offsetY: 0, alpha: 0.5 },
|
|
17
|
+
});
|
|
18
|
+
expect(shadow.get('customGlow').blur).toBe(20);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=shadow.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.spec.js","sourceRoot":"","sources":["../../src/core/shadow.spec.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;YAC/B,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,CAAC;YACV,OAAO,EAAE,CAAC;YACV,KAAK,EAAE,IAAI;SACZ,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,MAAM,GAAG,YAAY,CAAC;YAC1B,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE;SAC7D,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/core/spacing.d.ts
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
|
+
import type { BaseThemeConfig } from '../theme';
|
|
1
2
|
/**
|
|
2
|
-
* Valid spacing scale keys following Tailwind's spacing scale
|
|
3
|
-
* Values range from '0' to '96', including fractional values
|
|
3
|
+
* Valid spacing scale keys following Tailwind's spacing scale.
|
|
4
|
+
* Values range from '0' to '96', including fractional values and `px` (1px).
|
|
4
5
|
*/
|
|
5
6
|
export type SpacingKey = '0' | 'px' | '0.5' | '1' | '1.5' | '2' | '2.5' | '3' | '3.5' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '14' | '16' | '20' | '24' | '28' | '32' | '36' | '40' | '44' | '48' | '52' | '56' | '60' | '64' | '72' | '80' | '96';
|
|
7
|
+
/** Maps spacing scale keys to their pixel values. */
|
|
8
|
+
export type SpacingMap = Record<SpacingKey | string, number>;
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
export type SpacingMap = Record<SpacingKey, number>;
|
|
10
|
-
/**
|
|
11
|
-
* Spacing scale mapping following Tailwind's spacing scale
|
|
12
|
-
* Values are in pixels, with a base unit of 4px (1 = 4px)
|
|
10
|
+
* Spacing scale mapping following Tailwind's spacing scale.
|
|
11
|
+
* Values are in pixels, with a base unit of 4px (1 = 4px).
|
|
13
12
|
*/
|
|
14
13
|
export declare const spacingMap: SpacingMap;
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
15
|
+
* API for resolving spacing tokens to px/rem/css.
|
|
16
|
+
* The accepted keys are narrowed to default tokens plus theme keys.
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param key - Spacing scale key
|
|
23
|
-
* @returns Pixel value
|
|
24
|
-
*/
|
|
25
|
-
px: (key: SpacingKey | string) => number;
|
|
26
|
-
/**
|
|
27
|
-
* Get spacing value in rem units (divided by 16)
|
|
28
|
-
* @param key - Spacing scale key
|
|
29
|
-
* @returns Rem value
|
|
30
|
-
*/
|
|
31
|
-
rem: (key: SpacingKey | string) => number;
|
|
32
|
-
/**
|
|
33
|
-
* Get spacing value as CSS pixel string
|
|
34
|
-
* @param key - Spacing scale key
|
|
35
|
-
* @returns CSS pixel value string (e.g. "16px")
|
|
36
|
-
*/
|
|
37
|
-
css: (key: SpacingKey | string) => string;
|
|
18
|
+
export type SpacingApi<T extends SpacingMap | undefined> = {
|
|
19
|
+
px: (key: SpacingKey | (T extends SpacingMap ? keyof T : never)) => number;
|
|
20
|
+
rem: (key: SpacingKey | (T extends SpacingMap ? keyof T : never)) => number;
|
|
21
|
+
css: (key: SpacingKey | (T extends SpacingMap ? keyof T : never)) => string;
|
|
38
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Create a spacing API bound to an optional theme spacing map.
|
|
25
|
+
* @example
|
|
26
|
+
* const s = createSpacing({ gutter: 24 });
|
|
27
|
+
* s.px('gutter'); // 24
|
|
28
|
+
*/
|
|
29
|
+
export declare const createSpacing: <T extends SpacingMap | undefined = BaseThemeConfig["spacing"]>(themeSpacing?: T) => SpacingApi<T>;
|
|
30
|
+
/** Convenience instance using default spacing map (no theme). */
|
|
31
|
+
export declare const Spacing: SpacingApi<undefined>;
|
|
39
32
|
//# sourceMappingURL=spacing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../src/core/spacing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../src/core/spacing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe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f,UAAU,CAAC,CAAC,CA2Bd,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,OAAO,EAAE,UAAU,CAAC,SAAS,CACL,CAAC"}
|
package/dist/core/spacing.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ThemeManager } from '../theme/theme-manager';
|
|
2
1
|
/**
|
|
3
|
-
* Spacing scale mapping following Tailwind's spacing scale
|
|
4
|
-
* Values are in pixels, with a base unit of 4px (1 = 4px)
|
|
2
|
+
* Spacing scale mapping following Tailwind's spacing scale.
|
|
3
|
+
* Values are in pixels, with a base unit of 4px (1 = 4px).
|
|
5
4
|
*/
|
|
6
5
|
export const spacingMap = {
|
|
7
6
|
'0': 0,
|
|
@@ -41,42 +40,31 @@ export const spacingMap = {
|
|
|
41
40
|
'96': 384,
|
|
42
41
|
};
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* Create a spacing API bound to an optional theme spacing map.
|
|
44
|
+
* @example
|
|
45
|
+
* const s = createSpacing({ gutter: 24 });
|
|
46
|
+
* s.px('gutter'); // 24
|
|
45
47
|
*/
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* @param key - Spacing scale key
|
|
66
|
-
* @returns Rem value
|
|
67
|
-
*/
|
|
68
|
-
rem: (key) => {
|
|
69
|
-
const value = Spacing.getValueByKey(key);
|
|
70
|
-
return value / 16;
|
|
71
|
-
},
|
|
72
|
-
/**
|
|
73
|
-
* Get spacing value as CSS pixel string
|
|
74
|
-
* @param key - Spacing scale key
|
|
75
|
-
* @returns CSS pixel value string (e.g. "16px")
|
|
76
|
-
*/
|
|
77
|
-
css: (key) => {
|
|
78
|
-
const value = Spacing.getValueByKey(key);
|
|
79
|
-
return `${value}px`;
|
|
80
|
-
},
|
|
48
|
+
export const createSpacing = (themeSpacing) => {
|
|
49
|
+
const map = {
|
|
50
|
+
...spacingMap,
|
|
51
|
+
...themeSpacing,
|
|
52
|
+
};
|
|
53
|
+
const get = (key) => {
|
|
54
|
+
return typeof map[key] === 'number' ? map[key] : 0;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
px: (key) => {
|
|
58
|
+
return get(key);
|
|
59
|
+
},
|
|
60
|
+
rem: (key) => {
|
|
61
|
+
return get(key) / 16;
|
|
62
|
+
},
|
|
63
|
+
css: (key) => {
|
|
64
|
+
return `${get(key)}px`;
|
|
65
|
+
},
|
|
66
|
+
};
|
|
81
67
|
};
|
|
68
|
+
/** Convenience instance using default spacing map (no theme). */
|
|
69
|
+
export const Spacing = createSpacing(undefined);
|
|
82
70
|
//# sourceMappingURL=spacing.js.map
|
package/dist/core/spacing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../src/core/spacing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../src/core/spacing.ts"],"names":[],"mappings":"AA8CA;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,GAAG,EAAE,CAAC;IACN,EAAE,EAAE,CAAC;IACL,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,EAAE;IACT,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;IACT,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IAC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|
/* eslint-disable max-lines */
|
|
3
3
|
/* eslint-disable max-lines-per-function */
|
|
4
4
|
/* eslint-disable sonarjs/no-duplicate-string */
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { Spacing } from './spacing';
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { createSpacing, Spacing } from './spacing';
|
|
8
7
|
describe('Spacing', () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
ThemeManager.clear();
|
|
11
|
-
});
|
|
12
|
-
afterAll(() => {
|
|
13
|
-
ThemeManager.clear();
|
|
14
|
-
});
|
|
15
8
|
describe('px', () => {
|
|
16
9
|
it('should return pixel values', () => {
|
|
17
|
-
|
|
18
|
-
expect(
|
|
19
|
-
expect(
|
|
10
|
+
const spacing = createSpacing();
|
|
11
|
+
expect(spacing.px('2')).toBe(8);
|
|
12
|
+
expect(spacing.px('4')).toBe(16);
|
|
13
|
+
expect(spacing.px('8')).toBe(32);
|
|
20
14
|
});
|
|
21
15
|
});
|
|
22
16
|
describe('rem', () => {
|
|
23
17
|
it('should convert pixel values to rem', () => {
|
|
24
|
-
|
|
25
|
-
expect(
|
|
26
|
-
expect(
|
|
18
|
+
const spacing = createSpacing();
|
|
19
|
+
expect(spacing.rem('16')).toBe(4);
|
|
20
|
+
expect(spacing.rem('8')).toBe(2);
|
|
21
|
+
expect(spacing.rem('4')).toBe(1);
|
|
27
22
|
});
|
|
28
23
|
});
|
|
29
24
|
describe('css', () => {
|
|
30
25
|
it('should return pixel values as CSS strings', () => {
|
|
31
|
-
|
|
32
|
-
expect(
|
|
33
|
-
expect(
|
|
26
|
+
const spacing = createSpacing();
|
|
27
|
+
expect(spacing.css('2')).toBe('8px');
|
|
28
|
+
expect(spacing.css('4')).toBe('16px');
|
|
29
|
+
expect(spacing.css('8')).toBe('32px');
|
|
34
30
|
});
|
|
35
|
-
it('should
|
|
36
|
-
expect(Spacing.
|
|
37
|
-
expect(Spacing.css('
|
|
38
|
-
|
|
39
|
-
spacing: {
|
|
40
|
-
custom: 42,
|
|
41
|
-
'11': 100,
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
expect(Spacing.css('custom')).toBe('42px');
|
|
45
|
-
expect(Spacing.css('11')).toBe('100px');
|
|
31
|
+
it('should work with default Spacing constant', () => {
|
|
32
|
+
expect(Spacing.px('2')).toBe(8);
|
|
33
|
+
expect(Spacing.css('4')).toBe('16px');
|
|
34
|
+
expect(Spacing.rem('8')).toBe(2);
|
|
46
35
|
});
|
|
47
36
|
});
|
|
48
37
|
});
|