Skip to content

Commit 4f260f5

Browse files
committed
refactor: migration from NgStyle to style bindings
1 parent a6d6502 commit 4f260f5

File tree

10 files changed

+19
-23
lines changed

10 files changed

+19
-23
lines changed

src/app/views/dashboard/dashboard.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ <h4 class="card-title mb-0" id="traffic">Traffic</h4>
7070
<c-chart
7171
[data]="mainChart.data"
7272
[height]="300"
73-
[ngStyle]="{ 'marginTop.px': 40 }"
73+
[style.marginTop.px]="40"
7474
[options]="mainChart.options"
7575
[type]="mainChart.type"
7676
(chartRef)="handleChartRef($event)"

src/app/views/dashboard/dashboard.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { NgStyle } from '@angular/common';
21
import { Component, DestroyRef, DOCUMENT, effect, inject, OnInit, Renderer2, signal, WritableSignal } from '@angular/core';
32
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
43
import { ChartOptions } from 'chart.js';
@@ -41,7 +40,7 @@ interface IUser {
4140
@Component({
4241
templateUrl: 'dashboard.component.html',
4342
styleUrls: ['dashboard.component.scss'],
44-
imports: [WidgetsDropdownComponent, CardComponent, CardBodyComponent, RowComponent, ColComponent, ButtonDirective, IconDirective, ReactiveFormsModule, ButtonGroupComponent, FormCheckLabelDirective, ChartjsComponent, NgStyle, CardFooterComponent, GutterDirective, ProgressComponent, WidgetsBrandComponent, CardHeaderComponent, TableDirective, AvatarComponent]
43+
imports: [WidgetsDropdownComponent, CardComponent, CardBodyComponent, RowComponent, ColComponent, ButtonDirective, IconDirective, ReactiveFormsModule, ButtonGroupComponent, FormCheckLabelDirective, ChartjsComponent, CardFooterComponent, GutterDirective, ProgressComponent, WidgetsBrandComponent, CardHeaderComponent, TableDirective, AvatarComponent]
4544
})
4645
export class DashboardComponent implements OnInit {
4746

src/app/views/forms/floating-labels/floating-labels.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,28 @@
5050
</c-card-header>
5151
<c-card-body>
5252
<p class="text-body-secondary small">
53-
By default, <code>&lt;CFormTextarea&gt;</code>s will be the same height as
53+
By default, <code>&lt;textarea&gt;</code>s will be the same height as
5454
<code>&lt;input&gt;</code>s.
5555
</p>
5656
<app-docs-example href="forms/floating-labels#textareas">
5757
<div cFormFloating>
58-
<input
58+
<textarea
5959
cFormControl
6060
id="floatingTextarea"
6161
placeholder="Leave a comment here"
6262
type="text"
63-
>
63+
></textarea>
6464
<label cLabel for="floatingTextarea">Comments</label>
6565
</div>
6666
</app-docs-example>
6767
<p class="text-body-secondary small">
68-
To set a custom height on your <code>&lt;CFormTextarea;&gt;</code>, do not use the
68+
To set a custom height on your <code>&lt;textarea&gt;</code>, do not use the
6969
<code>rows</code> attribute. Instead, set an explicit <code>height</code> (either
7070
inline or via custom CSS).
7171
</p>
7272
<app-docs-example href="forms/floating-labels#textareas">
7373
<div cFormFloating>
74-
<textarea [ngStyle]="{ 'height.px': 100 }"
74+
<textarea [style.height.px]="100"
7575
cFormControl
7676
id="floatingTextarea2"
7777
placeholder="Leave a comment here"

src/app/views/forms/floating-labels/floating-labels.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component } from '@angular/core';
2-
import { NgStyle } from '@angular/common';
32
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
43
import {
54
CardBodyComponent,
@@ -19,6 +18,6 @@ import { DocsComponentsComponent, DocsExampleComponent } from '@docs-components/
1918
@Component({
2019
selector: 'app-floating-labels',
2120
templateUrl: './floating-labels.component.html',
22-
imports: [RowComponent, ColComponent, CardComponent, CardHeaderComponent, CardBodyComponent, DocsExampleComponent, FormFloatingDirective, FormControlDirective, FormLabelDirective, ReactiveFormsModule, FormsModule, FormDirective, NgStyle, FormSelectDirective, GutterDirective, DocsComponentsComponent]
21+
imports: [RowComponent, ColComponent, CardComponent, CardHeaderComponent, CardBodyComponent, DocsExampleComponent, FormFloatingDirective, FormControlDirective, FormLabelDirective, ReactiveFormsModule, FormsModule, FormDirective, FormSelectDirective, GutterDirective, DocsComponentsComponent]
2322
})
2423
export class FloatingLabelsComponent {}

src/app/views/forms/form-controls/form-controls.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,10 @@
226226
type="color">
227227
</c-col>
228228
<c-col xs="auto">
229-
<div [ngStyle]="{'backgroundColor': favoriteColor}" class="color-box p-1 m-1"></div>
229+
<div [style.backgroundColor]="favoriteColor()" class="color-box p-1 m-1"></div>
230230
</c-col>
231231
<c-col xs="auto">
232-
<strong>{{ favoriteColor }}</strong>
232+
<strong>{{ favoriteColor() }}</strong>
233233
</c-col>
234234
</c-row>
235235
</app-docs-example>

src/app/views/forms/form-controls/form-controls.component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { Component } from '@angular/core';
2-
import { NgStyle } from '@angular/common';
1+
import { Component, signal } from '@angular/core';
32
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
43
import {
54
ButtonDirective,
@@ -21,10 +20,10 @@ import { DocsComponentsComponent, DocsExampleComponent } from '@docs-components/
2120
selector: 'app-form-controls',
2221
templateUrl: './form-controls.component.html',
2322
styleUrls: ['./form-controls.component.scss'],
24-
imports: [RowComponent, ColComponent, CardComponent, CardHeaderComponent, CardBodyComponent, DocsExampleComponent, ReactiveFormsModule, FormsModule, FormDirective, FormLabelDirective, FormControlDirective, ButtonDirective, NgStyle, RowDirective, GutterDirective, ColDirective, DocsComponentsComponent]
23+
imports: [RowComponent, ColComponent, CardComponent, CardHeaderComponent, CardBodyComponent, DocsExampleComponent, ReactiveFormsModule, FormsModule, FormDirective, FormLabelDirective, FormControlDirective, ButtonDirective, RowDirective, GutterDirective, ColDirective, DocsComponentsComponent]
2524
})
2625
export class FormControlsComponent {
2726

28-
public favoriteColor = '#26ab3c';
27+
public favoriteColor = signal('#26ab3c');
2928

3029
}

src/app/views/notifications/toasters/toasters.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ <h5>Add toast with following props:</h5>
6464
</button>
6565
</form>
6666
</c-col>
67-
<c-col lg="6" sm="12" class="mt-3" [ngStyle]="{position: 'relative'}">
68-
<c-toaster [placement]="positionStatic" [ngStyle]="{display: 'contents'}">
67+
<c-col lg="6" sm="12" class="mt-3" [style.position]="'relative'">
68+
<c-toaster [placement]="positionStatic" [style.display]="'contents'">
6969
<c-toast [autohide]="false" [fade]="true" [visible]="true" color="danger">
7070
<c-toast-header>Toast title</c-toast-header>
7171
<c-toast-body>This is a static toast in a static toaster</c-toast-body>

src/app/views/notifications/toasters/toasters.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { JsonPipe, NgStyle, SlicePipe } from '@angular/common';
1+
import { JsonPipe, SlicePipe } from '@angular/common';
22
import { Component, OnInit, viewChildren } from '@angular/core';
33
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
44
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
@@ -46,7 +46,7 @@ export enum Colors {
4646
@Component({
4747
selector: 'app-toasters',
4848
templateUrl: './toasters.component.html',
49-
imports: [RowComponent, ColComponent, ToasterComponent, TextColorDirective, CardComponent, CardHeaderComponent, CardBodyComponent, ContainerComponent, ReactiveFormsModule, FormDirective, FormCheckComponent, FormCheckInputDirective, FormCheckLabelDirective, InputGroupComponent, InputGroupTextDirective, FormControlDirective, FormSelectDirective, ButtonDirective, NgStyle, ToastComponent, ToastHeaderComponent, ToastBodyComponent, AppToastComponent, JsonPipe, SlicePipe, TextColorDirective, DocsComponentsComponent]
49+
imports: [RowComponent, ColComponent, ToasterComponent, TextColorDirective, CardComponent, CardHeaderComponent, CardBodyComponent, ContainerComponent, ReactiveFormsModule, FormDirective, FormCheckComponent, FormCheckInputDirective, FormCheckLabelDirective, InputGroupComponent, InputGroupTextDirective, FormControlDirective, FormSelectDirective, ButtonDirective, ToastComponent, ToastHeaderComponent, ToastBodyComponent, AppToastComponent, JsonPipe, SlicePipe, TextColorDirective, DocsComponentsComponent]
5050
})
5151
export class ToastersComponent implements OnInit {
5252

src/app/views/pages/login/login.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h1>Login</h1>
4040
</form>
4141
</c-card-body>
4242
</c-card>
43-
<c-card [ngStyle]="{'minWidth.%': 44}" class="text-white bg-primary py-5">
43+
<c-card [style.minWidth.%]="44" class="text-white bg-primary py-5">
4444
<c-card-body class="text-center">
4545
<div>
4646
<h2>Sign up</h2>

src/app/views/pages/login/login.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component } from '@angular/core';
2-
import { NgStyle } from '@angular/common';
32
import { IconDirective } from '@coreui/icons-angular';
43
import {
54
ButtonDirective,
@@ -18,6 +17,6 @@ import {
1817
@Component({
1918
selector: 'app-login',
2019
templateUrl: './login.component.html',
21-
imports: [ContainerComponent, RowComponent, ColComponent, CardGroupComponent, CardComponent, CardBodyComponent, FormDirective, InputGroupComponent, InputGroupTextDirective, IconDirective, FormControlDirective, ButtonDirective, NgStyle]
20+
imports: [ContainerComponent, RowComponent, ColComponent, CardGroupComponent, CardComponent, CardBodyComponent, FormDirective, InputGroupComponent, InputGroupTextDirective, IconDirective, FormControlDirective, ButtonDirective]
2221
})
2322
export class LoginComponent {}

0 commit comments

Comments
 (0)