@newlogic-digital/core 0.9.2 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +4 -1
- package/modules/Serve.js +3 -3
- package/modules/Styles.js +27 -27
- package/modules/Templates.js +49 -8
- package/modules/tailwind/index.cjs +40 -0
- package/modules/tailwind/index.js +38 -1
- package/package.json +5 -4
package/index.js
CHANGED
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
root
|
16
16
|
} from "./modules/Core.js";
|
17
17
|
|
18
|
-
import { tailwindColors, tailwindColorsRgba, tailwindVariables } from './modules/tailwind/index.js'
|
18
|
+
import { tailwindColors, tailwindColorsRgba, tailwindVariables, tailwindColorsAccent, tailwindColorsCurrent, tailwindAnimations } from './modules/tailwind/index.js'
|
19
19
|
|
20
20
|
const defineConfig = (config) => new Core().init(config);
|
21
21
|
|
@@ -24,6 +24,9 @@ export {
|
|
24
24
|
tailwindColors,
|
25
25
|
tailwindVariables,
|
26
26
|
tailwindColorsRgba,
|
27
|
+
tailwindColorsAccent,
|
28
|
+
tailwindColorsCurrent,
|
29
|
+
tailwindAnimations,
|
27
30
|
Core,
|
28
31
|
Utils,
|
29
32
|
Styles,
|
package/modules/Serve.js
CHANGED
@@ -67,9 +67,6 @@ export const Serve = new class {
|
|
67
67
|
fsServe: {
|
68
68
|
strict: false
|
69
69
|
},
|
70
|
-
hmr: {
|
71
|
-
host: 'localhost'
|
72
|
-
},
|
73
70
|
watch: {
|
74
71
|
ignored: ['**/node_modules/**', '**/.git/**', '**/src/templates/**', '**/src/main.json', `**/${Config.paths.output.root}/*.html`]
|
75
72
|
}
|
@@ -83,6 +80,9 @@ export const Serve = new class {
|
|
83
80
|
https: {
|
84
81
|
key: fs.readFileSync(path.join(os.homedir(),'.ssh/localhost-key.pem')),
|
85
82
|
cert: fs.readFileSync(path.join(os.homedir(),'.ssh/localhost.pem')),
|
83
|
+
},
|
84
|
+
hmr: {
|
85
|
+
host: 'localhost'
|
86
86
|
}
|
87
87
|
}
|
88
88
|
})
|
package/modules/Styles.js
CHANGED
@@ -10,6 +10,32 @@ import glob from "glob";
|
|
10
10
|
import through from "through2";
|
11
11
|
import {Config, Exists, Functions, Modules, Utils, root} from "./Core.js";
|
12
12
|
|
13
|
+
const aspectRatio = () => {
|
14
|
+
return {
|
15
|
+
postcssPlugin: 'aspect-ratio',
|
16
|
+
Declaration: {
|
17
|
+
'aspect-ratio': (decl, {Rule, Declaration}) => {
|
18
|
+
const rule = decl.parent
|
19
|
+
const selector = rule.selector
|
20
|
+
const beforeRule = new Rule({selector: `${selector}:before`, raws: {after: rule.raws.after, semicolon: rule.raws.semicolon}})
|
21
|
+
const ratio = decl.value.replace(/['"]?((?:\d*\.?\d*)?)(?:\s*[:|\/]\s*)(\d*\.?\d*)['"]?/g, (match, width, height) => {
|
22
|
+
return (height / width) * 100 + '%'
|
23
|
+
})
|
24
|
+
|
25
|
+
beforeRule.append([
|
26
|
+
new Declaration({prop: 'padding-bottom', value: ratio}),
|
27
|
+
])
|
28
|
+
|
29
|
+
rule.after(beforeRule)
|
30
|
+
|
31
|
+
rule.nodes.length === 1 ? rule.remove() : decl.remove()
|
32
|
+
},
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
aspectRatio.postcss = true;
|
38
|
+
|
13
39
|
export class Styles {
|
14
40
|
get purge() {
|
15
41
|
return {
|
@@ -160,7 +186,7 @@ export class Styles {
|
|
160
186
|
}
|
161
187
|
|
162
188
|
gulp.src(`${root + Config.paths.input.styles}/${Config.styles.tailwind.basename}`)
|
163
|
-
.pipe(postcss(new Utils().postcssPlugins(Config.styles.tailwind.postcss, [tailwindcss(tailwindcssConfig), autoprefixer])))
|
189
|
+
.pipe(postcss(new Utils().postcssPlugins(Config.styles.tailwind.postcss, [tailwindcss(tailwindcssConfig), aspectRatio, autoprefixer])))
|
164
190
|
.pipe(gulpif(Config.styles.optimizations, clean()))
|
165
191
|
.pipe(gulp.dest(root + Config.paths.temp))
|
166
192
|
.on("end", resolve)
|
@@ -245,32 +271,6 @@ export class Styles {
|
|
245
271
|
});
|
246
272
|
}
|
247
273
|
|
248
|
-
const aspectRatio = () => {
|
249
|
-
return {
|
250
|
-
postcssPlugin: 'aspect-ratio',
|
251
|
-
Declaration: {
|
252
|
-
'aspect-ratio': (decl, {Rule, Declaration}) => {
|
253
|
-
const rule = decl.parent
|
254
|
-
const selector = rule.selector
|
255
|
-
const beforeRule = new Rule({selector: `${selector}:before`, raws: {after: rule.raws.after, semicolon: rule.raws.semicolon}})
|
256
|
-
const ratio = decl.value.replace(/['"]?((?:\d*\.?\d*)?)(?:\s*[:|\/]\s*)(\d*\.?\d*)['"]?/g, (match, width, height) => {
|
257
|
-
return (height / width) * 100 + '%'
|
258
|
-
})
|
259
|
-
|
260
|
-
beforeRule.append([
|
261
|
-
new Declaration({prop: 'padding-bottom', value: ratio}),
|
262
|
-
])
|
263
|
-
|
264
|
-
rule.after(beforeRule)
|
265
|
-
|
266
|
-
rule.nodes.length === 1 ? rule.remove() : decl.remove()
|
267
|
-
},
|
268
|
-
}
|
269
|
-
}
|
270
|
-
}
|
271
|
-
|
272
|
-
aspectRatio.postcss = true;
|
273
|
-
|
274
274
|
const build = lazypipe().pipe(() => gulpif("*.css", postcss(new Utils().postcssPlugins(Config.styles.postcss, [autoprefixer, aspectRatio, inset])))
|
275
275
|
).pipe(() => gulpif("*.less", Modules.less.module()));
|
276
276
|
|
package/modules/Templates.js
CHANGED
@@ -8,6 +8,9 @@ import gulp from "gulp";
|
|
8
8
|
import plumber from "gulp-plumber";
|
9
9
|
import minifier from "html-minifier";
|
10
10
|
import through from "through2";
|
11
|
+
import Prism from 'prismjs'
|
12
|
+
import loadLanguages from 'prismjs/components/index.js'
|
13
|
+
import NormalizeWhitespace from 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace.js'
|
11
14
|
import {Config, Exists, Functions, Modules, root} from "./Core.js";
|
12
15
|
|
13
16
|
export class Templates {
|
@@ -236,16 +239,54 @@ export class Templates {
|
|
236
239
|
type = type.replace(":mirror", "")
|
237
240
|
}
|
238
241
|
|
242
|
+
loadLanguages(['markup', 'css', 'javascript'])
|
243
|
+
|
244
|
+
const Normalize = new NormalizeWhitespace({
|
245
|
+
'remove-trailing': true,
|
246
|
+
'remove-indent': true,
|
247
|
+
'left-trim': true,
|
248
|
+
'right-trim': true,
|
249
|
+
});
|
250
|
+
|
251
|
+
const wrap = (code, lang) => {
|
252
|
+
return `<pre class="language-${lang}"><code>${code}</code></pre>`
|
253
|
+
}
|
254
|
+
|
255
|
+
const highlight = (str, lang) => {
|
256
|
+
if (!lang) {
|
257
|
+
return wrap(str, 'text')
|
258
|
+
}
|
259
|
+
lang = lang.toLowerCase()
|
260
|
+
const rawLang = lang
|
261
|
+
if (lang === 'vue' || lang === 'html') {
|
262
|
+
lang = 'markup'
|
263
|
+
}
|
264
|
+
if (lang === 'md') {
|
265
|
+
lang = 'markdown'
|
266
|
+
}
|
267
|
+
if (lang === 'ts') {
|
268
|
+
lang = 'typescript'
|
269
|
+
}
|
270
|
+
if (lang === 'py') {
|
271
|
+
lang = 'python'
|
272
|
+
}
|
273
|
+
if (!Prism.languages[lang]) {
|
274
|
+
try {
|
275
|
+
loadLanguages([lang])
|
276
|
+
} catch (e) {
|
277
|
+
console.warn(`Syntax highlight for language "${lang}" is not supported.`)
|
278
|
+
}
|
279
|
+
}
|
280
|
+
if (Prism.languages[lang]) {
|
281
|
+
const code = Prism.highlight(Normalize.normalize(str), Prism.languages[lang], lang)
|
282
|
+
return wrap(code, rawLang)
|
283
|
+
}
|
284
|
+
return wrap(str, 'text')
|
285
|
+
}
|
286
|
+
|
239
287
|
return {
|
240
288
|
chain: chain,
|
241
|
-
output: `${mirror ? output : ""}
|
242
|
-
<pre style="width: 100%">
|
243
|
-
<code class="language-${type}">
|
244
|
-
<xmp>
|
245
|
-
${output}
|
246
|
-
</xmp>
|
247
|
-
</code>
|
248
|
-
</pre>`
|
289
|
+
output: `${mirror ? output : ""}${highlight(output, type)}`
|
249
290
|
};
|
250
291
|
}
|
251
292
|
});
|
@@ -31,6 +31,31 @@ const tailwindColorsRgba = (colors = []) => {
|
|
31
31
|
return colors
|
32
32
|
};
|
33
33
|
|
34
|
+
const tailwindColorsAccent = (colors = []) => {
|
35
|
+
const result = {};
|
36
|
+
|
37
|
+
colors.forEach(color => {
|
38
|
+
result[`.accent-${color}`] = {
|
39
|
+
'--color-accent': `var(--color-${color})`,
|
40
|
+
'accent-color': 'rgb(var(--color-accent))'
|
41
|
+
};
|
42
|
+
});
|
43
|
+
|
44
|
+
return result
|
45
|
+
};
|
46
|
+
|
47
|
+
const tailwindColorsCurrent = (colors = []) => {
|
48
|
+
const result = {};
|
49
|
+
|
50
|
+
colors.forEach(color => {
|
51
|
+
result[`.text-${color}`] = {
|
52
|
+
'--color-current': `var(--color-${color})`
|
53
|
+
};
|
54
|
+
});
|
55
|
+
|
56
|
+
return result
|
57
|
+
};
|
58
|
+
|
34
59
|
const tailwindVariables = (type, variables = [], values = {}) => {
|
35
60
|
variables.forEach(name => {
|
36
61
|
values[name] = `var(--${type}-${name})`;
|
@@ -39,6 +64,21 @@ const tailwindVariables = (type, variables = [], values = {}) => {
|
|
39
64
|
return values
|
40
65
|
};
|
41
66
|
|
67
|
+
const tailwindAnimations = (values) => {
|
68
|
+
const result = {};
|
69
|
+
|
70
|
+
values.forEach(value => {
|
71
|
+
result[`.animation-${value}`] = {
|
72
|
+
'animation-name': value
|
73
|
+
};
|
74
|
+
});
|
75
|
+
|
76
|
+
return result
|
77
|
+
};
|
78
|
+
|
79
|
+
exports.tailwindAnimations = tailwindAnimations;
|
42
80
|
exports.tailwindColors = tailwindColors;
|
81
|
+
exports.tailwindColorsAccent = tailwindColorsAccent;
|
82
|
+
exports.tailwindColorsCurrent = tailwindColorsCurrent;
|
43
83
|
exports.tailwindColorsRgba = tailwindColorsRgba;
|
44
84
|
exports.tailwindVariables = tailwindVariables;
|
@@ -27,6 +27,31 @@ const tailwindColorsRgba = (colors = []) => {
|
|
27
27
|
return colors
|
28
28
|
}
|
29
29
|
|
30
|
+
const tailwindColorsAccent = (colors = []) => {
|
31
|
+
const result = {}
|
32
|
+
|
33
|
+
colors.forEach(color => {
|
34
|
+
result[`.accent-${color}`] = {
|
35
|
+
'--color-accent': `var(--color-${color})`,
|
36
|
+
'accent-color': 'rgb(var(--color-accent))'
|
37
|
+
}
|
38
|
+
})
|
39
|
+
|
40
|
+
return result
|
41
|
+
}
|
42
|
+
|
43
|
+
const tailwindColorsCurrent = (colors = []) => {
|
44
|
+
const result = {};
|
45
|
+
|
46
|
+
colors.forEach(color => {
|
47
|
+
result[`.text-${color}`] = {
|
48
|
+
'--color-current': `var(--color-${color})`
|
49
|
+
};
|
50
|
+
});
|
51
|
+
|
52
|
+
return result
|
53
|
+
};
|
54
|
+
|
30
55
|
const tailwindVariables = (type, variables = [], values = {}) => {
|
31
56
|
variables.forEach(name => {
|
32
57
|
values[name] = `var(--${type}-${name})`
|
@@ -35,4 +60,16 @@ const tailwindVariables = (type, variables = [], values = {}) => {
|
|
35
60
|
return values
|
36
61
|
}
|
37
62
|
|
38
|
-
|
63
|
+
const tailwindAnimations = (values) => {
|
64
|
+
const result = {};
|
65
|
+
|
66
|
+
values.forEach(value => {
|
67
|
+
result[`.animation-${value}`] = {
|
68
|
+
'animation-name': value
|
69
|
+
};
|
70
|
+
});
|
71
|
+
|
72
|
+
return result
|
73
|
+
}
|
74
|
+
|
75
|
+
export { tailwindColors, tailwindVariables, tailwindColorsRgba, tailwindColorsAccent, tailwindColorsCurrent, tailwindAnimations }
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@newlogic-digital/core",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.9.
|
4
|
+
"version": "0.9.6",
|
5
5
|
"main": "index.js",
|
6
6
|
"author": "New Logic Studio s.r.o.",
|
7
7
|
"description": "Set of tools that can be used to create modern web applications",
|
@@ -40,19 +40,20 @@
|
|
40
40
|
"lazypipe": "^1.0.2",
|
41
41
|
"lodash": "^4.17.21",
|
42
42
|
"postcss-custom-media": "^8.0.0",
|
43
|
-
"postcss-custom-properties": "^12.1.
|
43
|
+
"postcss-custom-properties": "^12.1.4",
|
44
44
|
"postcss-custom-selectors": "^6.0.0",
|
45
45
|
"postcss-import": "^14.0.2",
|
46
46
|
"postcss-nesting": "^10.1.2",
|
47
47
|
"rollup": "^2.66.1",
|
48
48
|
"rollup-plugin-import-map": "^2.2.2",
|
49
49
|
"rollup-plugin-terser": "^7.0.2",
|
50
|
-
"vite": "~2.7.13"
|
50
|
+
"vite": "~2.7.13",
|
51
|
+
"prismjs": "^1.26.0"
|
51
52
|
},
|
52
53
|
"peerDependencies": {
|
53
54
|
"autoprefixer": "^10.4.2",
|
54
55
|
"postcss": "^8.4.5",
|
55
|
-
"tailwindcss": "^3.0.
|
56
|
+
"tailwindcss": "^3.0.18"
|
56
57
|
},
|
57
58
|
"devDependencies": {
|
58
59
|
"vitepress": "^0.21.6"
|