Skip to content

Commit

Permalink
feat(design): convert callout 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 0205e92 commit 1de68ab
Show file tree
Hide file tree
Showing 20 changed files with 109 additions and 28 deletions.
42 changes: 42 additions & 0 deletions libs/design/callout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,48 @@ Callout is a versatile component that can be used to easily highlight a piece of
## Overview
Callouts can be used multiple times on a page. It's a flexible and extensible component that includes pre-styled content containers. It can be used alongside a product list to highlight a set of products, quickly lay out an accordion, showcase a set of features, etc.

## Usage

### Within a standalone component
To use callout 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_CALLOUT_COMPONENTS,
],
})
export class CustomComponent {}
```

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

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

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

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

> This method is deprecated. It's recommended to update all custom components to standalone.

## Supported Content Types
A `<daff-callout>` supports transclusion of any content and includes stylized `icon`, `tagline`, `title`, `subtitle`, and `body` content containers.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faMobile } from '@fortawesome/free-solid-svg-icons';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CALLOUT_COMPONENTS } from '@daffodil/design/callout';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
Expand All @@ -22,8 +22,8 @@ import { DaffContainerModule } from '@daffodil/design/container';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
DaffCalloutModule,
DaffContainerModule,
DAFF_CALLOUT_COMPONENTS,
DAFF_CONTAINER_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
ReactiveFormsModule,
Expand Down
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 { DaffCalloutModule } from '@daffodil/design/callout';
import { DAFF_CALLOUT_COMPONENTS } from '@daffodil/design/callout';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
Expand All @@ -21,7 +21,7 @@ import { DaffCalloutModule } from '@daffodil/design/callout';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
DaffCalloutModule,
DAFF_CALLOUT_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
ReactiveFormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faMobile } from '@fortawesome/free-solid-svg-icons';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CALLOUT_COMPONENTS } from '@daffodil/design/callout';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
Expand All @@ -17,8 +17,8 @@ import { DaffContainerModule } from '@daffodil/design/container';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
DaffCalloutModule,
DaffContainerModule,
DAFF_CALLOUT_COMPONENTS,
DAFF_CONTAINER_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { faMobile } from '@fortawesome/free-solid-svg-icons';

import { DAFF_BUTTON_COMPONENTS } from '@daffodil/design/button';
import { DaffCalloutModule } from '@daffodil/design/callout';
import { DaffContainerModule } from '@daffodil/design/container';
import { DAFF_CALLOUT_COMPONENTS } from '@daffodil/design/callout';
import { DAFF_CONTAINER_COMPONENTS } from '@daffodil/design/container';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
Expand All @@ -17,8 +17,8 @@ import { DaffContainerModule } from '@daffodil/design/container';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
DaffCalloutModule,
DaffContainerModule,
DAFF_CALLOUT_COMPONENTS,
DAFF_CONTAINER_COMPONENTS,
FaIconComponent,
DAFF_BUTTON_COMPONENTS,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffCalloutBodyDirective } from './callout-body.directive';
template: `
<h3 daffCalloutBody>Lorem Ipsum</h3>
`,
standalone: true,
imports: [
DaffCalloutBodyDirective,
],
})
class WrapperComponent {}

Expand All @@ -25,8 +29,7 @@ describe('@daffodil/design/callout | DaffCalloutBodyDirective', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCalloutBodyDirective,
imports: [
WrapperComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

@Directive({
selector: '[daffCalloutBody]',
standalone: true,
})

export class DaffCalloutBodyDirective {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffCalloutIconDirective } from './callout-icon.directive';
template: `
<h3 daffCalloutIcon>Lorem Ipsum</h3>
`,
standalone: true,
imports: [
DaffCalloutIconDirective,
],
})
class WrapperComponent {}

Expand All @@ -25,8 +29,7 @@ describe('@daffodil/design/callout | DaffCalloutIconDirective', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCalloutIconDirective,
imports: [
WrapperComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

@Directive({
selector: '[daffCalloutIcon]',
standalone: true,
})

export class DaffCalloutIconDirective {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffCalloutSubtitleDirective } from './callout-subtitle.directive';
template: `
<p daffCalloutSubtitle>Lorem Ipsum</p>
`,
standalone: true,
imports: [
DaffCalloutSubtitleDirective,
],
})
class WrapperComponent {}

Expand All @@ -25,8 +29,7 @@ describe('@daffodil/design/callout | DaffCalloutSubtitleDirective', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCalloutSubtitleDirective,
imports: [
WrapperComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

@Directive({
selector: '[daffCalloutSubtitle]',
standalone: true,
})

export class DaffCalloutSubtitleDirective {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffCalloutTaglineDirective } from './callout-tagline.directive';
template: `
<h3 daffCalloutTagline>Lorem Ipsum</h3>
`,
standalone: true,
imports: [
DaffCalloutTaglineDirective,
],
})
class WrapperComponent {}

Expand All @@ -25,8 +29,7 @@ describe('@daffodil/design/callout | DaffCalloutTaglineDirective', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCalloutTaglineDirective,
imports: [
WrapperComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

@Directive({
selector: '[daffCalloutTagline]',
standalone: true,
})

export class DaffCalloutTaglineDirective {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import { DaffCalloutTitleDirective } from './callout-title.directive';
template: `
<h3 daffCalloutTitle>Lorem Ipsum</h3>
`,
standalone: true,
imports: [
DaffCalloutTitleDirective,
],
})
class WrapperComponent {}

Expand All @@ -25,8 +29,7 @@ describe('@daffodil/design/callout | DaffCalloutTitleDirective', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DaffCalloutTitleDirective,
imports: [
WrapperComponent,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {

@Directive({
selector: '[daffCalloutTitle]',
standalone: true,
})

export class DaffCalloutTitleDirective {
Expand Down
3 changes: 1 addition & 2 deletions libs/design/callout/src/callout.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { DaffCalloutSubtitleDirective } from './callout-subtitle/callout-subtitl
import { DaffCalloutTaglineDirective } from './callout-tagline/callout-tagline.directive';
import { DaffCalloutTitleDirective } from './callout-title/callout-title.directive';

/** @deprecated in favor of {@link DAFF_CALLOUT_COMPONENTS} */
@NgModule({
imports: [
CommonModule,
],
declarations: [
DaffCalloutComponent,
DaffCalloutIconDirective,
DaffCalloutTitleDirective,
Expand Down
15 changes: 15 additions & 0 deletions libs/design/callout/src/callout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { DaffCalloutComponent } from './callout/callout.component';
import { DaffCalloutBodyDirective } from './callout-body/callout-body.directive';
import { DaffCalloutIconDirective } from './callout-icon/callout-icon.directive';
import { DaffCalloutSubtitleDirective } from './callout-subtitle/callout-subtitle.directive';
import { DaffCalloutTaglineDirective } from './callout-tagline/callout-tagline.directive';
import { DaffCalloutTitleDirective } from './callout-title/callout-title.directive';

export const DAFF_CALLOUT_COMPONENTS = <const>[
DaffCalloutComponent,
DaffCalloutIconDirective,
DaffCalloutTitleDirective,
DaffCalloutSubtitleDirective,
DaffCalloutTaglineDirective,
DaffCalloutBodyDirective,
];
7 changes: 5 additions & 2 deletions libs/design/callout/src/callout/callout.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import { DaffCalloutComponent } from './callout.component';
template: `
<daff-callout [color]="color" [textAlignment]="textAlignment" [compact]="compact"></daff-callout>
`,
standalone: true,
imports: [
DaffCalloutComponent,
],
})

class WrapperComponent {
Expand All @@ -36,9 +40,8 @@ describe('@daffodil/design/callout | DaffCalloutComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
imports: [
WrapperComponent,
DaffCalloutComponent,
],
})
.compileComponents();
Expand Down
1 change: 1 addition & 0 deletions libs/design/callout/src/callout/callout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
},
],
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
})
export class DaffCalloutComponent {
constructor(private textAlignable: DaffTextAlignableDirective) {
Expand Down
1 change: 1 addition & 0 deletions libs/design/callout/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { DaffCalloutModule } from './callout.module';
export { DAFF_CALLOUT_COMPONENTS } from './callout';
export * from './callout/callout.component';
export * from './callout-icon/callout-icon.directive';
export * from './callout-tagline/callout-tagline.directive';
Expand Down

0 comments on commit 1de68ab

Please sign in to comment.