Skip to content

Commit

Permalink
chore: change data and kebab-case
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaZhem committed Jul 19, 2024
1 parent d3233c9 commit 6817498
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
<div class="flex">
<tui-axes
class="axes"
[axisXLabels]="costService.costData.labelsX"
[axisYLabels]="costService.costData.labelsY"
[axisXLabels]="costService.labelsX"
[axisYLabels]="costService.labelsY"
>
<tui-bar-chart
[max]="10000"
[tuiHintContent]="costService.hint"
[value]="costService.costData.value"
[tuiHintContent]="hint"
[value]="costService.value"
/>
</tui-axes>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {CommonModule} from '@angular/common';
import {ChangeDetectionStrategy, Component, inject} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {TuiAxes, TuiBarChart} from '@taiga-ui/addon-charts';
import {TuiAppearance, TuiHint} from '@taiga-ui/core';
import type {TuiContext} from '@taiga-ui/cdk';
import {TuiAppearance, tuiFormatNumber, TuiHint} from '@taiga-ui/core';
import {TuiDataListWrapper} from '@taiga-ui/kit';
import {TuiCardLarge} from '@taiga-ui/layout';
import {TuiSelectModule} from '@taiga-ui/legacy';
Expand All @@ -29,5 +30,9 @@ import {CostService} from './cost.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CostComponent {
protected costService = inject(CostService);
protected costService = inject(CostService).costData;
protected hint = ({$implicit}: TuiContext<number>): string =>
this.costService.value
.reduce((result, set) => `${result}$${tuiFormatNumber(set[$implicit])}\n`, '')
.trim();
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {Injectable} from '@angular/core';
import type {TuiContext} from '@taiga-ui/cdk';
import {tuiFormatNumber} from '@taiga-ui/core';

interface CostData {
value: number[][];
labelsX: string[];
labelsY: string[];
readonly value: number[][];
readonly labelsX: string[];
readonly labelsY: string[];
}

const INITIAL_DATA: CostData = {
Expand All @@ -22,8 +20,4 @@ const INITIAL_DATA: CostData = {
})
export class CostService {
public readonly costData = INITIAL_DATA;
public hint = ({$implicit}: TuiContext<number>): string =>
this.costData.value
.reduce((result, set) => `${result}$${tuiFormatNumber(set[$implicit])}\n`, '')
.trim();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
[formControl]="control"
[style.display]="'none'"
/>
{{ lightingService.lightingData[ind].room }}
{{ lightingService[ind].room }}
</div>
<tui-icon
alt=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {LightingService} from './lighting.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LightingComponent {
protected lightingService = inject(LightingService);
protected lightingService = inject(LightingService).lightingData;
protected lightingForm = new FormArray(
this.lightingService.lightingData.map((item) => new FormControl(item.state)),
this.lightingService.map((item) => new FormControl(item.state)),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*ngFor="let control of safetyForm['controls']; let ind = index"
tuiBlock
>
{{ safetyService.safetyData[ind].name }}
{{ safetyService[ind].name }}
<input
tuiCheckbox
type="checkbox"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {SafetyService} from './safety.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SafetyComponent {
protected safetyService = inject(SafetyService);
protected safetyService = inject(SafetyService).safetyData;
protected safetyForm = new FormArray(
this.safetyService.safetyData.map((item) => new FormControl(item.state)),
this.safetyService.map((item) => new FormControl(item.state)),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</header>
<div class="group">
<tui-input-number
*ngFor="let input of climateControlService.climateControlData"
*ngFor="let input of climateControlService"
[(ngModel)]="input.value"
>
{{ input.name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ import {ClimateControlService} from './climate-control.service';
],
})
export class ClimateControlComponent {
protected climateControlService = inject(ClimateControlService);
protected climateControlService = inject(ClimateControlService).climateControlData;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<div
*ngFor="let i of controlPanelService.controlPanelData; let ind = index"
[ngClass]="{
LastCard:
ind == controlPanelService.controlPanelData.length - 1 &&
controlPanelService.controlPanelData.length % 2 == 1,
}"
>
<div *ngFor="let i of controlPanelService; let ind = index">
<button
tuiCardLarge
tuiHeader
tuiSurface="elevated"
class="buttonCard"
class="button-card"
>
<aside tuiAccessories>
<tui-avatar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
margin-bottom: auto;
}

.buttonCard {
.button-card {
max-width: max-content;
padding-right: 1.75rem;
gap: 1rem;
Expand All @@ -35,7 +35,7 @@
}
}

.LastCard {
div:last-child {
grid-column-end: 3;
grid-column-start: 1;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ import {ControlPanelService} from './control-panel.service';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ControlPanelComponent {
protected controlPanelService = inject(ControlPanelService);
protected controlPanelService = inject(ControlPanelService).controlPanelData;
}

0 comments on commit 6817498

Please sign in to comment.