Skip to content

Commit f2badc2

Browse files
committed
Merge branch 'feat/DS-2835' of github.com:koobiq/angular-components into feat/DS-2835
* 'feat/DS-2835' of github.com:koobiq/angular-components: fix(form-field): kbq-password-hint error (#DS-2868) (#277) feat(tooltip): components theming with CSS-vars (#DS-2840) (#279) feat(file-upload): components theming with CSS-vars (#DS-2812) (#273) feat(description-list): components theming with CSS-vars (#DS-2846) (#274) feat(tree-select): components theming with CSS-vars (#DS-2841) (#278) feat(empty-state): components theming with CSS-vars (#DS-2811) (#272) feat(code-block): components theming with CSS-vars (#DS-2806) (#271) feat(table): components theming with CSS-vars (#DS-2843) (#275) feat(toggle): components theming with CSS-vars (#DS-2839) (#280) feat(toast): components theming with CSS-vars (#DS-2837) (#281) feat(docs): theme switch refactoring (#DS-2796) (#266)
2 parents 25c5188 + 97d5009 commit f2badc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1406
-457
lines changed

apps/docs/src/app/components/navbar/navbar.component.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import { Component, ViewEncapsulation } from '@angular/core';
2-
import { KbqTheme, ThemeService } from '@koobiq/components/core';
1+
import { Component, OnDestroy, ViewEncapsulation } from '@angular/core';
2+
import { KbqTheme, KbqThemeSelector, ThemeService } from '@koobiq/components/core';
33
import { koobiqVersion } from '../../version';
44
import { DocStates, DocsNavbarState } from '../doс-states';
55
import { NavbarProperty, NavbarPropertyParameters } from './navbar-property';
66

7-
export enum Themes {
8-
Default = 'theme-light',
9-
Dark = 'theme-dark'
10-
}
11-
127
@Component({
138
selector: 'docs-navbar',
149
templateUrl: 'navbar.template.html',
@@ -18,7 +13,7 @@ export enum Themes {
1813
},
1914
encapsulation: ViewEncapsulation.None
2015
})
21-
export class NavbarComponent {
16+
export class NavbarComponent implements OnDestroy {
2217
version = koobiqVersion;
2318

2419
themeSwitch: NavbarProperty;
@@ -29,17 +24,17 @@ export class NavbarComponent {
2924
kbqThemes: KbqTheme[] = [
3025
{
3126
name: 'Как в системе',
32-
className: this.colorAutomaticTheme.matches ? Themes.Default : Themes.Dark,
27+
className: this.colorAutomaticTheme.matches ? KbqThemeSelector.Default : KbqThemeSelector.Dark,
3328
selected: false
3429
},
3530
{
3631
name: 'Светлая',
37-
className: Themes.Default,
32+
className: KbqThemeSelector.Default,
3833
selected: false
3934
},
4035
{
4136
name: 'Тёмная',
42-
className: Themes.Dark,
37+
className: KbqThemeSelector.Dark,
4338
selected: false
4439
}
4540
];
@@ -80,6 +75,15 @@ export class NavbarComponent {
8075
this.docStates.navbarMenu.subscribe((state) => (this.opened = state === DocsNavbarState.opened));
8176
}
8277

78+
ngOnDestroy() {
79+
this.themeService.ngOnDestroy();
80+
try {
81+
this.colorAutomaticTheme.removeEventListener('change', this.setAutoTheme);
82+
} catch (err) {
83+
console.error(err);
84+
}
85+
}
86+
8387
toggleMenu() {
8488
this.docStates.toggleNavbarMenu();
8589
}
@@ -93,7 +97,7 @@ export class NavbarComponent {
9397
private setAutoTheme = (e) => {
9498
this.themeService.themes[0] = {
9599
...this.themeService.themes[0],
96-
className: e.matches ? Themes.Default : Themes.Dark
100+
className: e.matches ? KbqThemeSelector.Default : KbqThemeSelector.Dark
97101
};
98102

99103
if (this.themeService.themes[0].selected) {

apps/docs/src/app/components/welcome/welcome.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class WelcomeComponent implements OnInit, OnDestroy {
3333
ngOnInit(): void {
3434
this.docCategories = this.docItems.getCategories().filter((category) => category.isPreviewed);
3535
this.currentTheme$ = this.themeService.current.pipe(
36-
map((currentTheme) => currentTheme.className.replace('theme-', ''))
36+
map((currentTheme) => currentTheme.className.replace('kbq-theme-', ''))
3737
);
3838
this.docStates.registerHeaderScrollContainer(this.elementRef.nativeElement);
3939
}

apps/docs/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<!-- /Yandex.Metrika counter -->
107107
</head>
108108

109-
<body class="docs-app-background theme-light docs">
109+
<body class="docs-app-background kbq-theme-light docs">
110110
<docs-app />
111111
</body>
112112
</html>

apps/docs/src/main.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
.docs {
1313
@include theme-kbq.docs-typography(tokens.$tokens, tokens.$typography-config, tokens.$markdown-typography-config);
1414

15-
&.theme-light {
15+
&.kbq-theme-light {
1616
@include hljs-light-theme();
1717

1818
@include theme-kbq.kbq-docs-theme(tokens.$default-theme-light);
1919
}
2020

21-
&.theme-dark {
21+
&.kbq-theme-dark {
2222
@include hljs-dark-theme();
2323

2424
@include theme-kbq.kbq-docs-theme(tokens.$default-theme-dark);

apps/docs/src/styles/_docsearch.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
--docsearch-footer-shadow: none;
264264
}
265265

266-
body.theme-dark {
266+
body.kbq-theme-dark {
267267
--docsearch-highlight-color: inherit;
268268
--docsearch-icon-color: #{$dark-icon-contrast-fade};
269269
--docsearch-text-color: #{$dark-foreground-contrast};

docs/guides/theming-2.0.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,26 @@
6060
- [button](/packages/components/button/button-tokens.scss)
6161
- [button-toggle](/packages/components/button-toggle/button-toggle-tokens.scss)
6262
- [checkbox,pseudo-checkbox](/packages/components/checkbox/checkbox-tokens.scss)
63+
- [code-block](/packages/components/code-block/code-block-tokens.scss)
6364
- [datepicker](/packages/components/datepicker/datepicker-tokens.scss)
65+
- [description-list](/packages/components/dl/dl-tokens.scss)
6466
- [divider](/packages/components/divider/divider-tokens.scss)
6567
- [dropdown](/packages/components/dropdown/dropdown-tokens.scss)
68+
- [empty-state](/packages/components/empty-state/empty-state-tokens.scss)
69+
- [file-upload](/packages/components/file-upload/file-upload-tokens.scss)
6670
- [form-field](/packages/components/form-field/form-field-tokens.scss)
6771
- [hint](/packages/components/form-field/hint-tokens.scss)
6872
- [icon](/packages/components/icon/icon-tokens.scss)
6973
- [icon-button](/packages/components/icon/icon-button-tokens.scss)
7074
- [icon-item](/packages/components/icon/icon-item-tokens.scss)
7175
- [input](/packages/components/input/input-tokens.scss)
7276
- [link](/packages/components/link/link-tokens.scss)
77+
- [table](/packages/components/table/table-tokens.scss)
7378
- [textarea](/packages/components/textarea/textarea-tokens.scss)
79+
- [toast](/packages/components/toast/toast-tokens.scss)
80+
- [toggle](/packages/components/toggle/toggle-tokens.scss)
81+
- [tooltip](/packages/components/tooltip/tooltip-tokens.scss)
82+
- [tree-select](/packages/components/tree-select/tree-select-tokens.scss)
7483

7584
### Откуда теперь брать значения дизайн-токенов для компонентов?
7685

docs/guides/theming.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ $dark: theming.kbq-dark-theme($tokens);
164164
@include theme-kbq.app-typography(tokens.$tokens, tokens.$typography-config, tokens.$markdown-typography-config);
165165

166166
/* selectors the same as in theme.service.ts */
167-
&.theme-light {
167+
&.kbq-theme-light {
168168
@include theme-kbq.app-theme(tokens.$light);
169169
}
170170

171-
&.theme-dark {
171+
&.kbq-theme-dark {
172172
@include theme-kbq.app-theme(tokens.$dark);
173173
}
174174
}
@@ -205,7 +205,7 @@ $dark: theming.kbq-dark-theme($tokens);
205205
href="favicon.ico"
206206
/>
207207
</head>
208-
<body class="theme-light kbq">
208+
<body class="kbq-theme-light kbq">
209209
<app-root></app-root>
210210
</body>
211211
</html>

packages/components-dev/input/template.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
От 8 до 15 символов
3333
</kbq-password-hint>
3434

35-
<kbq-password-hint [rule]="passwordRules.UpperLatin">Заглавная латинская буква</kbq-password-hint>
35+
@if (true) {
36+
<kbq-password-hint [rule]="passwordRules.UpperLatin">Заглавная латинская буква</kbq-password-hint>
37+
}
3638

3739
<kbq-password-hint [rule]="passwordRules.LowerLatin">Строчная латинская буква</kbq-password-hint>
3840

packages/components/badge/badge-tokens.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
--kbq-badge-outline-fade-on-theme-icon: hsla(216, 100%, 50%, 100%);
101101
--kbq-badge-outline-fade-on-contrast-background: transparent;
102102
--kbq-badge-outline-fade-on-contrast-color: hsla(229, 15%, 15%, 100%);
103-
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 80%, 100%);
103+
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 70%, 100%);
104104
--kbq-badge-outline-fade-on-contrast-caption: hsla(229, 15%, 15%, 100%);
105105
--kbq-badge-outline-fade-on-contrast-icon: hsla(229, 15%, 60%, 100%);
106106
--kbq-badge-outline-fade-on-success-background: transparent;

0 commit comments

Comments
 (0)