Skip to content

Commit

Permalink
feat(design): convert container component to standalone (#3054)
Browse files Browse the repository at this point in the history
  • Loading branch information
xelaint authored and damienwebdev committed Sep 27, 2024
1 parent 7f830b6 commit 994f8bb
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@daffodil/cart';
import { DaffCartFacade } from '@daffodil/cart/state';
import { DAFF_ACCORDION_COMPONENTS } from '@daffodil/design/accordion';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
import { DaffLoadingIconModule } from '@daffodil/design/loading-icon';
import { DaffPersonalAddress } from '@daffodil/geography';

Expand Down Expand Up @@ -51,7 +51,7 @@ import {
imports: [
CommonModule,
LetDirective,
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
DaffLoadingIconModule,
DAFF_ACCORDION_COMPONENTS,

Expand Down
4 changes: 2 additions & 2 deletions apps/demo/src/app/thank-you/pages/thank-you-view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Observable } from 'rxjs';
import { DaffCartFacade } from '@daffodil/cart/state';
import { DaffCheckoutPlacedOrderFacade } from '@daffodil/checkout/state';
import { DAFF_ACCORDION_COMPONENTS } from '@daffodil/design/accordion';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
import { DaffLoadingIconModule } from '@daffodil/design/loading-icon';
import { DaffOrder } from '@daffodil/order';

Expand All @@ -25,7 +25,7 @@ import { ThankYouComponent } from '../components/thank-you/thank-you.component';
CommonModule,
LetDirective,
ThankYouComponent,
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
CartSummaryWrapperModule,
DAFF_ACCORDION_COMPONENTS,
DaffLoadingIconModule,
Expand Down
43 changes: 42 additions & 1 deletion libs/design/container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,46 @@ Supported sizes: `xs | sm | md | lg | xl`
| Large | 1340px | lg |
| Extra Large | 1920px | xl |

<design-land-example-viewer-container example="container-sizes"></design-land-example-viewer-container>


## Usage
<design-land-example-viewer-container example="container-sizes"></design-land-example-viewer-container>

### Within a standalone component
To use container in a standalone component, import it directly into your custom component:

```ts
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
standalone: true,
imports: [
DAFF_CONTAINER_COMPONENTS,
],
})
export class CustomComponent {}
```

### Within a module (deprecated)
To use container in a module, import `DaffCalloutModule` into your custom module:

```ts
import { NgModule } from '@angular/core';

import { DaffCalloutModule } from '@daffodil/design/container';

@NgModule({
declarations: [
CustomComponent,
],
exports: [
CustomComponent,
],
imports: [
DaffCalloutModule,
],
})
export class CustomComponentModule { }
```

> This method is deprecated. It's recommended to update all custom components to standalone.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ReactiveFormsModule,
} from '@angular/forms';

import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
Expand All @@ -17,7 +17,7 @@ import { DaffContainerModule } from '@daffodil/design/container';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
ReactiveFormsModule,
NgFor,
],
Expand Down
5 changes: 3 additions & 2 deletions libs/design/container/src/container.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { NgModule } from '@angular/core';

import { DaffContainerComponent } from './container/container.component';

/**
* @deprecated in favor of {@link DAFF_CONTAINER_COMPONENTS}
*/
@NgModule({
imports: [
CommonModule,
],
declarations: [
DaffContainerComponent,
],
exports: [
Expand Down
5 changes: 5 additions & 0 deletions libs/design/container/src/container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DaffContainerComponent } from './container/container.component';

export const DAFF_CONTAINER_COMPONENTS = <const> [
DaffContainerComponent,
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffContainerComponent } from './container.component';

@Component({
template: `<daff-container [size]="size"></daff-container>`,
standalone: true,
imports: [
DaffContainerComponent,
],
})
class WrapperComponent {
size: DaffSizeAllType;
Expand All @@ -28,9 +32,8 @@ describe('@daffodil/design/container | DaffContainerComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
imports: [
WrapperComponent,
DaffContainerComponent,
],
})
.compileComponents();
Expand Down
1 change: 1 addition & 0 deletions libs/design/container/src/container/container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { DaffSizableDirective } from '@daffodil/design';
},
],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class DaffContainerComponent {
/**
Expand Down
1 change: 1 addition & 0 deletions libs/design/container/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { DaffContainerComponent } from './container/container.component';
export { DaffContainerModule } from './container.module';
export { DAFF_CONTAINER_COMPONENTS } from './container';
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faMobile } from '@fortawesome/free-solid-svg-icons';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
import { DaffHeroModule } from '@daffodil/design/hero';

@Component({
Expand All @@ -23,7 +23,7 @@ import { DaffHeroModule } from '@daffodil/design/hero';
standalone: true,
imports: [
DaffHeroModule,
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
ReactiveFormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faMobile } from '@fortawesome/free-solid-svg-icons';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
import { DaffHeroModule } from '@daffodil/design/hero';

@Component({
Expand All @@ -18,7 +18,7 @@ import { DaffHeroModule } from '@daffodil/design/hero';
standalone: true,
imports: [
DaffHeroModule,
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '@angular/core';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';
import { DaffNavbarModule } from '@daffodil/design/navbar';

@Component({
Expand All @@ -16,7 +16,7 @@ import { DaffNavbarModule } from '@daffodil/design/navbar';
standalone: true,
imports: [
DaffNavbarModule,
DaffContainerModule,
DAFF_CONTAINER_COMPONENTS,
DAFF_BUTTON_COMPONENTS,
],
})
Expand Down

0 comments on commit 994f8bb

Please sign in to comment.