Skip to content

Commit 328a70a

Browse files
xelaintdamienwebdev
authored andcommitted
feat(design): convert list component to standalone (#3054)
1 parent b54d941 commit 328a70a

File tree

13 files changed

+88
-22
lines changed

13 files changed

+88
-22
lines changed

apps/daffio/src/app/core/nav/sidebar-body/component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
Observable,
1111
} from 'rxjs';
1212

13-
import { DaffListModule } from '@daffodil/design/list';
13+
import { DAFF_LIST_COMPONENTS } from '@daffodil/design/list';
1414
import { DaffRouterDataService } from '@daffodil/router';
1515

1616
import { DaffioRouteWithNavLinks } from '../link/route.type';
@@ -24,7 +24,7 @@ import { DaffioNavLink } from '../link/type';
2424
standalone: true,
2525
imports: [
2626
AsyncPipe,
27-
DaffListModule,
27+
DAFF_LIST_COMPONENTS,
2828
RouterLink,
2929
],
3030
})

libs/design/list/README.md

+42-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,53 @@
11
# List
22
List is a flexible component that can be used to display a series of content. It can be modified to support a range of content types.
33

4+
## Usage
5+
6+
### Within a standalone component
7+
To use list in a standalone component, import it directly into your custom component:
8+
9+
```ts
10+
@Component({
11+
selector: 'custom-component',
12+
templateUrl: './custom-component.component.html',
13+
standalone: true,
14+
imports: [
15+
DAFF_LIST_COMPONENTS,
16+
],
17+
})
18+
export class CustomComponent {}
19+
```
20+
21+
### Within a module (deprecated)
22+
To use list in a module, import `DaffListModule` into your custom module:
23+
24+
```ts
25+
import { NgModule } from '@angular/core';
26+
27+
import { DaffListModule } from '@daffodil/design/list';
28+
29+
@NgModule({
30+
declarations: [
31+
CustomComponent,
32+
],
33+
exports: [
34+
CustomComponent,
35+
],
36+
imports: [
37+
DaffListModule,
38+
],
39+
})
40+
export class CustomComponentModule { }
41+
```
42+
43+
> This method is deprecated. It's recommended to update all custom components to standalone.
44+
445
## Basic List
546
A `<daff-list>` consists of multiple `<daff-list-item>`s.
647

748
<design-land-example-viewer-container example="basic-list"></design-land-example-viewer-container>
849

9-
## Nvigation List
50+
## Navigation List
1051
Use `<daff-nav-list>` for navigation lists. `<daff-list-item>` should be directly added to an anchor tag.
1152

1253
<design-land-example-viewer-container example="nav-list"></design-land-example-viewer-container>

libs/design/list/examples/src/basic-list/basic-list.component.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import {
33
Component,
44
} from '@angular/core';
55

6-
import { DaffListModule } from '@daffodil/design/list';
6+
import { DAFF_LIST_COMPONENTS } from '@daffodil/design/list';
77

88
@Component({
99
// eslint-disable-next-line @angular-eslint/component-selector
1010
selector: 'basic-list',
1111
templateUrl: './basic-list.component.html',
1212
changeDetection: ChangeDetectionStrategy.OnPush,
1313
standalone: true,
14-
imports: [DaffListModule],
14+
imports: [
15+
DAFF_LIST_COMPONENTS,
16+
],
1517
})
1618
export class BasicListComponent {}

libs/design/list/examples/src/icon-list/icon-list.component.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
66
import { faInfoCircle } from '@fortawesome/free-solid-svg-icons';
77

8-
import { DaffPrefixSuffixModule } from '@daffodil/design';
9-
import { DaffListModule } from '@daffodil/design/list';
8+
import { DAFF_LIST_COMPONENTS } from '@daffodil/design/list';
109

1110
@Component({
1211
// eslint-disable-next-line @angular-eslint/component-selector
@@ -15,9 +14,8 @@ import { DaffListModule } from '@daffodil/design/list';
1514
changeDetection: ChangeDetectionStrategy.OnPush,
1615
standalone: true,
1716
imports: [
18-
DaffListModule,
17+
DAFF_LIST_COMPONENTS,
1918
FaIconComponent,
20-
DaffPrefixSuffixModule,
2119
],
2220
})
2321
export class IconListComponent {

libs/design/list/examples/src/multiline-list/multiline-list.component.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import {
33
Component,
44
} from '@angular/core';
55

6-
import { DaffListModule } from '@daffodil/design/list';
6+
import { DAFF_LIST_COMPONENTS } from '@daffodil/design/list';
77

88
@Component({
99
// eslint-disable-next-line @angular-eslint/component-selector
1010
selector: 'multiline-list',
1111
templateUrl: './multiline-list.component.html',
1212
changeDetection: ChangeDetectionStrategy.OnPush,
1313
standalone: true,
14-
imports: [DaffListModule],
14+
imports: [
15+
DAFF_LIST_COMPONENTS,
16+
],
1517
})
1618
export class MultilineListComponent {}

libs/design/list/examples/src/nav-list/nav-list.component.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {
55
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
66
import { faChevronRight } from '@fortawesome/free-solid-svg-icons';
77

8-
import { DaffPrefixSuffixModule } from '@daffodil/design';
9-
import { DaffListModule } from '@daffodil/design/list';
8+
import { DAFF_LIST_COMPONENTS } from '@daffodil/design/list';
109

1110
@Component({
1211
// eslint-disable-next-line @angular-eslint/component-selector
@@ -15,9 +14,8 @@ import { DaffListModule } from '@daffodil/design/list';
1514
changeDetection: ChangeDetectionStrategy.OnPush,
1615
standalone: true,
1716
imports: [
18-
DaffListModule,
17+
DAFF_LIST_COMPONENTS,
1918
FaIconComponent,
20-
DaffPrefixSuffixModule,
2119
],
2220
})
2321
export class NavListComponent {

libs/design/list/src/list-item/list-item.component.spec.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { DaffListItemComponent } from './list-item.component';
1616
<daff-list-item>List Item</daff-list-item>
1717
<a daff-list-item>List Item</a>
1818
`,
19+
standalone: true,
20+
imports: [
21+
DaffListItemComponent,
22+
],
1923
})
2024
class WrapperComponent {}
2125

@@ -30,8 +34,7 @@ describe('@daffodil/design/list | DaffListItemComponent', () => {
3034

3135
beforeEach(waitForAsync(() => {
3236
TestBed.configureTestingModule({
33-
declarations: [
34-
DaffListItemComponent,
37+
imports: [
3538
WrapperComponent,
3639
],
3740
})

libs/design/list/src/list-item/list-item.component.ts

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { NgIf } from '@angular/common';
12
import {
23
Component,
34
ChangeDetectionStrategy,
@@ -8,6 +9,7 @@ import {
89

910
import {
1011
DaffPrefixDirective,
12+
DaffPrefixSuffixModule,
1113
DaffSuffixDirective,
1214
} from '@daffodil/design';
1315

@@ -17,6 +19,11 @@ import {
1719
'a[daff-list-item]',
1820
templateUrl: './list-item.component.html',
1921
changeDetection: ChangeDetectionStrategy.OnPush,
22+
standalone: true,
23+
imports: [
24+
NgIf,
25+
DaffPrefixSuffixModule,
26+
],
2027
})
2128

2229
export class DaffListItemComponent {

libs/design/list/src/list.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import { DaffPrefixSuffixModule } from '@daffodil/design';
66
import { DaffListComponent } from './list/list.component';
77
import { DaffListItemComponent } from './list-item/list-item.component';
88

9+
/**
10+
* @deprecated in favor of {@link DAFF_LIST_COMPONENTS}
11+
*/
912
@NgModule({
1013
imports: [
1114
CommonModule,
12-
DaffPrefixSuffixModule,
13-
],
14-
declarations: [
1515
DaffListComponent,
1616
DaffListItemComponent,
1717
],

libs/design/list/src/list.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { DaffPrefixSuffixModule } from '@daffodil/design';
2+
3+
import { DaffListComponent } from './list/list.component';
4+
import { DaffListItemComponent } from './list-item/list-item.component';
5+
6+
export const DAFF_LIST_COMPONENTS = <const>[
7+
DaffListComponent,
8+
DaffListItemComponent,
9+
DaffPrefixSuffixModule,
10+
];

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { DaffListComponent } from './list.component';
1616
<daff-list [mode]="mode"></daff-list>
1717
<daff-nav-list></daff-nav-list>
1818
`,
19+
standalone: true,
20+
imports: [
21+
DaffListComponent,
22+
],
1923
})
2024
class WrapperComponent {}
2125

@@ -29,9 +33,8 @@ describe('@daffodil/design/list | DaffListComponent', () => {
2933

3034
beforeEach(waitForAsync(() => {
3135
TestBed.configureTestingModule({
32-
declarations: [
36+
imports: [
3337
WrapperComponent,
34-
DaffListComponent,
3538
],
3639
})
3740
.compileComponents();

libs/design/list/src/list/list.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum DaffListTypeEnum {
2626
}],
2727
encapsulation: ViewEncapsulation.None,
2828
changeDetection: ChangeDetectionStrategy.OnPush,
29+
standalone: true,
2930
})
3031

3132
export class DaffListComponent {

libs/design/list/src/public_api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { DaffListModule } from './list.module';
2+
export { DAFF_LIST_COMPONENTS } from './list';
23
export * from './list/list.component';
34
export * from './list-item/list-item.component';

0 commit comments

Comments
 (0)