Skip to content

Commit

Permalink
fix(design): update createCustomElementFromExample for API break
Browse files Browse the repository at this point in the history
  • Loading branch information
damienwebdev committed Jul 22, 2024
1 parent a64c8f4 commit c20e3f6
Showing 1 changed file with 5 additions and 16 deletions.
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,
});

0 comments on commit c20e3f6

Please sign in to comment.