@medyll/cssfabric 0.2.0 → 0.2.1-beta.2
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/README.md +58 -38
- package/dist/NewMenu.svelte +41 -0
- package/dist/NewMenu.svelte.d.ts +19 -0
- package/dist/css/animation/animation.css +2 -0
- package/dist/css/base/base.css +47 -0
- package/dist/css/base/base.min.css +1 -0
- package/{styles → dist/css}/box/box.css +118 -0
- package/dist/css/box/box.min.css +1 -0
- package/{styles → dist/css}/box/box.responsive.css +3063 -1550
- package/dist/css/box/box.responsive.min.css +1 -0
- package/{styles → dist/css}/color/color.css +11 -9
- package/{styles → dist/css}/color/color.responsive.css +3446 -1932
- package/dist/css/color/color.responsive.min.css +1 -0
- package/dist/css/cssfabric.css +5167 -0
- package/dist/css/cssfabric.min.css +4877 -0
- package/dist/css/cssfabric.responsive.css +20419 -0
- package/dist/css/cssfabric.responsive.min.css +1 -0
- package/{styles → dist/css}/flex/flex.css +2 -0
- package/{styles → dist/css}/flex/flex.responsive.css +192 -114
- package/dist/css/flex/flex.responsive.min.css +1 -0
- package/{styles → dist/css}/grid/grid.css +2 -0
- package/{styles → dist/css}/grid/grid.responsive.css +230 -212
- package/dist/css/grid/grid.responsive.min.css +1 -0
- package/{styles → dist/css}/menu/menu.css +2 -0
- package/{styles → dist/css}/menu/menu.responsive.css +165 -78
- package/dist/css/menu/menu.responsive.min.css +1 -0
- package/{styles → dist/css}/overflow/overflow.css +2 -0
- package/{styles → dist/css}/overflow/overflow.responsive.css +98 -105
- package/dist/css/overflow/overflow.responsive.min.css +1 -0
- package/{styles → dist/css}/scale/scale.css +2 -0
- package/{styles → dist/css}/scale/scale.responsive.css +1520 -1152
- package/dist/css/scale/scale.responsive.min.css +1 -0
- package/{styles → dist/css}/table/table.css +2 -0
- package/{styles → dist/css}/table/table.responsive.css +162 -86
- package/dist/css/table/table.responsive.min.css +1 -0
- package/{styles → dist/css}/text/text.css +2 -0
- package/{styles → dist/css}/text/text.responsive.css +76 -55
- package/dist/css/text/text.responsive.min.css +1 -0
- package/{styles → dist/css}/theme/theme.css +51 -0
- package/{styles → dist/css}/theme/theme.min.css +1 -1
- package/{styles → dist/css}/vars.css +66 -67
- package/dist/css/vars.min.css +1 -0
- package/{styles → dist/css}/zindex/zindex.css +2 -0
- package/dist/cssFabric/config.d.ts +29 -0
- package/dist/cssFabric/config.js +29 -0
- package/dist/cssFabric/cssFabricSheet.d.ts +1226 -0
- package/dist/cssFabric/cssFabricSheet.js +1270 -0
- package/dist/cssFabric/cssProperties.d.ts +27 -0
- package/dist/cssFabric/cssProperties.js +343 -0
- package/dist/cssFabric/cssVariationsAi.d.ts +12 -0
- package/dist/cssFabric/cssVariationsAi.js +111 -0
- package/dist/cssFabric/index.d.ts +113 -0
- package/dist/cssFabric/index.js +341 -0
- package/dist/cssf/README.md +197 -0
- package/{init/importCssVars.d.ts → dist/cssf/cssf.d.ts} +1 -1
- package/dist/cssf/cssf.js +12 -0
- package/dist/cssf/cssfGuide.d.ts +14 -0
- package/dist/cssf/cssfGuide.js +50 -0
- package/dist/cssf/cssfLib.d.ts +134 -0
- package/dist/cssf/cssfLib.js +116 -0
- package/dist/cssf/cssfModel.d.ts +8 -0
- package/dist/cssf/cssfModel.js +59 -0
- package/dist/cssf/cssfPlugin.d.ts +3 -0
- package/dist/cssf/cssfPlugin.js +37 -0
- package/dist/cssf/cssfTransformer.d.ts +2 -0
- package/dist/cssf/cssfTransformer.js +100 -0
- package/dist/cssf/index.d.ts +6 -0
- package/dist/cssf/index.js +7 -0
- package/dist/cssfVsCode/.vscode/launch.json +17 -0
- package/dist/cssfVsCode/.vscodeignore +4 -0
- package/dist/cssfVsCode/CHANGELOG.md +9 -0
- package/dist/cssfVsCode/README.md +65 -0
- package/dist/cssfVsCode/language-configuration.json +36 -0
- package/dist/cssfVsCode/package.json +40 -0
- package/dist/cssfVsCode/syntaxes/cssf.tmLanguage.json +1868 -0
- package/dist/cssfVsCode/test.cssf +6 -0
- package/dist/cssfVsCode/vsc-extension-quickstart.md +29 -0
- package/{_generated → dist/generated}/cssFabric.vars.json +4 -4
- package/{_generated/export.variables.md → dist/generated/cssFabric.vars.md} +268 -240
- package/dist/index.d.ts +119 -0
- package/dist/index.js +120 -0
- package/dist/scripts/cssfabric.d.ts +24 -0
- package/{scripts → dist/scripts}/cssfabric.js +43 -43
- package/{scripts → dist/scripts}/cssfabricClassNames.d.ts +14 -14
- package/{scripts → dist/scripts}/cssfabricClassNames.js +146 -146
- package/dist/scripts/index.d.ts +2 -0
- package/{scripts → dist/scripts}/index.js +4 -4
- package/{scripts → dist/scripts}/utils.d.ts +5 -5
- package/{scripts → dist/scripts}/utils.js +38 -38
- package/dist/scss/_utils.scss +203 -0
- package/dist/scss/modules/_cssfabric-config.scss +178 -0
- package/dist/scss/modules/_mixins.scss +1 -0
- package/dist/scss/modules/animation/_animation-vars.scss +17 -0
- package/dist/scss/modules/animation/animation.scss +3 -0
- package/dist/scss/modules/base/_base-vars.scss +19 -0
- package/dist/scss/modules/base/base.scss +58 -0
- package/dist/scss/modules/box/_box-build.scss +305 -0
- package/dist/scss/modules/box/_box-vars.scss +121 -0
- package/dist/scss/modules/box/box-responsive.scss +18 -0
- package/dist/scss/modules/box/box.scss +3 -0
- package/dist/scss/modules/color/_color-build.scss +196 -0
- package/dist/scss/modules/color/_color-vars.scss +80 -0
- package/dist/scss/modules/color/color-responsive.scss +23 -0
- package/dist/scss/modules/color/color.scss +9 -0
- package/dist/scss/modules/css-fabric.scss +1 -0
- package/dist/scss/modules/flex/_flex-build.scss +150 -0
- package/dist/scss/modules/flex/_flex-vars.scss +84 -0
- package/dist/scss/modules/flex/flex-responsive.scss +25 -0
- package/dist/scss/modules/flex/flex.scss +3 -0
- package/dist/scss/modules/grid/_grid-build.scss +87 -0
- package/dist/scss/modules/grid/_grid-vars.scss +88 -0
- package/dist/scss/modules/grid/grid-responsive.scss +25 -0
- package/dist/scss/modules/grid/grid.scss +6 -0
- package/dist/scss/modules/menu/_menu-build.scss +120 -0
- package/dist/scss/modules/menu/_menu-vars.scss +29 -0
- package/dist/scss/modules/menu/menu-responsive.scss +19 -0
- package/dist/scss/modules/menu/menu.scss +6 -0
- package/dist/scss/modules/overflow/_overflow-build.scss +22 -0
- package/dist/scss/modules/overflow/_overflow-vars.scss +31 -0
- package/dist/scss/modules/overflow/overflow-responsive.scss +25 -0
- package/dist/scss/modules/overflow/overflow.scss +7 -0
- package/dist/scss/modules/scale/_scale-build.scss +142 -0
- package/dist/scss/modules/scale/_scale-vars.scss +84 -0
- package/dist/scss/modules/scale/scale-responsive.scss +23 -0
- package/dist/scss/modules/scale/scale.scss +8 -0
- package/dist/scss/modules/table/_table-build.scss +134 -0
- package/dist/scss/modules/table/_table-vars.scss +30 -0
- package/dist/scss/modules/table/table-responsive.scss +24 -0
- package/dist/scss/modules/table/table.scss +8 -0
- package/dist/scss/modules/text/_text-build.scss +166 -0
- package/dist/scss/modules/text/_text-vars.scss +87 -0
- package/dist/scss/modules/text/text-responsive.scss +26 -0
- package/dist/scss/modules/text/text.scss +6 -0
- package/dist/scss/modules/theme/_theme-build.scss +128 -0
- package/dist/scss/modules/theme/_theme-vars.scss +46 -0
- package/dist/scss/modules/theme/theme.scss +6 -0
- package/dist/scss/modules/vars.scss +46 -0
- package/dist/scss/modules/zindex/_zindex-vars.scss +14 -0
- package/dist/scss/modules/zindex/zindex.scss +15 -0
- package/package.json +70 -113
- package/_generated/readme.md +0 -0
- package/init/importCssVars.js +0 -2
- package/scripts/cssfabric.d.ts +0 -24
- package/scripts/index.d.ts +0 -2
- package/styles/animation/animation.css +0 -0
- package/styles/base/base.css +0 -215
- package/styles/base/base.min.css +0 -1
- package/styles/box/box.min.css +0 -1
- package/styles/box/box.responsive.min.css +0 -1
- package/styles/color/color.responsive.min.css +0 -1
- package/styles/cssfabric.css +0 -61792
- package/styles/cssfabric.min.css +0 -168
- package/styles/cssfabric.responsive.css +0 -200596
- package/styles/cssfabric.responsive.min.css +0 -108
- package/styles/flex/flex.responsive.min.css +0 -1
- package/styles/grid/grid.responsive.min.css +0 -1
- package/styles/menu/menu.responsive.min.css +0 -1
- package/styles/overflow/overflow.responsive.min.css +0 -1
- package/styles/scale/scale.responsive.min.css +0 -1
- package/styles/table/table.responsive.min.css +0 -1
- package/styles/text/text.responsive.min.css +0 -1
- package/styles/vars.min.css +0 -1
- /package/{styles → dist/css}/animation/animation.min.css +0 -0
- /package/{styles → dist/css}/color/color.min.css +0 -0
- /package/{styles → dist/css}/flex/flex.min.css +0 -0
- /package/{styles → dist/css}/grid/grid.min.css +0 -0
- /package/{styles → dist/css}/menu/menu.min.css +0 -0
- /package/{styles → dist/css}/overflow/overflow.min.css +0 -0
- /package/{styles → dist/css}/scale/scale.min.css +0 -0
- /package/{styles → dist/css}/table/table.min.css +0 -0
- /package/{styles → dist/css}/text/text.min.css +0 -0
- /package/{styles → dist/css}/zindex/zindex.min.css +0 -0
- /package/{_generated → dist/scss}/index.d.ts +0 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import fsExtra from 'fs-extra';
|
|
2
|
+
import { harmony } from 'simpler-color';
|
|
3
|
+
import { colorConfig } from './config.js';
|
|
4
|
+
import { CSSProperties } from './cssProperties.js';
|
|
5
|
+
import { cssFabricSheet } from './cssFabricSheet.js';
|
|
6
|
+
class CssFabricExport {
|
|
7
|
+
cssFabricModel;
|
|
8
|
+
exportPaths = {
|
|
9
|
+
css: './css-fabric.css',
|
|
10
|
+
json: './cssFabric.json'
|
|
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' }); */
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# About css stuff
|
|
2
|
+
|
|
3
|
+
- ## It's about css
|
|
4
|
+
|
|
5
|
+
It's about css and the way some revolutions did save the world.
|
|
6
|
+
It's not about suffering, it's about emancipation, because being static is always a first start.
|
|
7
|
+
And it's about css. And a bit about Tailwind. Because tailwind did save us.
|
|
8
|
+
|
|
9
|
+
#### lovy Granny
|
|
10
|
+
|
|
11
|
+
To learn me the little cssSheet redbook, my grandMa did the basis. She was born in 1480 and did work since her 14s at the W3C, her job was to set normes a normal way. She was a bit of a monster, but she was right.
|
|
12
|
+
|
|
13
|
+
#### complexity
|
|
14
|
+
|
|
15
|
+
And she was right with the method: keeping me with a clou transperçant my feet while repeating the declinations of cssRules was the way to make me strong. The feeling of css needs the knowledge of pain.
|
|
16
|
+
|
|
17
|
+
#### complexity and strength
|
|
18
|
+
|
|
19
|
+
Because if it's complex, you're strong!
|
|
20
|
+
|
|
21
|
+
- ## It's not about Tailwind
|
|
22
|
+
|
|
23
|
+
But i kept having some secrets toughs : but what if the word was organized an organized way ?
|
|
24
|
+
|
|
25
|
+
**questions** : i know that a property which randomly target the outer or the inner of the concerned element is savagely cool, but what if not ? what if top was a position ? what if i want to setup the left and the right of the same border declaration ? what if verbosity was not the goal ? may i dream or did i dream ?
|
|
26
|
+
**answers** : Because there were no problems, i decided to seek for a solution. And i did reach severals.
|
|
27
|
+
|
|
28
|
+
### utility classes are right
|
|
29
|
+
|
|
30
|
+
Around 2005, i did my first utility css monster. Based on php, acronym of "best language ever", it made me the king of velocity. Year and babies after, a non impressioné colleague asked me a simple question :
|
|
31
|
+
|
|
32
|
+
### Tailwind is right
|
|
33
|
+
|
|
34
|
+
He asked: do you know things about **Tailwind** ? Do you know it has a wild css coverage and a lot of pretty babies ?
|
|
35
|
+
|
|
36
|
+
- #### Humanity is a pretty monster
|
|
37
|
+
|
|
38
|
+
He revealed me also the existence of a "reseau social", called Twitter, so i headed to it and it was a 5 elements Lilo thing, the lagrimas revelation time. The humanity is seeking for a solution while css detonations do craters with border-radius-top-left properties. And people are fighting in their textual multi-verse, yelling to each others that tailwind is a master so why do you yell ?
|
|
39
|
+
|
|
40
|
+
- #### Tailwind is unsinkable
|
|
41
|
+
|
|
42
|
+
Humanity is a pretty and a monster, and css are born in this humanity nest. css is eradicating humanity and Tailwind is the anchor which prevents the word to sink. Working without utility classes is a time consuming task, obvious leading to the nearest of a delirium tremens : reporting this is not an information, this is a therapy.
|
|
43
|
+
|
|
44
|
+
- #### Css is a time traveling iceberg
|
|
45
|
+
|
|
46
|
+
But the fact is, Tailwind is the unsinkable boat, and css is the iceberg. Utility classes are a must, so why the anger ? Aren't we safe from the iceberg ? Each time we approach it, we defeat the risk with a re-implementation time loop, UnoCss being my favorite one.
|
|
47
|
+
|
|
48
|
+
- ## It's a about the void
|
|
49
|
+
|
|
50
|
+
> There is no solution.
|
|
51
|
+
|
|
52
|
+
There are no solutions.
|
|
53
|
+
The socle is the problem, here is the void:
|
|
54
|
+
|
|
55
|
+
```css
|
|
56
|
+
::void {
|
|
57
|
+
position: absolute; /* a flow */
|
|
58
|
+
width: 0; /* a size */
|
|
59
|
+
top: -50px; /* a position */
|
|
60
|
+
margin: -50px 20px; /* a position! **/
|
|
61
|
+
gap: 20px; /* a gutter */
|
|
62
|
+
padding: 20px; /* a gutter */
|
|
63
|
+
display: inline; /* a flow */
|
|
64
|
+
display: none; /* a state */
|
|
65
|
+
display: flex; /* Inhaltsausrichtung ? */
|
|
66
|
+
color: #000; /* a color */
|
|
67
|
+
background-color: #fff; /* a color */
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- ## It's about this time loop
|
|
72
|
+
|
|
73
|
+
Organization with Tailwind or other utility classes is mandatory for readability and maintainability. Because if you claim never going back to the code, then you'll have to admit the existence of fear.
|
|
74
|
+
What is the point ?
|
|
75
|
+
We love Tailwind, **Unocss** or others because they are global shorteners. You think, you write, bam !
|
|
76
|
+
Let's get it with some words :
|
|
77
|
+
|
|
78
|
+
#### from tailwind utility verb
|
|
79
|
+
|
|
80
|
+
Bringing back the shortness to the '\<style>' tag is a meeting point : seeming **near standards**. Here, categorization means readability and **predictability**.
|
|
81
|
+
|
|
82
|
+
This could be the only way, this is mine since epoch:
|
|
83
|
+
|
|
84
|
+
```scss
|
|
85
|
+
input {
|
|
86
|
+
--at-apply: padding gap;
|
|
87
|
+
--at-apply: width height;
|
|
88
|
+
--at-apply: left top right bottom margin;
|
|
89
|
+
--at-apply: border shadow radius;
|
|
90
|
+
--at-apply: color bg;
|
|
91
|
+
--at-apply: absolute fixed static sticky;
|
|
92
|
+
&:hover {
|
|
93
|
+
--at-apply: color bg;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### to semantic css words
|
|
99
|
+
|
|
100
|
+
right, bottom, top and left are a position. and collide with position being a property.
|
|
101
|
+
width and height are a size, a dimension, they should stick together.
|
|
102
|
+
margin and padding seem friends, but concern the outer vs the inner of the element.
|
|
103
|
+
utility needs semantics :
|
|
104
|
+
|
|
105
|
+
```css
|
|
106
|
+
input {
|
|
107
|
+
margin: padding gap;
|
|
108
|
+
size: width height;
|
|
109
|
+
position: left top right bottom middle center margin;
|
|
110
|
+
box: border shadow radius;
|
|
111
|
+
theme: color bg;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### with a single definition
|
|
116
|
+
|
|
117
|
+
thinking about css should be like a **pure function** : one though, same response.
|
|
118
|
+
This is not the case: the mental model needs to be switched depending on the css rule.
|
|
119
|
+
I mean, like working on **padding** and switching to **border** :
|
|
120
|
+
|
|
121
|
+
```scss
|
|
122
|
+
/** css-verse reality border in the world of paddings */
|
|
123
|
+
:css-verse {
|
|
124
|
+
.earth-606 {
|
|
125
|
+
padding: 10px 5px 2px 3rem;
|
|
126
|
+
}
|
|
127
|
+
.reality {
|
|
128
|
+
border: 1px 2px 4px none;
|
|
129
|
+
border-color: red white orange blue;
|
|
130
|
+
border-radius: 10px 20px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- ## It's about hoping
|
|
136
|
+
|
|
137
|
+
> hoping is having hope, but actively.
|
|
138
|
+
|
|
139
|
+
To implement this i need :
|
|
140
|
+
|
|
141
|
+
- a rule set: to decide the verbs
|
|
142
|
+
- a model: to ensure strict rules
|
|
143
|
+
- a parser : to walk trough the model
|
|
144
|
+
- a transformer : to render back the rules.
|
|
145
|
+
|
|
146
|
+
the needed mental strength :
|
|
147
|
+
|
|
148
|
+
- a guide: bringing active solidity
|
|
149
|
+
- a hole: there are some glitches to ditch in it, some properties to abandon, sadness to have
|
|
150
|
+
- a goal: the browser is not the goal, could it be ?
|
|
151
|
+
|
|
152
|
+
Let's start with something else : the guide to ensure consistency
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
/**
|
|
156
|
+
* cssGuide :
|
|
157
|
+
* transforms the model to a ts declaration file and an associated class methods.
|
|
158
|
+
*/
|
|
159
|
+
export class CssGuide {
|
|
160
|
+
cssfModelTypes: CssfModelTypes;
|
|
161
|
+
interfaceName = 'CssfInterface';
|
|
162
|
+
className = 'CssfCkass';
|
|
163
|
+
|
|
164
|
+
constructor(cssfModel: CssfModelTypes) {
|
|
165
|
+
this.cssfModelTypes = cssfModel;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
generate(objModel: Record<string, any>) {
|
|
169
|
+
const unify = (arr: string[] | string): string => {
|
|
170
|
+
return
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
let meta = `imports;\n`;
|
|
174
|
+
let interfaces = `export interface ${this.interfaceName} {\n`;
|
|
175
|
+
let classMethods = `export class ${this.className} {\n`;
|
|
176
|
+
|
|
177
|
+
for (const type of this.cssfModelTypes) {
|
|
178
|
+
meta += `type ${val};\n`;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
for (const [outerKey, value] of Object.entries(objModel)) {
|
|
182
|
+
interfaces += `${outerKey}: {\n`;
|
|
183
|
+
classMethods += `${outerKey}(decl: postcss.Declaration) {\n return {\n`;
|
|
184
|
+
|
|
185
|
+
for (const [key, val] of Object.entries(value)) {...}
|
|
186
|
+
|
|
187
|
+
interfaces += ' };\n';
|
|
188
|
+
classMethods += ' };\n }\n';
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interfaces += '}\n';
|
|
192
|
+
classMethods += '}\n';
|
|
193
|
+
|
|
194
|
+
return { meta, interfaces, classMethods };
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { CssGuide } from './cssfGuide.js';
|
|
3
|
+
import { cssfModelTypes, cssfModel } from './cssfModel.js';
|
|
4
|
+
/* const processor = postcss([myPlugin]);
|
|
5
|
+
|
|
6
|
+
processor.process('a { color: black; }').then((result) => {
|
|
7
|
+
console.log(result.css);
|
|
8
|
+
}); */
|
|
9
|
+
const cssGuide = new CssGuide(cssfModelTypes);
|
|
10
|
+
const { meta, interfaces, classMethods, classTypes, transformerTypes } = cssGuide.generate(cssfModel);
|
|
11
|
+
console.log(meta, interfaces, classMethods, classTypes, transformerTypes);
|
|
12
|
+
fs.writeFileSync('src/lib/cssf/cssfLib.ts', meta + classTypes + transformerTypes + interfaces + classMethods);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CssfModelTypes } from './cssfModel.js';
|
|
2
|
+
export declare class CssGuide {
|
|
3
|
+
cssfModelTypes: CssfModelTypes;
|
|
4
|
+
interfaceName: string;
|
|
5
|
+
className: string;
|
|
6
|
+
constructor(cssfModel: CssfModelTypes);
|
|
7
|
+
generate(objModel: Record<string, Record<string, any>>): {
|
|
8
|
+
meta: string;
|
|
9
|
+
classTypes: string;
|
|
10
|
+
transformerTypes: string;
|
|
11
|
+
interfaces: string;
|
|
12
|
+
classMethods: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export class CssGuide {
|
|
2
|
+
cssfModelTypes;
|
|
3
|
+
interfaceName = 'CssfInterface';
|
|
4
|
+
className = 'CssfClass';
|
|
5
|
+
constructor(cssfModel) {
|
|
6
|
+
this.cssfModelTypes = cssfModel;
|
|
7
|
+
}
|
|
8
|
+
generate(objModel) {
|
|
9
|
+
const unify = (arr) => {
|
|
10
|
+
const rr = Array.isArray(arr) ? arr : [arr];
|
|
11
|
+
function isType(val) {
|
|
12
|
+
return val === 'string' || val === 'number';
|
|
13
|
+
}
|
|
14
|
+
return rr.map((item) => (Array.isArray(item) ? `[${unify(item)}]` : `'${item}'`)).join(' | ');
|
|
15
|
+
};
|
|
16
|
+
let meta = `/** generated ! */\nimport postcss from 'postcss';\n\n\n\n`;
|
|
17
|
+
let interfaces = `export interface ${this.interfaceName} {\n{{interfaces}}\n}`;
|
|
18
|
+
let transformerTypes = `export interface ${this.interfaceName}T {\n{{transformer}}\n}`;
|
|
19
|
+
let classMethods = `export class ${this.className} {\n{{methods}}\n}`;
|
|
20
|
+
let classTypes = `/** generated types */\n{{types}}\n`;
|
|
21
|
+
let collectClassMethods = '';
|
|
22
|
+
let collectInterfaces = '';
|
|
23
|
+
let collectTypes = '';
|
|
24
|
+
let collectTransformerTypes = '';
|
|
25
|
+
for (const type of this.cssfModelTypes) {
|
|
26
|
+
const val = type.includes('=') ? type : type + ' = string | number';
|
|
27
|
+
collectTypes += `type ${val};\n`;
|
|
28
|
+
}
|
|
29
|
+
for (const [outerKey, value] of Object.entries(objModel)) {
|
|
30
|
+
collectInterfaces += ` ${outerKey}: {\n`;
|
|
31
|
+
collectTransformerTypes += ` ${outerKey}: {\n`;
|
|
32
|
+
collectClassMethods += ` ${outerKey}(decl: postcss.Declaration) {\n return {\n`;
|
|
33
|
+
for (const [key, val] of Object.entries(value)) {
|
|
34
|
+
collectInterfaces += ` ${key}: ${unify(val)};\n`;
|
|
35
|
+
collectTransformerTypes += ` ${key}: ( decl: postcss.Declaration, ...value: ${this.interfaceName}['${outerKey}']['${key}'][])=> void ;\n`;
|
|
36
|
+
collectClassMethods += ` ${key}: (...args: ${this.interfaceName}['${outerKey}']['${key}'][]) => {
|
|
37
|
+
return args;
|
|
38
|
+
},\n`;
|
|
39
|
+
}
|
|
40
|
+
collectInterfaces += ' };\n';
|
|
41
|
+
collectTransformerTypes += ' };\n';
|
|
42
|
+
collectClassMethods += ' };\n }\n ';
|
|
43
|
+
}
|
|
44
|
+
classMethods = classMethods.replace('{{methods}}', collectClassMethods);
|
|
45
|
+
interfaces = interfaces.replace('{{interfaces}}', collectInterfaces);
|
|
46
|
+
transformerTypes = transformerTypes.replace('{{transformer}}', collectTransformerTypes);
|
|
47
|
+
classTypes = classTypes.replace('{{types}}', collectTypes);
|
|
48
|
+
return { meta, classTypes, transformerTypes, interfaces, classMethods };
|
|
49
|
+
}
|
|
50
|
+
}
|