@aleph-alpha/config-css 0.21.2 → 1.0.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/CHANGELOG.md +18 -0
- package/dist/index.js +635 -663
- package/package.json +2 -2
- package/sd.config.js +9 -3
- package/src/index.ts +9 -6
- package/src/presetWebFontsAlephAlpha.ts +7 -2
- package/src/utils/convert-fonts.js +3 -1
- package/tsconfig.json +4 -1
- package/vite.config.ts +12 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/config-css",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"prettier": "@aleph-alpha/prettier-config-frontend",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"style-dictionary": "^4.0.1",
|
|
26
26
|
"vite-plugin-dts": "^4.0.0",
|
|
27
27
|
"@aleph-alpha/eslint-config-frontend": "0.5.0",
|
|
28
|
-
"@aleph-alpha/prettier-config-frontend": "0.
|
|
28
|
+
"@aleph-alpha/prettier-config-frontend": "2.0.0"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"transform:global": "npx token-transformer ./tokens.json ./transformed-tokens/global.json global,\"Spark Border Radius/Mode 1\",\"Spark Spacings/Mode 1\",\"Spark Text/Mode 1\" \"Spark Colors/Light mode/primitives\" --throwErrorWhenNotResolved",
|
package/sd.config.js
CHANGED
|
@@ -38,7 +38,10 @@ StyleDictionary.registerTransform({
|
|
|
38
38
|
return token.type === 'typography';
|
|
39
39
|
},
|
|
40
40
|
transform: function (token) {
|
|
41
|
-
return token.name
|
|
41
|
+
return token.name
|
|
42
|
+
.split('-')
|
|
43
|
+
.splice(1, token.name.split('-').length)
|
|
44
|
+
.join('-');
|
|
42
45
|
},
|
|
43
46
|
});
|
|
44
47
|
|
|
@@ -85,7 +88,9 @@ StyleDictionary.registerTransform({
|
|
|
85
88
|
|
|
86
89
|
const css = {};
|
|
87
90
|
keys.forEach((key) => {
|
|
88
|
-
const newKey = key
|
|
91
|
+
const newKey = key
|
|
92
|
+
.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2')
|
|
93
|
+
.toLowerCase();
|
|
89
94
|
|
|
90
95
|
if (allowedKeys.includes(newKey)) {
|
|
91
96
|
css[newKey] = value[key];
|
|
@@ -110,7 +115,8 @@ StyleDictionary.registerTransform({
|
|
|
110
115
|
if (!value) return;
|
|
111
116
|
|
|
112
117
|
if (value['font-family']) {
|
|
113
|
-
value['font-family'] =
|
|
118
|
+
value['font-family'] =
|
|
119
|
+
`var(--custom-font-family, ${value['font-family']})`;
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
return value;
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { definePreset, Preset, presetTypography, presetWind } from 'unocss';
|
|
|
2
2
|
import { presetAnimations } from 'unocss-preset-animations';
|
|
3
3
|
import presetTheme from 'unocss-preset-theme';
|
|
4
4
|
import presetLegacyCompat from '@unocss/preset-legacy-compat';
|
|
5
|
-
import boxShadowsSet from '
|
|
6
|
-
import darkModeSet from '
|
|
7
|
-
import lightModeSet from '
|
|
8
|
-
import spacingsSet from '
|
|
9
|
-
import typographySet from '
|
|
5
|
+
import boxShadowsSet from '#sd-output/box-shadows.json';
|
|
6
|
+
import darkModeSet from '#sd-output/dark-mode.json';
|
|
7
|
+
import lightModeSet from '#sd-output/light-mode.json';
|
|
8
|
+
import spacingsSet from '#sd-output/spacings.json';
|
|
9
|
+
import typographySet from '#sd-output/typography.json';
|
|
10
10
|
import { presetWebFontsAlephAlpha } from './presetWebFontsAlephAlpha';
|
|
11
11
|
|
|
12
12
|
type Theme = {
|
|
@@ -106,7 +106,10 @@ const tokenPreset: Preset<Theme> = definePreset<Theme>(() => {
|
|
|
106
106
|
},
|
|
107
107
|
},
|
|
108
108
|
],
|
|
109
|
-
rules: [
|
|
109
|
+
rules: [
|
|
110
|
+
...Object.entries(typographySet),
|
|
111
|
+
['h-screen', { height: '100vh' }],
|
|
112
|
+
],
|
|
110
113
|
theme: {
|
|
111
114
|
colors: lightModeSet,
|
|
112
115
|
spacing: spacingsSet,
|
|
@@ -12,7 +12,10 @@ import { inter500 } from './assets/fonts/inter500.woff2';
|
|
|
12
12
|
import { inter600 } from './assets/fonts/inter600.woff2';
|
|
13
13
|
import { inter700 } from './assets/fonts/inter700.woff2';
|
|
14
14
|
|
|
15
|
-
const normalizeEmbeddedFontDataUri = (
|
|
15
|
+
const normalizeEmbeddedFontDataUri = (
|
|
16
|
+
fontDataUri: string,
|
|
17
|
+
mimeType = 'font/woff2',
|
|
18
|
+
) => {
|
|
16
19
|
const normalizedUri = fontDataUri.trim();
|
|
17
20
|
const legacyPrefixes = [
|
|
18
21
|
'data:@file/octet-stream;base64,',
|
|
@@ -21,7 +24,9 @@ const normalizeEmbeddedFontDataUri = (fontDataUri: string, mimeType = 'font/woff
|
|
|
21
24
|
'data:%40file/binary;base64,',
|
|
22
25
|
];
|
|
23
26
|
|
|
24
|
-
const matchedPrefix = legacyPrefixes.find((prefix) =>
|
|
27
|
+
const matchedPrefix = legacyPrefixes.find((prefix) =>
|
|
28
|
+
normalizedUri.startsWith(prefix),
|
|
29
|
+
);
|
|
25
30
|
if (matchedPrefix) {
|
|
26
31
|
return `data:${mimeType};base64,${normalizedUri.slice(matchedPrefix.length)}`;
|
|
27
32
|
}
|
|
@@ -32,7 +32,9 @@ const args = process.argv.slice(2);
|
|
|
32
32
|
|
|
33
33
|
if (args.length < 2) {
|
|
34
34
|
console.log('Usage: node convert-fonts.js <input.woff2> <output.ts>');
|
|
35
|
-
console.log(
|
|
35
|
+
console.log(
|
|
36
|
+
'Example: node convert-fonts.js montserrat600.woff2 montserrat600.woff2.ts',
|
|
37
|
+
);
|
|
36
38
|
process.exit(1);
|
|
37
39
|
}
|
|
38
40
|
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
1
3
|
import { defineConfig } from 'vite';
|
|
2
4
|
import dts from 'vite-plugin-dts';
|
|
3
5
|
|
|
6
|
+
const dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
|
|
4
8
|
export default defineConfig({
|
|
9
|
+
resolve: {
|
|
10
|
+
alias: {
|
|
11
|
+
'#sd-output': resolve(dirname, 'sd-output'),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
5
14
|
build: {
|
|
6
15
|
lib: {
|
|
7
16
|
entry: './src/index.ts',
|
|
@@ -12,5 +21,7 @@ export default defineConfig({
|
|
|
12
21
|
external: ['unocss', 'unocss-preset-theme', 'unocss/preset-uno'],
|
|
13
22
|
},
|
|
14
23
|
},
|
|
15
|
-
|
|
24
|
+
// Use tsconfig `paths` for token JSON (not `../sd-output/`) so `rollupTypes` + API
|
|
25
|
+
// Extractor do not fail (see vite-plugin-dts FAQ: baseUrl + non-standard imports).
|
|
26
|
+
plugins: [dts({ rollupTypes: true, tsconfigPath: './tsconfig.json' })],
|
|
16
27
|
});
|