Skip to content

Commit 8fd50a6

Browse files
xelaintdamienwebdev
authored andcommitted
feat(design): convert hero to standalone (#3054)
1 parent 994f8bb commit 8fd50a6

20 files changed

+105
-26
lines changed

libs/design/hero/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,47 @@ Hero is a top level container that is large and captivating. It should only be u
44
## Overview
55
Heros are the first thing users see on a page and are designed to catch their attention. It's a flexible and extensible component that includes pre-styled content containers.
66

7+
## Usage
8+
9+
### Within a standalone component
10+
To use hero in a standalone component, import it directly into your custom component:
11+
12+
```ts
13+
@Component({
14+
selector: 'custom-component',
15+
templateUrl: './custom-component.component.html',
16+
standalone: true,
17+
imports: [
18+
DAFF_HERO_COMPONENTS,
19+
],
20+
})
21+
export class CustomComponent {}
22+
```
23+
24+
### Within a module (deprecated)
25+
To use hero in a module, import `DaffHeroModule` into your custom module:
26+
27+
```ts
28+
import { NgModule } from '@angular/core';
29+
30+
import { DaffHeroModule } from '@daffodil/design/hero';
31+
32+
@NgModule({
33+
declarations: [
34+
CustomComponent,
35+
],
36+
exports: [
37+
CustomComponent,
38+
],
39+
imports: [
40+
DaffHeroModule,
41+
],
42+
})
43+
export class CustomComponentModule { }
44+
```
45+
46+
> This method is deprecated. It's recommended to update all custom components to standalone.
47+
748
## Supported Content Types
849
A `daff-hero` supports transclusion of any content and includes stylized `icon`, `tagline`, `title`, `subtitle`, and `body` content containers.
950

libs/design/hero/examples/src/compact-hero/compact-hero.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {
22
ChangeDetectionStrategy,
33
Component,
44
} from '@angular/core';
5-
import { FormControl } from '@angular/forms';
65
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
76
import { faMobile } from '@fortawesome/free-solid-svg-icons';
87

98
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
9+
import { DAFF_HERO_COMPONENTS } from '@daffodil/design/hero';
1010

1111
@Component({
1212
// eslint-disable-next-line @angular-eslint/component-selector
@@ -16,8 +16,8 @@ import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
1616
changeDetection: ChangeDetectionStrategy.OnPush,
1717
standalone: true,
1818
imports: [
19-
DaffHeroModule,
2019
FaIconComponent,
20+
DAFF_HERO_COMPONENTS,
2121
DAFF_BUTTON_COMPONENTS,
2222
],
2323
})

libs/design/hero/examples/src/hero-text-alignment/hero-text-alignment.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { faMobile } from '@fortawesome/free-solid-svg-icons';
1212

1313
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
1414
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
15-
import { DaffHeroModule } from '@daffodil/design/hero';
15+
import { DAFF_HERO_COMPONENTS } from '@daffodil/design/hero';
1616

1717
@Component({
1818
// eslint-disable-next-line @angular-eslint/component-selector
@@ -22,7 +22,7 @@ import { DaffHeroModule } from '@daffodil/design/hero';
2222
changeDetection: ChangeDetectionStrategy.OnPush,
2323
standalone: true,
2424
imports: [
25-
DaffHeroModule,
25+
DAFF_HERO_COMPONENTS,
2626
DAFF_CONTAINER_COMPONENTS,
2727
FaIconComponent,
2828
DAFF_BUTTON_COMPONENTS,

libs/design/hero/examples/src/hero-theming/hero-theming.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { faMobile } from '@fortawesome/free-solid-svg-icons';
1111

1212
import { DaffPalette } from '@daffodil/design';
1313
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
14-
import { DaffHeroModule } from '@daffodil/design/hero';
14+
import { DAFF_HERO_COMPONENTS } from '@daffodil/design/hero';
1515

1616
@Component({
1717
// eslint-disable-next-line @angular-eslint/component-selector
@@ -21,7 +21,7 @@ import { DaffHeroModule } from '@daffodil/design/hero';
2121
changeDetection: ChangeDetectionStrategy.OnPush,
2222
standalone: true,
2323
imports: [
24-
DaffHeroModule,
24+
DAFF_HERO_COMPONENTS,
2525
FaIconComponent,
2626
DAFF_BUTTON_COMPONENTS,
2727
ReactiveFormsModule,

libs/design/hero/examples/src/hero-with-grid/hero-with-grid.component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { faMobile } from '@fortawesome/free-solid-svg-icons';
77

88
import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
99
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
10-
import { DaffHeroModule } from '@daffodil/design/hero';
10+
import { DAFF_HERO_COMPONENTS } from '@daffodil/design/hero';
1111

1212
@Component({
1313
// eslint-disable-next-line @angular-eslint/component-selector
@@ -17,7 +17,7 @@ import { DaffHeroModule } from '@daffodil/design/hero';
1717
changeDetection: ChangeDetectionStrategy.OnPush,
1818
standalone: true,
1919
imports: [
20-
DaffHeroModule,
20+
DAFF_HERO_COMPONENTS,
2121
DAFF_CONTAINER_COMPONENTS,
2222
FaIconComponent,
2323
DAFF_BUTTON_COMPONENTS,

libs/design/hero/src/hero-body/hero-body.directive.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { DaffHeroBodyDirective } from './hero-body.directive';
1313

1414
@Component({
1515
template: `<h1 daffHeroBody>Hero Body</h1>`,
16+
standalone: true,
17+
imports: [
18+
DaffHeroBodyDirective,
19+
],
1620
})
1721
class WrapperComponent {}
1822

@@ -23,8 +27,7 @@ describe('@daffodil/design/hero | DaffHeroBodyDirective', () => {
2327

2428
beforeEach(waitForAsync(() => {
2529
TestBed.configureTestingModule({
26-
declarations: [
27-
DaffHeroBodyDirective,
30+
imports: [
2831
WrapperComponent,
2932
],
3033
})

libs/design/hero/src/hero-body/hero-body.directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55

66
@Directive({
77
selector: '[daffHeroBody]',
8+
standalone: true,
89
})
910

1011
export class DaffHeroBodyDirective {

libs/design/hero/src/hero-icon/hero-icon.directive.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { DaffHeroIconDirective } from './hero-icon.directive';
1313

1414
@Component({
1515
template: `<div daffHeroIcon>Hero Icon</div>`,
16+
standalone: true,
17+
imports: [
18+
DaffHeroIconDirective,
19+
],
1620
})
1721
class WrapperComponent {}
1822

@@ -23,8 +27,7 @@ describe('@daffodil/design/hero | DaffHeroIconDirective', () => {
2327

2428
beforeEach(waitForAsync(() => {
2529
TestBed.configureTestingModule({
26-
declarations: [
27-
DaffHeroIconDirective,
30+
imports: [
2831
WrapperComponent,
2932
],
3033
})

libs/design/hero/src/hero-icon/hero-icon.directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55

66
@Directive({
77
selector: '[daffHeroIcon]',
8+
standalone: true,
89
})
910

1011
export class DaffHeroIconDirective {

libs/design/hero/src/hero-subtitle/hero-subtitle.directive.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { DaffHeroSubtitleDirective } from './hero-subtitle.directive';
1515
template: `
1616
<h1 daffHeroSubtitle>Lorem Ipsum</h1>
1717
`,
18+
standalone: true,
19+
imports: [
20+
DaffHeroSubtitleDirective,
21+
],
1822
})
1923
class WrapperComponent {}
2024

@@ -25,8 +29,7 @@ describe('@daffodil/design/hero | DaffHeroSubtitleDirective', () => {
2529

2630
beforeEach(waitForAsync(() => {
2731
TestBed.configureTestingModule({
28-
declarations: [
29-
DaffHeroSubtitleDirective,
32+
imports: [
3033
WrapperComponent,
3134
],
3235
})

libs/design/hero/src/hero-subtitle/hero-subtitle.directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55

66
@Directive({
77
selector: '[daffHeroSubtitle]',
8+
standalone: true,
89
})
910

1011
export class DaffHeroSubtitleDirective {

libs/design/hero/src/hero-tagline/hero-tagline.directive.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { DaffHeroTaglineDirective } from './hero-tagline.directive';
1515
template: `
1616
<h1 daffHeroTagline>Lorem Ipsum</h1>
1717
`,
18+
standalone: true,
19+
imports: [
20+
DaffHeroTaglineDirective,
21+
],
1822
})
1923
class WrapperComponent {}
2024

@@ -25,8 +29,7 @@ describe('@daffodil/design/hero | DaffHeroTaglineDirective', () => {
2529

2630
beforeEach(waitForAsync(() => {
2731
TestBed.configureTestingModule({
28-
declarations: [
29-
DaffHeroTaglineDirective,
32+
imports: [
3033
WrapperComponent,
3134
],
3235
})

libs/design/hero/src/hero-tagline/hero-tagline.directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55

66
@Directive({
77
selector: '[daffHeroTagline]',
8+
standalone: true,
89
})
910

1011
export class DaffHeroTaglineDirective {

libs/design/hero/src/hero-title/hero-title.directive.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { DaffHeroTitleDirective } from './hero-title.directive';
1515
template: `
1616
<h1 daffHeroTitle>Lorem Ipsum</h1>
1717
`,
18+
standalone: true,
19+
imports: [
20+
DaffHeroTitleDirective,
21+
],
1822
})
1923
class WrapperComponent {}
2024

@@ -25,8 +29,7 @@ describe('@daffodil/design/hero | DaffHeroTitleDirective', () => {
2529

2630
beforeEach(waitForAsync(() => {
2731
TestBed.configureTestingModule({
28-
declarations: [
29-
DaffHeroTitleDirective,
32+
imports: [
3033
WrapperComponent,
3134
],
3235
})

libs/design/hero/src/hero-title/hero-title.directive.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55

66
@Directive({
77
selector: '[daffHeroTitle]',
8+
standalone: true,
89
})
910

1011
export class DaffHeroTitleDirective {

libs/design/hero/src/hero.module.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import { DaffHeroSubtitleDirective } from './hero-subtitle/hero-subtitle.directi
88
import { DaffHeroTaglineDirective } from './hero-tagline/hero-tagline.directive';
99
import { DaffHeroTitleDirective } from './hero-title/hero-title.directive';
1010

11+
/**
12+
* @deprecated in favor of {@link DAFF_HERO_COMPONENTS}
13+
* */
1114
@NgModule({
1215
imports: [
1316
CommonModule,
14-
],
15-
declarations: [
1617
DaffHeroComponent,
1718
DaffHeroIconDirective,
1819
DaffHeroTaglineDirective,

libs/design/hero/src/hero.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { DaffHeroComponent } from './hero/hero.component';
2+
import { DaffHeroBodyDirective } from './hero-body/hero-body.directive';
3+
import { DaffHeroIconDirective } from './hero-icon/hero-icon.directive';
4+
import { DaffHeroSubtitleDirective } from './hero-subtitle/hero-subtitle.directive';
5+
import { DaffHeroTaglineDirective } from './hero-tagline/hero-tagline.directive';
6+
import { DaffHeroTitleDirective } from './hero-title/hero-title.directive';
7+
8+
export const DAFF_HERO_COMPONENTS = <const>[
9+
DaffHeroComponent,
10+
DaffHeroIconDirective,
11+
DaffHeroTaglineDirective,
12+
DaffHeroTitleDirective,
13+
DaffHeroSubtitleDirective,
14+
DaffHeroBodyDirective,
15+
];

libs/design/hero/src/hero/hero.component.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { DaffHeroComponent } from './hero.component';
1818

1919
@Component({
2020
template: `<daff-hero [color]="color" [textAlignment]="textAlignment" [compact]="compact"></daff-hero>`,
21+
standalone: true,
22+
imports: [
23+
DaffHeroComponent,
24+
],
2125
})
2226
class WrapperComponent {
2327
color: DaffPalette;
@@ -33,8 +37,7 @@ describe('@daffodil/design/hero | DaffHeroComponent', () => {
3337

3438
beforeEach(waitForAsync(() => {
3539
TestBed.configureTestingModule({
36-
declarations: [
37-
WrapperComponent,
40+
imports: [
3841
DaffHeroComponent,
3942
],
4043
})

libs/design/hero/src/hero/hero.component.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@ import {
1515
DaffTextAlignableDirective,
1616
} from '@daffodil/design';
1717

18-
/**
19-
* @inheritdoc
20-
*/
2118
@Component({
2219
selector: 'daff-hero',
2320
template: '<ng-content></ng-content>',
2421
styleUrls: ['./hero.component.scss'],
2522
encapsulation: ViewEncapsulation.None,
23+
changeDetection: ChangeDetectionStrategy.OnPush,
2624
hostDirectives: [
2725
{ directive: DaffArticleEncapsulatedDirective },
2826
{ directive: DaffManageContainerLayoutDirective },
@@ -39,7 +37,7 @@ import {
3937
inputs: ['color'],
4038
},
4139
],
42-
changeDetection: ChangeDetectionStrategy.OnPush,
40+
standalone: true,
4341
})
4442
export class DaffHeroComponent {
4543
constructor(private textAlignable: DaffTextAlignableDirective) {

libs/design/hero/src/public_api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export { DaffHeroModule } from './hero.module';
2+
export { DAFF_HERO_COMPONENTS } from './hero';
23
export * from './hero/hero.component';
34
export * from './hero-tagline/hero-tagline.directive';
45
export * from './hero-title/hero-title.directive';

0 commit comments

Comments
 (0)