diff --git a/devui-commons/src/demo-nav/d-demo-nav.component.html b/devui-commons/src/demo-nav/d-demo-nav.component.html new file mode 100644 index 00000000..af6c9a2a --- /dev/null +++ b/devui-commons/src/demo-nav/d-demo-nav.component.html @@ -0,0 +1,12 @@ +
+ +
+
{{ goToText }}
+
    +
  • + {{ navitem.value }} +
  • +
+
+
+
diff --git a/devui-commons/src/demo-nav/d-demo-nav.component.scss b/devui-commons/src/demo-nav/d-demo-nav.component.scss new file mode 100644 index 00000000..84aff66d --- /dev/null +++ b/devui-commons/src/demo-nav/d-demo-nav.component.scss @@ -0,0 +1,49 @@ +@import '~ng-devui/styles-var/devui-var.scss'; + +.demo-nav { + width: 240px; + position: fixed; + top: 100px; + right: 0; + height: 100%; + z-index: 1; + + .fast-forward { + width: 130px; + font-size: $devui-font-size-card-title; + color: $devui-text; + line-height: 24px; + font-weight: bold; + padding-bottom: 10px; + margin-left: 20px; + border-bottom: 1px solid $devui-dividing-line; + } + + .step-nav { + margin-top: 10px; + + & > li { + list-style: none; + padding-left: 20px; + cursor: pointer; + height: 50px; + line-height: 50px; + font-size: $devui-font-size; + color: $devui-text; + position: relative; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + + &.active { + color: $devui-link; + } + } + } +} + +@media (max-width: 1400px) { + .demo-nav { + display: none; + } +} diff --git a/devui-commons/src/demo-nav/d-demo-nav.component.ts b/devui-commons/src/demo-nav/d-demo-nav.component.ts new file mode 100644 index 00000000..7b42f2d1 --- /dev/null +++ b/devui-commons/src/demo-nav/d-demo-nav.component.ts @@ -0,0 +1,33 @@ +import { DOCUMENT } from '@angular/common'; +import { Component, Inject, Input, OnInit } from '@angular/core'; +import { Subscription } from 'rxjs'; +import { DevuiCommonsService } from '../../src/devui-commons.service'; +import { I18nUtil } from '../i18n/i18n.util'; + +@Component({ + selector: 'd-demo-nav', + templateUrl: './d-demo-nav.component.html', + styleUrls: ['./d-demo-nav.component.scss'], +}) +export class DDemoNavComponent implements OnInit { + @Input() navItems: any; + demoDocViewerMain; + goToText = 'Go To'; + subs: Subscription = new Subscription(); + + constructor( + @Inject(DOCUMENT) private doc: any, + private commonsService: DevuiCommonsService + ) {} + + ngOnInit(): void { + this.demoDocViewerMain = this.doc.querySelector('.doc-viewer-container .main'); + this.setI18n(); + this.subs = this.commonsService.on('languageEvent').subscribe((term) => this.setI18n(term)); + } + + setI18n(lang?): void { + const curLanguage = lang || I18nUtil.getCurrentLanguage() || 'zh-cn'; + this.goToText = curLanguage === 'zh-cn' ? '快速前往' : 'Go To'; + } +} diff --git a/devui-commons/src/demo-nav/d-demo-nav.module.ts b/devui-commons/src/demo-nav/d-demo-nav.module.ts new file mode 100644 index 00000000..003d318b --- /dev/null +++ b/devui-commons/src/demo-nav/d-demo-nav.module.ts @@ -0,0 +1,22 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { AnchorModule } from 'ng-devui/anchor'; +import { StickyModule } from 'ng-devui/sticky'; +import { DDemoNavComponent } from './d-demo-nav.component'; + +@NgModule({ + imports: [ + CommonModule, + StickyModule, + AnchorModule + ], + declarations: [ + DDemoNavComponent + ], + exports: [ + DDemoNavComponent, + StickyModule, + AnchorModule + ] +}) +export class DDemoNavModule {} diff --git a/src/app/theme-picker/theme-data-more.ts b/devui-commons/src/header/theme-picker/theme-data-more.ts similarity index 100% rename from src/app/theme-picker/theme-data-more.ts rename to devui-commons/src/header/theme-picker/theme-data-more.ts diff --git a/devui-commons/src/header/theme-picker/theme-picker-i18n.type.ts b/devui-commons/src/header/theme-picker/theme-picker-i18n.type.ts new file mode 100644 index 00000000..b999ede9 --- /dev/null +++ b/devui-commons/src/header/theme-picker/theme-picker-i18n.type.ts @@ -0,0 +1,42 @@ +export const themePicker = { + 'zh-cn': { + theme: '主题', + color: '主题颜色', + mode: '主题模式', + light: '浅色模式', + dark: '深色模式', + follow: '跟随系统', + largeSize: '大字号模式', + default: '默认主题', + extend: '扩展主题', + customize: '定制主题', + customizeDark: '深色', + customizeDownloadConfig: '下载主题文件', + customizeDownloadConfigHelp: '使用', + infinity: '无限', + sweet: '蜜糖', + deep: '深邃夜空', + provence: '普罗旺斯', + galaxy: '追光' + }, + 'en-us': { + theme: 'Theme', + color: 'Theme Color', + mode: 'Theme Mode', + light: 'Light Theme', + dark: 'Dark Theme', + follow: 'Follow System', + largeSize: 'Large FontSize', + default: 'Default', + extend: 'Extend', + customize: 'Customize', + customizeDark: 'Dark', + customizeDownloadConfig: 'Download Theme Config', + customizeDownloadConfigHelp: 'Usage', + infinity: 'Infinity', + sweet: 'Sweet', + deep: 'Deep', + provence: 'Provence', + galaxy: 'Galaxy' + } +} \ No newline at end of file diff --git a/devui-commons/src/header/theme-picker/theme-picker-img.ts b/devui-commons/src/header/theme-picker/theme-picker-img.ts new file mode 100644 index 00000000..1ef4b91d --- /dev/null +++ b/devui-commons/src/header/theme-picker/theme-picker-img.ts @@ -0,0 +1,7 @@ +export const themePickerImg = { + deep: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALAAAAAoCAMAAABpXIBCAAAAq1BMVEU2PlI3P1M3QFs0O1IAAAAQGSwDBQocJDgSFiA1PVEyOk4wOEwuNkobIzceJjohKT0YIDQoMEQlLUAWHjIqMkYmLkISGi4sNEgOFio3P1MHCQ0jKz8hJzYDBQoZHioICxEdIi4HDyMWGyYfJTMLDRQdIzEQExwCAwYbIC0SFh8LEyclKzsOFCIAAQQUGCMjKTkKEB4NERg5QVUECx4CCBgBBhIWHCk8RFgHDBqitgHvAAAACXRSTlPpphwcAOnppqaXFY5vAAAH90lEQVRYw6yWyY7bMBBEnQ2BRFFcRG0QcsjVR+fg//+zvGozlqPkEjmlZrfGFjBvCkVqLp8/frg0/6yWi662rrpz7W9qfrXH9xRauV1v7Xpb7/f72nBz44tubl3nXJq7ccxjCn3fh973vQ+s6OPwEHP68vXT58tHcE8CP+n49Ss/7dT1b9G6NUCKVcR6EN7bHVQ+gL4VbQPwXLjGcesDoLEP3ojjME3TEPvIWJYpfPl0+dCc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LhAwmEom5jplykfAaST2zGGtt91hR1Boja2Ppz4d9im+xGXR0p/zMERFns3cI80JXH5MHIFTugGBPAdoMBsrPfqU9uqwew504bFTgh3ucqn3lXgEjWfSlBfAOBncbidcnM5MiR87o+MidfC0V4cvLY7rOyL1bT4Y7J9yo64bHjAgY7Spm0OHbdx1XI6F0UWee2To5aDPuuY7BY7R4Mtn3Kjw4Rk38+Jrjzd4YDWbKNs0hxM6cd3VLG7GVggclFD0SGBLxAN8KdMnMTYIc/SfvN5eJp5Ei1lUiKmyka3MypXYjd60cBaVFcdMl8V0+/IJf+3Vo8EMrLVjjivoaHFA/kJfMAVkmD0id4O5J7gLWF42gxkdqjJKqaeDJ89+AcjNEnPHeaw4AAAAAElFTkSuQmCC' +} \ No newline at end of file diff --git a/devui-commons/src/header/theme-picker/theme-picker.component.html b/devui-commons/src/header/theme-picker/theme-picker.component.html index 1060817b..3fe90bf3 100644 --- a/devui-commons/src/header/theme-picker/theme-picker.component.html +++ b/devui-commons/src/header/theme-picker/theme-picker.component.html @@ -1,22 +1,87 @@
- 主题 + {{ themePicker.theme }}
-
-
主题模式
-
- - {{ '浅色模式' }} - {{ '深色模式' }} - -
-
+ + +
+
{{ themePicker.color }}
+
+
+ + + + + + + +
+
+
+
+
{{ themePicker.mode }}
+
+ + {{ themePicker.light }} + {{ themePicker.dark }} + +
+ + {{ themePicker.follow }} +
+
+ + {{ themePicker.largeSize }} +
+
+
+
+ +
+
+ {{ + themePicker[item.value] + }} + +
+
+
+
- - diff --git a/devui-commons/src/header/theme-picker/theme-picker.component.scss b/devui-commons/src/header/theme-picker/theme-picker.component.scss index 2e5eef55..86460a4c 100644 --- a/devui-commons/src/header/theme-picker/theme-picker.component.scss +++ b/devui-commons/src/header/theme-picker/theme-picker.component.scss @@ -6,9 +6,11 @@ } .theme-toggle { - font-size: 16px; + font-size: $devui-font-size-page-title; line-height: 1.5; cursor: pointer; + display: flex; + align-items: center; &:hover { color: $devui-link; @@ -22,6 +24,7 @@ height: 18px; position: relative; border: 1px solid $devui-brand; + margin-left: 8px; .brand-color { position: absolute; @@ -52,13 +55,12 @@ .theme-menu { padding: 8px 12px; - font-size: 12px; + font-size: $devui-font-size; line-height: 1.5; - width: 180px; - height: 110px; + width: 200px; // 根据tab页动态宽度 .title { - font-weight: bold; + font-weight: 600; padding-bottom: 4px; margin: 8px 0 4px 0; line-height: 1.5; @@ -70,6 +72,83 @@ } } +d-toggle, +d-select { + display: inline-block; +} + .theme-select-radio { padding-left: 4px; + padding-right: 0; +} + +.theme-follow-toggle { + transform: scale(0.8); +} + +.theme-follow-toggle + span { + vertical-align: middle; + line-height: 28px; + margin-left: 4px; +} + +.prefers-color-scheme { + display: none; +} + +@media screen and (prefers-color-scheme: light) { + .prefers-color-scheme { + display: inline-block; + } +} + +@media screen and (prefers-color-scheme: dark) { + .prefers-color-scheme { + display: inline-block; + } +} + +.theme-color .theme-brand { + display: block; + width: 20px; + height: 20px; + float: left; + margin: 10px; + cursor: pointer; + border: 1px solid $devui-line; +} + +.theme-color::after { + display: block; + content: ''; + clear: both; +} + +.devui-tick { + fill: $devui-light-text; +} + +.extend-theme-image { + background-repeat: no-repeat; + height: 40px; + margin-bottom: 8px; + border-radius: $devui-border-radius; + cursor: pointer; + display: flex; + justify-content: space-between; + align-items: center; +} + +.extend-theme-title { + margin: 0 8px; + color: $devui-light-text; +} + +.active-theme { + color: $devui-light-text; + margin-right: 8px; + background-color: $devui-brand; + border-radius: 50%; + opacity: 0.6; + padding: 4px; } diff --git a/devui-commons/src/header/theme-picker/theme-picker.component.ts b/devui-commons/src/header/theme-picker/theme-picker.component.ts index 0b1eb20a..8543f636 100644 --- a/devui-commons/src/header/theme-picker/theme-picker.component.ts +++ b/devui-commons/src/header/theme-picker/theme-picker.component.ts @@ -1,33 +1,189 @@ -import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; -import { ThemeService } from 'ng-devui/theme'; +import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; +import { Theme, ThemeService, ThemeServiceFollowSystemOff, ThemeServiceFollowSystemOn } from 'ng-devui/theme'; +import { Subscription } from 'rxjs'; +import { DevuiCommonsService } from '../../../src/devui-commons.service'; +import { I18nUtil } from '../../i18n/i18n.util'; +import { LargeFontSize } from './theme-data-more'; +import { themePicker } from './theme-picker-i18n.type'; +import { themePickerImg } from './theme-picker-img'; @Component({ selector: 'theme-picker', templateUrl: './theme-picker.component.html', styleUrls: ['./theme-picker.component.scss'], }) -export class ThemePickerComponent implements OnInit { - themeService: ThemeService; - themes; - theme: string; - themeMode: 'light' | 'dark' | string = 'light'; - themePrefix = 'devui'; - +export class ThemePickerComponent implements OnInit, OnDestroy { + themeService!: ThemeService; + themes: Theme[] = []; + theme: string = 'devui-light-theme'; + largeFontTheme: Theme; + fontSize: 'normal' | 'large' = 'normal'; + themeMode: 'light' | 'dark' = 'light'; + themePrefix: 'devui' | 'green' | string = 'devui'; + themePrefersColorScheme: boolean; + sub: Subscription; + largeFontSizeMode = false; + activeThemeType: string | number = 'devuiTheme'; + advancedThemeList = [{ value: 'infinity', url: themePickerImg.infinity }, + { value: 'sweet', url: themePickerImg.sweet }, + { value: 'provence', url: themePickerImg.provence }, + { value: 'deep', url: themePickerImg.deep }, + { value: 'galaxy', url: themePickerImg.galaxy }]; + currentAdvancedTheme = 'infinity'; + subs: Subscription = new Subscription(); + themePicker: any = {}; constructor( - private cdr: ChangeDetectorRef - ) {} - - ngOnInit(): void { - this.themeService = window['devuiThemeService']; - this.themes = window['devuiThemes']; - this.theme = window['devuiCurrentTheme']; - this.themePrefix = this.theme.split('-')[0]; - this.themeMode = this.theme.split('-')[1]; + private cdr: ChangeDetectorRef, + private commonsService: DevuiCommonsService + ) { } + + ngOnInit() { + if (typeof window !== 'undefined') { + this.themeService = window['devuiThemeService']; + this.themes = window['devuiThemes']; + this.theme = window['devuiCurrentTheme']; + } + const themeName = localStorage.getItem('user-custom-theme')?.split('-')[0]; + this.currentAdvancedTheme = this.advancedThemeList.find(theme => theme.value === themeName) ? themeName : 'infinity'; + this.advancedThemeChange(this.currentAdvancedTheme); + this.themePrefix = this.getThemePrefix(); + this.themeMode = this.themes[this.theme]?.isDark ? 'dark' : 'light'; + this.largeFontSizeMode = this.theme === 'devui-large-font-theme'; + this.largeFontTheme = this.themes['devui-large-font-theme']; + this.themePrefersColorScheme = this.getThemePrefersColorSchemeOn(); + this.initTheme(); this.cdr.detectChanges(); + if (this.themePrefersColorScheme) { + this.themePrefersColorSchemeChange(true); + } + this.setI18n(); + this.subs = this.commonsService.on('languageEvent').subscribe((term) => this.setI18n(term)); + } + + setI18n(lang?) { + const curLanguage = lang || I18nUtil.getCurrentLanguage() || 'zh-cn'; + this.themePicker = themePicker[curLanguage]; + } + + getThemePrefix() { + return (this.theme.split('-')[0] !== 'devui' && this.theme.split('-')[0] !== 'green') ? 'devui' : this.theme.split('-')[0]; + } + initTheme() { + if (!this.checkInitThemeType()) { + this.activeThemeType = 'devuiTheme'; + this.themesChange(); + } else { + this.activeThemeType = 'advancedTheme'; + const themeName = localStorage.getItem('user-custom-theme')?.split('-')[0]; + this.currentAdvancedTheme = this.advancedThemeList.find(theme => theme.value === themeName) ? themeName : 'infinity'; + this.advancedThemeChange(this.currentAdvancedTheme); + } + } + + checkInitThemeType() { + const advancedThemePrefixList = ['infinity', 'sweet', 'provence', 'deep', 'galaxy']; + return advancedThemePrefixList.some(item => localStorage.getItem('user-custom-theme').startsWith(item)); + } + + themePrefixChange(prefix: string) { + this.themePrefix = prefix; + if (this.themePrefersColorScheme) { + this.themePrefersColorSchemeChange(true); + } else { + this.themesChange(); + } + } + + themesChange() { + if (this.largeFontSizeMode) { + this.largeFontTheme.data = { ...this.themes[`${this.themePrefix}-${this.themeMode}-theme`].data, ...LargeFontSize}; + this.theme = `devui-large-font-theme`; + } else { + this.theme = `${this.themePrefix}-${this.themeMode}-theme`; + } + this.themeService.applyTheme(this.themes[this.theme]); + } + + advancedThemeChange(theme) { + this.currentAdvancedTheme = theme; + const validTheme = theme + '-theme'; + this.themeService.applyTheme(this.themes[validTheme]); } - themesChange(): void { - this.theme = `${this.themePrefix}-${this.themeMode}-theme`; + themeFontSizeChange() { + if (typeof window !== 'undefined' && this.largeFontSizeMode) { + this.largeFontTheme.data = { ...this.themes[window['devuiCurrentTheme']].data, ...LargeFontSize}; + this.theme = `devui-large-font-theme`; + } else { + this.theme = `${this.themePrefix}-${this.themeMode}-theme`; + } this.themeService.applyTheme(this.themes[this.theme]); } + + themeFontSizeSchemeChange(event: boolean) { + if (event) { + if (this.sub) { + ThemeServiceFollowSystemOff(this.sub); + } + this.sub = ThemeServiceFollowSystemOn({ + lightThemeName: `${this.themePrefix}-light-large-theme`, + darkThemeName: `${this.themePrefix}-dark-large-theme` + }); + this.setThemeFontSizeScheme('on'); + } else { + ThemeServiceFollowSystemOff(this.sub); + this.setThemeFontSizeScheme('off'); + this.sub = undefined; + this.themesChange(); + } + } + + themePrefersColorSchemeChange(event: boolean) { + if (event) { + if (this.sub) { + ThemeServiceFollowSystemOff(this.sub); + } + this.sub = ThemeServiceFollowSystemOn({ + lightThemeName: `${this.themePrefix}-light-theme`, + darkThemeName: `${this.themePrefix}-dark-theme` + }); + this.setThemePrefersColorScheme('on'); + } else { + ThemeServiceFollowSystemOff(this.sub); + this.setThemePrefersColorScheme('off'); + this.sub = undefined; + this.themesChange(); + } + } + + ngOnDestroy(): void { + if (this.themePrefersColorScheme) { + ThemeServiceFollowSystemOff(this.sub); + } + this.subs.unsubscribe(); + } + + getThemeFontSizeSchemeOn() { + return localStorage.getItem('devuiThemeFontSizeScheme') === 'on'; + } + + setThemeFontSizeScheme(value: 'on' | 'off') { + localStorage.setItem('devuiThemeFontSizeScheme', value); + } + + getThemePrefersColorSchemeOn() { + return localStorage.getItem('devuiThemePrefersColorScheme') === 'on'; + } + + setThemePrefersColorScheme(value: 'on' | 'off') { + localStorage.setItem('devuiThemePrefersColorScheme', value); + } + + activeTabChange(tab) { + if (tab === 'advancedTheme') { + this.advancedThemeChange(this.currentAdvancedTheme); + } else { + this.themesChange(); + } + } } diff --git a/devui/accordion/demo/accordion-demo.moudule.ts b/devui/accordion/demo/accordion-demo.moudule.ts index 1ee1812f..1db4906c 100755 --- a/devui/accordion/demo/accordion-demo.moudule.ts +++ b/devui/accordion/demo/accordion-demo.moudule.ts @@ -8,7 +8,7 @@ import { DevUIApiModule } from 'ng-devui/shared/devui-api/devui-api.module'; import { DevUICodeboxModule } from 'ng-devui/shared/devui-codebox'; import { ToggleModule } from 'ng-devui/toggle'; import { TranslateModule } from '@ngx-translate/core'; -import { DDemoNavModule } from 'src/app/component/d-demo-nav.module'; +import { DDemoNavModule } from 'devui-commons/src/demo-nav/d-demo-nav.module'; import { AccordionDemoComponent } from './accordion-demo.component'; import { BasicComponent } from './basic/basic.component'; import { ChangeKeyComponent } from './change-key/change-key.component'; diff --git a/devui/alert/demo/alert-demo.module.ts b/devui/alert/demo/alert-demo.module.ts index 186dba2e..1f948999 100755 --- a/devui/alert/demo/alert-demo.module.ts +++ b/devui/alert/demo/alert-demo.module.ts @@ -7,7 +7,7 @@ import { DevUIApiComponent } from 'ng-devui/shared/devui-api/devui-api.component import { DevUIApiModule } from 'ng-devui/shared/devui-api/devui-api.module'; import { DevUICodeboxModule } from 'ng-devui/shared/devui-codebox/devui-codebox.module'; import { TranslateModule } from '@ngx-translate/core'; -import { DDemoNavModule } from 'src/app/component/d-demo-nav.module'; +import { DDemoNavModule } from 'devui-commons/src/demo-nav/d-demo-nav.module'; import { AlertDemoComponent } from './alert-demo.component'; import { BasicComponent } from './basic/basic.component'; import { CloseComponent } from './close/close.component'; diff --git a/devui/anchor/demo/anchor-demo.module.ts b/devui/anchor/demo/anchor-demo.module.ts index f3398723..41d74725 100755 --- a/devui/anchor/demo/anchor-demo.module.ts +++ b/devui/anchor/demo/anchor-demo.module.ts @@ -10,7 +10,7 @@ import { DevUICodeboxModule } from 'ng-devui/shared/devui-codebox/devui-codebox. import { StickyModule } from 'ng-devui/sticky'; import { ToggleModule } from 'ng-devui/toggle'; import { TranslateModule } from '@ngx-translate/core'; -import { DDemoNavModule } from 'src/app/component/d-demo-nav.module'; +import { DDemoNavModule } from 'devui-commons/src/demo-nav/d-demo-nav.module'; import { AnchorDemoComponent } from './anchor-demo.component'; import { AsyncComponent } from './async/async.component'; import { BasicComponent } from './basic/basic.component'; diff --git a/devui/animations/demo/animations-demo.module.ts b/devui/animations/demo/animations-demo.module.ts index 520e92a7..960b0393 100644 --- a/devui/animations/demo/animations-demo.module.ts +++ b/devui/animations/demo/animations-demo.module.ts @@ -6,7 +6,7 @@ import { DevUIApiComponent } from 'ng-devui/shared/devui-api/devui-api.component import { DevUIApiModule } from 'ng-devui/shared/devui-api/devui-api.module'; import { DevUICodeboxModule } from 'ng-devui/shared/devui-codebox'; import { TranslateModule } from '@ngx-translate/core'; -import { DDemoNavModule } from 'src/app/component/d-demo-nav.module'; +import { DDemoNavModule } from 'devui-commons/src/demo-nav/d-demo-nav.module'; import { AnimationIconComponent } from './animation-icon/animation-icon.component'; import { AnimationsDemoComponent } from './animations-demo.component'; import { CollapseComponent } from './collapse/collapse.component'; diff --git a/devui/auto-complete/auto-complete-popup.component.html b/devui/auto-complete/auto-complete-popup.component.html index e0425b3a..4ca358bd 100755 --- a/devui/auto-complete/auto-complete-popup.component.html +++ b/devui/auto-complete/auto-complete-popup.component.html @@ -32,7 +32,7 @@ [backdrop]="true" >