-
Notifications
You must be signed in to change notification settings - Fork 15
/
_themes-core.scss
70 lines (64 loc) · 3.13 KB
/
_themes-core.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Created at 1398/4/27 (2019/7/18).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
*/
/**
* @param $themes-map - Custom themes should be passed via this argument.
* The "key" of each member is "the name of CSS class for that theme".
*
* Full schema of each member:
* css-class-name: (
* primary-base: base-palette, // example: $mat-purple // will be ignored if you set corresponding mat-palette (primary). Set it to `null` in this case.
* accent-base: base-palette, // example: $mat-green // will be ignored if you set corresponding mat-palette (accent). Set it to `null` in this case.
* warn-base?: base-palette, // DEFAULT: $mat-red // will be ignored if you set corresponding mat-palette (warn). Set it to `null` in this case.
* primary?: mat-palette, // DEFAULT: mat-palette(primary-base)
* accent?: mat-palette, // DEFAULT: mat-palette(accent-base)
* warn?: mat-palette, // DEFAULT: mat-palette(warn-base)
* light-or-dark?: {'light' | 'dark' | ''}, // DEFAULT: '' => "Both light & dark"
* ),
*
* @see `mat-palette()`: https://github.com/angular/components/blob/dcde115980a2e94fae8e667d1dfa300fc82a77cb/src/material/core/theming/_theming.scss#L12-L37
* @see https://material.angular.io/guide/theming
*/
//noinspection SassScssUnresolvedMixin, SassScssResolvedByNameOnly
@mixin make-stylesheets($themes-map) {
@each $css-class, $theme in $themes-map {
$primary-base: map-get($theme, primary-base);
$accent-base: map-get($theme, accent-base);
$warn-base: if(map-has-key($theme, warn-base), map-get($theme, warn-base), $mat-red);
$primary: if(map-has-key($theme, primary), map-get($theme, primary), mat-palette($primary-base));
$accent: if(map-has-key($theme, accent), map-get($theme, accent), mat-palette($accent-base));
$warn: if(map-has-key($theme, warn), map-get($theme, warn), mat-palette($warn-base));
$light-or-dark: if(map-has-key($theme, light-or-dark), map-get($theme, light-or-dark), '');
// Light-themes:
@if $light-or-dark == '' or $light-or-dark == 'light' or $light-or-dark == 'l' or $light-or-dark == 'both' {
.#{$css-class} {
$mat-theme: mat-light-theme($primary, $accent, $warn);
@include angular-material-theme($mat-theme);
@if mixin-exists(themed-stylesheets) {
@include themed-stylesheets($mat-theme);
}
}
}
// Dark-themes:
@if $light-or-dark == '' or $light-or-dark == 'dark' or $light-or-dark == 'd' or $light-or-dark == 'both' {
.#{$css-class}-dark {
$mat-theme: mat-dark-theme($primary, $accent, $warn);
@include angular-material-theme($mat-theme);
@if mixin-exists(themed-stylesheets) {
@include themed-stylesheets($mat-theme);
}
}
}
// Below stylesheets have been used in theme-switcher-tool (in the toolbar):
.theme-primary.#{$css-class} {
background-color: mat-color($primary);
}
.theme-accent.#{$css-class} {
background-color: mat-color($accent);
}
.theme-warn.#{$css-class} {
background-color: mat-color($warn);
}
}
}