zuii 1.1.0 → 1.2.1
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/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/index.js +7 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/components/Button/react/index.d.ts +36 -3
- package/dist/components/Button/react/index.js +27 -12
- package/dist/components/Button/style/button.css +1 -1
- package/dist/components/Icon/react/index.d.ts +26 -0
- package/dist/components/Icon/react/index.js +13 -0
- package/dist/components/Icon/style/icon.css +1 -0
- package/dist/core/styles/_tokens.scss +106 -0
- package/dist/core/styles/main.css +1 -1
- package/dist/core/styles/tokens.css +156 -0
- package/dist/core/styles/tokens.d.ts +83 -0
- package/dist/core/styles/tokens.ts +89 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -2
- package/dist/node_modules/.pnpm/@restart_ui@1.9.4_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@restart/ui/esm/Button.js +78 -0
- package/dist/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js +37 -0
- package/dist/node_modules/.pnpm/react-bootstrap@2.10.10_@types_react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-bootstrap/esm/Button.js +34 -0
- package/dist/node_modules/.pnpm/react-bootstrap@2.10.10_@types_react@19.2.10_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/react-bootstrap/esm/ThemeProvider.js +23 -0
- package/package.json +18 -5
- package/style-dictionary/README.md +95 -0
- package/style-dictionary/build.js +75 -0
- package/style-dictionary/config.js +32 -0
- package/style-dictionary/hooks/formats.js +86 -0
- package/style-dictionary/hooks/transforms.js +49 -0
- package/style-dictionary/platforms.js +50 -0
- package/style-dictionary/utils/color.js +20 -0
- package/dist/components/Button/js/Button.d.ts +0 -6
- package/dist/components/Button/js/Button.js +0 -7
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import StyleDictionary from 'style-dictionary';
|
|
3
|
+
import { getConfigs } from './config.js';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { dirname, join, resolve } from 'path';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Parse les arguments CLI pour extraire les chemins de tokens et le chemin de sortie
|
|
12
|
+
* @returns {{ tokenPaths: string[], outputPath: string }}
|
|
13
|
+
*/
|
|
14
|
+
const parseArgs = () => {
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
let tokenPaths = [];
|
|
17
|
+
let outputPath = null;
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < args.length; i++) {
|
|
20
|
+
if (args[i] === '--output' || args[i] === '-o') {
|
|
21
|
+
outputPath = args[i + 1];
|
|
22
|
+
i++; // Skip next argument
|
|
23
|
+
} else {
|
|
24
|
+
tokenPaths.push(args[i]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Si aucun chemin de tokens n'est fourni, utiliser 'tokens' par défaut
|
|
29
|
+
if (tokenPaths.length === 0) {
|
|
30
|
+
tokenPaths = ['tokens'];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Si aucun chemin de sortie n'est fourni, utiliser le répertoire courant du projet
|
|
34
|
+
if (!outputPath) {
|
|
35
|
+
outputPath = process.cwd();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { tokenPaths, outputPath: resolve(outputPath) };
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
console.log('🚀 Starting Style Dictionary build...');
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Lance le build pour toutes les configurations générées à partir des chemins fournis
|
|
45
|
+
*/
|
|
46
|
+
const runBuild = async () => {
|
|
47
|
+
try {
|
|
48
|
+
const { tokenPaths, outputPath } = parseArgs();
|
|
49
|
+
|
|
50
|
+
console.log(`📂 Output directory: ${outputPath}`);
|
|
51
|
+
|
|
52
|
+
// Résoudre les chemins de tokens par rapport au répertoire courant
|
|
53
|
+
const resolvedTokenPaths = tokenPaths.map(path => {
|
|
54
|
+
// Si le chemin est absolu, l'utiliser tel quel
|
|
55
|
+
if (path.startsWith('/')) return path;
|
|
56
|
+
// Sinon, le résoudre par rapport au répertoire courant
|
|
57
|
+
return resolve(process.cwd(), path);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const configs = getConfigs(resolvedTokenPaths, outputPath);
|
|
61
|
+
|
|
62
|
+
for (const config of configs) {
|
|
63
|
+
console.log(`\n📦 Building source: ${config.source}`);
|
|
64
|
+
const sd = new StyleDictionary(config);
|
|
65
|
+
await sd.buildAllPlatforms();
|
|
66
|
+
}
|
|
67
|
+
console.log('\n✅ Build completed successfully!');
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('\n❌ Build failed:', error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
runBuild();
|
|
75
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { transforms } from './hooks/transforms.js';
|
|
2
|
+
import { formats } from './hooks/formats.js';
|
|
3
|
+
import { getPlatforms } from './platforms.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hooks partagés (transformations et formats) pour toutes les sources de tokens
|
|
7
|
+
*/
|
|
8
|
+
const hooks = {
|
|
9
|
+
transforms,
|
|
10
|
+
formats
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Génère les configurations Style Dictionary pour les chemins de tokens fournis
|
|
15
|
+
* @param {string[]} paths - Tableau de chemins vers les dossiers de tokens
|
|
16
|
+
* @param {string} outputPath - Chemin de sortie pour les fichiers générés (défaut: 'src/core/styles/')
|
|
17
|
+
* @returns {Array} Tableau de configurations Style Dictionary
|
|
18
|
+
*/
|
|
19
|
+
export const getConfigs = (paths = ['tokens'], outputPath = 'src/core/styles/') => {
|
|
20
|
+
// S'assurer que outputPath se termine par un slash
|
|
21
|
+
const buildPath = outputPath.endsWith('/') ? outputPath : `${outputPath}/`;
|
|
22
|
+
|
|
23
|
+
return paths.map(path => ({
|
|
24
|
+
hooks,
|
|
25
|
+
source: [`${path}/**/*.json`],
|
|
26
|
+
platforms: getPlatforms(buildPath)
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Export par défaut pour compatibilité
|
|
31
|
+
export default getConfigs();
|
|
32
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { hexToRgb } from '../utils/color.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats personnalisés Style Dictionary
|
|
5
|
+
*/
|
|
6
|
+
export const formats = {
|
|
7
|
+
/**
|
|
8
|
+
* Format SCSS avec maps imbriquées
|
|
9
|
+
*/
|
|
10
|
+
'scss/variables-with-map': ({ dictionary }) => {
|
|
11
|
+
const processMap = (obj, depth = 0) => {
|
|
12
|
+
const indent = ' '.repeat(depth + 1);
|
|
13
|
+
let output = '';
|
|
14
|
+
if (obj.hasOwnProperty('value')) return `(${obj.value})`;
|
|
15
|
+
const keys = Object.keys(obj).filter(key =>
|
|
16
|
+
key !== 'original' && key !== 'filePath' && key !== 'isSource' &&
|
|
17
|
+
key !== 'path' && key !== 'name' && key !== 'attributes' && key !== 'modify'
|
|
18
|
+
);
|
|
19
|
+
if (keys.length === 0) return '()';
|
|
20
|
+
output += '(\n';
|
|
21
|
+
keys.forEach(key => {
|
|
22
|
+
const value = obj[key];
|
|
23
|
+
output += `${indent}"${key}": ${processMap(value, depth + 1)},\n`;
|
|
24
|
+
});
|
|
25
|
+
output += `${' '.repeat(depth)})`;
|
|
26
|
+
return output;
|
|
27
|
+
};
|
|
28
|
+
let output = `/**\n * Auto-generated\n */\n`;
|
|
29
|
+
Object.keys(dictionary.tokens).forEach(category => {
|
|
30
|
+
const mapContent = processMap(dictionary.tokens[category]);
|
|
31
|
+
output += `\n$${category}: ${mapContent};\n`;
|
|
32
|
+
});
|
|
33
|
+
return output;
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Format CSS personnalisé avec variations automatiques pour Bootstrap
|
|
37
|
+
*/
|
|
38
|
+
'css/custom-format': ({ dictionary }) => {
|
|
39
|
+
let output = `/**\n * Auto-generated\n */\n\n:root {\n`;
|
|
40
|
+
output += dictionary.allTokens
|
|
41
|
+
.filter(token => token.isSource)
|
|
42
|
+
.map(token => {
|
|
43
|
+
let name = token.name.replace('color-', '').replace('brands-', '').replace('-alias', '');
|
|
44
|
+
let tokenOutput = ` --${name}: ${token.value};`;
|
|
45
|
+
if (token.path.includes('color') && !name.includes('emphasis') && !name.includes('subtle') && !name.includes('gray')) {
|
|
46
|
+
const rgb = hexToRgb(token.value);
|
|
47
|
+
if (rgb) tokenOutput += `\n --${name}-rgb: ${rgb};`;
|
|
48
|
+
}
|
|
49
|
+
if (token.path.includes('brands') && token.value.startsWith('#')) {
|
|
50
|
+
const rgb = hexToRgb(token.value);
|
|
51
|
+
if (rgb) {
|
|
52
|
+
tokenOutput += `\n --${name}-rgb: ${rgb};`;
|
|
53
|
+
const variations = token.original?.variations;
|
|
54
|
+
const mixPercent = token.original?.mixPercent;
|
|
55
|
+
if (variations?.dark) {
|
|
56
|
+
tokenOutput += `\n --${name}-dark: ${variations.dark};`;
|
|
57
|
+
const darkRgb = hexToRgb(variations.dark);
|
|
58
|
+
if (darkRgb) tokenOutput += `\n --${name}-dark-rgb: ${darkRgb};`;
|
|
59
|
+
} else {
|
|
60
|
+
const mixPercentDark = mixPercent?.dark ?? 70;
|
|
61
|
+
tokenOutput += `\n --${name}-dark: color-mix(in srgb, var(--${name}), var(--black) ${mixPercentDark}%);`;
|
|
62
|
+
}
|
|
63
|
+
if (variations?.light) {
|
|
64
|
+
tokenOutput += `\n --${name}-light: ${variations.light};`;
|
|
65
|
+
const lightRgb = hexToRgb(variations.light);
|
|
66
|
+
if (lightRgb) tokenOutput += `\n --${name}-light-rgb: ${lightRgb};`;
|
|
67
|
+
} else {
|
|
68
|
+
const mixPercentLight = mixPercent?.light ?? 80;
|
|
69
|
+
tokenOutput += `\n --${name}-light: color-mix(in srgb, var(--${name}), var(--white) ${mixPercentLight}%);`;
|
|
70
|
+
}
|
|
71
|
+
tokenOutput += `\n --${name}-text-emphasis: var(--${name}-dark);`;
|
|
72
|
+
tokenOutput += `\n --${name}-bg-subtle: var(--${name}-light);`;
|
|
73
|
+
if (variations?.border) {
|
|
74
|
+
tokenOutput += `\n --${name}-border-subtle: ${variations.border};`;
|
|
75
|
+
} else {
|
|
76
|
+
const mixPercentBorder = mixPercent?.border ?? 60;
|
|
77
|
+
tokenOutput += `\n --${name}-border-subtle: color-mix(in srgb, var(--${name}), var(--white) ${mixPercentBorder}%);`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return tokenOutput;
|
|
82
|
+
}).join('\n');
|
|
83
|
+
output += `\n}`;
|
|
84
|
+
return output;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { colord, extend } from 'colord';
|
|
2
|
+
import mixPlugin from 'colord/plugins/mix';
|
|
3
|
+
|
|
4
|
+
extend([mixPlugin]);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transformations Style Dictionary
|
|
8
|
+
*/
|
|
9
|
+
export const transforms = {
|
|
10
|
+
/**
|
|
11
|
+
* Transformation de nom en kebab-case
|
|
12
|
+
*/
|
|
13
|
+
'name/kebab': {
|
|
14
|
+
type: 'name',
|
|
15
|
+
transform: (token) => token.path.join('-').toLowerCase()
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Transformation de nom en CONSTANT_CASE
|
|
19
|
+
*/
|
|
20
|
+
'name/constant': {
|
|
21
|
+
type: 'name',
|
|
22
|
+
transform: (token) => token.path.join('_').toUpperCase().replace(/-/g, '_')
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* Transformation de modification de couleurs (darken, lighten, alpha, mix)
|
|
26
|
+
*/
|
|
27
|
+
'color/modify': {
|
|
28
|
+
type: 'value',
|
|
29
|
+
transitive: true,
|
|
30
|
+
matcher: (token) => {
|
|
31
|
+
// token.path est un tableau comme ['color', 'gray', '100'] ou ['brands', 'primary']
|
|
32
|
+
const isColor = token.path[0] === 'color' || token.path[0] === 'brands';
|
|
33
|
+
const hasModify = !!token.modify;
|
|
34
|
+
return isColor && hasModify;
|
|
35
|
+
},
|
|
36
|
+
transform: (token) => {
|
|
37
|
+
let color = colord(token.value);
|
|
38
|
+
if (token.modify && Array.isArray(token.modify)) {
|
|
39
|
+
token.modify.forEach(mod => {
|
|
40
|
+
if (mod.type === 'darken') color = color.darken(mod.amount);
|
|
41
|
+
else if (mod.type === 'lighten') color = color.lighten(mod.amount);
|
|
42
|
+
else if (mod.type === 'alpha') color = color.alpha(mod.amount);
|
|
43
|
+
else if (mod.type === 'mix') color = color.mix(mod.color, mod.amount);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return color.toHex();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Génère les configurations de plateforme pour une destination donnée
|
|
3
|
+
*
|
|
4
|
+
* @param {string} buildPath - Chemin de sortie des fichiers
|
|
5
|
+
*/
|
|
6
|
+
export const getPlatforms = (buildPath) => ({
|
|
7
|
+
scss: {
|
|
8
|
+
transforms: [
|
|
9
|
+
'attribute/cti',
|
|
10
|
+
'name/kebab',
|
|
11
|
+
'size/rem',
|
|
12
|
+
'color/css',
|
|
13
|
+
'fontFamily/css',
|
|
14
|
+
'shadow/css/shorthand'
|
|
15
|
+
],
|
|
16
|
+
buildPath,
|
|
17
|
+
files: [{
|
|
18
|
+
destination: '_tokens.scss',
|
|
19
|
+
format: 'scss/variables-with-map'
|
|
20
|
+
}]
|
|
21
|
+
},
|
|
22
|
+
css: {
|
|
23
|
+
transforms: [
|
|
24
|
+
'attribute/cti',
|
|
25
|
+
'name/kebab',
|
|
26
|
+
'size/rem',
|
|
27
|
+
'color/css',
|
|
28
|
+
'fontFamily/css',
|
|
29
|
+
'shadow/css/shorthand'
|
|
30
|
+
],
|
|
31
|
+
buildPath,
|
|
32
|
+
files: [{
|
|
33
|
+
destination: 'tokens.css',
|
|
34
|
+
format: 'css/custom-format'
|
|
35
|
+
}]
|
|
36
|
+
},
|
|
37
|
+
ts: {
|
|
38
|
+
transforms: [
|
|
39
|
+
'attribute/cti',
|
|
40
|
+
'name/constant',
|
|
41
|
+
'size/rem',
|
|
42
|
+
'color/hex'
|
|
43
|
+
],
|
|
44
|
+
buildPath,
|
|
45
|
+
files: [{
|
|
46
|
+
destination: 'tokens.ts',
|
|
47
|
+
format: 'javascript/es6'
|
|
48
|
+
}]
|
|
49
|
+
}
|
|
50
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convertit une couleur hexadécimale en valeurs RGB séparées par des virgules
|
|
3
|
+
*
|
|
4
|
+
* @param {string} hex - Couleur au format hexadécimal (#RGB ou #RRGGBB)
|
|
5
|
+
* @returns {string|null} Valeurs RGB au format "r, g, b" (ex: "255, 0, 0") ou null si invalide
|
|
6
|
+
*/
|
|
7
|
+
export const hexToRgb = (hex) => {
|
|
8
|
+
if (typeof hex !== 'string' || !hex.startsWith('#')) return null;
|
|
9
|
+
let r, g, b;
|
|
10
|
+
if (hex.length === 4) {
|
|
11
|
+
r = parseInt(hex[1] + hex[1], 16);
|
|
12
|
+
g = parseInt(hex[2] + hex[2], 16);
|
|
13
|
+
b = parseInt(hex[3] + hex[3], 16);
|
|
14
|
+
} else {
|
|
15
|
+
r = parseInt(hex.slice(1, 3), 16);
|
|
16
|
+
g = parseInt(hex.slice(3, 5), 16);
|
|
17
|
+
b = parseInt(hex.slice(5, 7), 16);
|
|
18
|
+
}
|
|
19
|
+
return `${r}, ${g}, ${b}`;
|
|
20
|
+
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
const n = (t) => {
|
|
2
|
-
const e = document.createElement("button");
|
|
3
|
-
return e.innerText = t.label, e.classList.add("z-btn"), t.variant && e.classList.add(`is-${t.variant}`), t.onClick && e.addEventListener("click", t.onClick), e;
|
|
4
|
-
};
|
|
5
|
-
export {
|
|
6
|
-
n as renderButton
|
|
7
|
-
};
|