1
-
2
- // Custom Theming for Angular Material
3
- // For more information: https://material.angular.io/guide/theming
4
1
@use ' @angular/material' as mat ;
5
- // Plus imports for other components in your app.
6
2
7
- // Include the common styles for Angular Material. We include this here so that you only
8
- // have to load a single css file for Angular Material in your app.
9
- // Be sure that you only ever include this mixin once!
3
+ // ----------------------------------------------
4
+ // Custom Theme Maps for Body Styles
5
+ // ----------------------------------------------
6
+ $light-theme : (
7
+ background : white ,
8
+ text : black ,
9
+ link : blue
10
+ );
10
11
11
- $custom-typography : mat .define-typography-level (
12
- $font-family : montserrat ,
13
- $font-weight : 400 ,
14
- $font-size : 1rem ,
15
- $line-height : 1 ,
16
- $letter-spacing : normal ,
12
+ $custom-dark-theme : ( // renamed to avoid conflict with Angular Material variables
13
+ background : #2c2c2c ,
14
+ text : #e0e0e0 ,
15
+ link : #bb86fc
17
16
);
18
17
18
+ // ----------------------------------------------
19
+ // Angular Material Core Styles & Typography
20
+ // ----------------------------------------------
21
+ $custom-typography : mat .define-typography-level (
22
+ $font-family : montserrat ,
23
+ $font-weight : 400 ,
24
+ $font-size : 1rem ,
25
+ $line-height : 1 ,
26
+ $letter-spacing : normal ,
27
+ );
19
28
@include mat .core ($custom-typography );
20
29
21
- // Define the palettes for your theme using the Material Design palettes available in palette.scss
22
- // (imported above). For each palette, you can optionally specify a default, lighter, and darker
23
- // hue. Available color palettes: https://material.io/design/color/
24
- $DSOMM-primary : mat .define-palette (mat .$green-palette ,400 );
30
+ // ----------------------------------------------
31
+ // Angular Material Palettes
32
+ // ----------------------------------------------
33
+ $DSOMM-primary : mat .define-palette (mat .$green-palette , 400 );
25
34
$DSOMM-accent : mat .define-palette (mat .$pink-palette , A200 , A100 , A400 );
26
-
27
- // The warn palette is optional (defaults to red).
28
35
$DSOMM-warn : mat .define-palette (mat .$red-palette );
29
36
30
- // Create the theme object. A theme consists of configurations for individual
31
- // theming systems such as "color" or "typography".
32
- $DSOMM-theme : mat .define-light-theme ((
33
- color : (
34
- primary: $DSOMM-primary ,
35
- accent: $DSOMM-accent ,
36
- warn: $DSOMM-warn ,
37
- )
37
+ // ----------------------------------------------
38
+ // Define Angular Material Light and Dark Themes
39
+ // ----------------------------------------------
40
+ $DSOMM-light-theme : mat .define-light-theme ((
41
+ color : (
42
+ primary: $DSOMM-primary ,
43
+ accent: $DSOMM-accent ,
44
+ warn: $DSOMM-warn ,
45
+ )
38
46
));
39
47
40
- // Include theme styles for core and each component used in your app.
41
- // Alternatively, you can import and @include the theme mixins for each component
42
- // that you are using.
43
- @include mat .all-component-themes ($DSOMM-theme );
48
+ $DSOMM-dark-theme : mat .define-dark-theme ((
49
+ color : (
50
+ primary: $DSOMM-primary , // using the same palette; adjust if needed
51
+ accent: $DSOMM-accent ,
52
+ warn: $DSOMM-warn ,
53
+ )
54
+ ));
55
+
56
+ // Include Angular Material styles for the light theme by default
57
+ @include mat .all-component-themes ($DSOMM-light-theme );
58
+
59
+ // ----------------------------------------------
60
+ // Mixin to Apply Custom Body Styles
61
+ // ----------------------------------------------
62
+ @mixin apply-theme ($theme ) {
63
+ background-color : map-get ($theme , background );
64
+ color : map-get ($theme , text );
65
+
66
+ a {
67
+ color : map-get ($theme , link );
68
+ }
69
+ }
70
+
71
+ // Apply custom light theme styles to the body by default
72
+ body {
73
+ @include apply-theme ($light-theme );
74
+ }
44
75
76
+ // When night mode is active, override with custom dark theme styles and include Angular Material dark theme
77
+ body .night-mode {
78
+ @include apply-theme ($custom-dark-theme );
79
+ @include mat .all-component-themes ($DSOMM-dark-theme );
80
+ }
0 commit comments