-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(design): update createCustomElementFromExample for API break
- Loading branch information
1 parent
a64c8f4
commit c20e3f6
Showing
1 changed file
with
5 additions
and
16 deletions.
There are no files selected for viewing
21 changes: 5 additions & 16 deletions
21
apps/design-land/src/app/core/elements/create-element-from-example.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 |
---|---|---|
@@ -1,26 +1,15 @@ | ||
import { | ||
ɵcreateInjector, | ||
Injector, | ||
Type, | ||
} from '@angular/core'; | ||
import { createCustomElement } from '@angular/elements'; | ||
|
||
import { ComponentExample } from '@daffodil/design'; | ||
|
||
/** | ||
* Creates a custom element from a Component Example to be used to render complex | ||
* component examples in the docs. | ||
*/ | ||
export const createCustomElementFromExample = (example: ComponentExample, injector: Injector) => { | ||
if(typeof example === 'function'){ | ||
return { | ||
element: createCustomElement(example, { injector }), | ||
class: example, | ||
}; | ||
} else { | ||
return { | ||
element: createCustomElement(example.component, { injector: ɵcreateInjector(example.module, injector) }), | ||
class: example.component, | ||
}; | ||
} | ||
}; | ||
export const createCustomElementFromExample = (example: Type<unknown>, injector: Injector) => ({ | ||
element: createCustomElement(example, { injector }), | ||
class: example, | ||
}); | ||
|