Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Appearance remove initial transition #9059

Merged
merged 5 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions projects/core/directives/appearance/appearance.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
afterNextRender,
ChangeDetectionStrategy,
Component,
computed,
Expand All @@ -8,6 +9,7 @@ import {
signal,
ViewEncapsulation,
} from '@angular/core';
import {tuiInjectElement} from '@taiga-ui/cdk/utils/dom';
import {tuiIsString, tuiWithStyles} from '@taiga-ui/cdk/utils/miscellaneous';
import type {TuiInteractiveState} from '@taiga-ui/core/types';

Expand All @@ -29,6 +31,7 @@ class TuiAppearanceStyles {}
standalone: true,
selector: '[tuiAppearance]',
host: {
class: 'tui-appearance-initializing',
tuiAppearance: '',
'[attr.data-appearance]': 'appearance()',
'[attr.data-state]': 'state()',
Expand All @@ -37,6 +40,8 @@ class TuiAppearanceStyles {}
},
})
export class TuiAppearance {
private readonly el = tuiInjectElement();

protected readonly nothing = tuiWithStyles(TuiAppearanceStyles);
protected readonly modes = computed((mode = this.mode()) =>
!mode || tuiIsString(mode) ? mode : mode.join(' '),
Expand All @@ -48,6 +53,17 @@ export class TuiAppearance {
public readonly focus = signal<boolean | null>(null);
public readonly mode = signal<string | readonly string[] | null>(null);

constructor() {
afterNextRender(() => {
this.el.classList.toggle(
'tui-appearance-initializing',
// Triggering reflow so there's no transition
// eslint-disable-next-line
!!this.el.offsetWidth && false,
);
});
}

@Input()
public set tuiAppearance(appearance: TuiAppearanceOptions['appearance']) {
this.appearance.set(appearance);
Expand Down
4 changes: 4 additions & 0 deletions projects/core/styles/components/appearance.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
outline: 0.125rem solid transparent;
outline-offset: -0.125rem;

&.tui-appearance-initializing {
transition: none !important;
}

.appearance-focus({
outline-color: var(--tui-border-focus);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,13 @@
<button
iconStart="@tui.pencil"
tuiAsideItem
tuiOption
type="button"
>
Write
</button>
<button
iconStart="@tui.pie-chart"
tuiAsideItem
tuiOption
type="button"
[tuiDropdown]="submenu"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '@taiga-ui/core/directives/dropdown';
import {TuiIcons} from '@taiga-ui/core/directives/icons';
import {TUI_COMMON_ICONS, TUI_ICON_END} from '@taiga-ui/core/tokens';
import {TUI_CHEVRON, TuiChevron} from '@taiga-ui/kit/directives/chevron';

import {TuiHintAsideDirective} from './hint-aside.directive';

Expand Down Expand Up @@ -60,6 +61,10 @@ function provideIcon(): FactoryProvider {
return {
provide: TUI_ICON_END,
useFactory: (): string => {
if (inject(TuiChevron, {optional: true, self: true})) {
return inject(TUI_CHEVRON);
}

const {check, more} = inject(TUI_COMMON_ICONS);
const active =
inject(TuiDataListComponent, {optional: true}) &&
Expand Down
Loading