@massimo-cassandro/minimo 1.19.8 → 1.19.9
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/design-tokens/tokens-config-sample.mjs +18 -11
- package/design-tokens/utilities/build-tokens-src/config.mjs +7 -0
- package/design-tokens/utilities/build-tokens-src/formats/css.mjs +41 -6
- package/design-tokens/utilities/build-tokens-src/platforms.mjs +3 -0
- package/design-tokens/utilities/build-tokens.mjs +2 -0
- package/dev-tools/starter-kit/webpack-template.ejs +1 -0
- package/dev-tools/starter-kit/webpack.config.mjs +1 -0
- package/package.json +1 -1
- package/src/custom-properties.css +11 -9
|
@@ -18,7 +18,7 @@ const minimo_path = '../../node_modules/@massimo-cassandro/minimo';
|
|
|
18
18
|
const config = {
|
|
19
19
|
|
|
20
20
|
// ---------------------------------------------------------------------------
|
|
21
|
-
//
|
|
21
|
+
// BUILD-TOKENS & STYLE-DICTIONARY SETTINGS
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
23
|
|
|
24
24
|
// Path to the stylelint config used to lint the generated CSS file
|
|
@@ -49,11 +49,27 @@ const config = {
|
|
|
49
49
|
|
|
50
50
|
],
|
|
51
51
|
|
|
52
|
+
// If true, custom properties already present in the CSS destination file
|
|
53
|
+
// (destFile, from a previous build) take priority over the ones generated
|
|
54
|
+
// by this build. Properties found only in the pre-existing file (no longer
|
|
55
|
+
// generated) are kept too. Useful to preserve manual overrides/additions
|
|
56
|
+
// made directly in the compiled CSS across rebuilds. Ignored on the first
|
|
57
|
+
// build, when destFile does not exist yet. Default: false.
|
|
58
|
+
mergeCustomProps: false,
|
|
59
|
+
|
|
60
|
+
// Properties whose names begin with one of the following strings are grouped
|
|
61
|
+
// and placed at the beginning of the output CSS file
|
|
62
|
+
colorPropertiesPrefixes: ['accent', 'primary', 'secondary', 'neutral'],
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// PENPOT / FIGMA
|
|
52
67
|
// ---------------------------------------------------------------------------
|
|
53
68
|
// Optional design tokens output
|
|
54
69
|
// Generates one or more json(c) files in addition to the CSS output file, for use
|
|
55
70
|
// in Penpot or Figma projects or as an alternative to the .mjs source files
|
|
56
71
|
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
57
73
|
// Output format for Penpot token files: 'jsonc' or 'json'
|
|
58
74
|
// 'jsonc' -> adds a generated-file disclaimer header, uses .jsonc extension
|
|
59
75
|
// 'json' -> plain JSON, no disclaimer
|
|
@@ -75,18 +91,9 @@ const config = {
|
|
|
75
91
|
// e.g. {size.base} = 16px, "{size.base} * .25" -> "4px"
|
|
76
92
|
penpotExpressions: 'resolve',
|
|
77
93
|
|
|
78
|
-
// If true, custom properties already present in the CSS destination file
|
|
79
|
-
// (destFile, from a previous build) take priority over the ones generated
|
|
80
|
-
// by this build. Properties found only in the pre-existing file (no longer
|
|
81
|
-
// generated) are kept too. Useful to preserve manual overrides/additions
|
|
82
|
-
// made directly in the compiled CSS across rebuilds. Ignored on the first
|
|
83
|
-
// build, when destFile does not exist yet. Default: false.
|
|
84
|
-
mergeCustomProps: false,
|
|
85
|
-
|
|
86
|
-
|
|
87
94
|
|
|
88
95
|
// ---------------------------------------------------------------------------
|
|
89
|
-
//
|
|
96
|
+
// CHECK-UNRESOLVED-CUSTOM-PROPS.MJS SETTINGS
|
|
90
97
|
// ---------------------------------------------------------------------------
|
|
91
98
|
|
|
92
99
|
// If true, also reports custom properties that are defined (in destFile or
|
|
@@ -81,6 +81,13 @@ export const penpotExpressions = VALID_EXPR_MODES.includes(buildConfig.penpotExp
|
|
|
81
81
|
// build-tokens-src/merge-css.mjs). Default: false.
|
|
82
82
|
export const mergeCustomProps = buildConfig.mergeCustomProps === true;
|
|
83
83
|
|
|
84
|
+
// colorPropertiesPrefixes: custom properties whose first hyphen-separated
|
|
85
|
+
// name segment matches one of these prefixes are grouped together and moved
|
|
86
|
+
// to the beginning of the generated CSS file (see formats/css.mjs). Default: [].
|
|
87
|
+
export const colorPropertiesPrefixes = Array.isArray(buildConfig.colorPropertiesPrefixes)
|
|
88
|
+
? buildConfig.colorPropertiesPrefixes
|
|
89
|
+
: [];
|
|
90
|
+
|
|
84
91
|
// ---------------------------------------------------------------------------
|
|
85
92
|
// Source: resolve patterns relative to the config directory and normalise to
|
|
86
93
|
// forward-slash absolute paths (fast-glob, used internally by Style Dictionary,
|
|
@@ -239,19 +239,54 @@ StyleDictionary.registerFormat({
|
|
|
239
239
|
const sortedProps = Object.entries(finalProps)
|
|
240
240
|
.sort(([a], [b]) => a.localeCompare(b, 'en', { numeric: true, sensitivity: 'base' }));
|
|
241
241
|
|
|
242
|
+
// colorPropertiesPrefixes: properties whose first hyphen-separated name
|
|
243
|
+
// segment matches one of these prefixes are pulled out and placed, in
|
|
244
|
+
// prefix-list order, at the beginning of the output file.
|
|
245
|
+
const colorPropertiesPrefixes = options.colorPropertiesPrefixes ?? [];
|
|
246
|
+
const colorProps = [];
|
|
247
|
+
const restProps = [];
|
|
248
|
+
for (const entry of sortedProps) {
|
|
249
|
+
const prefix = entry[0].split('-')[0];
|
|
250
|
+
if (colorPropertiesPrefixes.includes(prefix)) {
|
|
251
|
+
colorProps.push(entry);
|
|
252
|
+
} else {
|
|
253
|
+
restProps.push(entry);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
colorProps.sort(([a], [b]) => {
|
|
257
|
+
const prefixA = a.split('-')[0];
|
|
258
|
+
const prefixB = b.split('-')[0];
|
|
259
|
+
const idxA = colorPropertiesPrefixes.indexOf(prefixA);
|
|
260
|
+
const idxB = colorPropertiesPrefixes.indexOf(prefixB);
|
|
261
|
+
if (idxA !== idxB) return idxA - idxB;
|
|
262
|
+
return a.localeCompare(b, 'en', { numeric: true, sensitivity: 'base' });
|
|
263
|
+
});
|
|
264
|
+
|
|
242
265
|
// A blank line is inserted between blocks of properties sharing the same
|
|
243
266
|
// first hyphen-separated segment (e.g. all `btn-*` together), to visually
|
|
244
267
|
// group related custom properties in the generated file.
|
|
245
268
|
const outLines = [];
|
|
246
269
|
let prevPrefix = null;
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
270
|
+
const appendBlock = (props) => {
|
|
271
|
+
for (const [name, tail] of props) {
|
|
272
|
+
const prefix = name.split('-')[0];
|
|
273
|
+
if (prevPrefix !== null && prefix !== prevPrefix) {
|
|
274
|
+
outLines.push('');
|
|
275
|
+
}
|
|
276
|
+
outLines.push(` --${name}: ${tail}`);
|
|
277
|
+
prevPrefix = prefix;
|
|
251
278
|
}
|
|
252
|
-
|
|
253
|
-
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
if (colorProps.length) {
|
|
282
|
+
outLines.push(' /** COLORS **/');
|
|
283
|
+
}
|
|
284
|
+
appendBlock(colorProps);
|
|
285
|
+
if (colorProps.length && restProps.length) {
|
|
286
|
+
outLines.push('', '');
|
|
287
|
+
prevPrefix = null;
|
|
254
288
|
}
|
|
289
|
+
appendBlock(restProps);
|
|
255
290
|
|
|
256
291
|
customPropsCount = sortedProps.length;
|
|
257
292
|
return `${selector} {\n${outLines.join('\n')}\n}\n`;
|
|
@@ -44,6 +44,7 @@ const PENPOT_TRANSFORMS = [
|
|
|
44
44
|
* Collected from sd.allTokens after SD initialisation.
|
|
45
45
|
* Ignored when penpotDestFile is set.
|
|
46
46
|
* @param {'keep'|'calc'|'resolve'} opts.penpotExpressions How to handle math expressions in dimension tokens.
|
|
47
|
+
* @param {string[]} opts.colorPropertiesPrefixes Name prefixes grouped at the top of the CSS output.
|
|
47
48
|
* @returns {Record<string, PlatformConfig>} platforms object ready for Style Dictionary config
|
|
48
49
|
*/
|
|
49
50
|
export const buildPlatforms = ({
|
|
@@ -54,6 +55,7 @@ export const buildPlatforms = ({
|
|
|
54
55
|
penpotFormat,
|
|
55
56
|
penpotExpressions = 'keep',
|
|
56
57
|
concreteFilePaths = [],
|
|
58
|
+
colorPropertiesPrefixes = [],
|
|
57
59
|
}) => {
|
|
58
60
|
/** @type {Record<string, PlatformConfig>} */
|
|
59
61
|
const platforms = {
|
|
@@ -67,6 +69,7 @@ export const buildPlatforms = ({
|
|
|
67
69
|
options: {
|
|
68
70
|
outputReferences: true,
|
|
69
71
|
showFileHeader: true,
|
|
72
|
+
colorPropertiesPrefixes,
|
|
70
73
|
},
|
|
71
74
|
},
|
|
72
75
|
],
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
penpotExpressions,
|
|
33
33
|
source,
|
|
34
34
|
mergeCustomProps,
|
|
35
|
+
colorPropertiesPrefixes,
|
|
35
36
|
} from './build-tokens-src/config.mjs';
|
|
36
37
|
|
|
37
38
|
// ── 2. Custom transforms ─────────────────────────────────────────────────────
|
|
@@ -95,6 +96,7 @@ const sd = new StyleDictionary({
|
|
|
95
96
|
penpotFormat,
|
|
96
97
|
penpotExpressions,
|
|
97
98
|
concreteFilePaths,
|
|
99
|
+
colorPropertiesPrefixes,
|
|
98
100
|
}),
|
|
99
101
|
});
|
|
100
102
|
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<!-- <%= require('./frontend/favicons/output/favicons.incl.ejs')({}) %> -->
|
|
12
12
|
|
|
13
13
|
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
14
|
+
<!-- <base href="<%= htmlWebpackPlugin.options.base %>"> -->
|
|
14
15
|
<%= htmlWebpackPlugin.tags.headTags %> <!-- opzionale, param `inject: false` -->
|
|
15
16
|
</head>
|
|
16
17
|
<body>
|
package/package.json
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
:root {
|
|
2
|
+
/** COLORS **/
|
|
2
3
|
--accent: #567d0d;
|
|
3
4
|
--accent-fg: #fff;
|
|
4
5
|
|
|
6
|
+
--primary-100: #083865;
|
|
7
|
+
--primary-100-fg: #fff;
|
|
8
|
+
|
|
9
|
+
--secondary-100: #650853;
|
|
10
|
+
--secondary-100-fg: #fff;
|
|
11
|
+
|
|
12
|
+
--neutral-100: #666;
|
|
13
|
+
--neutral-100-fg: #fff;
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
--alert-border-radius: var(--radius-sm);
|
|
6
17
|
--alert-box-shadow: 0 0 .5rem 0 oklch(0% 0 0 / .5);
|
|
7
18
|
|
|
@@ -252,14 +263,8 @@
|
|
|
252
263
|
--mpopup-min-width: 25rem;
|
|
253
264
|
--mpopup-width: max-content;
|
|
254
265
|
|
|
255
|
-
--neutral-100: #666;
|
|
256
|
-
--neutral-100-fg: #fff;
|
|
257
|
-
|
|
258
266
|
--overlay-color: rgb(0 0 0 / .6);
|
|
259
267
|
|
|
260
|
-
--primary-100: #083865;
|
|
261
|
-
--primary-100-fg: #fff;
|
|
262
|
-
|
|
263
268
|
--radius-base: var(--size-base);
|
|
264
269
|
--radius-lg: var(--size-lg);
|
|
265
270
|
--radius-md: var(--size-md);
|
|
@@ -276,9 +281,6 @@
|
|
|
276
281
|
--sdt-pagination-padding-inline: var(--size-xs);
|
|
277
282
|
--sdt-thead-hover-background-color: color-mix(in srgb, var(--table-thead-background-color) 90%, var(--accent));
|
|
278
283
|
|
|
279
|
-
--secondary-100: #650853;
|
|
280
|
-
--secondary-100-fg: #fff;
|
|
281
|
-
|
|
282
284
|
--sf-macro-btn-close-background-color: var(--btn-close-background-color);
|
|
283
285
|
--sf-macro-btn-close-position-bottom: auto;
|
|
284
286
|
--sf-macro-btn-close-position-left: auto;
|