@cdx-ui/styles 0.0.1-beta.87 → 0.0.1-beta.88
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/lib/commonjs/useCdxFonts.js +3 -6
- package/lib/commonjs/useCdxFonts.js.map +1 -1
- package/lib/module/useCdxFonts.js +3 -1
- package/lib/module/useCdxFonts.js.map +1 -1
- package/lib/typescript/useCdxFonts.d.ts +2 -1
- package/lib/typescript/useCdxFonts.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/presetJson.test.ts +120 -0
- package/src/__tests__/sd.config.test.ts +856 -0
- package/src/__tests__/types.test.ts +72 -0
- package/src/__tests__/useCdxFonts.test.ts +27 -0
- package/src/__tests__/useForgeFonts.test.ts +226 -0
- package/src/useCdxFonts.ts +3 -1
|
@@ -3,11 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _useForgeFonts.useForgeFonts;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
6
|
+
exports.useCdxFonts = void 0;
|
|
12
7
|
var _useForgeFonts = require("./useForgeFonts");
|
|
8
|
+
/** @deprecated Use `useForgeFonts` instead. Will be removed in a future major release. */
|
|
9
|
+
const useCdxFonts = exports.useCdxFonts = _useForgeFonts.useForgeFonts;
|
|
13
10
|
//# sourceMappingURL=useCdxFonts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_useForgeFonts","require"],"sourceRoot":"../../src","sources":["useCdxFonts.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_useForgeFonts","require","useCdxFonts","exports","useForgeFonts"],"sourceRoot":"../../src","sources":["useCdxFonts.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACO,MAAMC,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAGE,4BAAa","ignoreList":[]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { useForgeFonts } from './useForgeFonts';
|
|
4
|
+
|
|
3
5
|
/** @deprecated Use `useForgeFonts` instead. Will be removed in a future major release. */
|
|
4
|
-
export
|
|
6
|
+
export const useCdxFonts = useForgeFonts;
|
|
5
7
|
//# sourceMappingURL=useCdxFonts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useForgeFonts","useCdxFonts"],"sourceRoot":"../../src","sources":["useCdxFonts.ts"],"mappings":";;AAAA
|
|
1
|
+
{"version":3,"names":["useForgeFonts","useCdxFonts"],"sourceRoot":"../../src","sources":["useCdxFonts.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,iBAAiB;;AAE/C;AACA,OAAO,MAAMC,WAAW,GAAGD,aAAa","ignoreList":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useForgeFonts } from './useForgeFonts';
|
|
1
2
|
/** @deprecated Use `useForgeFonts` instead. Will be removed in a future major release. */
|
|
2
|
-
export
|
|
3
|
+
export declare const useCdxFonts: typeof useForgeFonts;
|
|
3
4
|
//# sourceMappingURL=useCdxFonts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCdxFonts.d.ts","sourceRoot":"","sources":["../../src/useCdxFonts.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"useCdxFonts.d.ts","sourceRoot":"","sources":["../../src/useCdxFonts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,0FAA0F;AAC1F,eAAO,MAAM,WAAW,sBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/styles",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.88",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@expo-google-fonts/manrope": "0.4.2",
|
|
66
66
|
"@expo-google-fonts/outfit": "0.4.3",
|
|
67
67
|
"@expo-google-fonts/public-sans": "0.4.2",
|
|
68
|
-
"@cdx-ui/utils": "0.0.1-beta.
|
|
68
|
+
"@cdx-ui/utils": "0.0.1-beta.88"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"expo-font": ">=13.0.0",
|
|
@@ -113,6 +113,6 @@
|
|
|
113
113
|
"tokens:fetch": "node scripts/figma-fetch-variables.mjs",
|
|
114
114
|
"tokens:build": "node scripts/build-tokens.mjs",
|
|
115
115
|
"fonts:validate": "node scripts/validate-font-tokens.mjs",
|
|
116
|
-
"test": "jest --config jest.config.js"
|
|
116
|
+
"test": "jest --config ../../jest.config.js --selectProjects styles"
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import poise from '../../tokens/presets/poise.json';
|
|
2
|
+
import prestige from '../../tokens/presets/prestige.json';
|
|
3
|
+
import pulse from '../../tokens/presets/pulse.json';
|
|
4
|
+
import { OVERRIDE_SCHEMA_VERSION } from '../types';
|
|
5
|
+
import type { Preset } from '../types';
|
|
6
|
+
|
|
7
|
+
interface PresetThemeMetadata {
|
|
8
|
+
name: string;
|
|
9
|
+
preset: string;
|
|
10
|
+
schemaVersion: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface PresetJson {
|
|
14
|
+
$extensions: {
|
|
15
|
+
'com.forge.ui.theme': PresetThemeMetadata;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
};
|
|
18
|
+
modes: {
|
|
19
|
+
light: Record<string, unknown>;
|
|
20
|
+
dark: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
platform: {
|
|
23
|
+
web: Record<string, unknown>;
|
|
24
|
+
ios: Record<string, unknown>;
|
|
25
|
+
android: Record<string, unknown>;
|
|
26
|
+
};
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const presets: readonly { name: string; key: Preset; data: PresetJson }[] = [
|
|
31
|
+
{ name: 'poise', key: 'poise', data: poise as unknown as PresetJson },
|
|
32
|
+
{ name: 'prestige', key: 'prestige', data: prestige as unknown as PresetJson },
|
|
33
|
+
{ name: 'pulse', key: 'pulse', data: pulse as unknown as PresetJson },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Tailwind theme namespaces every generated preset is expected to declare at
|
|
38
|
+
* the top level. `typography` is intentionally omitted because non-default
|
|
39
|
+
* presets (prestige, pulse) ship as deltas from poise and don't redeclare
|
|
40
|
+
* composite typography tokens — those resolve from the base preset at runtime.
|
|
41
|
+
*/
|
|
42
|
+
const REQUIRED_TOP_LEVEL_NAMESPACES = [
|
|
43
|
+
'color',
|
|
44
|
+
'font',
|
|
45
|
+
'font-weight',
|
|
46
|
+
'spacing',
|
|
47
|
+
'text',
|
|
48
|
+
'radius',
|
|
49
|
+
'blur',
|
|
50
|
+
'breakpoint',
|
|
51
|
+
'leading',
|
|
52
|
+
'tracking',
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
describe.each(presets)('preset JSON: $name.json', ({ key, data: preset }) => {
|
|
56
|
+
describe('top-level structure', () => {
|
|
57
|
+
it('has $extensions, modes, and platform top-level keys', () => {
|
|
58
|
+
expect(preset).toHaveProperty('$extensions');
|
|
59
|
+
expect(preset).toHaveProperty('modes');
|
|
60
|
+
expect(preset).toHaveProperty('platform');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it.each(REQUIRED_TOP_LEVEL_NAMESPACES)('declares the %s namespace', (ns) => {
|
|
64
|
+
expect(preset).toHaveProperty(ns);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('$extensions.com.forge.ui.theme metadata', () => {
|
|
69
|
+
const meta = preset.$extensions['com.forge.ui.theme'];
|
|
70
|
+
|
|
71
|
+
it('declares name, preset, and schemaVersion', () => {
|
|
72
|
+
expect(meta).toBeDefined();
|
|
73
|
+
expect(typeof meta.name).toBe('string');
|
|
74
|
+
expect(typeof meta.preset).toBe('string');
|
|
75
|
+
expect(typeof meta.schemaVersion).toBe('string');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('preset field matches the file name', () => {
|
|
79
|
+
expect(meta.preset).toBe(key);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('schemaVersion matches the current OVERRIDE_SCHEMA_VERSION', () => {
|
|
83
|
+
expect(meta.schemaVersion).toBe(OVERRIDE_SCHEMA_VERSION);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('modes', () => {
|
|
88
|
+
it('declares both light and dark modes (may be empty for delta presets)', () => {
|
|
89
|
+
expect(preset.modes).toHaveProperty('light');
|
|
90
|
+
expect(preset.modes).toHaveProperty('dark');
|
|
91
|
+
expect(typeof preset.modes.light).toBe('object');
|
|
92
|
+
expect(typeof preset.modes.dark).toBe('object');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('platform', () => {
|
|
97
|
+
it('declares web, ios, and android platforms', () => {
|
|
98
|
+
expect(preset.platform).toHaveProperty('web');
|
|
99
|
+
expect(preset.platform).toHaveProperty('ios');
|
|
100
|
+
expect(preset.platform).toHaveProperty('android');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it.each(['web', 'ios', 'android'] as const)('platform %s has a font group', (platform) => {
|
|
104
|
+
expect(preset.platform[platform]).toHaveProperty('font');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('poise preset (default — full semantic surface)', () => {
|
|
110
|
+
const data = poise as unknown as PresetJson;
|
|
111
|
+
|
|
112
|
+
it('declares the typography namespace (composite typography tokens)', () => {
|
|
113
|
+
expect(data).toHaveProperty('typography');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it.each(['light', 'dark'] as const)('mode %s carries semantic color and font groups', (mode) => {
|
|
117
|
+
expect(data.modes[mode]).toHaveProperty('color');
|
|
118
|
+
expect(data.modes[mode]).toHaveProperty('font');
|
|
119
|
+
});
|
|
120
|
+
});
|