Skip to content

Commit 644b513

Browse files
committed
docs: update README
1 parent 3dac6c4 commit 644b513

File tree

1 file changed

+10
-45
lines changed

1 file changed

+10
-45
lines changed

README.md

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,7 @@ You want to style your angular material dynamically with all the colors in the r
1414
```scss
1515
@use 'angular-material-css-vars' as mat-css-vars;
1616
17-
// init theme
18-
@include mat-css-vars.init-material-css-vars(
19-
// optional
20-
$dark-theme-selector: '.isDarkTheme',
21-
$light-theme-selector: '.isLightTheme',
22-
) using($mat-css-theme) {
23-
// If your app has any theme mixins, call them here.
24-
// $mat-css-theme gets set to an appropriate value before this content is called.
25-
// @include your-custom-component-theme($mat-css-theme);
26-
};
17+
@include mat-css-vars.init-material-css-vars();
2718
```
2819
4. Add to your main module:
2920
```typescript
@@ -34,16 +25,15 @@ import {MaterialCssVarsModule} from 'angular-material-css-vars';
3425
MaterialCssVarsModule.forRoot({
3526
// all optional
3627
isAutoContrast: true,
37-
darkThemeClass: 'isDarkTheme',
38-
lightThemeClass: 'isLightTheme',
28+
primary: '#3f51b5',
3929
// ...
4030
}),
4131
],
4232
})
4333
export class AppModule {
4434
}
4535
```
46-
5. Then use it like so:
36+
5. If you want to adjust the theme at runtime, you can use `MaterialCssVarsService`:
4737
```typescript
4838
import {MaterialCssVarsService} from 'angular-material-css-vars';
4939
@@ -90,36 +80,15 @@ There are also [some additional hacks](additional-hacks.md) (e.g. adding a color
9080
You can provide different options before initialization to change the body class used for the dark theme and to provide different default styles:
9181
```scss
9282
...
93-
@use 'angular-material-css-vars' as mat-css-vars;
94-
...
95-
96-
@include mat-css-vars.init-material-css-vars(
97-
// $default-light-theme: ... ;
98-
// $text: ... ;
83+
@use 'angular-material-css-vars' as mat-css-vars with (
9984
$dark-theme-selector: '.isDarkTheme',
100-
$light-theme-selector: '.isLightTheme',
85+
$light-theme-selector: '.isLightTheme'
10186
);
87+
...
10288
103-
```
104-
To make those variables take effect with your mixins, you need to make sure that they are also defined before using them. E.g.:
105-
```scss
106-
@use 'angular-material-css-vars' as mat-css-vars;
107-
108-
@include mat-css-vars.init-material-css-vars(
109-
// probably best put in a common variables file and imported before the mixins
110-
$dark-theme-selector: '.isDarkTheme',
111-
);
89+
@include mat-css-vars.init-material-css-vars();
11290
113-
.my-component {
114-
@include mat-css-vars.mat-css-dark-theme {
115-
// dark theme styles ...
116-
}
117-
}
11891
```
119-
120-
121-
A full list of the theme map [can be found here](https://github.com/johannesjo/angular-material-css-vars/blob/master/projects/material-css-vars/src/lib/_variables.scss).
122-
12392
12493
### Set default (fallback palettes)
12594
There are two ways to set the default fallback theme. One is using the `mat-css-palette-defaults` mixin.
@@ -133,14 +102,10 @@ There are two ways to set the default fallback theme. One is using the `mat-css-
133102
@include mat-css-vars.mat-css-set-palette-defaults(mat.$pink-palette, 'accent');
134103
@include mat-css-vars.mat-css-set-palette-defaults(mat.$red-palette, 'warn');
135104
```
136-
The other is to include your own variables for [$mat-css-default-light-theme](https://github.com/johannesjo/angular-material-css-vars/blob/master/projects/material-css-vars/src/lib/_variables.scss).
105+
The other is to include your own variables for [$default-light-theme](https://github.com/johannesjo/angular-material-css-vars/blob/master/projects/material-css-vars/src/lib/_variables.scss).
137106
```scss
138-
@use 'angular-material-css-vars' as mat-css-vars;
139-
140-
$mat-css-default-light-theme: map-merge(
141-
// if you don't want to enter ALL the properties
142-
mat-css-vars.$default-light-theme,
143-
(
107+
@use 'angular-material-css-vars' as mat-css-vars with (
108+
$default-light-theme: (
144109
--palette-primary-50: mat-css-vars.hex-to-rgb(#e1f5fe),
145110
--palette-primary-100: mat-css-vars.hex-to-rgb(#b3e5fc),
146111
--palette-primary-200: mat-css-vars.hex-to-rgb(#81d4fa),

0 commit comments

Comments
 (0)