Skip to content

Commit

Permalink
refactor!: remove deprecated core-enums, TuiColor, colorFallback, DEF…
Browse files Browse the repository at this point in the history
…AULT_COLORS, TuiColorHandler
  • Loading branch information
vladimirpotekhin authored and splincode committed Jul 21, 2022
1 parent dc5c30b commit 3097b4b
Show file tree
Hide file tree
Showing 128 changed files with 15,921 additions and 9,929 deletions.
24,687 changes: 15,638 additions & 9,049 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {ChangeDetectionStrategy, Component, Inject, Input} from '@angular/core';
import {TUI_DEFAULT_COLOR_HANDLER} from '@taiga-ui/addon-charts/constants';
import {TuiColorHandler} from '@taiga-ui/addon-charts/types';
import {
sum,
TuiContextWithImplicit,
Expand All @@ -9,7 +7,7 @@ import {
TuiMapper,
tuiPure,
} from '@taiga-ui/cdk';
import {TuiHintModeT, TuiSizeL, TuiSizeS} from '@taiga-ui/core';
import {TuiHintMode, TuiSizeL, TuiSizeS} from '@taiga-ui/core';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -38,10 +36,6 @@ export class TuiBarChartComponent {
@tuiDefaultProp()
max = NaN;

@Input()
@tuiDefaultProp()
colorHandler: TuiColorHandler = TUI_DEFAULT_COLOR_HANDLER;

@Input()
@tuiDefaultProp()
size: TuiSizeS | TuiSizeL | null = 'm';
Expand All @@ -56,7 +50,7 @@ export class TuiBarChartComponent {

@Input()
@tuiDefaultProp()
hintMode: TuiHintModeT | null = null;
hintMode: TuiHintMode | null = null;

constructor(@Inject(TuiIdService) idService: TuiIdService) {
this.autoIdString = idService.generate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
[value]="set"
[size]="size"
[collapsed]="collapsed"
[colorHandler]="colorHandler"
></tui-bar-set>
</div>
<ng-template
Expand Down
19 changes: 4 additions & 15 deletions projects/addon-charts/components/bar-set/bar-set.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import {ChangeDetectionStrategy, Component, Inject, Input} from '@angular/core';
import {DomSanitizer, SafeValue} from '@angular/platform-browser';
import {TUI_DEFAULT_COLOR_HANDLER} from '@taiga-ui/addon-charts/constants';
import {TuiColorHandler} from '@taiga-ui/addon-charts/types';
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
import {SafeValue} from '@angular/platform-browser';
import {tuiDefaultProp, tuiPure} from '@taiga-ui/cdk';
import {colorFallback, TuiSizeL, TuiSizeS} from '@taiga-ui/core';
import {TuiSizeL, TuiSizeS} from '@taiga-ui/core';

const PERCENT = 100;
const EMPTY_ARRAY: readonly number[] = [];
const FILLER_ARRAY: readonly number[] = [1];

// TODO: 3.0 Remove sanitizer when Angular version is bumped
@Component({
selector: 'tui-bar-set',
templateUrl: './bar-set.template.html',
Expand All @@ -21,10 +18,6 @@ export class TuiBarSetComponent {
@tuiDefaultProp()
value: readonly number[] = [];

@Input()
@tuiDefaultProp()
colorHandler: TuiColorHandler = TUI_DEFAULT_COLOR_HANDLER;

@Input()
@tuiDefaultProp()
size: TuiSizeS | TuiSizeL | null = 'm';
Expand All @@ -33,8 +26,6 @@ export class TuiBarSetComponent {
@tuiDefaultProp()
collapsed = false;

constructor(@Inject(DomSanitizer) private readonly sanitizer: DomSanitizer) {}

get computedValue(): readonly number[] {
return this.collapsed ? FILLER_ARRAY : this.value;
}
Expand All @@ -52,9 +43,7 @@ export class TuiBarSetComponent {
}

getColor(index: number): SafeValue {
return this.sanitizer.bypassSecurityTrustStyle(
`var(--tui-chart-${index}, ${colorFallback(this.colorHandler(index))})`,
);
return `var(--tui-chart-${index}`;
}

@tuiPure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
[style.background]="getColor(index)"
[value]="computedSegments"
[size]="computedSize"
[colorHandler]="colorHandler"
></tui-bar>
</ng-template>
29 changes: 6 additions & 23 deletions projects/addon-charts/components/bar/bar.component.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import {
ChangeDetectionStrategy,
Component,
HostBinding,
Inject,
Input,
} from '@angular/core';
import {DomSanitizer, SafeValue} from '@angular/platform-browser';
import {TUI_DEFAULT_COLOR_HANDLER} from '@taiga-ui/addon-charts/constants';
import {TuiColorHandler} from '@taiga-ui/addon-charts/types';
import {sum, tuiDefaultProp, tuiPure} from '@taiga-ui/cdk';
import {colorFallback, TuiSizeL, TuiSizeS} from '@taiga-ui/core';
import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/core';
import {SafeValue} from '@angular/platform-browser';
import {tuiDefaultProp, tuiPure, tuiSum} from '@taiga-ui/cdk';
import {TuiSizeL, TuiSizeS} from '@taiga-ui/core';

// TODO: 3.0 Remove sanitizer when Angular version is bumped
@Component({
selector: 'tui-bar',
templateUrl: './bar.template.html',
Expand All @@ -23,29 +14,21 @@ export class TuiBarComponent {
@tuiDefaultProp()
value: readonly number[] = [];

@Input()
@tuiDefaultProp()
colorHandler: TuiColorHandler = TUI_DEFAULT_COLOR_HANDLER;

@Input()
@HostBinding('attr.data-size')
@tuiDefaultProp()
size: TuiSizeS | TuiSizeL = 'm';

constructor(@Inject(DomSanitizer) private readonly sanitizer: DomSanitizer) {}

getHeight(value: number): number {
return (100 * value) / this.getSum(this.value);
}

getColor(index: number): SafeValue {
return this.sanitizer.bypassSecurityTrustStyle(
`var(--tui-chart-${index}, ${colorFallback(this.colorHandler(index))})`,
);
return `var(--tui-chart-${index}`;
}

@tuiPure
private getSum(value: readonly number[]): number {
return sum(...value);
return tuiSum(...value);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import {ChangeDetectionStrategy, Component, HostBinding, Input} from '@angular/core';
import {tuiDefaultProp} from '@taiga-ui/cdk';
import {colorFallback, TuiSizeS} from '@taiga-ui/core';
import {TuiSizeS} from '@taiga-ui/core';

// TODO: 3.0 Remove fallback
@Component({
selector: 'tui-legend-item',
templateUrl: './legend-item.template.html',
Expand Down Expand Up @@ -37,6 +36,6 @@ export class TuiLegendItemComponent {
return null;
}

return this.color.startsWith('var(') ? this.color : colorFallback(this.color);
return this.color;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
width: 0.5rem;
height: 0.5rem;
border-radius: 100%;
background: var(--tui-primary);

:host._disabled & {
background: var(--tui-base-04);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
>
<div class="t-wrapper">
<ng-content select="tui-primitive-checkbox"></ng-content>
<span class="t-dot"></span>
<span
class="t-dot"
[style.backgroundColor]="color || 'var(--tui-primary)'"
></span>
<span class="t-text">{{ text }}</span>
<ng-content></ng-content>
</div>
Expand Down
20 changes: 5 additions & 15 deletions projects/addon-charts/components/pie-chart/pie-chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import {
Input,
Output,
} from '@angular/core';
import {DomSanitizer, SafeValue} from '@angular/platform-browser';
import {TUI_DEFAULT_COLOR_HANDLER} from '@taiga-ui/addon-charts/constants';
import {TuiColorHandler} from '@taiga-ui/addon-charts/types';
import {SafeValue} from '@angular/platform-browser';
import {
sum,
TuiContextWithImplicit,
tuiDefaultProp,
TuiIdService,
tuiPure,
tuiSum,
} from '@taiga-ui/cdk';
import {colorFallback, TuiSizeXL, TuiSizeXS} from '@taiga-ui/core';
import {TuiSizeXL, TuiSizeXS} from '@taiga-ui/core';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

const RADII = {
Expand All @@ -36,7 +34,6 @@ const TRANSFORM = {
xl: 1.08,
};

// TODO: 3.0 Remove sanitizer when Angular version is bumped
@Component({
selector: 'tui-pie-chart',
templateUrl: './pie-chart.template.html',
Expand All @@ -55,10 +52,6 @@ export class TuiPieChartComponent {
@tuiDefaultProp()
size: TuiSizeXS | TuiSizeXL = 'm';

@Input()
@tuiDefaultProp()
colorHandler: TuiColorHandler = TUI_DEFAULT_COLOR_HANDLER;

@Input()
@tuiDefaultProp()
hintContent: PolymorpheusContent<TuiContextWithImplicit<number>> = '';
Expand All @@ -77,7 +70,6 @@ export class TuiPieChartComponent {
constructor(
@Inject(TuiIdService) idService: TuiIdService,
@Inject(Location) private readonly locationRef: Location,
@Inject(DomSanitizer) private readonly sanitizer: DomSanitizer,
) {
this.autoIdString = idService.generate();
}
Expand Down Expand Up @@ -124,14 +116,12 @@ export class TuiPieChartComponent {
}

getColor(index: number): SafeValue {
return this.sanitizer.bypassSecurityTrustStyle(
`var(--tui-chart-${index}, ${colorFallback(this.colorHandler(index))})`,
);
return `var(--tui-chart-${index}`;
}

@tuiPure
private getSum(value: readonly number[]): number {
return sum(...value);
return tuiSum(...value);
}

@tuiPure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import {
Input,
Output,
} from '@angular/core';
import {TUI_DEFAULT_COLOR_HANDLER} from '@taiga-ui/addon-charts/constants';
import {TuiRingChartContext} from '@taiga-ui/addon-charts/interfaces';
import {TuiColorHandler} from '@taiga-ui/addon-charts/types';
import {tuiDefaultProp} from '@taiga-ui/cdk';
import {TuiSizeS, TuiSizeXL} from '@taiga-ui/core';
import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus';

// TODO: 3.0 Refactor to use ng-content
@Component({
selector: 'tui-ring-chart',
templateUrl: './ring-chart.template.html',
Expand All @@ -30,16 +25,6 @@ export class TuiRingChartComponent {
@tuiDefaultProp()
size: TuiSizeS | TuiSizeXL = 'm';

/** @deprecated */
@Input()
@tuiDefaultProp()
colorHandler: TuiColorHandler = TUI_DEFAULT_COLOR_HANDLER;

/** @deprecated */
@Input()
@tuiDefaultProp()
content: PolymorpheusContent<TuiRingChartContext> = '';

@Input()
@tuiDefaultProp()
masked = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
<div class="t-content">
<div
*ngIf="content; else ngContent"
polymorpheus-outlet
automation-id="tui-ring-chart__content"
class="t-wrapper"
[content]="content"
[context]="{$implicit: activeItemIndex, value: value}"
></div>
<ng-template #ngContent>
<div class="t-wrapper">
<ng-content></ng-content>
</div>
</ng-template>
<div class="t-wrapper">
<ng-content></ng-content>
</div>
</div>

<tui-pie-chart
[masked]="true"
[value]="value"
[colorHandler]="colorHandler"
[size]="size"
[activeItemIndex]="activeItemIndex"
(activeItemIndexChange)="onActiveItemIndexChange($event)"
Expand Down
6 changes: 0 additions & 6 deletions projects/addon-charts/constants/default-color-handler.ts

This file was deleted.

31 changes: 0 additions & 31 deletions projects/addon-charts/constants/default-colors.ts

This file was deleted.

2 changes: 0 additions & 2 deletions projects/addon-charts/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from './default-color-handler';
export * from './default-colors';
export * from './line-handlers';
4 changes: 0 additions & 4 deletions projects/addon-charts/types/color-handler.ts

This file was deleted.

1 change: 0 additions & 1 deletion projects/addon-charts/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './color-handler';
export * from './line-handler';
export * from './line-type';
4 changes: 2 additions & 2 deletions projects/addon-commerce/components/money/money-options.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {InjectionToken, ValueProvider} from '@angular/core';
import {TuiCurrency} from '@taiga-ui/addon-commerce/enums';
import {TuiCurrencyVariants, TuiMoneySign} from '@taiga-ui/addon-commerce/types';
import {TuiDecimalT} from '@taiga-ui/core';
import {TuiDecimal} from '@taiga-ui/core';

export interface TuiMoneyOptions {
readonly decimal: TuiDecimalT;
readonly decimal: TuiDecimal;
readonly currency: TuiCurrencyVariants;
readonly sign: TuiMoneySign;
readonly colored: boolean;
Expand Down
4 changes: 2 additions & 2 deletions projects/addon-commerce/components/money/money.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
TuiMoneySignSymbol,
} from '@taiga-ui/addon-commerce/types';
import {CHAR_EN_DASH, CHAR_PLUS, tuiDefaultProp} from '@taiga-ui/cdk';
import {TuiDecimalT} from '@taiga-ui/core';
import {TuiDecimal} from '@taiga-ui/core';

import {TUI_MONEY_OPTIONS, TuiMoneyOptions} from './money-options';
import {tuiFormatSignSymbol} from './utils/format-sign-symbol';
Expand All @@ -29,7 +29,7 @@ export class TuiMoneyComponent {

@Input()
@tuiDefaultProp()
decimal: TuiDecimalT = this.options.decimal;
decimal: TuiDecimal = this.options.decimal;

@Input()
@tuiDefaultProp()
Expand Down
Loading

0 comments on commit 3097b4b

Please sign in to comment.