Skip to content

Commit

Permalink
refactor(testbed): remove ngClass and migrate to [class]
Browse files Browse the repository at this point in the history
  • Loading branch information
fmalcher committed Dec 12, 2024
1 parent cbcd58a commit 1a041f5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<button [ngClass]="ngClassDefinition" (click)="press.emit()">
<button [class]="classDefinition()" (click)="press.emit()">
<ng-content></ng-content>
</button>
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import { NgClass } from '@angular/common';
import { Component, input, output } from '@angular/core';
import { Component, computed, input, output } from '@angular/core';

@Component({
selector: 'sui-mixer-button',
templateUrl: './mixer-button.component.html',
styleUrls: ['./mixer-button.component.scss'],
imports: [NgClass],
imports: [],
})
export class MixerButtonComponent {
activeClass = input('default-active');
active = input(false);
press = output();

get ngClassDefinition() {
if (!this.activeClass) {
classDefinition = computed(() => {
if (!this.activeClass()) {
return;
}
return {
[this.activeClass()]: !!this.active(),
};
}
});
}
2 changes: 1 addition & 1 deletion packages/testbed/src/app/ui/prepost/prepost.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>
Toggle PRE/POST
</sui-mixer-button>
<span class="badge ms-2" [ngClass]="{ 'badge-success': post, 'badge-secondary': !post }">
<span class="badge ms-2" [class]="{ 'badge-success': post, 'badge-secondary': !post }">
{{ post ? 'POST' : 'PRE' }}
</span>
}
4 changes: 2 additions & 2 deletions packages/testbed/src/app/ui/prepost/prepost.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AsyncPipe, NgClass } from '@angular/common';
import { AsyncPipe } from '@angular/common';
import { Component, OnDestroy, OnInit, input } from '@angular/core';
import { Subject, takeUntil } from 'rxjs';
import { SendChannel } from 'soundcraft-ui-connection';
Expand All @@ -8,7 +8,7 @@ import { MixerButtonComponent } from '../mixer-button/mixer-button.component';
selector: 'sui-prepost',
templateUrl: './prepost.component.html',
styleUrls: ['./prepost.component.css'],
imports: [MixerButtonComponent, NgClass, AsyncPipe],
imports: [MixerButtonComponent, AsyncPipe],
})
export class PrepostComponent implements OnInit, OnDestroy {
channel = input.required<SendChannel>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="meter" [ngClass]="mode()">
<div class="meter" [class]="mode()">
<label>{{ sanitizedLabel() }}</label>
<div class="bar" [style.width]="barWidth()"></div>
</div>
3 changes: 1 addition & 2 deletions packages/testbed/src/app/ui/vu-meter/vu-meter.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, computed, input } from '@angular/core';
import { NgClass } from '@angular/common';

@Component({
selector: 'sui-vu-meter',
imports: [NgClass],
imports: [],
templateUrl: './vu-meter.component.html',
styleUrl: './vu-meter.component.scss',
})
Expand Down

0 comments on commit 1a041f5

Please sign in to comment.