Skip to content

Commit

Permalink
feat(core): Hint support 12 directions
Browse files Browse the repository at this point in the history
  • Loading branch information
waterplea authored and splincode committed Aug 1, 2022
1 parent 330dd3f commit adbbc9d
Show file tree
Hide file tree
Showing 104 changed files with 857 additions and 1,401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ export class TuiBarChartComponent {
return this.max || this.getMax(this.value, this.collapsed);
}

@tuiPure
getContentContext(index: number): TuiContextWithImplicit<number> {
return {
$implicit: index,
};
}

readonly percentMapper: TuiMapper<readonly number[], number> = (
set,
collapsed: boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,3 @@
box-shadow: 0 0 0 2px var(--tui-focus);
}
}

.t-text {
white-space: pre-wrap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
#hint="polymorpheus"
polymorpheus
>
<div
*polymorpheusOutlet="hintContent as text; context: getContentContext(index)"
class="t-text"
[textContent]="text"
></div>
<!-- TODO: Consider adding context to Hint directive -->
<ng-container *polymorpheusOutlet="hintContent as text; context: {$implicit: index}">
{{ text }}
</ng-container>
</ng-template>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@
}
}

.t-text {
white-space: pre-wrap;
}

.t-hint {
.shadow();
position: absolute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@
[style.bottom.%]="getBottom(point[1])"
></div>
<ng-template #hint>
<!-- TODO: Consider adding context to Hint directive -->
<ng-container *ngIf="hintDirective; else single">
<div
<ng-container
*polymorpheusOutlet="hintDirective.hint as text; context: getContentContext(point, index)"
class="t-text"
[textContent]="text"
></div>
>
{{ text }}
</ng-container>
</ng-container>
<ng-template #single>
<!-- TODO: Polymorpheus fix type -->
<div
<ng-container
*polymorpheusOutlet="$any(hintContent) as text; context: {$implicit: point, index: index}"
class="t-text"
[textContent]="text"
></div>
>
{{ text }}
</ng-container>
</ng-template>
</ng-template>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import {TuiHoveredModule, TuiRepeatTimesModule} from '@taiga-ui/cdk';
import {TuiPointerHintModule} from '@taiga-ui/core';
import {TuiHintModule} from '@taiga-ui/core';
import {PolymorpheusModule} from '@tinkoff/ng-polymorpheus';

import {TuiPieChartComponent} from './pie-chart.component';
Expand All @@ -13,7 +13,7 @@ import {TuiPieChartDirective} from './pie-chart.directive';
TuiRepeatTimesModule,
TuiHoveredModule,
PolymorpheusModule,
TuiPointerHintModule,
TuiHintModule,
],
declarations: [TuiPieChartComponent, TuiPieChartDirective],
exports: [TuiPieChartComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,3 @@
.t-placeholder {
fill: var(--tui-base-03);
}

.t-text {
white-space: pre-wrap;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
*tuiRepeatTimes="let index of segments.length"
fill="currentColor"
automation-id="tui-pie-chart__segment"
tuiHintPointer
tuiHintMode="onDark"
tuiHintDirection="top-right"
d=""
class="t-segment"
[attr.transform]="getTransform(index)"
[style.color]="getColor(index)"
[tuiPieChart]="segments[index]"
[tuiPointerHint]="getHint(hint)"
[tuiHint]="getHint(hint)"
(tuiHoveredChange)="onHovered($event, index)"
>
<ng-template #hint>
Expand All @@ -56,9 +57,8 @@
#template
let-index
>
<div
*polymorpheusOutlet="hintContent as text; context: {$implicit: index}"
class="t-text"
[textContent]="text"
></div>
<!-- TODO: Consider adding context to Hint directive -->
<ng-container *polymorpheusOutlet="hintContent as text; context: {$implicit: index}">
{{ text }}
</ng-container>
</ng-template>
2 changes: 0 additions & 2 deletions projects/addon-preview/components/preview/preview.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
TuiButtonModule,
TuiHintModule,
TuiLoaderModule,
TuiManualHintModule,
TuiSvgModule,
} from '@taiga-ui/core';
import {TuiSliderModule} from '@taiga-ui/kit';
Expand All @@ -31,7 +30,6 @@ import {TuiPreviewZoomComponent} from './zoom/preview-zoom.component';
TuiSliderModule,
TuiHintModule,
TuiDragModule,
TuiManualHintModule,
TuiResizeModule,
TuiSvgModule,
TuiLoaderModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<div
tuiHintMode="onDark"
tuiHintDirection="top-right"
[tuiManualHint]="hint"
[tuiManualHintShow]="!!(hintShow$ | async)"
[tuiHint]="hint"
[tuiHintManual]="!!(hintShow$ | async)"
></div>

<ng-template #hint>
Expand Down
20 changes: 20 additions & 0 deletions projects/core/abstract/abstract-driver.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Directive, Inject, Self} from '@angular/core';
import {TuiDestroyService} from '@taiga-ui/cdk';
import {Observable} from 'rxjs';
import {distinctUntilChanged, takeUntil} from 'rxjs/operators';

import {TuiDriver} from './driver';
import {TuiVehicle} from './vehicle';

@Directive()
export class AbstractTuiDriverDirective {
constructor(
@Self() @Inject(TuiDestroyService) destroy$: Observable<unknown>,
@Inject(TuiDriver) driver$: Observable<boolean>,
@Inject(TuiVehicle) vehicle: TuiVehicle,
) {
driver$.pipe(distinctUntilChanged(), takeUntil(destroy$)).subscribe(value => {
vehicle.toggle(value);
});
}
}
12 changes: 0 additions & 12 deletions projects/core/abstract/abstract-hint-options.ts

This file was deleted.

40 changes: 0 additions & 40 deletions projects/core/abstract/abstract-hint.ts

This file was deleted.

11 changes: 11 additions & 0 deletions projects/core/abstract/driver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {ExistingProvider, Type} from '@angular/core';
import {Observable} from 'rxjs';

export abstract class TuiDriver extends Observable<boolean> {}

export function tuiAsDriver(useExisting: Type<TuiDriver>): ExistingProvider {
return {
provide: TuiDriver,
useExisting,
};
}
7 changes: 5 additions & 2 deletions projects/core/abstract/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export * from './abstract-driver.directive';
export * from './abstract-dropdown';
export * from './abstract-hint';
export * from './abstract-hint-options';
export * from './abstract-textfield-host';
export * from './driver';
export * from './position-accessor';
export * from './rect-accessor';
export * from './vehicle';
15 changes: 15 additions & 0 deletions projects/core/abstract/position-accessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {ExistingProvider, Type} from '@angular/core';
import {TuiPoint} from '@taiga-ui/core/types';

export abstract class TuiPositionAccessor {
abstract getPosition(rect: ClientRect): TuiPoint;
}

export function tuiAsPositionAccessor(
useExisting: Type<TuiPositionAccessor>,
): ExistingProvider {
return {
provide: TuiPositionAccessor,
useExisting,
};
}
12 changes: 12 additions & 0 deletions projects/core/abstract/rect-accessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {ExistingProvider, Type} from '@angular/core';

export abstract class TuiRectAccessor {
abstract getClientRect(): ClientRect;
}

export function tuiAsRectAccessor(useExisting: Type<TuiRectAccessor>): ExistingProvider {
return {
provide: TuiRectAccessor,
useExisting,
};
}
12 changes: 12 additions & 0 deletions projects/core/abstract/vehicle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {ExistingProvider, Type} from '@angular/core';

export abstract class TuiVehicle {
abstract toggle(value: boolean): void;
}

export function tuiAsVehicle(useExisting: Type<TuiVehicle>): ExistingProvider {
return {
provide: TuiVehicle,
useExisting,
};
}
Loading

0 comments on commit adbbc9d

Please sign in to comment.