Skip to content

Commit 6f2f5a8

Browse files
committed
refactor: remove empty constructors, wrapper components host class, cleanups
1 parent caaca45 commit 6f2f5a8

File tree

83 files changed

+284
-575
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+284
-575
lines changed

projects/coreui-angular/src/lib/accordion/accordion-item/accordion-item.component.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
booleanAttribute,
44
Component,
55
ContentChildren,
6-
HostBinding,
76
Input,
87
OnDestroy,
98
OnInit,
@@ -47,13 +46,6 @@ export class AccordionItemComponent implements OnInit, OnDestroy, AfterContentIn
4746
return <boolean>this.visible;
4847
}
4948

50-
@HostBinding('class')
51-
get hostClasses(): any {
52-
return {
53-
'accordion-item': true
54-
};
55-
}
56-
5749
contentId = `accordion-item-${nextId++}`;
5850
itemContext = { $implicit: <boolean>this.visible };
5951
templates: any = {};

projects/coreui-angular/src/lib/accordion/accordion.service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { AccordionItemComponent } from './accordion-item/accordion-item.componen
33

44
@Injectable()
55
export class AccordionService {
6-
76
items: AccordionItemComponent[] = [];
87
alwaysOpen = false;
98

10-
constructor() { }
11-
129
addItem(item: AccordionItemComponent): void {
1310
this.items.push(item);
1411
}
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import { Directive, HostBinding } from '@angular/core';
1+
import { Directive } from '@angular/core';
22

33
@Directive({
44
selector: '[cAlertHeading]',
5-
standalone: true
5+
standalone: true,
6+
host: { class: 'alert-heading' }
67
})
7-
export class AlertHeadingDirective {
8-
9-
@HostBinding('class')
10-
get hostClasses(): any {
11-
12-
return {
13-
'alert-heading': true,
14-
};
15-
}
16-
17-
constructor() { }
18-
19-
}
8+
export class AlertHeadingDirective {}
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
import { Directive, HostBinding } from '@angular/core';
1+
import { Directive } from '@angular/core';
22

33
@Directive({
44
selector: '[cAlertLink]',
5-
standalone: true
5+
standalone: true,
6+
host: { class: 'alert-link' }
67
})
7-
export class AlertLinkDirective {
8-
9-
@HostBinding('class')
10-
get hostClasses(): any {
11-
12-
return {
13-
'alert-link': true,
14-
};
15-
}
16-
17-
constructor() { }
18-
19-
}
8+
export class AlertLinkDirective {}

projects/coreui-angular/src/lib/breadcrumb/breadcrumb/breadcrumb.component.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Component, HostBinding, Input } from '@angular/core';
33
@Component({
44
selector: 'c-breadcrumb',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'breadcrumb' }
78
})
89
export class BreadcrumbComponent {
910
/**
@@ -12,20 +13,15 @@ export class BreadcrumbComponent {
1213
* @default 'breadcrumb'
1314
*/
1415
@HostBinding('attr.aria-label')
15-
@Input() ariaLabel = 'breadcrumb';
16+
@Input()
17+
ariaLabel = 'breadcrumb';
1618

1719
/**
1820
* Default role for breadcrumb. [docs]
1921
* @type string
2022
* @default 'navigation'
2123
*/
2224
@HostBinding('attr.role')
23-
@Input() role = 'navigation';
24-
25-
@HostBinding('class')
26-
get hostClasses() {
27-
return {
28-
breadcrumb: true
29-
};
30-
}
25+
@Input()
26+
role = 'navigation';
3127
}

projects/coreui-angular/src/lib/button-group/button-toolbar/button-toolbar.component.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Component, HostBinding, Input } from '@angular/core';
33
@Component({
44
selector: 'c-button-toolbar',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'btn-toolbar' }
78
})
89
export class ButtonToolbarComponent {
910
/**
@@ -12,12 +13,6 @@ export class ButtonToolbarComponent {
1213
* @default 'toolbar'
1314
*/
1415
@HostBinding('attr.role')
15-
@Input() role = 'toolbar';
16-
17-
@HostBinding('class')
18-
get hostClasses(): any {
19-
return {
20-
'btn-toolbar': true
21-
};
22-
}
16+
@Input()
17+
role = 'toolbar';
2318
}

projects/coreui-angular/src/lib/button/button-close.directive.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import { ButtonDirective } from './button.directive';
55
@Directive({
66
selector: '[cButtonClose]',
77
standalone: true,
8-
hostDirectives: [
9-
{ directive: ThemeDirective, inputs: ['dark'] }
10-
]
8+
hostDirectives: [{ directive: ThemeDirective, inputs: ['dark'] }],
9+
host: { class: 'btn btn-close' }
1110
})
1211
export class ButtonCloseDirective extends ButtonDirective {
13-
1412
/**
1513
* Change the default color to white.
1614
* @type boolean

projects/coreui-angular/src/lib/button/button.directive.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { ButtonType, Colors, Shapes } from '../coreui.types';
55
@Directive({
66
selector: '[cButton]',
77
exportAs: 'cButton',
8-
standalone: true
8+
standalone: true,
9+
host: { class: 'btn' }
910
})
1011
export class ButtonDirective {
11-
1212
/**
1313
* Toggle the active state for the component. [docs]
1414
* @type boolean
@@ -43,7 +43,8 @@ export class ButtonDirective {
4343
* Different browsers may use different default types for the `<button>` element.
4444
*/
4545
@HostBinding('attr.type')
46-
@Input() type: ButtonType = 'button';
46+
@Input()
47+
type: ButtonType = 'button';
4748

4849
/**
4950
* Set the button variant to an outlined button or a ghost button.
@@ -68,7 +69,7 @@ export class ButtonDirective {
6869
@HostBinding('attr.aria-disabled')
6970
get ariaDisabled() {
7071
return this.disabled || null;
71-
};
72+
}
7273

7374
@HostBinding('attr.aria-pressed')
7475
get isActive(): boolean | null {
@@ -78,7 +79,7 @@ export class ButtonDirective {
7879
@HostBinding('attr.disabled')
7980
get attrDisabled() {
8081
return this.disabled ? '' : null;
81-
};
82+
}
8283

8384
@HostBinding('attr.tabindex')
8485
get tabIndex(): string | null {

projects/coreui-angular/src/lib/callout/callout.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { Colors } from '../coreui.types';
55
selector: 'c-callout, [cCallout]',
66
template: '<ng-content />',
77
styleUrls: ['./callout.component.scss'],
8-
standalone: true
8+
standalone: true,
9+
host: { class: 'callout' }
910
})
1011
export class CalloutComponent {
11-
1212
/**
1313
* Sets the color context of the component to one of CoreUI’s themed colors.
1414
* @type Colors
@@ -22,5 +22,4 @@ export class CalloutComponent {
2222
[`callout-${this.color}`]: !!this.color
2323
};
2424
}
25-
2625
}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import {Component, HostBinding} from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'c-card-body, [c-card-body]',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'card-body' }
78
})
8-
export class CardBodyComponent {
9-
10-
@HostBinding('class')
11-
get hostClasses(): any {
12-
return {
13-
'card-body': true,
14-
};
15-
}
16-
}
9+
export class CardBodyComponent {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import { Component, HostBinding } from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'c-card-footer, [c-card-footer]',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'card-footer' }
78
})
8-
export class CardFooterComponent {
9-
10-
@HostBinding('class')
11-
get hostClasses(): any {
12-
return {
13-
'card-footer': true
14-
};
15-
}
16-
}
9+
export class CardFooterComponent {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import { Component, HostBinding } from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'c-card-group, [c-card-group]',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'card-group' }
78
})
8-
export class CardGroupComponent {
9-
10-
@HostBinding('class')
11-
get hostClasses(): any {
12-
return {
13-
'card-group': true
14-
};
15-
}
16-
}
9+
export class CardGroupComponent {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
1-
import { Component, HostBinding } from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'c-card-header, [c-card-header]',
55
template: '<ng-content />',
6-
standalone: true
6+
standalone: true,
7+
host: { class: 'card-header' }
78
})
8-
export class CardHeaderComponent {
9-
10-
@HostBinding('class')
11-
get hostClasses(): any {
12-
return {
13-
'card-header': true
14-
};
15-
}
16-
}
9+
export class CardHeaderComponent {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
import { Component, HostBinding } from '@angular/core';
1+
import { Component } from '@angular/core';
22

33
@Component({
44
selector: 'c-card-img-overlay',
55
template: '<ng-content />',
66
styleUrls: ['./card-img-overlay.component.scss'],
7-
standalone: true
7+
standalone: true,
8+
host: { class: 'card-img-overlay' }
89
})
9-
export class CardImgOverlayComponent {
10-
11-
@HostBinding('class')
12-
get hostClasses(): any {
13-
return {
14-
'card-img-overlay': true
15-
};
16-
}
17-
}
10+
export class CardImgOverlayComponent {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { Directive, HostBinding } from '@angular/core';
1+
import { Directive } from '@angular/core';
22

33
@Directive({
44
selector: '[cCardLink]',
5-
standalone: true
5+
standalone: true,
6+
host: { class: 'card-link' }
67
})
7-
export class CardLinkDirective {
8-
9-
@HostBinding('class')
10-
get hostClasses(): any {
11-
return {
12-
'card-link': true
13-
};
14-
}
15-
}
8+
export class CardLinkDirective {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { Directive, HostBinding } from '@angular/core';
1+
import { Directive } from '@angular/core';
22

33
@Directive({
44
selector: '[cCardSubtitle]',
5-
standalone: true
5+
standalone: true,
6+
host: { class: 'card-subtitle' }
67
})
7-
export class CardSubtitleDirective {
8-
9-
@HostBinding('class')
10-
get hostClasses(): any {
11-
return {
12-
'card-subtitle': true
13-
};
14-
}
15-
}
8+
export class CardSubtitleDirective {}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
import { Directive, HostBinding } from '@angular/core';
1+
import { Directive } from '@angular/core';
22

33
@Directive({
44
selector: '[cCardText]',
5-
standalone: true
5+
standalone: true,
6+
host: { class: 'card-text' }
67
})
7-
export class CardTextDirective {
8-
9-
@HostBinding('class')
10-
get hostClasses(): any {
11-
return {
12-
'card-text': true
13-
};
14-
}
15-
}
8+
export class CardTextDirective {}

0 commit comments

Comments
 (0)