ng-alain-plugin-theme
Version:
NG-ALAIN theme plugin
97 lines (71 loc) • 2.49 kB
Markdown
NG-ALAIN theme plugin.
[](https://www.npmjs.com/package/ng-alain-plugin-theme)

- **themeCss** Generate theme styles for theme switching
- **colorLess** Generate `color.less`, dynamically customize colors
Install `ng-alain-plugin-theme` to `devDependencies`.
```bash
yarn add -D ng-alain-plugin-theme
npm i ng-alain-plugin-theme --save-dev
```
You can use `npx` to complete the generated project `color.less` and theme style, like this:
```bash
npx ng-alain-plugin-theme -t=themeCss
npx ng-alain-plugin-theme -t=colorLess
npx ng-alain-plugin-theme -t=themeCss -debug
```
You muse add `ng-alain.json` file in root path, for example, you want to generate `dark` and `dust` style:
```json
{
"$schema": "./node_modules/ng-alain/schema.json",
"theme": {
"list": [
{
"theme": "dark"
},
{
"key": "dust",
"modifyVars": {
"@primary-color": "#F5222D"
}
}
]
}
}
```
> We provide a completed [JSON Schema](https://github.com/ng-alain/delon/blob/master/packages/schematics/schema.json) that you can write very conveniently.
Execute the following command:
```bash
npx ng-alain-plugin-theme -t=themeCss
```
You can refer to how [ng-alain scaffold](https://github.com/ng-alain/ng-alain/blob/master/src/app/layout/default/setting-drawer/setting-drawer.component.ts#L241) uses `style.dark.css`.
If you using [NG-ALAIN](https://ng-alain.com/) scaffold, execute the following command with default parameters:
```bash
npx ng-alain-plugin-theme -t=colorLess
```
You can refer to how [delon document site](https://github.com/ng-alain/delon/blob/master/src/app/shared/components/footer/footer.component.ts#L47-L89) uses `color.less`.
Or use `ng-alain.json` to change the default parameters:
```json
{
"$schema": "./node_modules/ng-alain/schema.json",
"colorLess": {
"variables": ["@primary-color"],
"ngZorroAntd": "./node_modules/ng-zorro-antd/",
"styleFilePath": "./src/styles.less",
"themeFilePath": "./src/styles/theme.less",
"outputFilePath": "./src/assets/color.less"
}
}
```
MIT