|
1 |
| -import { Component, HostBinding, Input } from '@angular/core'; |
| 1 | +import { Component, computed, input } from '@angular/core'; |
2 | 2 |
|
3 | 3 | import { Colors } from '../coreui.types';
|
4 | 4 |
|
5 | 5 | @Component({
|
6 | 6 | selector: 'c-spinner',
|
7 | 7 | templateUrl: './spinner.component.html',
|
8 |
| - standalone: true |
| 8 | + standalone: true, |
| 9 | + host: { |
| 10 | + '[attr.role]': 'role()', |
| 11 | + '[class]': 'hostClasses()' |
| 12 | + } |
9 | 13 | })
|
10 | 14 | export class SpinnerComponent {
|
11 | 15 | /**
|
12 | 16 | * Sets the color context of the component to one of CoreUI’s themed colors.
|
13 | 17 | * @type Colors
|
14 | 18 | */
|
15 |
| - @Input() color?: Colors; |
| 19 | + readonly color = input<Colors>(); |
16 | 20 |
|
17 | 21 | /**
|
18 | 22 | * Label for accessibility.
|
19 | 23 | * @type string
|
20 | 24 | * @default 'Loading...'
|
21 | 25 | */
|
22 |
| - @Input() label: string = "Loading..."; |
| 26 | + readonly label = input('Loading...'); |
23 | 27 |
|
24 | 28 | /**
|
25 | 29 | * Size the component small.
|
26 | 30 | * @type string
|
27 | 31 | * @values 'sm'
|
28 | 32 | */
|
29 |
| - @Input() size?: 'sm'; |
| 33 | + readonly size = input<'sm'>(); |
30 | 34 |
|
31 | 35 | /**
|
32 | 36 | * Set the button variant to an outlined button or a ghost button.
|
33 | 37 | * @values 'border' | 'grow'
|
34 | 38 | * @default 'border'
|
35 | 39 | */
|
36 |
| - @Input() variant?: 'border' | 'grow' = 'border'; |
37 |
| - |
38 |
| - @Input() |
39 |
| - @HostBinding('attr.role') role = 'status'; |
| 40 | + readonly variant = input<'border' | 'grow'>('border'); |
| 41 | + /** |
| 42 | + * Default role attr for Spinner. [docs] |
| 43 | + * @type string |
| 44 | + * @default 'status' |
| 45 | + */ |
| 46 | + readonly role = input('status'); |
40 | 47 |
|
41 |
| - @HostBinding('class') |
42 |
| - get hostClasses(): any { |
| 48 | + readonly hostClasses = computed(() => { |
43 | 49 | return {
|
44 |
| - [`spinner-${this.variant}`]: true, |
45 |
| - [`text-${this.color}`]: !!this.color, |
46 |
| - [`spinner-${this.variant}-${this.size}`]: !!this.size |
| 50 | + [`spinner-${this.variant()}`]: true, |
| 51 | + [`text-${this.color()}`]: !!this.color(), |
| 52 | + [`spinner-${this.variant()}-${this.size()}`]: !!this.size() |
47 | 53 | };
|
48 |
| - } |
| 54 | + }); |
49 | 55 | }
|
0 commit comments