-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(daffio): replace dynamic doc renderer with service in page compo…
…nent (#3419)
- Loading branch information
Showing
27 changed files
with
141 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/docs/api/components/api-content/api-content.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { DaffioDocsApiContentComponent } from './api-content.component'; | ||
import { provideDaffioDocsDynamicContentComponents } from '../../../dynamic-content/dynamic-content-components.token'; | ||
|
||
export const daffioDocsApiContentComponentProvider = () => provideDaffioDocsDynamicContentComponents(DaffioDocsApiContentComponent); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
apps/daffio/src/app/docs/components/doc-renderer/component.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
apps/daffio/src/app/docs/dynamic-content/dynamic-content-component.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Inject, | ||
Injectable, | ||
Type, | ||
} from '@angular/core'; | ||
|
||
import { daffArrayToDict } from '@daffodil/core'; | ||
import { | ||
DaffDoc, | ||
DaffDocKind, | ||
} from '@daffodil/docs-utils'; | ||
|
||
import { | ||
DAFFIO_DOCS_DYNAMIC_CONTENT_COMPONENTS, | ||
DaffioDocsDynamicContentComponentInjection, | ||
} from './dynamic-content-components.token'; | ||
import { DaffioDocsDynamicContent } from './dynamic-content.type'; | ||
import { DaffioDocsDefaultContentComponent } from '../components/default-content/default-content.component'; | ||
|
||
@Injectable() | ||
export class DaffioDocsDynamicContentComponentService<T extends DaffDoc = DaffDoc> { | ||
private readonly _map: Record<DaffDocKind, DaffioDocsDynamicContentComponentInjection<T>> = daffArrayToDict(this.components, (c) => c.kind); | ||
|
||
constructor( | ||
@Inject(DAFFIO_DOCS_DYNAMIC_CONTENT_COMPONENTS) private components: Array<DaffioDocsDynamicContentComponentInjection<T>>, | ||
) {} | ||
|
||
getComponent(doc: T): Type<DaffioDocsDynamicContent<T>> { | ||
return this._map[doc.kind] || DaffioDocsDefaultContentComponent; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/daffio/src/app/docs/dynamic-content/dynamic-content-components.token.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Type } from '@angular/core'; | ||
|
||
import { createMultiInjectionToken } from '@daffodil/core'; | ||
import { | ||
DaffDoc, | ||
DaffDocKind, | ||
} from '@daffodil/docs-utils'; | ||
|
||
import { DaffioDocsDynamicContent } from './dynamic-content.type'; | ||
|
||
export type DaffioDocsDynamicContentComponentInjection<T extends DaffDoc = DaffDoc> = {readonly kind: DaffDocKind} & Type<DaffioDocsDynamicContent<T>>; | ||
|
||
export const { | ||
token: DAFFIO_DOCS_DYNAMIC_CONTENT_COMPONENTS, | ||
provider: provideDaffioDocsDynamicContentComponents, | ||
} = createMultiInjectionToken<DaffioDocsDynamicContentComponentInjection>('DAFFIO_DOCS_DYNAMIC_CONTENT_COMPONENTS'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/docs/guides/components/guides-content/guides-content.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { DaffioDocsGuidesContentComponent } from './guides-content.component'; | ||
import { provideDaffioDocsDynamicContentComponents } from '../../../dynamic-content/dynamic-content-components.token'; | ||
|
||
export const daffioDocsGuidesContentComponentProvider = () => provideDaffioDocsDynamicContentComponents(DaffioDocsGuidesContentComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { NgModule } from '@angular/core'; | ||
|
||
import { daffioDocsGuideComponentProvider } from './components/doc/provider'; | ||
import { daffioDocsGuidesContentComponentProvider } from './components/guides-content/guides-content.provider'; | ||
import { DaffioGuidesRoutingModule } from './guides-routing.module'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
DaffioGuidesRoutingModule, | ||
], | ||
providers: [ | ||
daffioDocsGuideComponentProvider(), | ||
daffioDocsGuidesContentComponentProvider(), | ||
], | ||
}) | ||
export class DaffioGuidesModule {} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
apps/daffio/src/app/docs/packages/components/packages-content/packages-content.provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { DaffioDocsPackagesContentComponent } from './packages-content.component'; | ||
import { provideDaffioDocsDynamicContentComponents } from '../../../dynamic-content/dynamic-content-components.token'; | ||
|
||
export const daffioDocsPackagesContentComponentProvider = () => provideDaffioDocsDynamicContentComponents(DaffioDocsPackagesContentComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apps/daffio/src/app/docs/pages/docs-page/docs-page.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<daffio-doc-renderer [doc]="doc$ | async"></daffio-doc-renderer> | ||
<ng-template [ngComponentOutlet]="component$ | async" [ngComponentOutletInputs]="{doc: doc$ | async}"></ng-template> |
Oops, something went wrong.