Skip to content

Commit 1b29d93

Browse files
mattjokeHejdaJakub
authored andcommitted
feat(app): Added script for color migration
* color-migration.js will use _styles.css in apps and generate static files with colors instead of var(--variable) * added color-migration.js as a postinstall script * replaces all style.css with _style.css (which are used as a template by the script) * added style.css files to .gitignore file
1 parent aa19812 commit 1b29d93

File tree

11 files changed

+272
-85
lines changed

11 files changed

+272
-85
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
- name: Install Dependencies
3434
if: steps.cache-npm.outputs.cache-hit != 'true'
3535
run: npm ci --legacy-peer-deps
36+
- name: Run color-migration script
37+
run: node ./color-migration.js
3638
- name: Build
3739
run: npm run build
3840
- name: Run Prettier

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,11 @@ apps/linker/src/assets/config/instanceFavicon.ico
5858
apps/admin-gui-e2e/dist
5959

6060
.angular
61+
62+
# Remove dynamically generated style.css files
63+
apps/admin-gui/src/styles.scss
64+
apps/consolidator/src/styles.scss
65+
apps/linker/src/styles.scss
66+
apps/password-reset/src/styles.scss
67+
apps/publications/src/styles.scss
68+
apps/user-profile/src/styles.scss

.vscode/extensions.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/admin-gui/src/styles.scss renamed to apps/admin-gui/src/_styles.scss

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
// Custom Theming for Angular Material
44
// For more information: https://material.angular.io/guide/theming
55

6+
// IMPORTANT
7+
// Changes to the styles should be made in the _styles.scss file.
8+
// Changes to the styles.scss would result in the styles being overwritten
9+
// during the build process and the changes would be lost.
10+
611
@function mat-color-from-palette($palette, $hue: default, $opacity: null) {
712
@if type-of($hue) == number and $hue >= 0 and $hue <= 1 {
813
@return mat-color-from-palette($palette, default, $hue);
@@ -40,21 +45,22 @@ $perun-accent: mat.define-palette(mat.$green-palette, 600);
4045
$perun-warn: mat.define-palette(mat.$red-palette);
4146

4247
// Create the theme object (a Sass map containing all of the palettes).
43-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
44-
// $perun-theme: mat.define-light-theme($perun-primary, $perun-accent, $perun-warn);
4548
$perun-theme: mat.define-light-theme(
4649
(
4750
color: (
4851
primary: $perun-primary,
4952
accent: $perun-accent,
5053
warn: $perun-warn,
5154
),
55+
typography: mat.define-typography-config(),
56+
density: 0,
5257
)
5358
);
5459

5560
// Include theme styles for core and each component used in your app.
5661
// Alternatively, you can import and @include the theme mixins for each component
5762
// that you are using.
63+
mat.$theme-ignore-duplication-warnings: true;
5864
@include mat.all-component-themes($perun-theme);
5965

6066
:root {
@@ -119,9 +125,7 @@ $perun-theme: mat.define-light-theme(
119125
200: rgba(var(--vo-theme-primary-200), 1),
120126
300: rgba(var(--vo-theme-primary-300), 1),
121127
400: rgba(var(--vo-theme-primary-400), 1),
122-
//FIXME(theme-error): we want ot load color from the config
123-
//500: rgba(var(--vo-theme-primary-500), 1),
124-
500: rgba(#283593, 1),
128+
500: rgba(var(--vo-theme-primary-500), 1),
125129
600: rgba(var(--vo-theme-primary-600), 1),
126130
700: rgba(var(--vo-theme-primary-700), 1),
127131
800: rgba(var(--vo-theme-primary-800), 1),
@@ -151,9 +155,6 @@ $perun-theme: mat.define-light-theme(
151155
$vo-primary: mat.define-palette($vo-dynamic-colors, 500);
152156
$vo-accent: mat.define-palette(mat.$green-palette, 600);
153157

154-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
155-
// $vo-theme: mat.define-light-theme($vo-primary, $vo-accent);
156-
// @include mat.all-component-themes($vo-theme);
157158
$vo-theme: mat.define-light-theme(
158159
(
159160
color: (
@@ -181,9 +182,7 @@ $perun-theme: mat.define-light-theme(
181182
200: rgba(var(--facility-theme-primary-200), 1),
182183
300: rgba(var(--facility-theme-primary-300), 1),
183184
400: rgba(var(--facility-theme-primary-400), 1),
184-
//FIXME(theme-error): we want ot load color from the config
185-
// 500: rgba(var(--facility-theme-primary-500), 1),
186-
500: rgba(#d84315, 1),
185+
500: rgba(var(--facility-theme-primary-500), 1),
187186
600: rgba(var(--facility-theme-primary-600), 1),
188187
700: rgba(var(--facility-theme-primary-700), 1),
189188
800: rgba(var(--facility-theme-primary-800), 1),
@@ -212,10 +211,6 @@ $perun-theme: mat.define-light-theme(
212211

213212
$facility-primary: mat.define-palette($facility-dynamic-colors, 500);
214213
$facility-accent: mat.define-palette(mat.$green-palette, 600);
215-
216-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
217-
// $facility-theme: mat.define-light-theme($facility-primary, $facility-accent);
218-
// @include mat.all-component-themes($facility-theme);
219214
$facility-theme: mat.define-light-theme(
220215
(
221216
color: (
@@ -243,9 +238,7 @@ $perun-theme: mat.define-light-theme(
243238
200: rgba(var(--resource-theme-primary-200), 1),
244239
300: rgba(var(--resource-theme-primary-300), 1),
245240
400: rgba(var(--resource-theme-primary-400), 1),
246-
//FIXME(theme-error): we want ot load color from the config
247-
// 500: rgba(var(--resource-theme-primary-500), 1),
248-
500: rgba(#6a1b9a, 1),
241+
500: rgba(var(--resource-theme-primary-500), 1),
249242
600: rgba(var(--resource-theme-primary-600), 1),
250243
700: rgba(var(--resource-theme-primary-700), 1),
251244
800: rgba(var(--resource-theme-primary-800), 1),
@@ -274,10 +267,6 @@ $perun-theme: mat.define-light-theme(
274267

275268
$resource-primary: mat.define-palette($resource-dynamic-colors, 500);
276269
$resource-accent: mat.define-palette(mat.$green-palette, 600);
277-
278-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
279-
// $resource-theme: mat.define-light-theme($resource-primary, $resource-accent);
280-
// @include mat.all-component-themes($resource-theme);
281270
$resource-theme: mat.define-light-theme(
282271
(
283272
color: (
@@ -305,9 +294,7 @@ $perun-theme: mat.define-light-theme(
305294
200: rgba(var(--group-theme-primary-200), 1),
306295
300: rgba(var(--group-theme-primary-300), 1),
307296
400: rgba(var(--group-theme-primary-400), 1),
308-
//FIXME(theme-error): we want ot load color from the config
309-
// 500: rgba(var(--group-theme-primary-500), 1),
310-
500: rgba(#33691e, 1),
297+
500: rgba(var(--group-theme-primary-500), 1),
311298
600: rgba(var(--group-theme-primary-600), 1),
312299
700: rgba(var(--group-theme-primary-700), 1),
313300
800: rgba(var(--group-theme-primary-800), 1),
@@ -336,10 +323,6 @@ $perun-theme: mat.define-light-theme(
336323

337324
$group-primary: mat.define-palette($group-dynamic-colors, 500);
338325
$group-accent: mat.define-palette(mat.$green-palette, 600);
339-
340-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
341-
// $group-theme: mat.define-light-theme($group-primary, $group-accent);
342-
// @include mat.all-component-themes($group-theme);
343326
$group-theme: mat.define-light-theme(
344327
(
345328
color: (
@@ -367,9 +350,7 @@ $perun-theme: mat.define-light-theme(
367350
200: rgba(var(--member-theme-primary-200), 1),
368351
300: rgba(var(--member-theme-primary-300), 1),
369352
400: rgba(var(--member-theme-primary-400), 1),
370-
//FIXME(theme-error): we want ot load color from the config
371-
// 500: rgba(var(--member-theme-primary-500), 1),
372-
500: rgba(#ad1457, 1),
353+
500: rgba(var(--member-theme-primary-500), 1),
373354
600: rgba(var(--member-theme-primary-600), 1),
374355
700: rgba(var(--member-theme-primary-700), 1),
375356
800: rgba(var(--member-theme-primary-800), 1),
@@ -398,10 +379,6 @@ $perun-theme: mat.define-light-theme(
398379

399380
$member-primary: mat.define-palette($member-dynamic-colors, 500);
400381
$member-accent: mat.define-palette(mat.$green-palette, 600);
401-
402-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
403-
// $member-theme: mat.define-light-theme($member-primary, $member-accent);
404-
// @include mat.all-component-themes($member-theme);
405382
$member-theme: mat.define-light-theme(
406383
(
407384
color: (
@@ -429,9 +406,7 @@ $perun-theme: mat.define-light-theme(
429406
200: rgba(var(--admin-theme-primary-200), 1),
430407
300: rgba(var(--admin-theme-primary-300), 1),
431408
400: rgba(var(--admin-theme-primary-400), 1),
432-
//FIXME(theme-error): we want ot load color from the config
433-
// 500: rgba(var(--admin-theme-primary-500), 1),
434-
500: rgba(#c62828, 1),
409+
500: rgba(var(--admin-theme-primary-500), 1),
435410
600: rgba(var(--admin-theme-primary-600), 1),
436411
700: rgba(var(--admin-theme-primary-700), 1),
437412
800: rgba(var(--admin-theme-primary-800), 1),
@@ -460,10 +435,6 @@ $perun-theme: mat.define-light-theme(
460435

461436
$admin-primary: mat.define-palette($admin-dynamic-colors, 500);
462437
$admin-accent: mat.define-palette(mat.$green-palette, 600);
463-
464-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
465-
// $admin-theme: mat.define-light-theme($admin-primary, $admin-accent);
466-
// @include mat.all-component-themes($admin-theme);
467438
$admin-theme: mat.define-light-theme(
468439
(
469440
color: (
@@ -491,9 +462,7 @@ $perun-theme: mat.define-light-theme(
491462
200: rgba(var(--user-theme-primary-200), 1),
492463
300: rgba(var(--user-theme-primary-300), 1),
493464
400: rgba(var(--user-theme-primary-400), 1),
494-
//FIXME(theme-error): we want ot load color from the config
495-
// 500: rgba(var(--user-theme-primary-500), 1),
496-
500: rgba(#00796b, 1),
465+
500: rgba(var(--user-theme-primary-500), 1),
497466
600: rgba(var(--user-theme-primary-600), 1),
498467
700: rgba(var(--user-theme-primary-700), 1),
499468
800: rgba(var(--user-theme-primary-800), 1),
@@ -522,10 +491,6 @@ $perun-theme: mat.define-light-theme(
522491

523492
$user-primary: mat.define-palette($user-dynamic-colors, 500);
524493
$user-accent: mat.define-palette(mat.$green-palette, 600);
525-
526-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
527-
// $user-theme: mat.define-light-theme($user-primary, $user-accent);
528-
// @include mat.all-component-themes($user-theme);
529494
$user-theme: mat.define-light-theme(
530495
(
531496
color: (
@@ -545,9 +510,7 @@ $perun-theme: mat.define-light-theme(
545510
200: rgba(var(--service-theme-primary-200), 1),
546511
300: rgba(var(--service-theme-primary-300), 1),
547512
400: rgba(var(--service-theme-primary-400), 1),
548-
//FIXME(theme-error): we want ot load color from the config
549-
// 500: rgba(var(--service-theme-primary-500), 1),
550-
500: rgba(#561335, 1),
513+
500: rgba(var(--service-theme-primary-500), 1),
551514
600: rgba(var(--service-theme-primary-600), 1),
552515
700: rgba(var(--service-theme-primary-700), 1),
553516
800: rgba(var(--service-theme-primary-800), 1),
@@ -576,10 +539,6 @@ $perun-theme: mat.define-light-theme(
576539

577540
$service-primary: mat.define-palette($service-dynamic-colors, 500);
578541
$service-accent: mat.define-palette(mat.$green-palette, 600);
579-
580-
//FIXME(theme-error): old definition of theme - will be able to be removed if the new definition is correct
581-
// $service-theme: mat.define-light-theme($service-primary, $service-accent);
582-
// @include mat.all-component-themes($service-theme);
583542
$service-theme: mat.define-light-theme(
584543
(
585544
color: (

apps/consolidator/src/styles.scss renamed to apps/consolidator/src/_styles.scss

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Custom Theming for Angular Material
33
// For more information: https://material.angular.io/guide/theming
44

5+
// IMPORTANT
6+
// Changes to the styles should be made in the _styles.scss file.
7+
// Changes to the styles.scss would result in the styles being overwritten
8+
// during the build process and the changes would be lost.
9+
510
@function mat-color-from-palette($palette, $hue: default, $opacity: null) {
611
@if type-of($hue) == number and $hue >= 0 and $hue <= 1 {
712
@return mat-color-from-palette($palette, default, $hue);
@@ -39,7 +44,17 @@ $perun-accent: mat.define-palette(mat.$green-palette, 600);
3944
$perun-warn: mat.define-palette(mat.$red-palette);
4045

4146
// Create the theme object (a Sass map containing all of the palettes).
42-
$perun-theme: mat.define-light-theme($perun-primary, $perun-accent, $perun-warn);
47+
$perun-theme: mat.define-light-theme(
48+
(
49+
color: (
50+
primary: $perun-primary,
51+
accent: $perun-accent,
52+
warn: $perun-warn,
53+
),
54+
typography: mat.define-typography-config(),
55+
density: 0,
56+
)
57+
);
4358

4459
// Include theme styles for core and each component used in your app.
4560
// Alternatively, you can import and @include the theme mixins for each component
@@ -83,9 +98,16 @@ $perun-theme: mat.define-light-theme($perun-primary, $perun-accent, $perun-warn)
8398
$user-primary: mat.define-palette($user-dynamic-colors, 500);
8499
$user-accent: mat.define-palette(mat.$green-palette, 600);
85100

86-
$user-theme: mat.define-light-theme($user-primary, $user-accent);
101+
$user-theme: mat.define-light-theme(
102+
(
103+
color: (
104+
primary: $user-primary,
105+
accent: $user-accent,
106+
),
107+
)
108+
);
87109

88-
@include mat.all-component-themes($user-theme);
110+
@include mat.all-component-colors($user-theme);
89111
}
90112

91113
button {

apps/linker/src/styles.scss renamed to apps/linker/src/_styles.scss

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
// Custom Theming for Angular Material
33
// For more information: https://material.angular.io/guide/theming
44

5+
// IMPORTANT
6+
// Changes to the styles should be made in the _styles.scss file.
7+
// Changes to the styles.scss would result in the styles being overwritten
8+
// during the build process and the changes would be lost.
9+
510
@function mat-color-from-palette($palette, $hue: default, $opacity: null) {
611
@if type-of($hue) == number and $hue >= 0 and $hue <= 1 {
712
@return mat-color-from-palette($palette, default, $hue);
@@ -39,7 +44,17 @@ $perun-accent: mat.define-palette(mat.$green-palette, 600);
3944
$perun-warn: mat.define-palette(mat.$red-palette);
4045

4146
// Create the theme object (a Sass map containing all of the palettes).
42-
$perun-theme: mat.define-light-theme($perun-primary, $perun-accent, $perun-warn);
47+
$perun-theme: mat.define-light-theme(
48+
(
49+
color: (
50+
primary: $perun-primary,
51+
accent: $perun-accent,
52+
warn: $perun-warn,
53+
),
54+
typography: mat.define-typography-config(),
55+
density: 0,
56+
)
57+
);
4358

4459
// Include theme styles for core and each component used in your app.
4560
// Alternatively, you can import and @include the theme mixins for each component
@@ -83,9 +98,16 @@ $perun-theme: mat.define-light-theme($perun-primary, $perun-accent, $perun-warn)
8398
$user-primary: mat.define-palette($user-dynamic-colors, 500);
8499
$user-accent: mat.define-palette(mat.$green-palette, 600);
85100

86-
$user-theme: mat.define-light-theme($user-primary, $user-accent);
101+
$user-theme: mat.define-light-theme(
102+
(
103+
color: (
104+
primary: $user-primary,
105+
accent: $user-accent,
106+
),
107+
)
108+
);
87109

88-
@include mat.all-component-themes($user-theme);
110+
@include mat.all-component-colors($user-theme);
89111
}
90112

91113
.spinner-container {

apps/password-reset/src/styles.scss renamed to apps/password-reset/src/_styles.scss

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
// For more information: https://material.angular.io/guide/theming
55
// Plus imports for other components in your app.
66

7-
// Include the common styles for Angular Material.
7+
// IMPORTANT
8+
// Changes to the styles should be made in the _styles.scss file.
9+
// Changes to the styles.scss would result in the styles being overwritten
10+
// during the build process and the changes would be lost.
11+
12+
// Include the common styles for Angular Material. We include this here so that you only
813
@include mat.all-component-typographies();
914
@include mat.core();
1015

@@ -19,11 +24,16 @@ $password-reset-warn: mat.define-palette(mat.$red-palette);
1924

2025
// Create the theme object (a Sass map containing all of the palettes).
2126
$password-reset-theme: mat.define-light-theme(
22-
$password-reset-primary,
23-
$password-reset-accent,
24-
$password-reset-warn
27+
(
28+
color: (
29+
primary: $password-reset-primary,
30+
accent: $password-reset-accent,
31+
warn: $password-reset-warn,
32+
),
33+
typography: mat.define-typography-config(),
34+
density: 0,
35+
)
2536
);
26-
2737
// Include theme styles for core and each component used in your app.
2838
// Alternatively, you can import and @include the theme mixins for each component
2939
// that you are using.

0 commit comments

Comments
 (0)