@lukfel/ng-scaffold 22.1.14 → 22.2.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 +645 -643
- package/fesm2022/lukfel-ng-scaffold.mjs +2 -2
- package/fesm2022/lukfel-ng-scaffold.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/add-styles.d.ts +2 -1
- package/schematics/ng-add/add-styles.js +52 -27
- package/schematics/ng-add/add-styles.js.map +1 -1
- package/schematics/ng-add/index.d.ts +2 -1
- package/schematics/ng-add/index.js +2 -2
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +5 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +22 -7
- package/schematics/package.json +3 -0
- package/styles/_theme.scss +28 -2
- package/styles/fonts/roboto/roboto-v30-latin-400.ttf +0 -0
- package/styles/fonts/roboto/roboto-v30-latin-500.ttf +0 -0
- package/styles/fonts/roboto/roboto-v30-latin-700.ttf +0 -0
package/package.json
CHANGED
|
@@ -4,9 +4,58 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.addStyles = addStyles;
|
|
7
|
-
|
|
7
|
+
const M3_SNIPPET = `
|
|
8
|
+
@use "@lukfel/ng-scaffold/styles" as lf;
|
|
9
|
+
@use '@angular/material' as mat;
|
|
10
|
+
|
|
11
|
+
// Define themes (use Material palettes or create your own)
|
|
12
|
+
// 'theme-type' takes 'light', 'dark' or 'color-scheme' (follows the OS setting)
|
|
13
|
+
$base-theme: (
|
|
14
|
+
primary: mat.$rose-palette,
|
|
15
|
+
tertiary: mat.$blue-palette,
|
|
16
|
+
theme-type: light,
|
|
17
|
+
font-family: 'Roboto'
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
$theme2: (
|
|
21
|
+
primary: mat.$rose-palette,
|
|
22
|
+
tertiary: mat.$blue-palette,
|
|
23
|
+
theme-type: dark
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
// Include themes (use ThemeService to switch between themes)
|
|
27
|
+
@include lf.scaffold-theme-m3($base-theme);
|
|
28
|
+
@include lf.scaffold-colors-m3($theme2, 'theme2');
|
|
29
|
+
|
|
30
|
+
`;
|
|
31
|
+
const M2_SNIPPET = `
|
|
32
|
+
@use "@lukfel/ng-scaffold/styles" as lf;
|
|
33
|
+
@use '@angular/material' as mat;
|
|
34
|
+
|
|
35
|
+
// Define themes (use Material palettes or create your own)
|
|
36
|
+
$base-theme: (
|
|
37
|
+
primary: mat.m2-define-palette(mat.$m2-pink-palette),
|
|
38
|
+
accent: mat.m2-define-palette(mat.$m2-blue-palette),
|
|
39
|
+
warn: mat.m2-define-palette(mat.$m2-red-palette),
|
|
40
|
+
dark: false,
|
|
41
|
+
font-family: 'Roboto'
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
$theme2: (
|
|
45
|
+
primary: mat.m2-define-palette(mat.$m2-pink-palette),
|
|
46
|
+
accent: mat.m2-define-palette(mat.$m2-blue-palette),
|
|
47
|
+
dark: true
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// Include themes (use ThemeService to switch between themes)
|
|
51
|
+
@include lf.scaffold-theme-m2($base-theme);
|
|
52
|
+
@include lf.scaffold-colors-m2($theme2, 'theme2');
|
|
53
|
+
|
|
54
|
+
`;
|
|
55
|
+
function addStyles(options = {}) {
|
|
8
56
|
return (tree, context) => {
|
|
9
|
-
|
|
57
|
+
const useM2 = options.materialVersion === 'm2';
|
|
58
|
+
context.logger.info(`[Styles] Searching for root styles (Material ${useM2 ? '2' : '3'}) ...`);
|
|
10
59
|
const possiblePaths = ['src/styles.scss', 'src/styles.sass', 'src/styles.css'];
|
|
11
60
|
const path = possiblePaths.find((p) => tree.exists(p));
|
|
12
61
|
if (!path) {
|
|
@@ -18,32 +67,8 @@ function addStyles() {
|
|
|
18
67
|
context.logger.info('[Styles] Styles already added. Skip.');
|
|
19
68
|
return tree;
|
|
20
69
|
}
|
|
21
|
-
const SNIPPET = `
|
|
22
|
-
@use "@lukfel/ng-scaffold/styles" as lf;
|
|
23
|
-
@use '@angular/material' as mat;
|
|
24
|
-
|
|
25
|
-
// Define themes (use Material palettes or create your own)
|
|
26
|
-
$base-theme: (
|
|
27
|
-
primary: mat.m2-define-palette(mat.$m2-pink-palette),
|
|
28
|
-
accent: mat.m2-define-palette(mat.$m2-blue-palette),
|
|
29
|
-
warn: mat.m2-define-palette(mat.$m2-red-palette),
|
|
30
|
-
dark: false,
|
|
31
|
-
font-family: 'Roboto'
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
$theme2: (
|
|
35
|
-
primary: mat.m2-define-palette(mat.$m2-pink-palette),
|
|
36
|
-
accent: mat.m2-define-palette(mat.$m2-blue-palette),
|
|
37
|
-
dark: true
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
// Include themes (use ThemeService to switch between themes)
|
|
41
|
-
@include lf.scaffold-theme($base-theme);
|
|
42
|
-
@include lf.scaffold-colors($theme2, 'theme2');
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
70
|
const recorder = tree.beginUpdate(path);
|
|
46
|
-
recorder.insertLeft(0,
|
|
71
|
+
recorder.insertLeft(0, useM2 ? M2_SNIPPET : M3_SNIPPET);
|
|
47
72
|
tree.commitUpdate(recorder);
|
|
48
73
|
context.logger.info('[Styles] Successfully added.');
|
|
49
74
|
return tree;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-styles.js","sourceRoot":"","sources":["../../../../projects/ng-scaffold/schematics/ng-add/add-styles.ts"],"names":[],"mappings":";AAAA;;GAEG;;
|
|
1
|
+
{"version":3,"file":"add-styles.js","sourceRoot":"","sources":["../../../../projects/ng-scaffold/schematics/ng-add/add-styles.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAuDH,8BA0BC;AA5ED,MAAM,UAAU,GAAG;;;;;;;;;;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C,CAAC;QAC5B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -6,7 +6,7 @@ const add_config_1 = require("./add-config");
|
|
|
6
6
|
const add_component_1 = require("./add-component");
|
|
7
7
|
const add_styles_1 = require("./add-styles");
|
|
8
8
|
const add_template_1 = require("./add-template");
|
|
9
|
-
function ngAdd() {
|
|
10
|
-
return (0, schematics_1.chain)([(0, add_component_1.addComponent)(), (0, add_config_1.addConfig)(), (0, add_template_1.addTemplate)(), (0, add_styles_1.addStyles)()]);
|
|
9
|
+
function ngAdd(options = {}) {
|
|
10
|
+
return (0, schematics_1.chain)([(0, add_component_1.addComponent)(), (0, add_config_1.addConfig)(), (0, add_template_1.addTemplate)(), (0, add_styles_1.addStyles)(options)]);
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ng-scaffold/schematics/ng-add/index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ng-scaffold/schematics/ng-add/index.ts"],"names":[],"mappings":";;AAOA,sBAEC;AATD,2DAAyD;AACzD,6CAAyC;AACzC,mDAA+C;AAC/C,6CAAyC;AACzC,iDAA6C;AAG7C,SAAgB,KAAK,CAAC,UAAkB,EAAE;IACxC,OAAO,IAAA,kBAAK,EAAC,CAAC,IAAA,4BAAY,GAAE,EAAE,IAAA,sBAAS,GAAE,EAAE,IAAA,0BAAW,GAAE,EAAE,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../projects/ng-scaffold/schematics/ng-add/schema.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/schema",
|
|
3
|
-
"$id": "NgAddSchema",
|
|
4
|
-
"title": "Ng Add Options",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "NgAddSchema",
|
|
4
|
+
"title": "Ng Add Options",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"materialVersion": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Which Angular Material theming API to set up in the global styles.",
|
|
10
|
+
"enum": ["m3", "m2"],
|
|
11
|
+
"default": "m3",
|
|
12
|
+
"x-prompt": {
|
|
13
|
+
"message": "Which Angular Material theming API should be used?",
|
|
14
|
+
"type": "list",
|
|
15
|
+
"items": [
|
|
16
|
+
{ "value": "m3", "label": "Material 3 (recommended)" },
|
|
17
|
+
{ "value": "m2", "label": "Material 2 (legacy)" }
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
package/styles/_theme.scss
CHANGED
|
@@ -19,7 +19,7 @@ $lf-default-theme: (
|
|
|
19
19
|
// Material requires to split up the mat.all-component-themes and mat.all-component-colors
|
|
20
20
|
// since mat.all-component-themes should also be imported once, but mat.all-component-colors
|
|
21
21
|
// can be imported multiple times
|
|
22
|
-
@mixin scaffold-theme($theme: $lf-default-theme) {
|
|
22
|
+
@mixin scaffold-theme-m2($theme: $lf-default-theme) {
|
|
23
23
|
$theme: map-merge($lf-default-theme, $theme);
|
|
24
24
|
|
|
25
25
|
@if(map-get($theme, 'dark') == false) {
|
|
@@ -53,7 +53,7 @@ $lf-default-theme: (
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// Set M2 colors
|
|
56
|
-
@mixin scaffold-colors($theme: $lf-default-theme, $class) {
|
|
56
|
+
@mixin scaffold-colors-m2($theme: $lf-default-theme, $class) {
|
|
57
57
|
$theme: map-merge($lf-default-theme, $theme);
|
|
58
58
|
|
|
59
59
|
.#{$class} {
|
|
@@ -115,6 +115,16 @@ $lf-default-theme: (
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
// Legacy aliases for apps written before the -m2 suffix existed.
|
|
119
|
+
// These always mean M2; never repoint them at M3.
|
|
120
|
+
@mixin scaffold-theme($theme: $lf-default-theme) {
|
|
121
|
+
@include scaffold-theme-m2($theme);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@mixin scaffold-colors($theme: $lf-default-theme, $class) {
|
|
125
|
+
@include scaffold-colors-m2($theme, $class);
|
|
126
|
+
}
|
|
127
|
+
|
|
118
128
|
// ============================================================================
|
|
119
129
|
// Material 3 (M3) Theming
|
|
120
130
|
// ============================================================================
|
|
@@ -203,6 +213,7 @@ $lf-default-theme-m3: (
|
|
|
203
213
|
}
|
|
204
214
|
|
|
205
215
|
@include shape-variables-m3();
|
|
216
|
+
@include elevation-compat-m3();
|
|
206
217
|
@include toolbar-color-compat();
|
|
207
218
|
@include container-color-compat($m2);
|
|
208
219
|
@include color-variables-m3('body', $m2);
|
|
@@ -289,6 +300,21 @@ $lf-default-theme-m3: (
|
|
|
289
300
|
}
|
|
290
301
|
}
|
|
291
302
|
|
|
303
|
+
// Elevation backwards compatibility
|
|
304
|
+
// M3 sets no --mat-app-* tokens and Angular emits the elevation fallbacks
|
|
305
|
+
// malformed ("--mat-sys-shadow" with no var()), so .mat-elevation-z* would
|
|
306
|
+
// resolve to an invalid box-shadow. M2's dp scale lines up with M3's six
|
|
307
|
+
// levels at 0, 1, 3, 6, 8 and 12.
|
|
308
|
+
@mixin elevation-compat-m3() {
|
|
309
|
+
:root {
|
|
310
|
+
@each $level, $elevations in (0: (0), 1: (1, 2), 2: (3, 4, 5), 3: (6, 7), 4: (8, 9, 10, 11), 5: (12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)) {
|
|
311
|
+
@each $z in $elevations {
|
|
312
|
+
--mat-app-elevation-shadow-level-#{$z}: var(--mat-sys-level#{$level});
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
292
318
|
// Container colour backwards compatibility
|
|
293
319
|
// M3 renders FABs and selected chips on a *container* tone, where M2 used the main
|
|
294
320
|
// hue. Container and foreground are restored as a pair: the container alone would
|
|
Binary file
|
|
Binary file
|
|
Binary file
|