@medyll/cssfabric 0.0.10

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 (165) hide show
  1. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  2. package/.idea/cssfabric.iml +11 -0
  3. package/.idea/misc.xml +9 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/.vscode/settings.json +24 -0
  7. package/README.md +240 -0
  8. package/cssfabric.config.js +3 -0
  9. package/cssfabric.json +8 -0
  10. package/gulpfile.js +610 -0
  11. package/lib/_generated/export.variables.json +583 -0
  12. package/lib/index.d.ts +2 -0
  13. package/lib/index.js +7 -0
  14. package/lib/scripts/cssfabric.d.ts +24 -0
  15. package/lib/scripts/cssfabric.js +48 -0
  16. package/lib/scripts/cssfabricClassNames.d.ts +14 -0
  17. package/lib/scripts/cssfabricClassNames.js +150 -0
  18. package/lib/scripts/utils.d.ts +5 -0
  19. package/lib/scripts/utils.js +40 -0
  20. package/lib/styles/core/animation/animation.css +0 -0
  21. package/lib/styles/core/animation/animation.min.css +0 -0
  22. package/lib/styles/core/base/base.css +222 -0
  23. package/lib/styles/core/base/base.min.css +1 -0
  24. package/lib/styles/core/box/box.css +2263 -0
  25. package/lib/styles/core/box/box.min.css +1 -0
  26. package/lib/styles/core/box/box.responsive.css +13590 -0
  27. package/lib/styles/core/box/box.responsive.min.css +1 -0
  28. package/lib/styles/core/color/color.css +923 -0
  29. package/lib/styles/core/color/color.min.css +1 -0
  30. package/lib/styles/core/color/color.responsive.css +5550 -0
  31. package/lib/styles/core/color/color.responsive.min.css +1 -0
  32. package/lib/styles/core/flex/flex.css +140 -0
  33. package/lib/styles/core/flex/flex.min.css +1 -0
  34. package/lib/styles/core/flex/flex.responsive.css +852 -0
  35. package/lib/styles/core/flex/flex.responsive.min.css +1 -0
  36. package/lib/styles/core/grid/grid.css +50 -0
  37. package/lib/styles/core/grid/grid.min.css +1 -0
  38. package/lib/styles/core/grid/grid.responsive.css +312 -0
  39. package/lib/styles/core/grid/grid.responsive.min.css +1 -0
  40. package/lib/styles/core/main.css +2263 -0
  41. package/lib/styles/core/main.min.css +1 -0
  42. package/lib/styles/core/menu/menu.css +97 -0
  43. package/lib/styles/core/menu/menu.min.css +1 -0
  44. package/lib/styles/core/menu/menu.responsive.css +504 -0
  45. package/lib/styles/core/menu/menu.responsive.min.css +1 -0
  46. package/lib/styles/core/overflow/overflow.css +60 -0
  47. package/lib/styles/core/overflow/overflow.min.css +1 -0
  48. package/lib/styles/core/overflow/overflow.responsive.css +367 -0
  49. package/lib/styles/core/overflow/overflow.responsive.min.css +1 -0
  50. package/lib/styles/core/scale/scale.css +639 -0
  51. package/lib/styles/core/scale/scale.min.css +1 -0
  52. package/lib/styles/core/scale/scale.responsive.css +3846 -0
  53. package/lib/styles/core/scale/scale.responsive.min.css +1 -0
  54. package/lib/styles/core/table/table.css +72 -0
  55. package/lib/styles/core/table/table.min.css +1 -0
  56. package/lib/styles/core/table/table.responsive.css +444 -0
  57. package/lib/styles/core/table/table.responsive.min.css +1 -0
  58. package/lib/styles/core/text/text.css +147 -0
  59. package/lib/styles/core/text/text.min.css +1 -0
  60. package/lib/styles/core/text/text.responsive.css +894 -0
  61. package/lib/styles/core/text/text.responsive.min.css +1 -0
  62. package/lib/styles/core/theme/theme.css +197 -0
  63. package/lib/styles/core/theme/theme.min.css +1 -0
  64. package/lib/styles/core/vars.css +278 -0
  65. package/lib/styles/core/vars.min.css +1 -0
  66. package/lib/styles/core/zindex/zindex.css +279 -0
  67. package/lib/styles/core/zindex/zindex.min.css +1 -0
  68. package/lib/styles/cssfabric.css +7631 -0
  69. package/lib/styles/cssfabric.min.css +15 -0
  70. package/lib/styles/cssfabric.responsive.css +26359 -0
  71. package/lib/styles/cssfabric.responsive.min.css +9 -0
  72. package/package.json +67 -0
  73. package/src/_generated/export.variables.json +756 -0
  74. package/src/_generated/export.variables.md +240 -0
  75. package/src/_generated/index.d.ts +3 -0
  76. package/src/cssfabric/_utils.scss +205 -0
  77. package/src/cssfabric/index.d.ts +3 -0
  78. package/src/cssfabric/modules/_cssfabric-config.scss +89 -0
  79. package/src/cssfabric/modules/_mixins.scss +1 -0
  80. package/src/cssfabric/modules/animation/_animation-build.scss +121 -0
  81. package/src/cssfabric/modules/animation/_animation-vars.scss +17 -0
  82. package/src/cssfabric/modules/animation/animation.scss +3 -0
  83. package/src/cssfabric/modules/base/_base-vars.scss +17 -0
  84. package/src/cssfabric/modules/base/base.scss +80 -0
  85. package/src/cssfabric/modules/box/_box-build.scss +215 -0
  86. package/src/cssfabric/modules/box/_box-vars.scss +119 -0
  87. package/src/cssfabric/modules/box/box-responsive.scss +18 -0
  88. package/src/cssfabric/modules/box/box.scss +3 -0
  89. package/src/cssfabric/modules/color/_color-build.scss +108 -0
  90. package/src/cssfabric/modules/color/_color-vars.scss +80 -0
  91. package/src/cssfabric/modules/color/color-responsive.scss +23 -0
  92. package/src/cssfabric/modules/color/color.scss +3 -0
  93. package/src/cssfabric/modules/css-fabric.scss +2 -0
  94. package/src/cssfabric/modules/flex/_flex-build.scss +169 -0
  95. package/src/cssfabric/modules/flex/_flex-vars.scss +87 -0
  96. package/src/cssfabric/modules/flex/flex-responsive.scss +25 -0
  97. package/src/cssfabric/modules/flex/flex.scss +3 -0
  98. package/src/cssfabric/modules/grid/_grid-build.scss +91 -0
  99. package/src/cssfabric/modules/grid/_grid-vars.scss +87 -0
  100. package/src/cssfabric/modules/grid/grid-responsive.scss +25 -0
  101. package/src/cssfabric/modules/grid/grid.scss +3 -0
  102. package/src/cssfabric/modules/main.scss +3 -0
  103. package/src/cssfabric/modules/menu/_menu-build.scss +119 -0
  104. package/src/cssfabric/modules/menu/_menu-vars.scss +29 -0
  105. package/src/cssfabric/modules/menu/menu-responsive.scss +19 -0
  106. package/src/cssfabric/modules/menu/menu.scss +3 -0
  107. package/src/cssfabric/modules/overflow/_overflow-build.scss +22 -0
  108. package/src/cssfabric/modules/overflow/_overflow-vars.scss +31 -0
  109. package/src/cssfabric/modules/overflow/overflow-responsive.scss +25 -0
  110. package/src/cssfabric/modules/overflow/overflow.scss +5 -0
  111. package/src/cssfabric/modules/scale/_scale-build.scss +129 -0
  112. package/src/cssfabric/modules/scale/_scale-vars.scss +75 -0
  113. package/src/cssfabric/modules/scale/scale-responsive.scss +23 -0
  114. package/src/cssfabric/modules/scale/scale.scss +3 -0
  115. package/src/cssfabric/modules/table/_table-build.scss +134 -0
  116. package/src/cssfabric/modules/table/_table-vars.scss +30 -0
  117. package/src/cssfabric/modules/table/table-responsive.scss +24 -0
  118. package/src/cssfabric/modules/table/table.scss +3 -0
  119. package/src/cssfabric/modules/text/_text-build.scss +109 -0
  120. package/src/cssfabric/modules/text/_text-vars.scss +87 -0
  121. package/src/cssfabric/modules/text/text-responsive.scss +25 -0
  122. package/src/cssfabric/modules/text/text.scss +5 -0
  123. package/src/cssfabric/modules/theme/_theme-build.scss +77 -0
  124. package/src/cssfabric/modules/theme/_theme-vars.scss +47 -0
  125. package/src/cssfabric/modules/theme/theme.scss +5 -0
  126. package/src/cssfabric/modules/vars.scss +120 -0
  127. package/src/cssfabric/modules/zindex/_zindex-vars.scss +19 -0
  128. package/src/cssfabric/modules/zindex/zindex.scss +18 -0
  129. package/src/index.d.ts +3 -0
  130. package/src/index.ts +4 -0
  131. package/src/scripts/cssfabric.ts +54 -0
  132. package/src/scripts/cssfabricClassNames.ts +216 -0
  133. package/src/scripts/utils.ts +37 -0
  134. package/src/vendor/index.d.ts +3 -0
  135. package/src/vendor/normalize/normalize.min.css +2 -0
  136. package/src/vendor/sass-json-export/CHANGELOG.md +26 -0
  137. package/src/vendor/sass-json-export/Gruntfile.js +60 -0
  138. package/src/vendor/sass-json-export/LICENSE +20 -0
  139. package/src/vendor/sass-json-export/README.md +90 -0
  140. package/src/vendor/sass-json-export/package.json +60 -0
  141. package/src/vendor/sass-json-export/stylesheets/encode/api/_json.scss +26 -0
  142. package/src/vendor/sass-json-export/stylesheets/encode/encode.scss +17 -0
  143. package/src/vendor/sass-json-export/stylesheets/encode/helpers/_quote.scss +9 -0
  144. package/src/vendor/sass-json-export/stylesheets/encode/mixins/_json.scss +42 -0
  145. package/src/vendor/sass-json-export/stylesheets/encode/types/_bool.scss +7 -0
  146. package/src/vendor/sass-json-export/stylesheets/encode/types/_color.scss +8 -0
  147. package/src/vendor/sass-json-export/stylesheets/encode/types/_list.scss +14 -0
  148. package/src/vendor/sass-json-export/stylesheets/encode/types/_map.scss +15 -0
  149. package/src/vendor/sass-json-export/stylesheets/encode/types/_null.scss +7 -0
  150. package/src/vendor/sass-json-export/stylesheets/encode/types/_number.scss +8 -0
  151. package/src/vendor/sass-json-export/stylesheets/encode/types/_string.scss +8 -0
  152. package/src/vendor/sass-json-export/stylesheets/sass-json-export.scss +2 -0
  153. package/src/vendor/sass-json-export/test/encode/_index.scss +14 -0
  154. package/src/vendor/sass-json-export/test/encode/api/_json.scss +29 -0
  155. package/src/vendor/sass-json-export/test/encode/helpers/_quote.scss +6 -0
  156. package/src/vendor/sass-json-export/test/encode/types/_bool.scss +6 -0
  157. package/src/vendor/sass-json-export/test/encode/types/_color.scss +7 -0
  158. package/src/vendor/sass-json-export/test/encode/types/_list.scss +25 -0
  159. package/src/vendor/sass-json-export/test/encode/types/_map.scss +17 -0
  160. package/src/vendor/sass-json-export/test/encode/types/_null.scss +8 -0
  161. package/src/vendor/sass-json-export/test/encode/types/_number.scss +68 -0
  162. package/src/vendor/sass-json-export/test/encode/types/_string.scss +9 -0
  163. package/src/vendor/sass-json-export/test/test.scss +9 -0
  164. package/tsconfig.json +46 -0
  165. package/webpack.config.js +53 -0
package/gulpfile.js ADDED
@@ -0,0 +1,610 @@
1
+ // ## WIP
2
+
3
+ const gulp = require("gulp"),
4
+ unescapeJs = require("unescape-js"),
5
+ jsonTransform = require("gulp-json-transform"),
6
+ cache = require("gulp-cached"),
7
+ gulpSass = require("gulp-sass"),
8
+ // sassExport = require("gulp-sass-export"),
9
+ mergeJson = require("gulp-merge-json"),
10
+ gulFileList = require("gulp-filelist"),
11
+ minifyCss = require("gulp-minify-css"),
12
+ fs = require("fs"),
13
+ gulpRename = require("gulp-rename"),
14
+ gulpDownload = require("gulp-download-stream"),
15
+ gulpConcat = require("gulp-concat-util"),
16
+ sassJson = require("gulp-sass-json"),
17
+ sassExport = require("gulp-sass-export"),
18
+ sassVarsToJs = require("gulp-sass-vars-to-js"),
19
+ parse = require("sass-parser")(),
20
+ gulpJsBeautifier = require('gulp-jsbeautifier'),
21
+ modifyFile = require("gulp-modify-file"),
22
+ json2md = require("json2md"),
23
+ gulpIgnore = require("gulp-ignore");
24
+
25
+
26
+ gulpSass.compiler = require("sass");
27
+
28
+ const fabricConfig = require("./cssfabric.json");
29
+
30
+ const {
31
+ fabricRootDir,
32
+ fabricStylesDir,
33
+ fabricConfDir,
34
+ fabricModuleDir,
35
+ fabricGeneratedDir,
36
+ } = fabricConfig;
37
+
38
+ const doFabric = {
39
+ /**
40
+ * build readme fragment from _generated json file
41
+ * @param file_content
42
+ * @param file_info
43
+ * @returns {{}}
44
+ */
45
+ fabricReadmeFile: (file_content, file_info) => {
46
+ // name of the module, from path
47
+ const fileContent = file_content || {}
48
+ const moduleList = fileContent?.cssfabric?.modules;
49
+
50
+ let out = [];
51
+ const content = [];
52
+ const docContent = [];
53
+
54
+ const table = {headers: ["modules", ""]};
55
+ const rows = [];
56
+
57
+ const labelIn = "<span style='width:80px;display:inline-block;overflow:visible'><b>";
58
+ const labelOut = "</b></span>";
59
+
60
+ const labelNestedIn = "<span style='margin-left:20px;width:80px;display:inline-block;overflow:visible'>- ";
61
+ const labelNestedOut = "</span>";
62
+
63
+ const eol = '<br>&nbsp;&nbsp;-&nbsp;&nbsp;';
64
+
65
+ out.push({h1: "Welcome to cssfabric"});
66
+ out.push({p: "Willing to bring my utility-first 2011 css framework to a more decent life !"});
67
+ out.push({p: "This is also a learning point about gulp, webpack, packages and friends."});
68
+ out.push({blockquote: "yaocf !"});
69
+ out.push({p: "<br/>"});
70
+ out.push({h2: "Incoming features"});
71
+ out.push({p: "<br/>"});
72
+
73
+ Object.keys(moduleList).forEach((moduleListKey, moduleListIndex, a) => {
74
+ const moduleListValue = moduleList[moduleListKey];
75
+
76
+ let title = moduleListValue?._metadata?.title;
77
+ let description = moduleListValue?._metadata?.description;
78
+ let docs = moduleListValue?._docs || {};
79
+
80
+ let config = Object.keys(moduleListValue?._data);
81
+ let cssProps = config?.cssProps;
82
+ let collect;
83
+ let collectContentList;
84
+ let nestedLevels;
85
+
86
+
87
+ if (docs?.attributes) {
88
+
89
+ docContent.push({hr: ''});
90
+ docContent.push({h4: `<strong>module ${title}</strong>`});
91
+
92
+
93
+ Object.keys(docs.attributes).forEach((attributeCode) => {
94
+
95
+ collectContentList = [];
96
+ collect = {};
97
+ nestedLevels = [];
98
+
99
+ const attributeValue = docs.attributes[attributeCode];
100
+ // looking for tag
101
+
102
+ if (typeof attributeValue === "object" && !Array.isArray(attributeValue)) {
103
+ collect.title = `[${attributeCode}]`;
104
+ // si tag
105
+ if (attributeValue?.tag) {
106
+ collect.tag = `${labelIn}shorthand${labelOut}: ${attributeValue.tag}`;
107
+ }
108
+ // si about
109
+ if (attributeValue?.about) {
110
+ collect.about = `- ${attributeValue.about}`;
111
+ }
112
+ // si keys
113
+ if (attributeValue?.keys) {
114
+ console.log(title,'keys isArrayOfType ', isArrayOfType(attributeValue.keys))
115
+ switch (isArrayOfType(attributeValue.keys)) {
116
+ case "strings":
117
+ case "numbers":
118
+ collect.keys = `${labelIn}keys${labelOut}: ${attributeValue.keys.join('&nbsp;&nbsp;')}`;
119
+ break;
120
+ case "arrays":
121
+ collect.keys = `${labelIn}keys${labelOut}:${eol}` + attributeValue.keys.map((x) => x.join('&nbsp;&nbsp;')).join(eol)
122
+ break;
123
+ case "objects":
124
+ break;
125
+ }
126
+ }
127
+ // si levels
128
+ if (attributeValue?.levels) {
129
+ // si typeof level array => array of string or of arrays
130
+ if (Array.isArray(attributeValue.levels)) {
131
+ // if [][]
132
+ console.log(title,'levels isArrayOfType ', isArrayOfType(attributeValue.levels))
133
+ switch (isArrayOfType(attributeValue.levels)) {
134
+ case "strings":
135
+ case "numbers":
136
+ collect.levels = `${labelIn}levels${labelOut}: ${eol}${attributeValue.levels.join('&nbsp;&nbsp;')}`;
137
+ break;
138
+ case "arrays":
139
+ collect.levels = `${labelIn}levels${labelOut}:${eol}` + attributeValue.levels.map((x) => x.join('&nbsp;&nbsp;')).join(eol)
140
+ break;
141
+
142
+ }
143
+
144
+ // if {}[] ..... ?
145
+ if (attributeValue.levels.every(x => typeof x === 'object' && !Array.isArray(x))) {
146
+ collect.levels = `${labelIn}levels${labelOut}: ${eol}${attributeValue.levels.map((x) => x.join('&nbsp;&nbsp;')).join(eol)}`;
147
+ }
148
+
149
+ }
150
+ // si typeof level object
151
+ if (!Array.isArray(attributeValue.levels) && typeof (attributeValue.levels === "object")) {
152
+ nestedLevels.push(`${labelIn}level keys${labelOut}:`);
153
+ Object.keys(attributeValue.levels).forEach((levelKey) => {
154
+ let levelValue = attributeValue.levels[levelKey].join('&nbsp;&nbsp;&nbsp;&nbsp;')
155
+ // console.log(levelValue)
156
+ nestedLevels.push(`${labelNestedIn}${levelKey}${labelNestedOut}: ${levelValue}`);
157
+ })
158
+ // [].concat(...arr));
159
+ }
160
+ }
161
+ }
162
+
163
+ if (collect.title) docContent.push({h4: collect.title});
164
+ if (collect.about) docContent.push({"p": collect.about});
165
+
166
+ if (collect.tag) collectContentList.push(collect.tag);
167
+ if (collect.keys) collectContentList.push(collect.keys);
168
+ if (collect.levels) collectContentList.push(collect.levels);
169
+
170
+ if (nestedLevels && nestedLevels.length) collectContentList.push(nestedLevels.join('<br/>'));
171
+
172
+ docContent.push({"ul": collectContentList});
173
+
174
+ // docContent.push({"p": "<br/>"}) ;
175
+
176
+ });
177
+ //docContent.push({p: '<br/><br/>'});
178
+
179
+ }
180
+
181
+ rows.push([title, description]);
182
+
183
+ });
184
+
185
+ function isArrayOfType(arr) {
186
+ let ret = '';
187
+
188
+ if(!Array.isArray(arr)){
189
+ console.log(Array.isArray(arr),{arr})
190
+ }
191
+ if (arr.every(x => Array.isArray(x))) ret = 'arrays'
192
+ if (arr.every(x => typeof x === 'string')) ret = 'strings'
193
+ if (arr.every(x => typeof x === 'number')) ret = 'numbers'
194
+ if (arr.every(x => typeof x === 'object' && !Array.isArray(x))) ret = 'objects'
195
+
196
+ return ret;
197
+ }
198
+
199
+ console.log({docContent});
200
+
201
+
202
+ table.rows = rows;
203
+
204
+ out.push({table: table})
205
+ out.push({p: "<br/>"});
206
+ out.push({ul: content});
207
+ out.push({p: "<br/>"});
208
+ out.push({h3: "More details"});
209
+ out = out.concat(docContent);
210
+
211
+ return json2md(out);
212
+ },
213
+
214
+ /**
215
+ * transform scss to json file with all modules variables
216
+ * @param file
217
+ * @returns {string}
218
+ */
219
+ fabricSassToJson: (file) => {
220
+ let {file_content, file_info} = file;
221
+
222
+ let obj;
223
+ obj = file_content.obj;
224
+ obj = obj.split("|").filter(n => n);
225
+
226
+ const redPath = "";
227
+ const redModulePath = fabricModuleDir + "/";
228
+
229
+ let header = '';
230
+ let footer = '';
231
+
232
+ let importExport = `@import "./src/${redPath}vendor/sass-json-export/stylesheets/sass-json-export.scss";`;
233
+
234
+
235
+ Object.values(obj).forEach((v, k, a) => {
236
+ let module_path = redModulePath + v;
237
+ let module_name = v
238
+ .replace("_", "")
239
+ .split("/")
240
+ ?.pop()
241
+ .split(".")?.[0]
242
+ .replace("-vars", "");
243
+
244
+ if (v) {
245
+ header += makeHeader(module_path, module_name);
246
+ footer += makeFooter(module_name);
247
+ }
248
+ });
249
+
250
+ // return ""
251
+
252
+ let out = header;
253
+ out += "\r\n" + importExport + "\r\n";
254
+ out += footer;
255
+
256
+ function makeHeader(path, module_name) {
257
+ // form is module-vars.$module-config
258
+ return '@use "' + path + '.scss" as ' + module_name + "; \r\n";
259
+ }
260
+
261
+ function makeFooter(module_name) {
262
+ // form is module.$module-(config|*)
263
+ let out1 = ` ( _data: ${module_name}.$${module_name}-config , _metadata :${module_name}.$${module_name}-metadata , _docs :${module_name}.$${module_name}-docs )`;
264
+
265
+ return (
266
+ "@include json-encode(" + out1 + ",comment," + module_name + ");\r\n"
267
+ );
268
+ }
269
+
270
+
271
+ return out;
272
+ },
273
+ // todo use regexp
274
+ fabricCssVarExportFile: (filePath) => {
275
+ let module_path = filePath
276
+ .split("modules/")[1]
277
+ .replace("modules", "")
278
+ .replace(".scss", "");
279
+
280
+ let module_filename = filePath
281
+ .substring(filePath.lastIndexOf("/"))
282
+ .replace(".scss", "")
283
+ .replace("/", "");
284
+
285
+ let module_name = filePath
286
+ .substring(filePath.lastIndexOf("/_"))
287
+ .replace(".scss", "")
288
+ .replace("-vars", "")
289
+ .replace("_", "")
290
+ .replace("/", "");
291
+
292
+ return `|{"module_path" : "${module_path}","module_filename" : "${module_filename}","module_name" : "${module_name}"}`;
293
+ }
294
+ }
295
+
296
+
297
+ function fabricVarExportFile(filePath) {
298
+ // name of the module, from path
299
+ let module_name = filePath
300
+ .substring(filePath.lastIndexOf("modules/"))
301
+ .split("\\")
302
+ ?.pop()
303
+ .split(".")?.[0]
304
+ .replace("modules/", "");
305
+
306
+ return module_name + "|";
307
+ }
308
+
309
+
310
+ // exports sass maps to json
311
+ function task_cssVarsExport(cb) {
312
+ let sourceFiles = fabricModuleDir + "/**/_*-vars.scss";
313
+ gulp
314
+ .src(sourceFiles)
315
+ .pipe(
316
+ gulFileList("cssfabric-vars.css", {
317
+ destRowTemplate: doFabric.fabricCssVarExportFile,
318
+ removeExtensions: false,
319
+ })
320
+ )
321
+ .pipe(
322
+ modifyFile((content, path, file) => {
323
+ let exp = content.split("|"); // JSON.parse()
324
+ let header = '';
325
+ let footer = "";
326
+
327
+ let utils = `@use '${fabricRootDir}/utils' as utils;` + "\r\n";
328
+ const openVarTag = ":root{";
329
+ const closeVarTag = "}";
330
+
331
+ Object.values(exp).forEach((v, k, a) => {
332
+ if (v) {
333
+ moduleConf = JSON.parse(v);
334
+
335
+ if (moduleConf) {
336
+ header +=
337
+ `@use '${fabricModuleDir}/${moduleConf.module_path}' as ${moduleConf.module_name};` +
338
+ "\r\n";
339
+ footer +=
340
+ `@include utils.scssVarsToCssVars(${moduleConf.module_name},${moduleConf.module_name}.$${moduleConf.module_name}-config);` +
341
+ "\r\n";
342
+ }
343
+ }
344
+ });
345
+
346
+ const out = utils + header + openVarTag + footer + closeVarTag;
347
+
348
+ return out;
349
+ })
350
+ )
351
+ .pipe(gulpSass({outputStyle: "expanded", includePaths: [fabricModuleDir]}).on("error", gulpSass.logError))
352
+ .pipe(gulp.dest(fabricStylesDir))
353
+ .on("end", () => {
354
+ return cb();
355
+ });
356
+ }
357
+
358
+ // exports sass maps to json
359
+ function task_varsExport(cb) {
360
+ let sourceFiles = fabricModuleDir + "/**/_*-vars.scss";
361
+
362
+ gulp
363
+ .src(sourceFiles)
364
+ //.pipe(cache(task_varsExport))
365
+ .pipe(
366
+ gulFileList("ghost", {
367
+ destRowTemplate: fabricVarExportFile,
368
+ removeExtensions: false,
369
+ })
370
+ )
371
+ .pipe(gulpConcat("export-variables.try"))
372
+ .pipe(gulpConcat.header('{"obj":"'))
373
+ .pipe(gulpConcat.footer('"}'))
374
+ .pipe(
375
+ jsonTransform(function (file_content, file_info) {
376
+ return doFabric.fabricSassToJson({file_content: file_content, file_info});
377
+ })
378
+ )
379
+ .pipe(cache(task_varsExport))
380
+ // .pipe(sass().on('error', sass.logError))
381
+ .pipe(gulpSass({outputStyle: "expanded"}).on("error", gulpSass.logError))
382
+ .pipe(
383
+ modifyFile((content, path, file) => {
384
+ const start = '{"cssfabric":{"modules":{';
385
+ const end = " }}}";
386
+
387
+ const regexIn = /\/\*\! json-encode: {/gm;
388
+ const regexOut = /} \*\//gm;
389
+
390
+ let exp = content
391
+ .replace(regexIn, "")
392
+ .replace(regexOut, ",")
393
+ .replace(/,\s*$/, "");
394
+
395
+ return `${start}${exp}${end}`;
396
+ })
397
+ )
398
+ .pipe(gulpJsBeautifier())
399
+ .pipe(
400
+ gulpRename(function (path) {
401
+ path.dirname = path.dirname;
402
+ path.extname = ".json";
403
+ path.basename = path.basename.replace("-", ".");
404
+ })
405
+ )
406
+ .pipe(gulp.dest(fabricGeneratedDir))
407
+ .on("end", () => {
408
+ return cb();
409
+ });
410
+
411
+ return cb();
412
+ }
413
+
414
+ function task_readme(cb) {
415
+ gulp
416
+ .src(fabricGeneratedDir + "/*.json")
417
+ .pipe(
418
+ jsonTransform(function (file_content, file_info) {
419
+ return doFabric.fabricReadmeFile(file_content, file_info);
420
+ })
421
+ )
422
+ .pipe(
423
+ gulpRename(function (path) {
424
+ path.dirname = path.dirname;
425
+ path.extname = ".md";
426
+ path.basename = path.basename.replace("-", ".");
427
+ })
428
+ )
429
+ .pipe(gulp.dest(fabricGeneratedDir))
430
+ .on("end", () => {
431
+ return cb();
432
+ });
433
+ }
434
+
435
+ /**
436
+ * concatenate css files
437
+ * by min | responsive | ...
438
+ *
439
+ * @param {function} cb gulp callback
440
+ */
441
+ function task_mergeInclude(cb) {
442
+ //
443
+ const dest = fabricStylesDir;
444
+ const dir = fabricStylesDir + "/core";
445
+
446
+ const steps = [];
447
+ // normal stylesheets
448
+ steps.push(
449
+ gulp
450
+ .src([
451
+ `${dir}/**/*.css`,
452
+ `!${dir}/**/*responsive*.css`,
453
+ `!${dir}/**/*min*.css`,
454
+ ])
455
+ .pipe(gulpConcat("cssfabric.css"))
456
+ .pipe(gulpConcat.header("/** Merged by Mydde */"))
457
+ .pipe(cache(task_mergeInclude))
458
+ .pipe(gulp.dest(dest))
459
+ .on("end", () => {
460
+ return cb();
461
+ })
462
+ );
463
+
464
+ // normal minified stylesheets
465
+ steps.push(
466
+ gulp
467
+ .src([`${dir}/**/*min.css`, `!${dir}/**/*responsive*.css`])
468
+ .pipe(gulpConcat("cssfabric.min.css"))
469
+ .pipe(cache(task_mergeInclude))
470
+ .pipe(gulp.dest(dest))
471
+ .on("end", () => {
472
+ return cb();
473
+ })
474
+ );
475
+
476
+ // responsive stylesheets
477
+ steps.push(
478
+ gulp
479
+ .src([`${dir}/**/*responsive.css`, `!${dir}/**/*min..css`])
480
+ .pipe(gulpConcat("cssfabric.responsive.css"))
481
+ .pipe(cache(task_mergeInclude))
482
+ .pipe(gulp.dest(dest))
483
+ .on("end", () => {
484
+ return cb();
485
+ })
486
+ );
487
+
488
+ // responsive minified stylesheets
489
+ steps.push(
490
+ gulp
491
+ .src([`${dir}/**/*responsive.min.css`])
492
+ .pipe(gulpConcat("cssfabric.responsive.min.css"))
493
+ .pipe(cache(task_mergeInclude))
494
+ .pipe(gulp.dest(dest))
495
+ .on("end", () => {
496
+ return cb();
497
+ })
498
+ );
499
+
500
+ return [...steps];
501
+ }
502
+
503
+ /**
504
+ * task_sass2css
505
+ * transform scss to css
506
+ * store files in /lib
507
+ *
508
+ * rename *-responsive to *.responsive, because not dot in sass file
509
+ *
510
+ * @param {function} cb
511
+ * @returns function
512
+ */
513
+ function task_sass2css(cb) {
514
+ return (
515
+ gulp
516
+ .src(`${fabricModuleDir}/**/*.scss`)
517
+ .pipe(gulpIgnore.exclude("**/*css-fabric*"))
518
+ .pipe(
519
+ gulpRename(function (path) {
520
+ /*path.dirname = path.dirname;
521
+ path.extname = path.extname;*/
522
+ path.basename = path.basename.replace("-", ".");
523
+ })
524
+ )
525
+ // to css and to /core
526
+ .pipe(
527
+ gulpSass({outputStyle: "expanded"}).on("error", gulpSass.logError)
528
+ )
529
+ .pipe(gulp.dest(`${fabricStylesDir}/core`))
530
+ // to css and minify and to /core
531
+ .pipe(
532
+ minifyCss({
533
+ keepSpecialComments: 0,
534
+ })
535
+ )
536
+ .pipe(
537
+ gulpRename(function (path) {
538
+ /*path.dirname = path.dirname;*/
539
+ path.extname = ".min.css";
540
+ path.basename = path.basename.replace("-", ".");
541
+ })
542
+ )
543
+ .pipe(gulp.dest(`${fabricStylesDir}/core`))
544
+ .on("end", () => {
545
+ return cb();
546
+ })
547
+ );
548
+ }
549
+
550
+ function taskDownload(cb) {
551
+ return gulpDownload(
552
+ "https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css"
553
+ )
554
+ .pipe(gulp.dest("./src/vendor/normalize/"))
555
+ .on("end", () => {
556
+ return cb();
557
+ });
558
+ }
559
+
560
+ function watchSassTask(cb) {
561
+ // scss , css , scss
562
+ gulp.watch(
563
+ fabricModuleDir + "/**/*.scss",
564
+ gulp.series(task_sass2css, task_mergeInclude, task_varsExport) // watchCssExportVars
565
+ ); // task_varsExport
566
+
567
+ cb();
568
+ }
569
+
570
+ // todo change to styleDir
571
+ function watchInclude(cb) {
572
+ // gulp.watch(fabricStylesDir, task_mergeInclude);
573
+ //gulp.watch(fabricModuleDir, task_mergeInclude);
574
+
575
+ cb();
576
+ }
577
+
578
+ function watchReadme(cb) {
579
+ // console.log([fabricModuleDir,"!"+fabricModuleDir + "/**/_*.scss"])
580
+ gulp.watch(
581
+ [fabricModuleDir, "!" + fabricModuleDir + "/**/_*.scss"],
582
+ task_readme
583
+ );
584
+
585
+ cb();
586
+ }
587
+
588
+ function watchExportVars(cb) {
589
+ gulp.watch(fabricRootDir, gulp.series(task_varsExport));
590
+
591
+ cb();
592
+ }
593
+
594
+ function watchCssExportVars(cb) {
595
+ gulp.watch(fabricModuleDir, gulp.series(task_cssVarsExport));
596
+
597
+ cb();
598
+ }
599
+
600
+ // oly one called by npm
601
+ exports.watchSass = watchSassTask;
602
+
603
+ exports.watchInclude = watchInclude;
604
+ exports.watchReadme = watchReadme;
605
+ exports.watchExportVars = watchExportVars;
606
+
607
+ exports.watchCssExport = watchCssExportVars;
608
+
609
+ exports.taskDownload = taskDownload;
610
+ exports.task_readme = task_readme;