├── src ├── styles.less ├── assets │ ├── .gitkeep │ └── demo.gif ├── styles │ ├── themes │ │ ├── base.less │ │ ├── dark.less │ │ ├── default.less │ │ └── mixin.less │ ├── dark.less │ └── default.less ├── favicon.ico ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── app │ ├── pages │ │ └── welcome │ │ │ ├── welcome.component.less │ │ │ ├── welcome-routing.module.ts │ │ │ ├── welcome.module.ts │ │ │ ├── welcome.component.html │ │ │ └── welcome.component.ts │ ├── app-initializer.service.ts │ ├── app.component.ts │ ├── app-routing.module.ts │ ├── icons-provider.module.ts │ ├── app.component.spec.ts │ ├── app.module.ts │ ├── theme.service.ts │ ├── app.component.html │ └── app.component.less ├── index.html ├── main.ts ├── test.ts └── polyfills.ts ├── e2e ├── src │ ├── app.po.ts │ └── app.e2e-spec.ts ├── tsconfig.json └── protractor.conf.js ├── .editorconfig ├── tsconfig.app.json ├── tsconfig.spec.json ├── .browserslistrc ├── .gitignore ├── tsconfig.json ├── README.md ├── package.json ├── karma.conf.js ├── tslint.json └── angular.json /src/styles.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/styles/themes/base.less: -------------------------------------------------------------------------------- 1 | @margin-md: 17px; 2 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjunhan/nz-themes/HEAD/src/favicon.ico -------------------------------------------------------------------------------- /src/assets/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yangjunhan/nz-themes/HEAD/src/assets/demo.gif -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/styles/dark.less: -------------------------------------------------------------------------------- 1 | @import '../../node_modules/ng-zorro-antd/ng-zorro-antd'; 2 | @import "./themes/dark"; 3 | -------------------------------------------------------------------------------- /src/styles/default.less: -------------------------------------------------------------------------------- 1 | @import '../../node_modules/ng-zorro-antd/ng-zorro-antd'; 2 | @import "./themes/default"; 3 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.less: -------------------------------------------------------------------------------- 1 | @import "mixin"; 2 | 3 | .themeMixin({ 4 | :host { 5 | ::ng-deep nz-radio-group { 6 | margin-bottom: @margin-md; 7 | } 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /src/styles/themes/dark.less: -------------------------------------------------------------------------------- 1 | @import (multiple) '../../../node_modules/ng-zorro-antd/src/style/themes/dark'; 2 | @import './base'; 3 | @layout-sider-background: @component-background; 4 | @layout-header-background: @component-background; 5 | -------------------------------------------------------------------------------- /src/styles/themes/default.less: -------------------------------------------------------------------------------- 1 | @import (multiple) '../../../node_modules/ng-zorro-antd/src/style/themes/default'; 2 | @import './base'; 3 | @layout-sider-background: @white; 4 | @layout-trigger-background: @white; 5 | @layout-header-background: @white; 6 | -------------------------------------------------------------------------------- /src/styles/themes/mixin.less: -------------------------------------------------------------------------------- 1 | .themeMixin(@rules) { 2 | html { 3 | &.default { 4 | @import './default.less'; 5 | @rules(); 6 | } 7 | &.dark { 8 | @import './dark.less'; 9 | @rules(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | async navigateTo(): Promise { 5 | return browser.get(browser.baseUrl); 6 | } 7 | 8 | async getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "../out-tsc/e2e", 6 | "module": "commonjs", 7 | "target": "es2018", 8 | "types": [ 9 | "jasmine", 10 | "node" 11 | ] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NzThemes 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/app/app-initializer.service.ts: -------------------------------------------------------------------------------- 1 | import { APP_INITIALIZER } from '@angular/core'; 2 | import { ThemeService } from './theme.service'; 3 | 4 | export const AppInitializerProvider = { 5 | provide: APP_INITIALIZER, 6 | useFactory: (themeService: ThemeService) => () => { 7 | return themeService.loadTheme(); 8 | }, 9 | deps: [ThemeService], 10 | multi: true, 11 | }; 12 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { WelcomeComponent } from './welcome.component'; 4 | 5 | const routes: Routes = [ 6 | { path: '', component: WelcomeComponent }, 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [RouterModule.forChild(routes)], 11 | exports: [RouterModule] 12 | }) 13 | export class WelcomeRoutingModule { } 14 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { ThemeService } from './theme.service'; 3 | 4 | @Component({ 5 | selector: 'app-root', 6 | templateUrl: './app.component.html', 7 | styleUrls: ['./app.component.less'], 8 | }) 9 | export class AppComponent { 10 | isCollapsed = false; 11 | 12 | constructor(private themeService: ThemeService) {} 13 | 14 | toggleTheme(): void { 15 | this.themeService.toggleTheme().then(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', pathMatch: 'full', redirectTo: '/welcome' }, 6 | { path: 'welcome', loadChildren: () => import('./pages/welcome/welcome.module').then(m => m.WelcomeModule) } 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [RouterModule.forRoot(routes)], 11 | exports: [RouterModule] 12 | }) 13 | export class AppRoutingModule { } 14 | -------------------------------------------------------------------------------- /src/app/icons-provider.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { NZ_ICONS, NzIconModule } from 'ng-zorro-antd/icon'; 3 | 4 | import { 5 | MenuFoldOutline, 6 | MenuUnfoldOutline, 7 | FormOutline, 8 | DashboardOutline 9 | } from '@ant-design/icons-angular/icons'; 10 | 11 | const icons = [MenuFoldOutline, MenuUnfoldOutline, DashboardOutline, FormOutline]; 12 | 13 | @NgModule({ 14 | imports: [NzIconModule], 15 | exports: [NzIconModule], 16 | providers: [ 17 | { provide: NZ_ICONS, useValue: icons } 18 | ] 19 | }) 20 | export class IconsProviderModule { 21 | } 22 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | 3 | import { WelcomeRoutingModule } from './welcome-routing.module'; 4 | 5 | import { WelcomeComponent } from './welcome.component'; 6 | import { NzCollapseModule } from 'ng-zorro-antd/collapse'; 7 | import { CommonModule } from '@angular/common'; 8 | import { NzRadioModule } from 'ng-zorro-antd/radio'; 9 | import { FormsModule } from '@angular/forms'; 10 | 11 | @NgModule({ 12 | imports: [ 13 | WelcomeRoutingModule, 14 | CommonModule, 15 | NzCollapseModule, 16 | NzRadioModule, 17 | FormsModule, 18 | ], 19 | declarations: [WelcomeComponent], 20 | exports: [WelcomeComponent], 21 | }) 22 | export class WelcomeModule {} 23 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

11 | A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many 12 | households across the world. 13 |

14 |
15 |
16 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/app/pages/welcome/welcome.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-welcome', 5 | templateUrl: './welcome.component.html', 6 | styleUrls: ['./welcome.component.less'], 7 | }) 8 | export class WelcomeComponent implements OnInit { 9 | radioValue = 'A'; 10 | panels = [ 11 | { 12 | active: true, 13 | name: 'This is panel header 1', 14 | disabled: false, 15 | }, 16 | { 17 | active: false, 18 | disabled: false, 19 | name: 'This is panel header 2', 20 | }, 21 | { 22 | active: false, 23 | disabled: true, 24 | name: 'This is panel header 3', 25 | }, 26 | ]; 27 | 28 | constructor() {} 29 | 30 | ngOnInit(): void {} 31 | } 32 | -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', async () => { 12 | await page.navigateTo(); 13 | expect(await page.getTitleText()).toEqual('nz-themes app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitReturns": true, 10 | "noFallthroughCasesInSwitch": true, 11 | "sourceMap": true, 12 | "declaration": false, 13 | "downlevelIteration": true, 14 | "experimentalDecorators": true, 15 | "moduleResolution": "node", 16 | "importHelpers": true, 17 | "target": "es2015", 18 | "module": "es2020", 19 | "lib": [ 20 | "es2018", 21 | "dom" 22 | ] 23 | }, 24 | "angularCompilerOptions": { 25 | "strictInjectionParameters": true, 26 | "strictInputAccessModifiers": true, 27 | "strictTemplates": true 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | SELENIUM_PROMISE_MANAGER: false, 20 | baseUrl: 'http://localhost:4200/', 21 | framework: 'jasmine', 22 | jasmineNodeOpts: { 23 | showColors: true, 24 | defaultTimeoutInterval: 30000, 25 | print: function() {} 26 | }, 27 | onPrepare() { 28 | require('ts-node').register({ 29 | project: require('path').join(__dirname, './tsconfig.json') 30 | }); 31 | jasmine.getEnv().addReporter(new SpecReporter({ 32 | spec: { 33 | displayStacktrace: StacktraceOption.PRETTY 34 | } 35 | })); 36 | } 37 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NzThemes 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 11.0.4. 4 | 5 | ![Demo](https://github.com/yangjunhan/nz-themes/blob/master/src/assets/demo.gif) 6 | 7 | ## Development server 8 | 9 | Run `ng serve` for a dev server. Navigate to `http://localhost:4201/`. The app will automatically reload if you change any of the source files. 10 | 11 | ## Code scaffolding 12 | 13 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 14 | 15 | ## Build 16 | 17 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 18 | 19 | ## Running unit tests 20 | 21 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 22 | 23 | ## Running end-to-end tests 24 | 25 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 26 | 27 | ## Further help 28 | 29 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 30 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async () => { 7 | await TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | }); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'nz-themes'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('nz-themes'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('nz-themes app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { IconsProviderModule } from './icons-provider.module'; 7 | import { NzLayoutModule } from 'ng-zorro-antd/layout'; 8 | import { NzMenuModule } from 'ng-zorro-antd/menu'; 9 | import { FormsModule } from '@angular/forms'; 10 | import { HttpClientModule } from '@angular/common/http'; 11 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 12 | import { NZ_I18N } from 'ng-zorro-antd/i18n'; 13 | import { zh_CN } from 'ng-zorro-antd/i18n'; 14 | import { registerLocaleData } from '@angular/common'; 15 | import zh from '@angular/common/locales/zh'; 16 | import { AppInitializerProvider } from './app-initializer.service'; 17 | 18 | registerLocaleData(zh); 19 | 20 | @NgModule({ 21 | declarations: [AppComponent], 22 | imports: [ 23 | BrowserModule, 24 | AppRoutingModule, 25 | IconsProviderModule, 26 | NzLayoutModule, 27 | NzMenuModule, 28 | FormsModule, 29 | HttpClientModule, 30 | BrowserAnimationsModule, 31 | ], 32 | providers: [AppInitializerProvider, { provide: NZ_I18N, useValue: zh_CN }], 33 | bootstrap: [AppComponent], 34 | }) 35 | export class AppModule {} 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nz-themes", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~11.0.4", 15 | "@angular/common": "~11.0.4", 16 | "@angular/compiler": "~11.0.4", 17 | "@angular/core": "~11.0.4", 18 | "@angular/forms": "~11.0.4", 19 | "@angular/platform-browser": "~11.0.4", 20 | "@angular/platform-browser-dynamic": "~11.0.4", 21 | "@angular/router": "~11.0.4", 22 | "ng-zorro-antd": "^11.0.0", 23 | "rxjs": "~6.6.0", 24 | "tslib": "^2.0.0", 25 | "zone.js": "~0.10.2" 26 | }, 27 | "devDependencies": { 28 | "@angular-devkit/build-angular": "~0.1100.4", 29 | "@angular/cli": "~11.0.4", 30 | "@angular/compiler-cli": "~11.0.4", 31 | "@types/jasmine": "~3.6.0", 32 | "@types/node": "^12.11.1", 33 | "codelyzer": "^6.0.0", 34 | "jasmine-core": "~3.6.0", 35 | "jasmine-spec-reporter": "~5.0.0", 36 | "karma": "~5.1.0", 37 | "karma-chrome-launcher": "~3.1.0", 38 | "karma-coverage": "~2.0.3", 39 | "karma-jasmine": "~4.0.0", 40 | "karma-jasmine-html-reporter": "^1.5.0", 41 | "protractor": "~7.0.0", 42 | "ts-node": "~8.3.0", 43 | "tslint": "~6.1.0", 44 | "typescript": "~4.0.2" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/nz-themes'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /src/app/theme.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | enum ThemeType { 4 | dark = 'dark', 5 | default = 'default', 6 | } 7 | 8 | @Injectable({ 9 | providedIn: 'root', 10 | }) 11 | export class ThemeService { 12 | currentTheme = ThemeType.default; 13 | 14 | constructor() {} 15 | 16 | private reverseTheme(theme: string): ThemeType { 17 | return theme === ThemeType.dark ? ThemeType.default : ThemeType.dark; 18 | } 19 | 20 | private removeUnusedTheme(theme: ThemeType): void { 21 | document.documentElement.classList.remove(theme); 22 | const removedThemeStyle = document.getElementById(theme); 23 | if (removedThemeStyle) { 24 | document.head.removeChild(removedThemeStyle); 25 | } 26 | } 27 | 28 | private loadCss(href: string, id: string): Promise { 29 | return new Promise((resolve, reject) => { 30 | const style = document.createElement('link'); 31 | style.rel = 'stylesheet'; 32 | style.href = href; 33 | style.id = id; 34 | style.onload = resolve; 35 | style.onerror = reject; 36 | document.head.append(style); 37 | }); 38 | } 39 | 40 | public loadTheme(firstLoad = true): Promise { 41 | const theme = this.currentTheme; 42 | if (firstLoad) { 43 | document.documentElement.classList.add(theme); 44 | } 45 | return new Promise((resolve, reject) => { 46 | this.loadCss(`${theme}.css`, theme).then( 47 | (e) => { 48 | if (!firstLoad) { 49 | document.documentElement.classList.add(theme); 50 | } 51 | this.removeUnusedTheme(this.reverseTheme(theme)); 52 | resolve(e); 53 | }, 54 | (e) => reject(e) 55 | ); 56 | }); 57 | } 58 | 59 | public toggleTheme(): Promise { 60 | this.currentTheme = this.reverseTheme(this.currentTheme); 61 | return this.loadTheme(false); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 8 | 14 | 36 | 37 | 38 | 39 |
40 | 41 | 45 | 46 | 47 | 48 | 49 |
50 |
51 | 52 |
53 | 54 |
55 |
56 |
57 |
58 | -------------------------------------------------------------------------------- /src/app/app.component.less: -------------------------------------------------------------------------------- 1 | @import "mixin"; 2 | 3 | .themeMixin({ 4 | :host { 5 | .sidebar-logo { 6 | background: @primary-1; 7 | h1 { 8 | color: @text-color; 9 | } 10 | } 11 | 12 | .app-header { 13 | background: @layout-header-background; 14 | } 15 | 16 | .header-trigger { 17 | color: @text-color; 18 | } 19 | 20 | .inner-content { 21 | background: @layout-trigger-background; 22 | } 23 | 24 | .trigger:hover { 25 | color: #1890ff; 26 | } 27 | } 28 | }); 29 | 30 | :host { 31 | display: flex; 32 | text-rendering: optimizeLegibility; 33 | -webkit-font-smoothing: antialiased; 34 | -moz-osx-font-smoothing: grayscale; 35 | 36 | .app-layout { 37 | height: 100vh; 38 | 39 | .menu-sidebar { 40 | position: relative; 41 | z-index: 10; 42 | min-height: 100vh; 43 | box-shadow: 2px 0 6px rgba(0,21,41,.35); 44 | 45 | ::ng-deep .ant-menu-inline { 46 | border-right: none; 47 | } 48 | } 49 | 50 | .sidebar-logo { 51 | position: relative; 52 | height: 64px; 53 | padding-left: 24px; 54 | overflow: hidden; 55 | line-height: 64px; 56 | transition: all .3s; 57 | } 58 | 59 | .sidebar-logo img { 60 | display: inline-block; 61 | height: 32px; 62 | width: 32px; 63 | vertical-align: middle; 64 | } 65 | 66 | .sidebar-logo h1 { 67 | display: inline-block; 68 | margin: 0 0 0 20px; 69 | font-weight: 600; 70 | font-size: 14px; 71 | font-family: Avenir,Helvetica Neue,Arial,Helvetica,sans-serif; 72 | vertical-align: middle; 73 | } 74 | } 75 | 76 | nz-header { 77 | padding: 0; 78 | width: 100%; 79 | z-index: 2; 80 | 81 | .app-header { 82 | position: relative; 83 | height: 64px; 84 | padding: 0; 85 | box-shadow: 0 1px 4px rgba(0,21,41,.08); 86 | 87 | .header-trigger { 88 | height: 64px; 89 | padding: 20px 24px; 90 | font-size: 20px; 91 | cursor: pointer; 92 | transition: all .3s,padding 0s; 93 | } 94 | } 95 | } 96 | 97 | nz-content { 98 | margin: 24px; 99 | 100 | .inner-content { 101 | padding: 24px; 102 | height: 100%; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rulesDirectory": [ 4 | "codelyzer" 5 | ], 6 | "rules": { 7 | "align": { 8 | "options": [ 9 | "parameters", 10 | "statements" 11 | ] 12 | }, 13 | "array-type": false, 14 | "arrow-return-shorthand": true, 15 | "curly": true, 16 | "deprecation": { 17 | "severity": "warning" 18 | }, 19 | "eofline": true, 20 | "import-blacklist": [ 21 | true, 22 | "rxjs/Rx" 23 | ], 24 | "import-spacing": true, 25 | "indent": { 26 | "options": [ 27 | "spaces" 28 | ] 29 | }, 30 | "max-classes-per-file": false, 31 | "max-line-length": [ 32 | true, 33 | 140 34 | ], 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-console": [ 47 | true, 48 | "debug", 49 | "info", 50 | "time", 51 | "timeEnd", 52 | "trace" 53 | ], 54 | "no-empty": false, 55 | "no-inferrable-types": [ 56 | true, 57 | "ignore-params" 58 | ], 59 | "no-non-null-assertion": true, 60 | "no-redundant-jsdoc": true, 61 | "no-switch-case-fall-through": true, 62 | "no-var-requires": false, 63 | "object-literal-key-quotes": [ 64 | true, 65 | "as-needed" 66 | ], 67 | "quotemark": [ 68 | true, 69 | "single" 70 | ], 71 | "semicolon": { 72 | "options": [ 73 | "always" 74 | ] 75 | }, 76 | "space-before-function-paren": { 77 | "options": { 78 | "anonymous": "never", 79 | "asyncArrow": "always", 80 | "constructor": "never", 81 | "method": "never", 82 | "named": "never" 83 | } 84 | }, 85 | "typedef": [ 86 | true, 87 | "call-signature" 88 | ], 89 | "typedef-whitespace": { 90 | "options": [ 91 | { 92 | "call-signature": "nospace", 93 | "index-signature": "nospace", 94 | "parameter": "nospace", 95 | "property-declaration": "nospace", 96 | "variable-declaration": "nospace" 97 | }, 98 | { 99 | "call-signature": "onespace", 100 | "index-signature": "onespace", 101 | "parameter": "onespace", 102 | "property-declaration": "onespace", 103 | "variable-declaration": "onespace" 104 | } 105 | ] 106 | }, 107 | "variable-name": { 108 | "options": [ 109 | "ban-keywords", 110 | "check-format", 111 | "allow-pascal-case" 112 | ] 113 | }, 114 | "whitespace": { 115 | "options": [ 116 | "check-branch", 117 | "check-decl", 118 | "check-operator", 119 | "check-separator", 120 | "check-type", 121 | "check-typecast" 122 | ] 123 | }, 124 | "component-class-suffix": true, 125 | "contextual-lifecycle": true, 126 | "directive-class-suffix": true, 127 | "no-conflicting-lifecycle": true, 128 | "no-host-metadata-property": true, 129 | "no-input-rename": true, 130 | "no-inputs-metadata-property": true, 131 | "no-output-native": true, 132 | "no-output-on-prefix": true, 133 | "no-output-rename": true, 134 | "no-outputs-metadata-property": true, 135 | "template-banana-in-box": true, 136 | "template-no-negated-async": true, 137 | "use-lifecycle-interface": true, 138 | "use-pipe-transform-interface": true, 139 | "directive-selector": [ 140 | true, 141 | "attribute", 142 | "app", 143 | "camelCase" 144 | ], 145 | "component-selector": [ 146 | true, 147 | "element", 148 | "app", 149 | "kebab-case" 150 | ] 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "nz-themes": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "less" 11 | }, 12 | "@schematics/angular:application": { 13 | "strict": true 14 | } 15 | }, 16 | "root": "", 17 | "sourceRoot": "src", 18 | "prefix": "app", 19 | "architect": { 20 | "build": { 21 | "builder": "@angular-devkit/build-angular:browser", 22 | "options": { 23 | "outputPath": "dist/nz-themes", 24 | "index": "src/index.html", 25 | "main": "src/main.ts", 26 | "polyfills": "src/polyfills.ts", 27 | "tsConfig": "tsconfig.app.json", 28 | "aot": true, 29 | "assets": [ 30 | "src/favicon.ico", 31 | "src/assets", 32 | { 33 | "glob": "**/*", 34 | "input": "./node_modules/@ant-design/icons-angular/src/inline-svg/", 35 | "output": "/assets/" 36 | } 37 | ], 38 | "styles": [ 39 | "src/styles.less", 40 | { 41 | "input": "src/styles/default.less", 42 | "bundleName": "default", 43 | "inject": false 44 | }, 45 | { 46 | "input": "src/styles/dark.less", 47 | "bundleName": "dark", 48 | "inject": false 49 | } 50 | ], 51 | "stylePreprocessorOptions": { 52 | "includePaths": ["src/styles/themes"] 53 | }, 54 | "scripts": [] 55 | }, 56 | "configurations": { 57 | "production": { 58 | "fileReplacements": [ 59 | { 60 | "replace": "src/environments/environment.ts", 61 | "with": "src/environments/environment.prod.ts" 62 | } 63 | ], 64 | "optimization": true, 65 | "outputHashing": "all", 66 | "sourceMap": false, 67 | "namedChunks": false, 68 | "extractLicenses": true, 69 | "vendorChunk": false, 70 | "buildOptimizer": true, 71 | "budgets": [ 72 | { 73 | "type": "initial", 74 | "maximumWarning": "500kb", 75 | "maximumError": "1mb" 76 | }, 77 | { 78 | "type": "anyComponentStyle", 79 | "maximumWarning": "2kb", 80 | "maximumError": "4kb" 81 | } 82 | ] 83 | } 84 | } 85 | }, 86 | "serve": { 87 | "builder": "@angular-devkit/build-angular:dev-server", 88 | "options": { 89 | "browserTarget": "nz-themes:build", 90 | "port": 4201 91 | }, 92 | "configurations": { 93 | "production": { 94 | "browserTarget": "nz-themes:build:production" 95 | } 96 | } 97 | }, 98 | "extract-i18n": { 99 | "builder": "@angular-devkit/build-angular:extract-i18n", 100 | "options": { 101 | "browserTarget": "nz-themes:build" 102 | } 103 | }, 104 | "test": { 105 | "builder": "@angular-devkit/build-angular:karma", 106 | "options": { 107 | "main": "src/test.ts", 108 | "polyfills": "src/polyfills.ts", 109 | "tsConfig": "tsconfig.spec.json", 110 | "karmaConfig": "karma.conf.js", 111 | "assets": [ 112 | "src/favicon.ico", 113 | "src/assets" 114 | ], 115 | "styles": [ 116 | "src/styles.less" 117 | ], 118 | "scripts": [] 119 | } 120 | }, 121 | "lint": { 122 | "builder": "@angular-devkit/build-angular:tslint", 123 | "options": { 124 | "tsConfig": [ 125 | "tsconfig.app.json", 126 | "tsconfig.spec.json", 127 | "e2e/tsconfig.json" 128 | ], 129 | "exclude": [ 130 | "**/node_modules/**" 131 | ] 132 | } 133 | }, 134 | "e2e": { 135 | "builder": "@angular-devkit/build-angular:protractor", 136 | "options": { 137 | "protractorConfig": "e2e/protractor.conf.js", 138 | "devServerTarget": "nz-themes:serve" 139 | }, 140 | "configurations": { 141 | "production": { 142 | "devServerTarget": "nz-themes:serve:production" 143 | } 144 | } 145 | } 146 | } 147 | } 148 | }, 149 | "defaultProject": "nz-themes" 150 | } 151 | --------------------------------------------------------------------------------