@medyll/cssfabric 0.2.1-beta.4 → 0.2.1-beta.6

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.
Files changed (45) hide show
  1. package/README.md +42 -34
  2. package/dist/fabric/CssFabric.d.ts +46 -0
  3. package/dist/fabric/CssFabric.js +97 -0
  4. package/dist/{cssFabric/index.d.ts → fabric/CssFabricBuilder.d.ts} +3 -45
  5. package/dist/{cssFabric/index.js → fabric/CssFabricBuilder.js} +3 -133
  6. package/dist/fabric/CssFabricExport.d.ts +10 -0
  7. package/dist/fabric/CssFabricExport.js +59 -0
  8. package/dist/fabric/bin/exports.d.ts +2 -0
  9. package/dist/fabric/bin/exports.js +13 -0
  10. package/dist/fabric/css/css-fabric-sheet.css +15366 -0
  11. package/dist/fabric/css/css-fabric-vars-colors.css +387 -0
  12. package/dist/fabric/css/cssFabric-sheet.json +1 -0
  13. package/dist/fabric/css/cssFabric-vars-colors.json +1 -0
  14. package/dist/{cssFabric → fabric}/cssProperties.js +0 -1
  15. package/dist/fabric/index.d.ts +9 -0
  16. package/dist/fabric/index.js +10 -0
  17. package/dist/fabric/types.d.ts +16 -0
  18. package/dist/fabric/types.js +10 -0
  19. package/dist/index.d.ts +14 -9
  20. package/dist/index.js +14 -9
  21. package/dist/{scripts → legacy/scripts}/cssfabric.js +1 -1
  22. package/dist/{scripts → legacy/scripts}/cssfabricClassNames.js +50 -30
  23. package/package.json +2 -1
  24. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/.vscode/launch.json +0 -0
  25. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/.vscodeignore +0 -0
  26. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/CHANGELOG.md +0 -0
  27. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/README.md +0 -0
  28. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/language-configuration.json +0 -0
  29. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/package.json +0 -0
  30. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/syntaxes/cssf.tmLanguage.json +0 -0
  31. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/test.cssf +0 -0
  32. /package/dist/{cssfVsCode → extensions/cssfabric-vscode}/vsc-extension-quickstart.md +0 -0
  33. /package/dist/{cssFabric → fabric}/config.d.ts +0 -0
  34. /package/dist/{cssFabric → fabric}/config.js +0 -0
  35. /package/dist/{cssFabric → fabric}/cssFabricSheet.d.ts +0 -0
  36. /package/dist/{cssFabric → fabric}/cssFabricSheet.js +0 -0
  37. /package/dist/{cssFabric → fabric}/cssProperties.d.ts +0 -0
  38. /package/dist/{cssFabric → fabric}/cssVariationsAi.d.ts +0 -0
  39. /package/dist/{cssFabric → fabric}/cssVariationsAi.js +0 -0
  40. /package/dist/{scripts → legacy/scripts}/cssfabric.d.ts +0 -0
  41. /package/dist/{scripts → legacy/scripts}/cssfabricClassNames.d.ts +0 -0
  42. /package/dist/{scripts → legacy/scripts}/index.d.ts +0 -0
  43. /package/dist/{scripts → legacy/scripts}/index.js +0 -0
  44. /package/dist/{scripts → legacy/scripts}/utils.d.ts +0 -0
  45. /package/dist/{scripts → legacy/scripts}/utils.js +0 -0
package/README.md CHANGED
@@ -1,58 +1,66 @@
1
- # create-svelte
1
+ # @medyll/cssfabric
2
2
 
3
- Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
3
+ @medyll/cssfabric is a ready-to-use CSS utility className.
4
4
 
5
- Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging).
6
-
7
- ## Creating a project
8
-
9
- If you're seeing this, you've probably already done this step. Congrats!
5
+ ## Installation
10
6
 
7
+ install @medyll/cssfabric with your preferred package manager
11
8
  ```bash
12
- # create a new project in the current directory
13
- npm create svelte@latest
14
-
15
- # create a new project in my-app
16
- npm create svelte@latest my-app
9
+ npm install @medyll/cssfabric
10
+ # or
11
+ yarn add @medyll/cssfabric
12
+ # or whatever
13
+ ...
17
14
  ```
18
15
 
19
- ## Developing
20
16
 
21
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
17
+ ## Configuration
18
+ ### Add `data-theme` attribute to `body`
22
19
 
23
- ```bash
24
- npm run dev
20
+ Add the `data-theme` attribute to the `body` in your main html file:
25
21
 
26
- # or start the server and open the app in a new browser tab
27
- npm run dev -- --open
22
+ ```html
23
+ <body data-theme="dark">
24
+ <!-- Application content -->
25
+ </body>
28
26
  ```
29
27
 
30
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
28
+ The `data-theme` attribute can be set to "dark" or "light" depending on your needs.
29
+ ### Add imports from @medyll/cssfabric in the main file
31
30
 
32
- ## Building
31
+ Add the following imports in the main file:
33
32
 
34
- To build your library:
35
-
36
- ```bash
37
- npm run package
33
+ ```js
34
+ # example
35
+ import "@medyll/cssfabric/cssfabric.min.css";
36
+ # example for svelte
37
+ import "@medyll/cssfabric/cssfabric.min.css?inline";
38
38
  ```
39
39
 
40
- To create a production version of your showcase app:
40
+ ### Import your theme definition
41
41
 
42
- ```bash
43
- npm run build
42
+ ```html
43
+ # example for svelte
44
+ <style global lang="scss">
45
+ @import "path-to/own-cssfabric-theme.scss";
46
+ </style>
44
47
  ```
45
48
 
46
- You can preview the production build with `npm run preview`.
47
49
 
48
- > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
50
+ Example of a scss theme definition:
49
51
 
50
- ## Publishing
52
+ ```scss
53
+ // own-cssfabric-theme.scss
54
+ @charset "utf-8";
51
55
 
52
- Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
56
+ $theme-color-primary: #98B148;
57
+ $theme-color-secondary: #55492B;
58
+ $theme-color-tertiary: #9999CC;
53
59
 
54
- To publish your library to [npm](https://www.npmjs.com):
60
+ $theme-dark-color-foreground: #f1f1f1;
61
+ $theme-dark-color-background: #27323a;
62
+ $theme-dark-color-paper: #3a3b3b;
55
63
 
56
- ```bash
57
- npm publish
64
+ // Overrides the default values of @medyll/cssfabric's configuration and deliver new `css properties`.
65
+ @import "../node_modules/@medyll/cssfabric/src/cssfabric/modules/vars.scss";
58
66
  ```
@@ -0,0 +1,46 @@
1
+ import { CssFabricBuilder, CssFabricBuilderParams } from './CssFabricBuilder.js';
2
+ import { CssFabricExport } from './CssFabricExport.js';
3
+ import type { cssFabricModelType, cssFabricModelKey } from './types.js';
4
+ /**
5
+ * Represents a CSS Fabric class.
6
+ */
7
+ export declare class CssFabric {
8
+ /**
9
+ * The vendor method returns a string with the vendor name and an optional fragment.
10
+ * @param fragment - Optional fragment to append to the vendor name.
11
+ * @returns A string with the vendor name and the fragment.
12
+ */
13
+ vendor: (fragment?: string) => string;
14
+ cssFabricModel: cssFabricModelType;
15
+ cssFabricBuilderParams: CssFabricBuilderParams;
16
+ cssFabricBuilder: CssFabricBuilder;
17
+ constructor();
18
+ /**
19
+ * Cleans the model key by removing single quotes.
20
+ * @param modelKey - The model key to clean.
21
+ * @returns The cleaned model key.
22
+ */
23
+ private cleanModelKey;
24
+ /**
25
+ * Sets the parameters for the CssFabricBuilder.
26
+ * @param params - Partial parameters to set for the CssFabricBuilder.
27
+ */
28
+ setParams(params: Partial<CssFabricBuilderParams>): void;
29
+ /**
30
+ * Creates CSS fabric variables and colors based on the provided model keys.
31
+ * @param args - The model keys to create CSS fabric variables and colors for.
32
+ * @returns An object with the export and css properties.
33
+ */
34
+ createCssFabricVarsColors(...args: cssFabricModelKey[]): {
35
+ export: CssFabricExport['export'];
36
+ css: string;
37
+ };
38
+ /**
39
+ * Generates the CSS fabric sheet.
40
+ * @returns An object with the export and css properties.
41
+ */
42
+ cssFabricSheet(): {
43
+ export: (options: any) => void;
44
+ css: Record<string, any>;
45
+ };
46
+ }
@@ -0,0 +1,97 @@
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
+ /**
6
+ * Represents a CSS Fabric class.
7
+ */
8
+ export class CssFabric {
9
+ /**
10
+ * The vendor method returns a string with the vendor name and an optional fragment.
11
+ * @param fragment - Optional fragment to append to the vendor name.
12
+ * @returns A string with the vendor name and the fragment.
13
+ */
14
+ vendor = (fragment = '') => `${this.cssFabricBuilderParams.vendorName}${fragment}`;
15
+ cssFabricModel = {};
16
+ cssFabricBuilderParams;
17
+ cssFabricBuilder;
18
+ constructor() {
19
+ this.cssFabricBuilder = new CssFabricBuilder();
20
+ this.cssFabricBuilderParams = new CssFabricBuilderParams();
21
+ }
22
+ /**
23
+ * Cleans the model key by removing single quotes.
24
+ * @param modelKey - The model key to clean.
25
+ * @returns The cleaned model key.
26
+ */
27
+ cleanModelKey(modelKey) {
28
+ return modelKey.replace(/'/g, '');
29
+ }
30
+ /**
31
+ * Sets the parameters for the CssFabricBuilder.
32
+ * @param params - Partial parameters to set for the CssFabricBuilder.
33
+ */
34
+ setParams(params) {
35
+ this.cssFabricBuilderParams = {
36
+ ...this.cssFabricBuilderParams,
37
+ ...params
38
+ };
39
+ }
40
+ /**
41
+ * Creates CSS fabric variables and colors based on the provided model keys.
42
+ * @param args - The model keys to create CSS fabric variables and colors for.
43
+ * @returns An object with the export and css properties.
44
+ */
45
+ createCssFabricVarsColors(...args) {
46
+ args.forEach((modelKey) => {
47
+ switch (this.cleanModelKey(modelKey)) {
48
+ case 'base':
49
+ this.cssFabricModel.base = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.theme, this.vendor());
50
+ break;
51
+ case 'palette':
52
+ this.cssFabricModel.palette = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.palette, this.vendor('palette-'));
53
+ break;
54
+ case 'presets':
55
+ this.cssFabricModel.presets = this.cssFabricBuilder.flattenIt(['primary', 'secondary', 'tertiary', 'accent'], this.cssFabricBuilderParams.presets, this.vendor('presets-'));
56
+ break;
57
+ case 'status':
58
+ this.cssFabricModel.status = this.cssFabricBuilder.mainRule(this.cssFabricBuilderParams.config.status, this.vendor('status-'));
59
+ break;
60
+ case 'out':
61
+ // assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
62
+ this.cssFabricModel.out = this.cssFabricBuilder.makeDefaultVariations(['primary', 'secondary', 'tertiary'], ['lighten', 'darken', 'opacity'], this.vendor());
63
+ break;
64
+ case 'gray':
65
+ this.cssFabricModel.gray = this.cssFabricBuilder.createProgression({
66
+ property: this.vendor(`color-gray`),
67
+ iteratorMask: `color-mix(in srgb, ${this.vendor(`color-gray`)} ${this.cssFabricBuilderParams.correspondances.gray} ##%);`,
68
+ steps: this.cssFabricBuilderParams.defaultVariationSteps
69
+ }, 'json');
70
+ break;
71
+ case 'out2':
72
+ // assombrir et rendre opaque 'primary', 'secondary', 'tertiary'
73
+ this.cssFabricModel.out2 = this.cssFabricBuilder.makeDefaultVariations(['foreground', 'bg'], ['lighten', 'darken', 'opacity'], this.vendor());
74
+ break;
75
+ default:
76
+ console.log('default', modelKey);
77
+ break;
78
+ }
79
+ });
80
+ return {
81
+ export: (options) => new CssFabricExport(this.cssFabricModel, options).export(options),
82
+ css: JSON.stringify(this.cssFabricModel)
83
+ };
84
+ }
85
+ /**
86
+ * Generates the CSS fabric sheet.
87
+ * @returns An object with the export and css properties.
88
+ */
89
+ cssFabricSheet() {
90
+ const cssP = new CSSProperties(cssFabricSheet /* , ['overflow'] */);
91
+ const cssF = cssP.generateCSS();
92
+ return {
93
+ export: (options) => new CssFabricExport(cssF, options).export(options),
94
+ css: cssF
95
+ };
96
+ }
97
+ }
@@ -1,18 +1,6 @@
1
1
  import { colorConfig } from './config.js';
2
- type Steps = [number, number, number];
3
- type Mask = string;
4
- type ToMask = string;
5
- type EaseTrigger = number;
6
- type Ease = number;
7
- declare class CssFabricExport {
8
- private cssFabricModel;
9
- exportPaths: Record<'css' | 'json', string>;
10
- constructor(cssFabricModel: cssFabricModelType, exportPaths?: CssFabricExport['exportPaths']);
11
- export(options: CssFabricExport['exportPaths']): void;
12
- private createCssFile;
13
- private createJsonModel;
14
- }
15
- declare class CssFabricBuilder {
2
+ import type { Ease, EaseTrigger, Mask, Steps, ToMask } from './types.js';
3
+ export declare class CssFabricBuilder {
16
4
  cssFabricBuilderParams: CssFabricBuilderParams;
17
5
  constructor();
18
6
  parseModel(json: Record<string, any>, parentKey?: string): string;
@@ -48,7 +36,7 @@ declare class CssFabricBuilder {
48
36
  makeDefaultVariations(arr1: string[], arr2: string[], prefix: string, vendor?: string): Record<string, any>;
49
37
  mainRule(vars: Record<string, any>, prefix: string): Record<string, any>;
50
38
  }
51
- declare class CssFabricBuilderParams {
39
+ export declare class CssFabricBuilderParams {
52
40
  vendorName: string;
53
41
  variations: {
54
42
  readonly none: "var({#vendor}-color-##);";
@@ -81,33 +69,3 @@ declare class CssFabricBuilderParams {
81
69
  setDefaultVariationSteps(variationSteps: typeof CssFabricBuilderParams.prototype.defaultVariationSteps): void;
82
70
  private deepMerge;
83
71
  }
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,45 +1,6 @@
1
- import fsExtra from 'fs-extra';
2
1
  import { harmony } from 'simpler-color';
3
2
  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 {
3
+ export class CssFabricBuilder {
43
4
  // defaultVariationSteps
44
5
  cssFabricBuilderParams;
45
6
  constructor() {
@@ -168,8 +129,7 @@ class CssFabricBuilder {
168
129
  return collect;
169
130
  }
170
131
  }
171
- // primary.presets
172
- class CssFabricBuilderParams {
132
+ export class CssFabricBuilderParams {
173
133
  vendorName = '--cssfab-';
174
134
  variations = {
175
135
  none: 'var({#vendor}-color-##);',
@@ -214,6 +174,7 @@ class CssFabricBuilderParams {
214
174
  ];
215
175
  config = {};
216
176
  constructor() {
177
+ // color , vendor
217
178
  this.baseColors = harmony('#9e3902');
218
179
  this.config = this.deepMerge(colorConfig, { theme: harmony('#9e3902') });
219
180
  return this;
@@ -248,94 +209,3 @@ class CssFabricBuilderParams {
248
209
  }, objects[0]);
249
210
  }
250
211
  }
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,10 @@
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
+ private parseModel;
10
+ }
@@ -0,0 +1,59 @@
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
+ //this.parseModel(this.cssFabricModel);
20
+ fsExtra.ensureFileSync(this.exportPaths.css);
21
+ fsExtra.writeFile(this.exportPaths.css, this.parseModel(this.cssFabricModel), (err) => {
22
+ if (err) {
23
+ console.error(err);
24
+ return;
25
+ }
26
+ console.log('File created successfully.');
27
+ });
28
+ }
29
+ createJsonModel() {
30
+ fsExtra.ensureFileSync(this.exportPaths.json);
31
+ fsExtra.writeFile(this.exportPaths.json, JSON.stringify(this.cssFabricModel), (err) => {
32
+ if (err) {
33
+ console.error(err);
34
+ return;
35
+ }
36
+ console.log('File created successfully.');
37
+ });
38
+ }
39
+ parseModel(json, parentKey = '') {
40
+ let css = parse(json, parentKey);
41
+ return `:root{\n${css}}`;
42
+ function parse(json, parentKey = '', titre = '') {
43
+ let css = '';
44
+ for (const key in json) {
45
+ if (typeof json[key] === 'object') {
46
+ css += `\n/* ${key} */ `;
47
+ //titre += `/* ----${key}--- */ `;
48
+ css += parse(json[key], '', titre);
49
+ }
50
+ else {
51
+ css += titre;
52
+ css += `\n${parentKey}${key}: ${json[key]}`;
53
+ titre = '';
54
+ }
55
+ }
56
+ return css;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,2 @@
1
+ import { CssFabric } from '../CssFabric.js';
2
+ export declare const cssFabric: CssFabric;
@@ -0,0 +1,13 @@
1
+ import { CssFabric } from '../CssFabric.js';
2
+ export const cssFabric = new CssFabric();
3
+ const styleSheet = cssFabric.cssFabricSheet();
4
+ styleSheet.export({
5
+ css: './src/lib/fabric/css/css-fabric-sheet.css',
6
+ json: './src/lib/fabric/css/cssFabric-sheet.json'
7
+ });
8
+ //
9
+ const model = cssFabric.createCssFabricVarsColors('base', 'palette', 'presets', 'status', 'out', 'gray', 'out2');
10
+ model.export({
11
+ css: './src/lib/fabric/css/css-fabric-vars-colors.css',
12
+ json: './src/lib/fabric/css/cssFabric-vars-colors.json'
13
+ });