@medyll/cssfabric 0.2.1-beta.3 → 0.2.1-beta.5
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/cssFabric/CssFabric.d.ts +20 -0
- package/dist/cssFabric/CssFabric.js +71 -0
- package/dist/cssFabric/CssFabricBuilder.d.ts +71 -0
- package/dist/cssFabric/CssFabricBuilder.js +210 -0
- package/dist/cssFabric/CssFabricExport.d.ts +9 -0
- package/dist/cssFabric/CssFabricExport.js +37 -0
- package/dist/cssFabric/bin/exports.d.ts +2 -0
- package/dist/cssFabric/bin/exports.js +14 -0
- package/dist/cssFabric/index.d.ts +9 -113
- package/dist/cssFabric/index.js +10 -341
- package/dist/cssFabric/types.d.ts +16 -0
- package/dist/cssFabric/types.js +10 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CssFabricBuilder, CssFabricBuilderParams } from './CssFabricBuilder.js';
|
|
2
|
+
import { CssFabricExport } from './CssFabricExport.js';
|
|
3
|
+
import type { cssFabricModelType, cssFabricModelKey } from './types.js';
|
|
4
|
+
export declare class CssFabric {
|
|
5
|
+
vendor: (fragment?: string) => string;
|
|
6
|
+
cssFabricModel: cssFabricModelType;
|
|
7
|
+
cssFabricBuilderParams: CssFabricBuilderParams;
|
|
8
|
+
cssFabricBuilder: CssFabricBuilder;
|
|
9
|
+
constructor();
|
|
10
|
+
private cleanModelKey;
|
|
11
|
+
setParams(params: Partial<CssFabricBuilderParams>): void;
|
|
12
|
+
createCssFabricVarsColors(...args: cssFabricModelKey[]): {
|
|
13
|
+
export: CssFabricExport['export'];
|
|
14
|
+
css: string;
|
|
15
|
+
};
|
|
16
|
+
cssFabricSheet(): {
|
|
17
|
+
export: (options: any) => void;
|
|
18
|
+
css: Record<string, any>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CssFabricBuilder, CssFabricBuilderParams } from './CssFabricBuilder.js';
|
|
2
|
+
import { CssFabricExport } from './CssFabricExport.js';
|
|
3
|
+
import { cssFabricSheet } from './cssFabricSheet.js';
|
|
4
|
+
import { CSSProperties } from './cssProperties.js';
|
|
5
|
+
export class CssFabric {
|
|
6
|
+
vendor = (fragment = '') => `${this.cssFabricBuilderParams.vendorName}${fragment}`;
|
|
7
|
+
cssFabricModel = {};
|
|
8
|
+
cssFabricBuilderParams;
|
|
9
|
+
cssFabricBuilder;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.cssFabricBuilder = new CssFabricBuilder();
|
|
12
|
+
this.cssFabricBuilderParams = new CssFabricBuilderParams();
|
|
13
|
+
}
|
|
14
|
+
cleanModelKey(modelKey) {
|
|
15
|
+
return modelKey.replace(/'/g, '');
|
|
16
|
+
}
|
|
17
|
+
setParams(params) {
|
|
18
|
+
this.cssFabricBuilderParams = {
|
|
19
|
+
...this.cssFabricBuilderParams,
|
|
20
|
+
...params
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
createCssFabricVarsColors(...args) {
|
|
24
|
+
args.forEach((modelKey) => {
|
|
25
|
+
switch (this.cleanModelKey(modelKey)) {
|
|
26
|
+
case 'base':
|
|
27
|
+
this.cssFabricModel.base = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.theme, this.vendor());
|
|
28
|
+
break;
|
|
29
|
+
case 'palette':
|
|
30
|
+
this.cssFabricModel.palette = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.palette, this.vendor('palette-'));
|
|
31
|
+
break;
|
|
32
|
+
case 'presets':
|
|
33
|
+
this.cssFabricModel.presets = this.cssFabricBuilder.flattenIt(['primary', 'secondary', 'tertiary', 'accent'], this.cssFabricBuilderParams.presets, this.vendor('presets-'));
|
|
34
|
+
break;
|
|
35
|
+
case 'status':
|
|
36
|
+
this.cssFabricModel.status = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.status, this.vendor('status-'));
|
|
37
|
+
break;
|
|
38
|
+
case 'out':
|
|
39
|
+
// assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
|
|
40
|
+
this.cssFabricModel.out = this.cssFabricBuilder.makeDefaultVariations(['primary', 'secondary', 'tertiary'], ['lighten', 'darken', 'opacity'], this.vendor());
|
|
41
|
+
break;
|
|
42
|
+
case 'gray':
|
|
43
|
+
this.cssFabricModel.gray = this.cssFabricBuilder.createProgression({
|
|
44
|
+
property: this.vendor(`color-gray`),
|
|
45
|
+
iteratorMask: `color-mix(in srgb, ${this.vendor(`color-gray`)} ${this.cssFabricBuilderParams.correspondances.gray} ##%);`,
|
|
46
|
+
steps: this.cssFabricBuilderParams.defaultVariationSteps
|
|
47
|
+
}, 'json');
|
|
48
|
+
break;
|
|
49
|
+
case 'out2':
|
|
50
|
+
// assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
|
|
51
|
+
this.cssFabricModel.out2 = this.cssFabricBuilder.makeDefaultVariations(['foreground', 'bg'], ['lighten', 'darken', 'opacity'], this.vendor());
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
console.log('default', modelKey);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return {
|
|
59
|
+
export: (options) => new CssFabricExport(this.cssFabricModel, options).export(options),
|
|
60
|
+
css: JSON.stringify(this.cssFabricModel)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
cssFabricSheet() {
|
|
64
|
+
const cssP = new CSSProperties(cssFabricSheet /* , ['overflow'] */);
|
|
65
|
+
const cssF = cssP.generateCSS();
|
|
66
|
+
return {
|
|
67
|
+
export: (options) => new CssFabricExport(cssF, options).export(options),
|
|
68
|
+
css: cssF
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { colorConfig } from './config.js';
|
|
2
|
+
import type { Ease, EaseTrigger, Mask, Steps, ToMask } from './types.js';
|
|
3
|
+
export declare class CssFabricBuilder {
|
|
4
|
+
cssFabricBuilderParams: CssFabricBuilderParams;
|
|
5
|
+
constructor();
|
|
6
|
+
parseModel(json: Record<string, any>, parentKey?: string): string;
|
|
7
|
+
createProgression(options: {
|
|
8
|
+
property: string;
|
|
9
|
+
steps: {
|
|
10
|
+
steps: Steps;
|
|
11
|
+
presets?: string[];
|
|
12
|
+
ease: [Ease, EaseTrigger];
|
|
13
|
+
reverseValue?: boolean;
|
|
14
|
+
};
|
|
15
|
+
iteratorMask: string;
|
|
16
|
+
propertyValue?: {
|
|
17
|
+
content: [Mask, ToMask];
|
|
18
|
+
apply: string;
|
|
19
|
+
};
|
|
20
|
+
}, format?: 'css' | 'json'): {};
|
|
21
|
+
/**
|
|
22
|
+
* Dispatches elements based on the input mask.
|
|
23
|
+
*
|
|
24
|
+
* @template M - The type of the mask key.
|
|
25
|
+
* @template E - The type of the element.
|
|
26
|
+
* @template A - The type of the value.
|
|
27
|
+
*
|
|
28
|
+
* @param inputMask - The input mask.
|
|
29
|
+
* @param creatorFunction - The function to create the element based on the mask key.
|
|
30
|
+
* @param apply - The function to apply the value to the element.
|
|
31
|
+
*/
|
|
32
|
+
dispatchHandleElements<M extends string = string, E = Element, A = any>(inputMask: any[], creatorFunction: (maskKey: M, index: number) => E, apply: (element: E, value: A) => void): void;
|
|
33
|
+
enqueue(callback: (callbackKey: string) => void, ...rest: string[][]): any;
|
|
34
|
+
flattenIt(arr1: string[], arr2: string[], scope?: string): Record<string, any>;
|
|
35
|
+
makeVariation(themeColor: string, variation: string): any;
|
|
36
|
+
makeDefaultVariations(arr1: string[], arr2: string[], prefix: string, vendor?: string): Record<string, any>;
|
|
37
|
+
mainRule(vars: Record<string, any>, prefix: string): Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
export declare class CssFabricBuilderParams {
|
|
40
|
+
vendorName: string;
|
|
41
|
+
variations: {
|
|
42
|
+
readonly none: "var({#vendor}-color-##);";
|
|
43
|
+
readonly light: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
|
|
44
|
+
readonly lighter: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
|
|
45
|
+
readonly dark: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
46
|
+
readonly darker: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
47
|
+
readonly complement: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
48
|
+
readonly invert: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
49
|
+
readonly 'alpha-low': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
50
|
+
readonly alpha: "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
51
|
+
readonly 'alpha-high': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
52
|
+
};
|
|
53
|
+
defaultVariationSteps: {
|
|
54
|
+
readonly steps: readonly [0, 100, 10];
|
|
55
|
+
readonly ease: readonly [2, 20];
|
|
56
|
+
};
|
|
57
|
+
correspondances: Record<string, any>;
|
|
58
|
+
baseColors: {
|
|
59
|
+
primary: string;
|
|
60
|
+
secondary: string;
|
|
61
|
+
accent: string;
|
|
62
|
+
neutral: string;
|
|
63
|
+
error: string;
|
|
64
|
+
};
|
|
65
|
+
presets: string[];
|
|
66
|
+
config: typeof colorConfig;
|
|
67
|
+
constructor();
|
|
68
|
+
setVariations(variations: typeof CssFabricBuilderParams.prototype.variations): void;
|
|
69
|
+
setDefaultVariationSteps(variationSteps: typeof CssFabricBuilderParams.prototype.defaultVariationSteps): void;
|
|
70
|
+
private deepMerge;
|
|
71
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { harmony } from 'simpler-color';
|
|
2
|
+
import { colorConfig } from './config.js';
|
|
3
|
+
export class CssFabricBuilder {
|
|
4
|
+
// defaultVariationSteps
|
|
5
|
+
cssFabricBuilderParams;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.cssFabricBuilderParams = new CssFabricBuilderParams();
|
|
8
|
+
}
|
|
9
|
+
parseModel(json, parentKey = '') {
|
|
10
|
+
let css = parse(json, parentKey);
|
|
11
|
+
return `:root{\n${css}}`;
|
|
12
|
+
function parse(json, parentKey = '', titre = '') {
|
|
13
|
+
let css = '';
|
|
14
|
+
for (const key in json) {
|
|
15
|
+
if (typeof json[key] === 'object') {
|
|
16
|
+
css += `\n/* ${key} */ `;
|
|
17
|
+
//titre += `/* ----${key}--- */ `;
|
|
18
|
+
css += parse(json[key], '', titre);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
css += titre;
|
|
22
|
+
css += `\n${parentKey}${key}: ${json[key]}`;
|
|
23
|
+
titre = '';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return css;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
createProgression(options, format = 'css') {
|
|
30
|
+
const { property, iteratorMask, propertyValue } = options;
|
|
31
|
+
const { presets } = options.steps ?? this.cssFabricBuilderParams.defaultVariationSteps;
|
|
32
|
+
let [from, to, increment] = options.steps.steps;
|
|
33
|
+
const [ease, trigger] = options.steps.ease;
|
|
34
|
+
if (presets) {
|
|
35
|
+
//sizeof prests becomes steps.
|
|
36
|
+
// cancels ease
|
|
37
|
+
if (presets) {
|
|
38
|
+
increment = to / presets.length;
|
|
39
|
+
options.steps.steps = [from, to, to / presets.length];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
let css = '';
|
|
43
|
+
let cssKey = {};
|
|
44
|
+
for (let i = from; i <= to; i += i < trigger || i >= to - trigger ? increment / ease : increment) {
|
|
45
|
+
const iteratorTo = options.steps.reverseValue ? to - i : i;
|
|
46
|
+
const prop = `${property}-${i}`;
|
|
47
|
+
const content = propertyValue?.content[0]
|
|
48
|
+
? `${propertyValue?.content[0].replace('##', propertyValue.content[1])} ${propertyValue?.apply}`
|
|
49
|
+
: '';
|
|
50
|
+
const newVal = `${iteratorMask.replace('##', iteratorTo.toString())}`;
|
|
51
|
+
css += `${prop}-${i}: ${content} ${newVal};\rn`;
|
|
52
|
+
cssKey[`${prop}`] = `${content} ${newVal}`;
|
|
53
|
+
}
|
|
54
|
+
return format === 'css' ? css : cssKey;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Dispatches elements based on the input mask.
|
|
58
|
+
*
|
|
59
|
+
* @template M - The type of the mask key.
|
|
60
|
+
* @template E - The type of the element.
|
|
61
|
+
* @template A - The type of the value.
|
|
62
|
+
*
|
|
63
|
+
* @param inputMask - The input mask.
|
|
64
|
+
* @param creatorFunction - The function to create the element based on the mask key.
|
|
65
|
+
* @param apply - The function to apply the value to the element.
|
|
66
|
+
*/
|
|
67
|
+
dispatchHandleElements(inputMask, creatorFunction, apply) {
|
|
68
|
+
inputMask.forEach((maskKey, index) => {
|
|
69
|
+
const element = creatorFunction(inputMask[index], maskKey);
|
|
70
|
+
apply(element, inputMask[index]);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
enqueue(callback, ...rest) {
|
|
74
|
+
const buildObject = (rootKeys, distributionKeys, index = 0) => {
|
|
75
|
+
if (index >= distributionKeys.length) {
|
|
76
|
+
return rootKeys.reduce((acc, key) => ({ ...acc, [key]: callback(key) }), {});
|
|
77
|
+
}
|
|
78
|
+
const currentDistribution = distributionKeys[index];
|
|
79
|
+
return rootKeys.reduce((acc, key) => {
|
|
80
|
+
const nestedObject = buildObject(currentDistribution, distributionKeys, index + 1);
|
|
81
|
+
return { ...acc, [key]: nestedObject };
|
|
82
|
+
}, {});
|
|
83
|
+
};
|
|
84
|
+
return buildObject(rest[0], rest.slice(1));
|
|
85
|
+
}
|
|
86
|
+
flattenIt(arr1, arr2, scope = 'color-') {
|
|
87
|
+
const legacy = {};
|
|
88
|
+
arr1.forEach((themeColor) => {
|
|
89
|
+
legacy[themeColor] = {};
|
|
90
|
+
arr2.forEach((props2) => {
|
|
91
|
+
if (!legacy[themeColor][props2])
|
|
92
|
+
legacy[themeColor][props2] = {};
|
|
93
|
+
const tag = `${scope}${[themeColor, props2].join('-')}`;
|
|
94
|
+
legacy[themeColor][props2] = {
|
|
95
|
+
[tag]: this.makeVariation(themeColor, props2)
|
|
96
|
+
.replace('##', themeColor)
|
|
97
|
+
.replace('{#vendor}', this.cssFabricBuilderParams.vendorName)
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return legacy;
|
|
102
|
+
}
|
|
103
|
+
makeVariation(themeColor, variation) {
|
|
104
|
+
return this.cssFabricBuilderParams.variations?.[variation]
|
|
105
|
+
? this.cssFabricBuilderParams.variations[variation]
|
|
106
|
+
: themeColor;
|
|
107
|
+
}
|
|
108
|
+
makeDefaultVariations(arr1, arr2, prefix, vendor = '--cssfab-') {
|
|
109
|
+
const out = {};
|
|
110
|
+
arr1.forEach((themeColor) => {
|
|
111
|
+
out[themeColor] = {};
|
|
112
|
+
arr2.forEach((props2) => {
|
|
113
|
+
out[themeColor][props2] = this.createProgression({
|
|
114
|
+
property: `${vendor}${themeColor}-${props2}`,
|
|
115
|
+
iteratorMask: `color-mix(in srgb, var(${prefix}${themeColor}) ${this.cssFabricBuilderParams.correspondances[props2]} ##%);`,
|
|
116
|
+
steps: this.cssFabricBuilderParams.defaultVariationSteps
|
|
117
|
+
}, 'json');
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
return out;
|
|
121
|
+
}
|
|
122
|
+
mainRule(vars, prefix) {
|
|
123
|
+
const collect = {};
|
|
124
|
+
if (vars)
|
|
125
|
+
Object.keys(vars).forEach((key) => {
|
|
126
|
+
const val = vars[key];
|
|
127
|
+
collect[key] = { [`${prefix}${key}`]: `${val};` };
|
|
128
|
+
});
|
|
129
|
+
return collect;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export class CssFabricBuilderParams {
|
|
133
|
+
vendorName = '--cssfab-';
|
|
134
|
+
variations = {
|
|
135
|
+
none: 'var({#vendor}-color-##);',
|
|
136
|
+
light: 'color-mix(in srgb, var({#vendor}-color-##) white ##%);',
|
|
137
|
+
lighter: 'color-mix(in srgb, var({#vendor}-color-##) white ##%);',
|
|
138
|
+
dark: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
139
|
+
darker: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
140
|
+
complement: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
141
|
+
invert: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
142
|
+
'alpha-low': 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);',
|
|
143
|
+
alpha: 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);',
|
|
144
|
+
'alpha-high': 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);'
|
|
145
|
+
};
|
|
146
|
+
defaultVariationSteps = {
|
|
147
|
+
steps: [0, 100, 10],
|
|
148
|
+
ease: [2, 20]
|
|
149
|
+
};
|
|
150
|
+
correspondances = {
|
|
151
|
+
lighten: 'white',
|
|
152
|
+
light: 'white',
|
|
153
|
+
lighter: 'white',
|
|
154
|
+
darken: 'black',
|
|
155
|
+
dark: 'black',
|
|
156
|
+
darker: 'black',
|
|
157
|
+
gray: '#333',
|
|
158
|
+
opacity: 'transparent',
|
|
159
|
+
'alpha-high': 'transparent',
|
|
160
|
+
'alpha-low': 'transparent',
|
|
161
|
+
alpha: 'transparent'
|
|
162
|
+
};
|
|
163
|
+
baseColors;
|
|
164
|
+
presets = [
|
|
165
|
+
'light',
|
|
166
|
+
'lighter',
|
|
167
|
+
'dark',
|
|
168
|
+
'darker',
|
|
169
|
+
'complement',
|
|
170
|
+
'invert',
|
|
171
|
+
'alpha-low',
|
|
172
|
+
'alpha',
|
|
173
|
+
'alpha-high'
|
|
174
|
+
];
|
|
175
|
+
config = {};
|
|
176
|
+
constructor() {
|
|
177
|
+
this.baseColors = harmony('#9e3902');
|
|
178
|
+
this.config = this.deepMerge(colorConfig, { theme: harmony('#9e3902') });
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
setVariations(variations) {
|
|
182
|
+
this.variations = { ...this.variations, ...variations };
|
|
183
|
+
}
|
|
184
|
+
setDefaultVariationSteps(variationSteps) {
|
|
185
|
+
this.defaultVariationSteps = { ...this.defaultVariationSteps, ...variationSteps };
|
|
186
|
+
}
|
|
187
|
+
deepMerge(...objects) {
|
|
188
|
+
function objectMerge(target, source) {
|
|
189
|
+
for (const key of Object.keys(source)) {
|
|
190
|
+
const currenttarget = target[key];
|
|
191
|
+
const currentsource = source[key];
|
|
192
|
+
if (currenttarget) {
|
|
193
|
+
const objectsource = typeof currentsource === 'object';
|
|
194
|
+
const objecttarget = typeof currenttarget === 'object';
|
|
195
|
+
if (objectsource && objecttarget) {
|
|
196
|
+
void (Array.isArray(currenttarget) && Array.isArray(currentsource)
|
|
197
|
+
? void (target[key] = currenttarget.concat(currentsource))
|
|
198
|
+
: void objectMerge(currenttarget, currentsource));
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
target[key] = currentsource;
|
|
203
|
+
}
|
|
204
|
+
return target;
|
|
205
|
+
}
|
|
206
|
+
return objects.reduce(function (prev, next) {
|
|
207
|
+
return { ...prev, ...objectMerge(prev, next) };
|
|
208
|
+
}, objects[0]);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { cssFabricModelType } from './types.js';
|
|
2
|
+
export declare class CssFabricExport {
|
|
3
|
+
private cssFabricModel;
|
|
4
|
+
exportPaths: Record<'css' | 'json', string>;
|
|
5
|
+
constructor(cssFabricModel: cssFabricModelType, exportPaths?: CssFabricExport['exportPaths']);
|
|
6
|
+
export(options: CssFabricExport['exportPaths']): void;
|
|
7
|
+
private createCssFile;
|
|
8
|
+
private createJsonModel;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fsExtra from 'fs-extra';
|
|
2
|
+
export class CssFabricExport {
|
|
3
|
+
cssFabricModel;
|
|
4
|
+
exportPaths = {
|
|
5
|
+
css: './css-fabric.css',
|
|
6
|
+
json: './cssFabric.json'
|
|
7
|
+
};
|
|
8
|
+
constructor(cssFabricModel, exportPaths) {
|
|
9
|
+
this.cssFabricModel = cssFabricModel;
|
|
10
|
+
this.exportPaths = { ...exportPaths, ...this.exportPaths };
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
export(options) {
|
|
14
|
+
this.exportPaths = { ...this.exportPaths, ...options };
|
|
15
|
+
this.createCssFile();
|
|
16
|
+
this.createJsonModel();
|
|
17
|
+
}
|
|
18
|
+
createCssFile() {
|
|
19
|
+
// cssFabricBuilder.parseModel(cssCollection
|
|
20
|
+
fsExtra.writeFile(this.exportPaths.css, this.cssFabricModel.toString(), (err) => {
|
|
21
|
+
if (err) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log('File created successfully.');
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
createJsonModel() {
|
|
29
|
+
fsExtra.writeFile(this.exportPaths.json, JSON.stringify(this.cssFabricModel), (err) => {
|
|
30
|
+
if (err) {
|
|
31
|
+
console.error(err);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
console.log('File created successfully.');
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CssFabric } from '../CssFabric.js';
|
|
2
|
+
export const cssFabric = new CssFabric();
|
|
3
|
+
const styleSheet = cssFabric.cssFabricSheet();
|
|
4
|
+
styleSheet.export({ css: './css-fabric-sheet.css', json: './cssFabric-sheet.json' });
|
|
5
|
+
/* const model = cssFabric.createCssFabricVarsColors(
|
|
6
|
+
'base',
|
|
7
|
+
'palette',
|
|
8
|
+
'presets',
|
|
9
|
+
'status',
|
|
10
|
+
'out',
|
|
11
|
+
'gray',
|
|
12
|
+
'out2'
|
|
13
|
+
);
|
|
14
|
+
model.export({ css: './css-fabric.css', json: './cssFabric.json' }); */
|
|
@@ -1,113 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
constructor(cssFabricModel: cssFabricModelType, exportPaths?: CssFabricExport['exportPaths']);
|
|
11
|
-
export(options: CssFabricExport['exportPaths']): void;
|
|
12
|
-
private createCssFile;
|
|
13
|
-
private createJsonModel;
|
|
14
|
-
}
|
|
15
|
-
declare class CssFabricBuilder {
|
|
16
|
-
cssFabricBuilderParams: CssFabricBuilderParams;
|
|
17
|
-
constructor();
|
|
18
|
-
parseModel(json: Record<string, any>, parentKey?: string): string;
|
|
19
|
-
createProgression(options: {
|
|
20
|
-
property: string;
|
|
21
|
-
steps: {
|
|
22
|
-
steps: Steps;
|
|
23
|
-
presets?: string[];
|
|
24
|
-
ease: [Ease, EaseTrigger];
|
|
25
|
-
reverseValue?: boolean;
|
|
26
|
-
};
|
|
27
|
-
iteratorMask: string;
|
|
28
|
-
propertyValue?: {
|
|
29
|
-
content: [Mask, ToMask];
|
|
30
|
-
apply: string;
|
|
31
|
-
};
|
|
32
|
-
}, format?: 'css' | 'json'): {};
|
|
33
|
-
/**
|
|
34
|
-
* Dispatches elements based on the input mask.
|
|
35
|
-
*
|
|
36
|
-
* @template M - The type of the mask key.
|
|
37
|
-
* @template E - The type of the element.
|
|
38
|
-
* @template A - The type of the value.
|
|
39
|
-
*
|
|
40
|
-
* @param inputMask - The input mask.
|
|
41
|
-
* @param creatorFunction - The function to create the element based on the mask key.
|
|
42
|
-
* @param apply - The function to apply the value to the element.
|
|
43
|
-
*/
|
|
44
|
-
dispatchHandleElements<M extends string = string, E = Element, A = any>(inputMask: any[], creatorFunction: (maskKey: M, index: number) => E, apply: (element: E, value: A) => void): void;
|
|
45
|
-
enqueue(callback: (callbackKey: string) => void, ...rest: string[][]): any;
|
|
46
|
-
flattenIt(arr1: string[], arr2: string[], scope?: string): Record<string, any>;
|
|
47
|
-
makeVariation(themeColor: string, variation: string): any;
|
|
48
|
-
makeDefaultVariations(arr1: string[], arr2: string[], prefix: string, vendor?: string): Record<string, any>;
|
|
49
|
-
mainRule(vars: Record<string, any>, prefix: string): Record<string, any>;
|
|
50
|
-
}
|
|
51
|
-
declare class CssFabricBuilderParams {
|
|
52
|
-
vendorName: string;
|
|
53
|
-
variations: {
|
|
54
|
-
readonly none: "var({#vendor}-color-##);";
|
|
55
|
-
readonly light: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
|
|
56
|
-
readonly lighter: "color-mix(in srgb, var({#vendor}-color-##) white ##%);";
|
|
57
|
-
readonly dark: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
58
|
-
readonly darker: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
59
|
-
readonly complement: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
60
|
-
readonly invert: "color-mix(in srgb, var({#vendor}-color-##) black ##%);";
|
|
61
|
-
readonly 'alpha-low': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
62
|
-
readonly alpha: "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
63
|
-
readonly 'alpha-high': "color-mix(in srgb, var({#vendor}-color-##) transparent ##%);";
|
|
64
|
-
};
|
|
65
|
-
defaultVariationSteps: {
|
|
66
|
-
readonly steps: readonly [0, 100, 10];
|
|
67
|
-
readonly ease: readonly [2, 20];
|
|
68
|
-
};
|
|
69
|
-
correspondances: Record<string, any>;
|
|
70
|
-
baseColors: {
|
|
71
|
-
primary: string;
|
|
72
|
-
secondary: string;
|
|
73
|
-
accent: string;
|
|
74
|
-
neutral: string;
|
|
75
|
-
error: string;
|
|
76
|
-
};
|
|
77
|
-
presets: string[];
|
|
78
|
-
config: typeof colorConfig;
|
|
79
|
-
constructor();
|
|
80
|
-
setVariations(variations: typeof CssFabricBuilderParams.prototype.variations): void;
|
|
81
|
-
setDefaultVariationSteps(variationSteps: typeof CssFabricBuilderParams.prototype.defaultVariationSteps): void;
|
|
82
|
-
private deepMerge;
|
|
83
|
-
}
|
|
84
|
-
declare enum ModelConfigKeys {
|
|
85
|
-
base = 0,
|
|
86
|
-
palette = 1,
|
|
87
|
-
presets = 2,
|
|
88
|
-
status = 3,
|
|
89
|
-
out = 4,
|
|
90
|
-
gray = 5,
|
|
91
|
-
out2 = 6
|
|
92
|
-
}
|
|
93
|
-
type cssFabricModelKey = keyof typeof ModelConfigKeys;
|
|
94
|
-
type cssFabricModelType = Record<cssFabricModelKey, any>;
|
|
95
|
-
declare class CssFabric {
|
|
96
|
-
vendor: (fragment?: string) => string;
|
|
97
|
-
cssFabricModel: cssFabricModelType;
|
|
98
|
-
cssFabricBuilderParams: CssFabricBuilderParams;
|
|
99
|
-
cssFabricBuilder: CssFabricBuilder;
|
|
100
|
-
constructor();
|
|
101
|
-
private cleanModelKey;
|
|
102
|
-
setParams(params: Partial<CssFabricBuilderParams>): void;
|
|
103
|
-
createCssFabricVarsColors(...args: cssFabricModelKey[]): {
|
|
104
|
-
export: CssFabricExport['export'];
|
|
105
|
-
css: string;
|
|
106
|
-
};
|
|
107
|
-
cssFabricSheet(): {
|
|
108
|
-
export: (options: any) => void;
|
|
109
|
-
css: Record<string, any>;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
export declare const cssFabric: CssFabric;
|
|
113
|
-
export {};
|
|
1
|
+
export * from './bin/exports.js';
|
|
2
|
+
export * from './config.js';
|
|
3
|
+
export * from './CssFabric.js';
|
|
4
|
+
export * from './CssFabricBuilder.js';
|
|
5
|
+
export * from './CssFabricExport.js';
|
|
6
|
+
export * from './cssFabricSheet.js';
|
|
7
|
+
export * from './cssProperties.js';
|
|
8
|
+
export * from './cssVariationsAi.js';
|
|
9
|
+
export * from './types.js';
|
package/dist/cssFabric/index.js
CHANGED
|
@@ -1,341 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
constructor(cssFabricModel, exportPaths) {
|
|
13
|
-
this.cssFabricModel = cssFabricModel;
|
|
14
|
-
this.exportPaths = { ...exportPaths, ...this.exportPaths };
|
|
15
|
-
return this;
|
|
16
|
-
}
|
|
17
|
-
export(options) {
|
|
18
|
-
this.exportPaths = { ...this.exportPaths, ...options };
|
|
19
|
-
this.createCssFile();
|
|
20
|
-
this.createJsonModel();
|
|
21
|
-
}
|
|
22
|
-
createCssFile() {
|
|
23
|
-
// cssFabricBuilder.parseModel(cssCollection
|
|
24
|
-
fsExtra.writeFile(this.exportPaths.css, this.cssFabricModel.toString(), (err) => {
|
|
25
|
-
if (err) {
|
|
26
|
-
console.error(err);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
console.log('File created successfully.');
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
createJsonModel() {
|
|
33
|
-
fsExtra.writeFile(this.exportPaths.json, JSON.stringify(this.cssFabricModel), (err) => {
|
|
34
|
-
if (err) {
|
|
35
|
-
console.error(err);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
console.log('File created successfully.');
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class CssFabricBuilder {
|
|
43
|
-
// defaultVariationSteps
|
|
44
|
-
cssFabricBuilderParams;
|
|
45
|
-
constructor() {
|
|
46
|
-
this.cssFabricBuilderParams = new CssFabricBuilderParams();
|
|
47
|
-
}
|
|
48
|
-
parseModel(json, parentKey = '') {
|
|
49
|
-
let css = parse(json, parentKey);
|
|
50
|
-
return `:root{\n${css}}`;
|
|
51
|
-
function parse(json, parentKey = '', titre = '') {
|
|
52
|
-
let css = '';
|
|
53
|
-
for (const key in json) {
|
|
54
|
-
if (typeof json[key] === 'object') {
|
|
55
|
-
css += `\n/* ${key} */ `;
|
|
56
|
-
//titre += `/* ----${key}--- */ `;
|
|
57
|
-
css += parse(json[key], '', titre);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
css += titre;
|
|
61
|
-
css += `\n${parentKey}${key}: ${json[key]}`;
|
|
62
|
-
titre = '';
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return css;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
createProgression(options, format = 'css') {
|
|
69
|
-
const { property, iteratorMask, propertyValue } = options;
|
|
70
|
-
const { presets } = options.steps ?? this.cssFabricBuilderParams.defaultVariationSteps;
|
|
71
|
-
let [from, to, increment] = options.steps.steps;
|
|
72
|
-
const [ease, trigger] = options.steps.ease;
|
|
73
|
-
if (presets) {
|
|
74
|
-
//sizeof prests becomes steps.
|
|
75
|
-
// cancels ease
|
|
76
|
-
if (presets) {
|
|
77
|
-
increment = to / presets.length;
|
|
78
|
-
options.steps.steps = [from, to, to / presets.length];
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
let css = '';
|
|
82
|
-
let cssKey = {};
|
|
83
|
-
for (let i = from; i <= to; i += i < trigger || i >= to - trigger ? increment / ease : increment) {
|
|
84
|
-
const iteratorTo = options.steps.reverseValue ? to - i : i;
|
|
85
|
-
const prop = `${property}-${i}`;
|
|
86
|
-
const content = propertyValue?.content[0]
|
|
87
|
-
? `${propertyValue?.content[0].replace('##', propertyValue.content[1])} ${propertyValue?.apply}`
|
|
88
|
-
: '';
|
|
89
|
-
const newVal = `${iteratorMask.replace('##', iteratorTo.toString())}`;
|
|
90
|
-
css += `${prop}-${i}: ${content} ${newVal};\rn`;
|
|
91
|
-
cssKey[`${prop}`] = `${content} ${newVal}`;
|
|
92
|
-
}
|
|
93
|
-
return format === 'css' ? css : cssKey;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Dispatches elements based on the input mask.
|
|
97
|
-
*
|
|
98
|
-
* @template M - The type of the mask key.
|
|
99
|
-
* @template E - The type of the element.
|
|
100
|
-
* @template A - The type of the value.
|
|
101
|
-
*
|
|
102
|
-
* @param inputMask - The input mask.
|
|
103
|
-
* @param creatorFunction - The function to create the element based on the mask key.
|
|
104
|
-
* @param apply - The function to apply the value to the element.
|
|
105
|
-
*/
|
|
106
|
-
dispatchHandleElements(inputMask, creatorFunction, apply) {
|
|
107
|
-
inputMask.forEach((maskKey, index) => {
|
|
108
|
-
const element = creatorFunction(inputMask[index], maskKey);
|
|
109
|
-
apply(element, inputMask[index]);
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
enqueue(callback, ...rest) {
|
|
113
|
-
const buildObject = (rootKeys, distributionKeys, index = 0) => {
|
|
114
|
-
if (index >= distributionKeys.length) {
|
|
115
|
-
return rootKeys.reduce((acc, key) => ({ ...acc, [key]: callback(key) }), {});
|
|
116
|
-
}
|
|
117
|
-
const currentDistribution = distributionKeys[index];
|
|
118
|
-
return rootKeys.reduce((acc, key) => {
|
|
119
|
-
const nestedObject = buildObject(currentDistribution, distributionKeys, index + 1);
|
|
120
|
-
return { ...acc, [key]: nestedObject };
|
|
121
|
-
}, {});
|
|
122
|
-
};
|
|
123
|
-
return buildObject(rest[0], rest.slice(1));
|
|
124
|
-
}
|
|
125
|
-
flattenIt(arr1, arr2, scope = 'color-') {
|
|
126
|
-
const legacy = {};
|
|
127
|
-
arr1.forEach((themeColor) => {
|
|
128
|
-
legacy[themeColor] = {};
|
|
129
|
-
arr2.forEach((props2) => {
|
|
130
|
-
if (!legacy[themeColor][props2])
|
|
131
|
-
legacy[themeColor][props2] = {};
|
|
132
|
-
const tag = `${scope}${[themeColor, props2].join('-')}`;
|
|
133
|
-
legacy[themeColor][props2] = {
|
|
134
|
-
[tag]: this.makeVariation(themeColor, props2)
|
|
135
|
-
.replace('##', themeColor)
|
|
136
|
-
.replace('{#vendor}', this.cssFabricBuilderParams.vendorName)
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
return legacy;
|
|
141
|
-
}
|
|
142
|
-
makeVariation(themeColor, variation) {
|
|
143
|
-
return this.cssFabricBuilderParams.variations?.[variation]
|
|
144
|
-
? this.cssFabricBuilderParams.variations[variation]
|
|
145
|
-
: themeColor;
|
|
146
|
-
}
|
|
147
|
-
makeDefaultVariations(arr1, arr2, prefix, vendor = '--cssfab-') {
|
|
148
|
-
const out = {};
|
|
149
|
-
arr1.forEach((themeColor) => {
|
|
150
|
-
out[themeColor] = {};
|
|
151
|
-
arr2.forEach((props2) => {
|
|
152
|
-
out[themeColor][props2] = this.createProgression({
|
|
153
|
-
property: `${vendor}${themeColor}-${props2}`,
|
|
154
|
-
iteratorMask: `color-mix(in srgb, var(${prefix}${themeColor}) ${this.cssFabricBuilderParams.correspondances[props2]} ##%);`,
|
|
155
|
-
steps: this.cssFabricBuilderParams.defaultVariationSteps
|
|
156
|
-
}, 'json');
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
return out;
|
|
160
|
-
}
|
|
161
|
-
mainRule(vars, prefix) {
|
|
162
|
-
const collect = {};
|
|
163
|
-
if (vars)
|
|
164
|
-
Object.keys(vars).forEach((key) => {
|
|
165
|
-
const val = vars[key];
|
|
166
|
-
collect[key] = { [`${prefix}${key}`]: `${val};` };
|
|
167
|
-
});
|
|
168
|
-
return collect;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
// primary.presets
|
|
172
|
-
class CssFabricBuilderParams {
|
|
173
|
-
vendorName = '--cssfab-';
|
|
174
|
-
variations = {
|
|
175
|
-
none: 'var({#vendor}-color-##);',
|
|
176
|
-
light: 'color-mix(in srgb, var({#vendor}-color-##) white ##%);',
|
|
177
|
-
lighter: 'color-mix(in srgb, var({#vendor}-color-##) white ##%);',
|
|
178
|
-
dark: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
179
|
-
darker: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
180
|
-
complement: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
181
|
-
invert: 'color-mix(in srgb, var({#vendor}-color-##) black ##%);',
|
|
182
|
-
'alpha-low': 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);',
|
|
183
|
-
alpha: 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);',
|
|
184
|
-
'alpha-high': 'color-mix(in srgb, var({#vendor}-color-##) transparent ##%);'
|
|
185
|
-
};
|
|
186
|
-
defaultVariationSteps = {
|
|
187
|
-
steps: [0, 100, 10],
|
|
188
|
-
ease: [2, 20]
|
|
189
|
-
};
|
|
190
|
-
correspondances = {
|
|
191
|
-
lighten: 'white',
|
|
192
|
-
light: 'white',
|
|
193
|
-
lighter: 'white',
|
|
194
|
-
darken: 'black',
|
|
195
|
-
dark: 'black',
|
|
196
|
-
darker: 'black',
|
|
197
|
-
gray: '#333',
|
|
198
|
-
opacity: 'transparent',
|
|
199
|
-
'alpha-high': 'transparent',
|
|
200
|
-
'alpha-low': 'transparent',
|
|
201
|
-
alpha: 'transparent'
|
|
202
|
-
};
|
|
203
|
-
baseColors;
|
|
204
|
-
presets = [
|
|
205
|
-
'light',
|
|
206
|
-
'lighter',
|
|
207
|
-
'dark',
|
|
208
|
-
'darker',
|
|
209
|
-
'complement',
|
|
210
|
-
'invert',
|
|
211
|
-
'alpha-low',
|
|
212
|
-
'alpha',
|
|
213
|
-
'alpha-high'
|
|
214
|
-
];
|
|
215
|
-
config = {};
|
|
216
|
-
constructor() {
|
|
217
|
-
this.baseColors = harmony('#9e3902');
|
|
218
|
-
this.config = this.deepMerge(colorConfig, { theme: harmony('#9e3902') });
|
|
219
|
-
return this;
|
|
220
|
-
}
|
|
221
|
-
setVariations(variations) {
|
|
222
|
-
this.variations = { ...this.variations, ...variations };
|
|
223
|
-
}
|
|
224
|
-
setDefaultVariationSteps(variationSteps) {
|
|
225
|
-
this.defaultVariationSteps = { ...this.defaultVariationSteps, ...variationSteps };
|
|
226
|
-
}
|
|
227
|
-
deepMerge(...objects) {
|
|
228
|
-
function objectMerge(target, source) {
|
|
229
|
-
for (const key of Object.keys(source)) {
|
|
230
|
-
const currenttarget = target[key];
|
|
231
|
-
const currentsource = source[key];
|
|
232
|
-
if (currenttarget) {
|
|
233
|
-
const objectsource = typeof currentsource === 'object';
|
|
234
|
-
const objecttarget = typeof currenttarget === 'object';
|
|
235
|
-
if (objectsource && objecttarget) {
|
|
236
|
-
void (Array.isArray(currenttarget) && Array.isArray(currentsource)
|
|
237
|
-
? void (target[key] = currenttarget.concat(currentsource))
|
|
238
|
-
: void objectMerge(currenttarget, currentsource));
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
target[key] = currentsource;
|
|
243
|
-
}
|
|
244
|
-
return target;
|
|
245
|
-
}
|
|
246
|
-
return objects.reduce(function (prev, next) {
|
|
247
|
-
return { ...prev, ...objectMerge(prev, next) };
|
|
248
|
-
}, objects[0]);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
var ModelConfigKeys;
|
|
252
|
-
(function (ModelConfigKeys) {
|
|
253
|
-
ModelConfigKeys[ModelConfigKeys["base"] = 0] = "base";
|
|
254
|
-
ModelConfigKeys[ModelConfigKeys["palette"] = 1] = "palette";
|
|
255
|
-
ModelConfigKeys[ModelConfigKeys["presets"] = 2] = "presets";
|
|
256
|
-
ModelConfigKeys[ModelConfigKeys["status"] = 3] = "status";
|
|
257
|
-
ModelConfigKeys[ModelConfigKeys["out"] = 4] = "out";
|
|
258
|
-
ModelConfigKeys[ModelConfigKeys["gray"] = 5] = "gray";
|
|
259
|
-
ModelConfigKeys[ModelConfigKeys["out2"] = 6] = "out2";
|
|
260
|
-
})(ModelConfigKeys || (ModelConfigKeys = {}));
|
|
261
|
-
class CssFabric {
|
|
262
|
-
vendor = (fragment = '') => `${this.cssFabricBuilderParams.vendorName}${fragment}`;
|
|
263
|
-
cssFabricModel = {};
|
|
264
|
-
cssFabricBuilderParams;
|
|
265
|
-
cssFabricBuilder;
|
|
266
|
-
constructor() {
|
|
267
|
-
this.cssFabricBuilder = new CssFabricBuilder();
|
|
268
|
-
this.cssFabricBuilderParams = new CssFabricBuilderParams();
|
|
269
|
-
}
|
|
270
|
-
cleanModelKey(modelKey) {
|
|
271
|
-
return modelKey.replace(/'/g, '');
|
|
272
|
-
}
|
|
273
|
-
setParams(params) {
|
|
274
|
-
this.cssFabricBuilderParams = {
|
|
275
|
-
...this.cssFabricBuilderParams,
|
|
276
|
-
...params
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
createCssFabricVarsColors(...args) {
|
|
280
|
-
args.forEach((modelKey) => {
|
|
281
|
-
switch (this.cleanModelKey(modelKey)) {
|
|
282
|
-
case 'base':
|
|
283
|
-
this.cssFabricModel.base = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.theme, this.vendor());
|
|
284
|
-
break;
|
|
285
|
-
case 'palette':
|
|
286
|
-
this.cssFabricModel.palette = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.palette, this.vendor('palette-'));
|
|
287
|
-
break;
|
|
288
|
-
case 'presets':
|
|
289
|
-
this.cssFabricModel.presets = this.cssFabricBuilder.flattenIt(['primary', 'secondary', 'tertiary', 'accent'], this.cssFabricBuilderParams.presets, this.vendor('presets-'));
|
|
290
|
-
break;
|
|
291
|
-
case 'status':
|
|
292
|
-
this.cssFabricModel.status = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.status, this.vendor('status-'));
|
|
293
|
-
break;
|
|
294
|
-
case 'out':
|
|
295
|
-
// assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
|
|
296
|
-
this.cssFabricModel.out = this.cssFabricBuilder.makeDefaultVariations(['primary', 'secondary', 'tertiary'], ['lighten', 'darken', 'opacity'], this.vendor());
|
|
297
|
-
break;
|
|
298
|
-
case 'gray':
|
|
299
|
-
this.cssFabricModel.gray = this.cssFabricBuilder.createProgression({
|
|
300
|
-
property: this.vendor(`color-gray`),
|
|
301
|
-
iteratorMask: `color-mix(in srgb, ${this.vendor(`color-gray`)} ${this.cssFabricBuilderParams.correspondances.gray} ##%);`,
|
|
302
|
-
steps: this.cssFabricBuilderParams.defaultVariationSteps
|
|
303
|
-
}, 'json');
|
|
304
|
-
break;
|
|
305
|
-
case 'out2':
|
|
306
|
-
// assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
|
|
307
|
-
this.cssFabricModel.out2 = this.cssFabricBuilder.makeDefaultVariations(['foreground', 'bg'], ['lighten', 'darken', 'opacity'], this.vendor());
|
|
308
|
-
break;
|
|
309
|
-
default:
|
|
310
|
-
console.log('default', modelKey);
|
|
311
|
-
break;
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
return {
|
|
315
|
-
export: (options) => new CssFabricExport(this.cssFabricModel, options).export(options),
|
|
316
|
-
css: JSON.stringify(this.cssFabricModel)
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
cssFabricSheet() {
|
|
320
|
-
const cssP = new CSSProperties(cssFabricSheet /* , ['overflow'] */);
|
|
321
|
-
const cssF = cssP.generateCSS();
|
|
322
|
-
return {
|
|
323
|
-
export: (options) => new CssFabricExport(cssF, options).export(options),
|
|
324
|
-
css: cssF
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
// overflow , text-overflow, text-decoration
|
|
329
|
-
export const cssFabric = new CssFabric();
|
|
330
|
-
const styleSheet = cssFabric.cssFabricSheet();
|
|
331
|
-
styleSheet.export({ css: './css-fabric-sheet.css', json: './cssFabric-sheet.json' });
|
|
332
|
-
/* const model = cssFabric.createCssFabricVarsColors(
|
|
333
|
-
'base',
|
|
334
|
-
'palette',
|
|
335
|
-
'presets',
|
|
336
|
-
'status',
|
|
337
|
-
'out',
|
|
338
|
-
'gray',
|
|
339
|
-
'out2'
|
|
340
|
-
);
|
|
341
|
-
model.export({ css: './css-fabric.css', json: './cssFabric.json' }); */
|
|
1
|
+
// Reexport of entry components
|
|
2
|
+
export * from './bin/exports.js';
|
|
3
|
+
export * from './config.js';
|
|
4
|
+
export * from './CssFabric.js';
|
|
5
|
+
export * from './CssFabricBuilder.js';
|
|
6
|
+
export * from './CssFabricExport.js';
|
|
7
|
+
export * from './cssFabricSheet.js';
|
|
8
|
+
export * from './cssProperties.js';
|
|
9
|
+
export * from './cssVariationsAi.js';
|
|
10
|
+
export * from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Steps = [number, number, number];
|
|
2
|
+
export type Mask = string;
|
|
3
|
+
export type ToMask = string;
|
|
4
|
+
export type EaseTrigger = number;
|
|
5
|
+
export type Ease = number;
|
|
6
|
+
export declare enum ModelConfigKeys {
|
|
7
|
+
base = 0,
|
|
8
|
+
palette = 1,
|
|
9
|
+
presets = 2,
|
|
10
|
+
status = 3,
|
|
11
|
+
out = 4,
|
|
12
|
+
gray = 5,
|
|
13
|
+
out2 = 6
|
|
14
|
+
}
|
|
15
|
+
export type cssFabricModelKey = keyof typeof ModelConfigKeys;
|
|
16
|
+
export type cssFabricModelType = Record<cssFabricModelKey, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var ModelConfigKeys;
|
|
2
|
+
(function (ModelConfigKeys) {
|
|
3
|
+
ModelConfigKeys[ModelConfigKeys["base"] = 0] = "base";
|
|
4
|
+
ModelConfigKeys[ModelConfigKeys["palette"] = 1] = "palette";
|
|
5
|
+
ModelConfigKeys[ModelConfigKeys["presets"] = 2] = "presets";
|
|
6
|
+
ModelConfigKeys[ModelConfigKeys["status"] = 3] = "status";
|
|
7
|
+
ModelConfigKeys[ModelConfigKeys["out"] = 4] = "out";
|
|
8
|
+
ModelConfigKeys[ModelConfigKeys["gray"] = 5] = "gray";
|
|
9
|
+
ModelConfigKeys[ModelConfigKeys["out2"] = 6] = "out2";
|
|
10
|
+
})(ModelConfigKeys || (ModelConfigKeys = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -55,11 +55,16 @@ export * from './cssf/cssfModel.js';
|
|
|
55
55
|
export * from './cssf/cssfPlugin.js';
|
|
56
56
|
export * from './cssf/cssfTransformer.js';
|
|
57
57
|
export * from './cssf/index.js';
|
|
58
|
+
export * from './cssFabric/bin/exports.js';
|
|
58
59
|
export * from './cssFabric/config.js';
|
|
60
|
+
export * from './cssFabric/CssFabric.js';
|
|
61
|
+
export * from './cssFabric/CssFabricBuilder.js';
|
|
62
|
+
export * from './cssFabric/CssFabricExport.js';
|
|
59
63
|
export * from './cssFabric/cssFabricSheet.js';
|
|
60
64
|
export * from './cssFabric/cssProperties.js';
|
|
61
65
|
export * from './cssFabric/cssVariationsAi.js';
|
|
62
66
|
export * from './cssFabric/index.js';
|
|
67
|
+
export * from './cssFabric/types.js';
|
|
63
68
|
export * from './index.js';
|
|
64
69
|
export { default as NewMenu } from './NewMenu.svelte';
|
|
65
70
|
export * from './scripts/cssfabric.js';
|
package/dist/index.js
CHANGED
|
@@ -56,11 +56,16 @@ export * from './cssf/cssfModel.js';
|
|
|
56
56
|
export * from './cssf/cssfPlugin.js';
|
|
57
57
|
export * from './cssf/cssfTransformer.js';
|
|
58
58
|
export * from './cssf/index.js';
|
|
59
|
+
export * from './cssFabric/bin/exports.js';
|
|
59
60
|
export * from './cssFabric/config.js';
|
|
61
|
+
export * from './cssFabric/CssFabric.js';
|
|
62
|
+
export * from './cssFabric/CssFabricBuilder.js';
|
|
63
|
+
export * from './cssFabric/CssFabricExport.js';
|
|
60
64
|
export * from './cssFabric/cssFabricSheet.js';
|
|
61
65
|
export * from './cssFabric/cssProperties.js';
|
|
62
66
|
export * from './cssFabric/cssVariationsAi.js';
|
|
63
67
|
export * from './cssFabric/index.js';
|
|
68
|
+
export * from './cssFabric/types.js';
|
|
64
69
|
export * from './index.js';
|
|
65
70
|
export { default as NewMenu } from './NewMenu.svelte';
|
|
66
71
|
export * from './scripts/cssfabric.js';
|