anu-lib-style
v0.0.21
Published
```bash npm i primeng@17 primeicons@7 primeflex@3 @ic-lib/style ```
Readme
npm i primeng@17 primeicons@7 primeflex@3 @ic-lib/styleTheme Configuration
- Create a
theme(you may select you own name preference) folder in you angular application undersrc - Create
dark.scssandlight.scssfile underthemeand it will look like below respectively.
@import "@ic-lib/style/scss/theme-dark";@import "@ic-lib/style/scss/theme-light";- Now in
angular.jsonunderarchitect > build > options > stylesimport themes like this.
"styles": [
...
{
"input": "./src/theme/light.scss",
"bundleName": "ic-light",
"inject": false
},
{
"input": "./src/theme/dark.scss",
"bundleName": "ic-dark",
"inject": false
}
],- In application
src/index.htmladd this line into header section
<link id="ic-theme" rel="stylesheet" type="text/css" href="ic-light.css" />- Import this line in your global scss (
src/style.scss) file at the top
@import "@ic-lib/style/scss/global";Switch Theme (Only required in Shell app)
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { InputSwitchModule } from 'primeng/inputswitch';
import { ThemeService } from "@ic-lib/style";
@Component({
selector: 'app-root',
standalone: true,
imports: [InputSwitchModule, FormsModule],
templateUrl: './app.component.html',
styleUrl: './app.component.scss'
})
export class AppComponent {
isLight = true
constructor(private theme: ThemeService) {}
toggleTheme() {
this.isLight ? this.theme.switchTheme('ic-light') : this.theme.switchTheme('ic-dark');
}
}Common issue in local development
- Angular 17 onwards npm link lib will be ignored by
viteoptimizer. While you lib in watch mode, the changes will get ignored. To fix that. Opentsconfig.app.jsonand add this line of code. so vite will not add the lib in cache.
{
...
"compilerOptions": {
...
"paths": {
"@ic-lib/style": ["./node_modules/@ic-lib/style"]
}
},
...
}