From 1000d1964a507ceb43a5e2ef432511f1881846d2 Mon Sep 17 00:00:00 2001 From: Alex Inkin Date: Wed, 10 Apr 2024 21:06:07 +0800 Subject: [PATCH] refactor(core)!: drop `Mode` directive (#7191) Co-authored-by: Vladimir Potekhin --- .../components/axes/axes.component.ts | 15 +-- .../components/axes/axes.style.less | 32 ----- .../pie-chart/pie-chart.component.ts | 4 +- .../input-card-grouped.component.ts | 5 - .../input-card-grouped.style.less | 11 +- .../components/demo/demo.component.ts | 33 ++--- .../addon-doc/components/demo/demo.module.ts | 6 +- .../addon-doc/components/demo/demo.style.less | 33 ++--- .../components/demo/demo.template.html | 104 ++-------------- .../documentation/documentation.module.ts | 2 - .../components/main/main.component.ts | 33 +---- .../addon-doc/components/main/main.module.ts | 4 - .../addon-doc/components/main/main.style.less | 21 ++-- .../components/main/main.template.html | 7 +- .../navigation/navigation.component.ts | 12 +- .../navigation/navigation.module.ts | 2 - .../navigation/navigation.template.html | 5 +- projects/addon-doc/interfaces/demo-params.ts | 2 +- projects/addon-doc/services/index.ts | 4 +- .../addon-doc/services/theme-dark.options.ts | 5 + .../addon-doc/services/theme-dark.service.ts | 34 +++++ .../addon-doc/services/theme-night.options.ts | 7 -- .../addon-doc/services/theme-night.service.ts | 45 ------- projects/addon-doc/tokens/doc-icons.ts | 8 +- projects/addon-doc/tokens/i18n.ts | 3 +- .../components/preview/preview.template.html | 2 +- .../preview/zoom/preview-zoom.template.html | 4 +- .../table/directives/table.directive.ts | 3 - .../table/providers/table.providers.ts | 2 - .../components/table/td/td.style.less | 2 +- .../components/table/th/th.style.less | 6 +- .../table-bars-host/table-bars-host.module.ts | 4 +- .../table-bars-host.template.html | 3 +- projects/cdk/abstract/interactive.ts | 3 +- projects/cdk/abstract/theme-switcher.ts | 2 + .../cdk/tokens/focusable-item-accessor.ts | 6 + .../core/components/error/error.component.ts | 11 +- .../core/components/error/error.style.less | 4 - .../core/components/error/error.template.html | 1 - projects/core/components/index.ts | 1 - .../core/components/label/label.component.ts | 11 -- .../core/components/label/label.style.less | 4 - .../value-decoration.style.less | 8 -- projects/core/components/root/root.style.less | 14 ++- projects/core/components/theme-night/index.ts | 2 - .../components/theme-night/ng-package.json | 5 - .../theme-night/theme-night.component.ts | 11 -- .../theme-night/theme-night.module.ts | 9 -- .../theme-night/theme-night.style.less | 58 --------- .../components/tooltip/tooltip.component.ts | 19 +-- .../directives/dropdown/dropdown.component.ts | 12 +- .../directives/dropdown/dropdown.style.less | 8 -- .../core/directives/hint/hint.component.ts | 6 +- .../core/directives/hint/hint.directive.ts | 2 +- projects/core/directives/hint/hint.style.less | 6 +- projects/core/directives/index.ts | 1 - projects/core/directives/mode/index.ts | 2 - .../core/directives/mode/mode.directive.ts | 11 -- projects/core/directives/mode/mode.module.ts | 9 -- projects/core/directives/mode/ng-package.json | 5 - projects/core/directives/wrapper/README.md | 2 - .../directives/wrapper/wrapper.directive.ts | 12 +- projects/core/providers/index.ts | 1 - projects/core/providers/mode.provider.ts | 27 ---- ...theme.service.ts => dark-theme.service.ts} | 6 +- projects/core/services/index.ts | 2 +- ...ice.spec.ts => dark-theme.service.spec.ts} | 8 +- projects/core/styles/mixins/textfield.less | 31 +---- projects/core/styles/mixins/textfield.scss | 30 ----- .../core/styles/theme/appearance/glass.less | 2 +- .../styles/theme/appearance/opposite.less | 2 +- projects/core/styles/theme/variables.less | 5 +- projects/core/styles/theme/wrapper/glass.less | 3 +- projects/core/styles/theme/wrapper/icon.less | 3 +- projects/core/styles/theme/wrapper/mono.less | 3 +- .../core/styles/theme/wrapper/opposite.less | 3 +- .../core/styles/theme/wrapper/outline.less | 27 +--- .../theme/wrapper/secondary-destructive.less | 13 -- .../core/styles/theme/wrapper/secondary.less | 48 ------- projects/core/styles/theme/wrapper/table.less | 6 - .../core/styles/theme/wrapper/textfield.less | 25 +--- projects/core/tokens/index.ts | 1 - projects/core/tokens/mode.ts | 9 -- projects/core/types/brightness.ts | 4 + .../utils/miscellaneous/is-editing-key.ts | 2 +- .../tests/addon-doc/navigation.spec.ts | 4 +- .../tests/core/button/button.spec.ts | 6 +- .../tests/core/calendars/calendars.spec.ts | 10 +- .../tests/core/hint/hint.spec.ts | 6 +- .../tests/demo/get-demo-paths.ts | 1 - .../tests/kit/tabs/tabs.spec.ts | 5 +- .../demo/src/modules/app/app.component.ts | 7 +- projects/demo/src/modules/app/app.routes.ts | 31 +---- .../customization/customization.component.ts | 117 ------------------ .../app/customization/customization.module.ts | 22 ---- .../customization/customization.providers.ts | 37 ------ .../customization/customization.style.less | 3 - .../customization/customization.template.html | 68 ---------- projects/demo/src/modules/app/demo-routes.ts | 4 +- projects/demo/src/modules/app/pages.ts | 18 +-- .../charts/bar-chart/examples/2/index.ts | 4 +- .../modules/components/abstract/control.ts | 2 +- .../src/modules/components/abstract/hint.ts | 2 +- .../inherited-documentation.component.ts | 2 +- .../components/alert/examples/2/index.html | 12 +- .../alert-example/alert-example.component.ts | 4 +- .../alert-example/alert-example.template.html | 40 +++--- .../alert-example-with-data.component.ts | 15 +-- .../alert-example-with-data.template.html | 8 +- .../components/carousel/carousel.module.ts | 2 - .../components/carousel/examples/4/index.html | 6 +- .../modules/components/group/group.module.ts | 2 - .../input-card-grouped.template.html | 5 +- .../input-password/examples/2/index.html | 2 +- .../components/input/examples/5/index.html | 18 +-- .../components/input/examples/5/index.less | 4 - .../components/input/input.component.ts | 3 - .../modules/components/input/input.module.ts | 2 - .../components/input/input.template.html | 10 -- .../components/link/examples/3/index.html | 2 +- .../notification/examples/1/index.html | 2 +- .../notification/examples/3/index.html | 30 +---- .../notification/notification.module.ts | 2 - .../primitive-textfield.component.ts | 2 +- .../primitive-textfield.module.ts | 4 - .../scrollbar/examples/5/style.less | 2 +- .../scrollbar/examples/5/template.html | 2 +- .../components/scrollbar/scrollbar.module.ts | 2 - .../components/slider/examples/6/index.html | 6 +- .../components/slider/slider.module.ts | 2 - .../swipe-action/examples/2/index.html | 1 - .../components/tabs/examples/3/index.html | 3 +- .../modules/components/tabs/tabs.module.ts | 2 - .../components/tag/examples/2/index.html | 10 +- .../src/modules/components/tag/tag.module.ts | 3 +- .../examples/import/import-module.md | 15 --- .../examples/import/insert-component.md | 12 -- .../examples/import/insert-template.md | 7 -- .../theme-night/theme-night.component.ts | 19 --- .../theme-night/theme-night.module.ts | 17 --- .../theme-night/theme-night.template.html | 61 --------- .../theme-switcher/examples/1/index.html | 19 --- .../theme-switcher/examples/1/index.ts | 13 -- .../examples/elderly/elderly.component.ts | 12 -- .../examples/elderly/elderly.style.less | 14 --- .../theme-switcher.component.ts | 17 --- .../theme-switcher/theme-switcher.module.ts | 31 ----- .../theme-switcher/theme-switcher.style.less | 33 ----- .../theme-switcher.template.html | 34 ----- .../components/tooltip/examples/2/index.html | 3 +- .../components/tooltip/tooltip.module.ts | 2 - .../customization/variables/index.html | 18 --- .../modules/customization/wrapper/index.html | 13 -- .../modules/customization/wrapper/index.ts | 3 - .../hint-manual/examples/1/index.html | 20 +-- .../hint-manual/hint-manual.module.ts | 8 +- .../hint-pointer/hint-pointer.module.ts | 3 +- .../directives/hint/examples/1/index.html | 2 +- .../directives/media/examples/2/index.html | 8 +- .../modules/directives/media/media.module.ts | 3 +- .../mode/examples/import/import-module.md | 14 --- .../mode/examples/import/insert-template.md | 3 - .../modules/directives/mode/mode.component.ts | 19 --- .../modules/directives/mode/mode.module.ts | 26 ---- .../directives/mode/mode.template.html | 66 ---------- .../{mode => theme}/examples/1/index.html | 4 +- .../{mode => theme}/examples/1/index.less | 1 + .../{mode => theme}/examples/1/index.ts | 9 +- .../src/modules/directives/theme/index.html | 20 +++ .../src/modules/directives/theme/index.ts | 11 ++ .../card-large/examples/11/index.html | 7 +- .../experimental/cell/examples/6/index.html | 2 +- .../surface/examples/7/index.html | 16 +-- .../surface/examples/7/index.less | 3 + .../experimental/surface/surface.module.ts | 2 - .../experimental/tooltip/tooltip.module.ts | 2 - .../demo/src/modules/icons/icons.component.ts | 10 -- .../themes/bootstrap/bootstrap.component.ts | 12 -- .../themes/bootstrap/bootstrap.style.less | 102 --------------- .../themes/material/material.component.ts | 12 -- .../themes/material/material.style.less | 104 ---------------- .../demo/src/modules/themes/themes.module.ts | 10 -- .../components/navigation/aside.component.ts | 2 +- .../components/navigation/header.component.ts | 2 +- .../components/tooltip/tooltip.component.ts | 19 +-- .../accordion-item.component.ts | 7 +- .../accordion-item/accordion-item.style.less | 59 +-------- .../breadcrumbs/breadcrumbs.component.ts | 4 +- .../kit/components/filter/filter.module.ts | 2 - .../components/filter/filter.template.html | 1 - .../input-password.component.ts | 17 +-- .../input-tag/input-tag.component.ts | 15 +-- .../components/input-tag/input-tag.options.ts | 2 +- .../components/input-tag/input-tag.style.less | 2 +- .../input-tag/input-tag.template.html | 2 +- .../test/input-tag-no-mode.component.spec.ts | 58 --------- .../pagination/pagination.component.ts | 8 +- .../progress-bar/progress-bar.component.less | 4 - .../progress-bar/progress-bar.component.ts | 15 +-- .../progress-circle.component.ts | 15 +-- .../progress-circle.style.less | 4 - projects/kit/components/push/index.ts | 1 - .../kit/components/push/push.component.ts | 3 +- .../kit/components/push/push.directive.ts | 29 ----- projects/kit/components/push/push.module.ts | 15 +-- projects/kit/components/tag/tag.component.ts | 13 +- projects/kit/components/tag/tag.style.less | 33 ++--- .../components/textarea/textarea.component.ts | 5 - .../components/textarea/textarea.style.less | 16 --- .../directives/skeleton/skeleton.style.less | 2 +- 210 files changed, 373 insertions(+), 2350 deletions(-) create mode 100644 projects/addon-doc/services/theme-dark.options.ts create mode 100644 projects/addon-doc/services/theme-dark.service.ts delete mode 100644 projects/addon-doc/services/theme-night.options.ts delete mode 100644 projects/addon-doc/services/theme-night.service.ts delete mode 100644 projects/core/components/theme-night/index.ts delete mode 100644 projects/core/components/theme-night/ng-package.json delete mode 100644 projects/core/components/theme-night/theme-night.component.ts delete mode 100644 projects/core/components/theme-night/theme-night.module.ts delete mode 100644 projects/core/components/theme-night/theme-night.style.less delete mode 100644 projects/core/directives/mode/index.ts delete mode 100644 projects/core/directives/mode/mode.directive.ts delete mode 100644 projects/core/directives/mode/mode.module.ts delete mode 100644 projects/core/directives/mode/ng-package.json delete mode 100644 projects/core/providers/mode.provider.ts rename projects/core/services/{night-theme.service.ts => dark-theme.service.ts} (69%) rename projects/core/services/test/{night-theme.service.spec.ts => dark-theme.service.spec.ts} (84%) delete mode 100644 projects/core/tokens/mode.ts delete mode 100644 projects/demo/src/modules/app/customization/customization.component.ts delete mode 100644 projects/demo/src/modules/app/customization/customization.module.ts delete mode 100644 projects/demo/src/modules/app/customization/customization.providers.ts delete mode 100644 projects/demo/src/modules/app/customization/customization.style.less delete mode 100644 projects/demo/src/modules/app/customization/customization.template.html delete mode 100644 projects/demo/src/modules/components/theme-night/examples/import/import-module.md delete mode 100644 projects/demo/src/modules/components/theme-night/examples/import/insert-component.md delete mode 100644 projects/demo/src/modules/components/theme-night/examples/import/insert-template.md delete mode 100644 projects/demo/src/modules/components/theme-night/theme-night.component.ts delete mode 100644 projects/demo/src/modules/components/theme-night/theme-night.module.ts delete mode 100644 projects/demo/src/modules/components/theme-night/theme-night.template.html delete mode 100644 projects/demo/src/modules/components/theme-switcher/examples/1/index.html delete mode 100644 projects/demo/src/modules/components/theme-switcher/examples/1/index.ts delete mode 100644 projects/demo/src/modules/components/theme-switcher/examples/elderly/elderly.component.ts delete mode 100644 projects/demo/src/modules/components/theme-switcher/examples/elderly/elderly.style.less delete mode 100644 projects/demo/src/modules/components/theme-switcher/theme-switcher.component.ts delete mode 100644 projects/demo/src/modules/components/theme-switcher/theme-switcher.module.ts delete mode 100644 projects/demo/src/modules/components/theme-switcher/theme-switcher.style.less delete mode 100644 projects/demo/src/modules/components/theme-switcher/theme-switcher.template.html delete mode 100644 projects/demo/src/modules/directives/mode/examples/import/import-module.md delete mode 100644 projects/demo/src/modules/directives/mode/examples/import/insert-template.md delete mode 100644 projects/demo/src/modules/directives/mode/mode.component.ts delete mode 100644 projects/demo/src/modules/directives/mode/mode.module.ts delete mode 100644 projects/demo/src/modules/directives/mode/mode.template.html rename projects/demo/src/modules/directives/{mode => theme}/examples/1/index.html (93%) rename projects/demo/src/modules/directives/{mode => theme}/examples/1/index.less (88%) rename projects/demo/src/modules/directives/{mode => theme}/examples/1/index.ts (56%) create mode 100644 projects/demo/src/modules/directives/theme/index.html create mode 100644 projects/demo/src/modules/directives/theme/index.ts delete mode 100644 projects/demo/src/modules/themes/bootstrap/bootstrap.component.ts delete mode 100644 projects/demo/src/modules/themes/bootstrap/bootstrap.style.less delete mode 100644 projects/demo/src/modules/themes/material/material.component.ts delete mode 100644 projects/demo/src/modules/themes/material/material.style.less delete mode 100644 projects/demo/src/modules/themes/themes.module.ts delete mode 100644 projects/kit/components/input-tag/test/input-tag-no-mode.component.spec.ts delete mode 100644 projects/kit/components/push/push.directive.ts diff --git a/projects/addon-charts/components/axes/axes.component.ts b/projects/addon-charts/components/axes/axes.component.ts index 41e1a44d6448..e9692ea8a899 100644 --- a/projects/addon-charts/components/axes/axes.component.ts +++ b/projects/addon-charts/components/axes/axes.component.ts @@ -1,24 +1,13 @@ -import { - ChangeDetectionStrategy, - Component, - HostBinding, - inject, - Input, -} from '@angular/core'; +import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/core'; import {TUI_ALWAYS_DASHED, TUI_ALWAYS_SOLID} from '@taiga-ui/addon-charts/constants'; import type {TuiLineHandler, TuiLineType} from '@taiga-ui/addon-charts/types'; import {CHAR_NO_BREAK_SPACE} from '@taiga-ui/cdk'; -import {MODE_PROVIDER, TUI_MODE} from '@taiga-ui/core'; @Component({ selector: 'tui-axes', templateUrl: './axes.template.html', styleUrls: ['./axes.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [MODE_PROVIDER], - host: { - '($.data-mode.attr)': 'mode$', - }, }) export class TuiAxesComponent { @Input() @@ -60,8 +49,6 @@ export class TuiAxesComponent { @Input() public verticalLinesHandler: TuiLineHandler = TUI_ALWAYS_DASHED; - protected readonly mode$ = inject(TUI_MODE); - public get hasXLabels(): boolean { return !!this.axisXLabels.length; } diff --git a/projects/addon-charts/components/axes/axes.style.less b/projects/addon-charts/components/axes/axes.style.less index 42d4f89e5489..2dd4b2f3950d 100644 --- a/projects/addon-charts/components/axes/axes.style.less +++ b/projects/addon-charts/components/axes/axes.style.less @@ -20,14 +20,6 @@ border-width: 1px; border-color: var(--tui-base-03); isolation: isolate; - - :host[data-mode='onDark'] & { - border-color: rgba(255, 255, 255, 0.48); - } - - :host[data-mode='onLight'] & { - border-color: rgba(0, 0, 0, 0.48); - } } .t-horizontal { @@ -55,14 +47,6 @@ border-width: 1px; border-color: var(--tui-base-03); - :host[data-mode='onDark'] & { - border-color: rgba(255, 255, 255, 0.48); - } - - :host[data-mode='onLight'] & { - border-color: rgba(0, 0, 0, 0.48); - } - &_vertical { :host._centered &:first-child { flex: 1 0 1px; @@ -90,10 +74,6 @@ &_primary { transform: rotate(180deg); } - - :host[data-mode='onDark'] & { - color: var(--tui-text-02-night); - } } .t-labels-y { @@ -103,10 +83,6 @@ justify-content: space-between; color: var(--tui-text-02); - :host[data-mode='onDark'] & { - color: var(--tui-text-02-night); - } - &_primary { text-align: right; padding-right: 0.75rem; @@ -148,14 +124,6 @@ flex: 1; margin-bottom: 1.5625rem; - :host[data-mode='onDark'] & { - border-color: rgba(255, 255, 255, 0.48); - } - - :host[data-mode='onLight'] & { - border-color: rgba(0, 0, 0, 0.48); - } - &:before { content: ''; display: block; diff --git a/projects/addon-charts/components/pie-chart/pie-chart.component.ts b/projects/addon-charts/components/pie-chart/pie-chart.component.ts index 6cc1d5df1c1c..8dfdbcb73d04 100644 --- a/projects/addon-charts/components/pie-chart/pie-chart.component.ts +++ b/projects/addon-charts/components/pie-chart/pie-chart.component.ts @@ -34,9 +34,7 @@ const TRANSFORM = { templateUrl: './pie-chart.template.html', styleUrls: ['./pie-chart.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, - viewProviders: [ - tuiHintOptionsProvider({direction: 'top-right', appearance: 'onDark'}), - ], + viewProviders: [tuiHintOptionsProvider({direction: 'top-right', appearance: 'dark'})], }) export class TuiPieChartComponent { private readonly hintOptions = inject(TuiHintOptionsDirective, {optional: true}); diff --git a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts index ae7b209cd1a6..8974d42b1962 100644 --- a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts +++ b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.component.ts @@ -30,11 +30,9 @@ import { } from '@taiga-ui/cdk'; import type {TuiDataListHost} from '@taiga-ui/core'; import { - MODE_PROVIDER, TEXTFIELD_CONTROLLER_PROVIDER, TUI_COMMON_ICONS, TUI_DIGIT_REGEXP, - TUI_MODE, TUI_NON_DIGIT_REGEXP, TUI_TEXTFIELD_WATCHED_CONTROLLER, tuiAsDataListHost, @@ -59,11 +57,9 @@ const EXPIRE_COMPLETE_LENGTH = 5; // MM/YY tuiAsFocusableItemAccessor(TuiInputCardGroupedComponent), tuiAsControl(TuiInputCardGroupedComponent), tuiAsDataListHost(TuiInputCardGroupedComponent), - MODE_PROVIDER, TEXTFIELD_CONTROLLER_PROVIDER, ], host: { - '($.data-mode.attr)': 'mode$', 'data-size': 'l', }, }) @@ -126,7 +122,6 @@ export class TuiInputCardGroupedComponent separator: '/', }); - protected readonly mode$ = inject(TUI_MODE); protected readonly cardGroupedTexts$ = inject(TUI_INPUT_CARD_GROUPED_TEXTS); protected readonly controller = inject(TUI_TEXTFIELD_WATCHED_CONTROLLER); protected readonly icons = inject(TUI_COMMON_ICONS); diff --git a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.style.less b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.style.less index f3e888792f2c..ed3992cadbf5 100644 --- a/projects/addon-commerce/components/input-card-grouped/input-card-grouped.style.less +++ b/projects/addon-commerce/components/input-card-grouped/input-card-grouped.style.less @@ -13,10 +13,6 @@ width: @width-full; border-radius: var(--tui-radius-m); - &[data-mode='onDark'] { - --tui-autofill: var(--tui-autofill-night); - } - :host-context(tui-root._mobile) { width: @width-mobile; } @@ -119,12 +115,7 @@ opacity: 1; } - :host[data-mode='onDark'] &::placeholder { - color: var(--tui-text-03-night); - } - - &&&_card, - :host[data-mode='onDark'] &&&_card { + &&&_card { // @note: (&&&_) it's increasing css cascade priority &:not(.t-input_hidden), &:not(.t-input_hidden)::placeholder, diff --git a/projects/addon-doc/components/demo/demo.component.ts b/projects/addon-doc/components/demo/demo.component.ts index 1d4c8bd7ed67..3fa7311573ae 100644 --- a/projects/addon-doc/components/demo/demo.component.ts +++ b/projects/addon-doc/components/demo/demo.component.ts @@ -5,7 +5,6 @@ import { Component, ContentChild, ElementRef, - forwardRef, HostBinding, HostListener, inject, @@ -18,21 +17,17 @@ import {FormGroup} from '@angular/forms'; import type {Params, UrlTree} from '@angular/router'; import {UrlSerializer} from '@angular/router'; import type {TuiDemoParams} from '@taiga-ui/addon-doc/interfaces'; +import {TuiThemeDarkService} from '@taiga-ui/addon-doc/services'; import {TUI_DOC_DEMO_TEXTS, TUI_DOC_URL_STATE_HANDLER} from '@taiga-ui/addon-doc/tokens'; import {tuiCoerceValueIsTrue} from '@taiga-ui/addon-doc/utils'; import { - TUI_IS_MOBILE, tuiClamp, tuiCleanObject, - TuiDestroyService, tuiPure, tuiPx, TuiResizeableDirective, tuiToInteger, } from '@taiga-ui/cdk'; -import type {TuiBrightness} from '@taiga-ui/core'; -import {TuiModeDirective} from '@taiga-ui/core'; -import {Subject} from 'rxjs'; const MIN_WIDTH = 160; @@ -41,13 +36,6 @@ const MIN_WIDTH = 160; templateUrl: './demo.template.html', styleUrls: ['./demo.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, - providers: [ - TuiDestroyService, - { - provide: TuiModeDirective, - useExisting: forwardRef(() => TuiDocDemoComponent), - }, - ], }) export class TuiDocDemoComponent implements OnInit { @ViewChild(TuiResizeableDirective, {static: true}) @@ -71,12 +59,13 @@ export class TuiDocDemoComponent implements OnInit { @HostBinding('class._sticky') public sticky = true; - public mode: TuiBrightness | null = this.params.tuiMode || null; - public readonly change$ = new Subject(); - @ContentChild(TemplateRef) protected readonly template: TemplateRef> | null = null; + protected dark = tuiCoerceValueIsTrue( + this.params.darkMode ?? inject(TuiThemeDarkService).value, + ); + protected testForm?: FormGroup; protected readonly updateOnVariants = ['change', 'blur', 'submit'] as const; @@ -87,8 +76,6 @@ export class TuiDocDemoComponent implements OnInit { protected opaque = tuiCoerceValueIsTrue(this.params.sandboxOpaque ?? true); protected expanded = tuiCoerceValueIsTrue(this.params.sandboxExpanded ?? false); protected sandboxWidth = tuiToInteger(this.params.sandboxWidth); - protected readonly items: readonly TuiBrightness[] = ['onLight', 'onDark']; - protected readonly isMobile = inject(TUI_IS_MOBILE); protected readonly texts = inject(TUI_DOC_DEMO_TEXTS); public ngOnInit(): void { @@ -107,10 +94,9 @@ export class TuiDocDemoComponent implements OnInit { this.updateUrl({sandboxWidth: this.sandboxWidth}); } - protected onModeChange(mode: TuiBrightness | null): void { - this.mode = mode; - this.updateUrl({sandboxWidth: this.sandboxWidth}); - this.change$.next(); + protected onModeChange(dark: boolean): void { + this.dark = dark; + this.updateUrl({sandboxWidth: this.sandboxWidth, darkMode: this.dark}); } protected toggleDetails(): void { @@ -161,11 +147,10 @@ export class TuiDocDemoComponent implements OnInit { const {queryParams} = tree; delete queryParams.sandboxWidth; - delete queryParams.tuiMode; tree.queryParams = { ...queryParams, - ...tuiCleanObject({tuiMode: this.mode, ...params}), + ...tuiCleanObject({...params}), }; this.locationRef.go(this.urlStateHandler(tree)); diff --git a/projects/addon-doc/components/demo/demo.module.ts b/projects/addon-doc/components/demo/demo.module.ts index 1f4a84f5d29c..1a49a75cf0c3 100644 --- a/projects/addon-doc/components/demo/demo.module.ts +++ b/projects/addon-doc/components/demo/demo.module.ts @@ -1,7 +1,6 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; -import {RouterModule} from '@angular/router'; import {TuiResizerModule} from '@taiga-ui/cdk'; import { TuiButtonDirective, @@ -10,7 +9,6 @@ import { TuiGroupDirective, TuiHintModule, TuiLinkDirective, - TuiModeModule, TuiSvgModule, TuiTextfieldControllerModule, TuiTooltipModule, @@ -21,6 +19,7 @@ import { TuiChevronDirective, TuiDataListWrapperModule, TuiSelectModule, + TuiSwitchComponent, } from '@taiga-ui/kit'; import {TuiDocDemoComponent} from './demo.component'; @@ -30,14 +29,12 @@ import {TuiDocDemoComponent} from './demo.component'; CommonModule, ReactiveFormsModule, FormsModule, - RouterModule, TuiLinkDirective, TuiButtonDirective, TuiSelectModule, TuiExpandModule, TuiGroupDirective, TuiTooltipModule, - TuiModeModule, TuiCheckboxComponent, TuiSvgModule, TuiDataListWrapperModule, @@ -47,6 +44,7 @@ import {TuiDocDemoComponent} from './demo.component'; TuiResizerModule, TuiBlockDirective, TuiChevronDirective, + TuiSwitchComponent, ], declarations: [TuiDocDemoComponent], exports: [TuiDocDemoComponent], diff --git a/projects/addon-doc/components/demo/demo.style.less b/projects/addon-doc/components/demo/demo.style.less index f45c7033b5b5..0bd2c72704b2 100644 --- a/projects/addon-doc/components/demo/demo.style.less +++ b/projects/addon-doc/components/demo/demo.style.less @@ -12,10 +12,11 @@ pointer-events: none; } -.t-bg-toggle { +.t-settings { position: absolute; bottom: ~'calc(100% + 0.75rem)'; display: flex; + gap: 2rem; align-items: center; justify-content: flex-end; pointer-events: none; @@ -26,6 +27,12 @@ } } +.t-label { + display: flex; + align-items: center; + gap: 0.5rem; +} + .t-wrapper { box-shadow: var(--tui-shadow-dropdown); display: flex; @@ -35,6 +42,7 @@ min-height: 6rem; width: 100%; min-width: 10rem; + color: var(--tui-text-01); background-color: var(--tui-base-01); overflow: hidden; pointer-events: auto; @@ -52,29 +60,6 @@ -0.625rem 0; } - &.t-wrapper_dark { - background-color: @color-dark; - color: var(--tui-base-01); - } - - &.t-wrapper_gray { - background-color: @color-gray; - } - - &.t-wrapper_dark.t-wrapper_transparent { - background-image: linear-gradient(45deg, var(--tui-focus) 25%, transparent 25%), - linear-gradient(-45deg, var(--tui-focus) 25%, transparent 25%), - linear-gradient(45deg, transparent 75%, var(--tui-focus) 75%), - linear-gradient(-45deg, transparent 75%, var(--tui-focus) 75%); - } - - &.t-wrapper_gray.t-wrapper_transparent { - background-image: linear-gradient(45deg, var(--tui-base-05) 25%, transparent 25%), - linear-gradient(-45deg, var(--tui-base-05) 25%, transparent 25%), - linear-gradient(45deg, transparent 75%, var(--tui-base-05) 75%), - linear-gradient(-45deg, transparent 75%, var(--tui-base-05) 75%); - } - :host-context(tui-root._mobile) & { min-height: auto; } diff --git a/projects/addon-doc/components/demo/demo.template.html b/projects/addon-doc/components/demo/demo.template.html index 7f877fdcec17..b4c32b93961e 100644 --- a/projects/addon-doc/components/demo/demo.template.html +++ b/projects/addon-doc/components/demo/demo.template.html @@ -1,96 +1,18 @@ -
- - {{ texts[0] }} - - - tuiMode - - - - + - - - tuiMode: - -
- - - -
-
- +