diff --git a/packages/app-experiments/src/Experiment1.tsx b/packages/app-experiments/src/Experiment1.tsx index 6453ad1179..0b5496f431 100644 --- a/packages/app-experiments/src/Experiment1.tsx +++ b/packages/app-experiments/src/Experiment1.tsx @@ -192,14 +192,19 @@ function createExtensionPointRef( // point: 'bottom' // }) -const SplitLayout = container.createExtension({ +const gridItemExtensionPointTypeRef = createExtensionPointTypeRef<{ + title: string; + Component: ComponentType; +}>(); + +const SplitGridLayout = container.createExtension({ points: { top: { - typeRef: coreExtensionPointTypes.component, + typeRef: gridItemExtensionPointTypeRef, configSchema: z.object({}), }, bottom: { - typeRef: coreExtensionPointTypes.component, + typeRef: gridItemExtensionPointTypeRef, configSchema: z.object({}), }, }, @@ -207,6 +212,8 @@ const SplitLayout = container.createExtension({ factory: ({ id, points }) => () => { + const topCards = useExtensionInstanceChildren(id, points.top); + const bottomCards = useExtensionInstanceChildren(id, points.bottom); return (
- + {topCards.map(card => ( + <> +

{card.title}

+ + + ))}
- + {bottomCards.map(card => ( + <> +

{card.title}

+ + + ))}
); }, }); -// const SnazzySplitLayout = container.replaceExtension(SplitLayout, { +// const SnazzySplitLayout = container.replaceExtension(SplitGridLayout, { // factory: ({ id, points }) => { // ... // } @@ -238,9 +255,9 @@ const SplitLayout = container.createExtension({ const Box = container.createExtension({ points: {}, - mountTypeRef: coreExtensionPointTypes.component, - factory: ({ config }: { config: { color: string } }) => { - return () => ( + mountTypeRef: gridItemExtensionPointTypeRef, + factory: ({ config }: { config: { color: string; title?: string } }) => { + const Component = () => ( /** * If I need stuff, I have to get it from context. */ @@ -248,6 +265,9 @@ const Box = container.createExtension({ {config.color} ); + // registerOutput(gridItemExtensionPointTypeRef, {title: config.title ?? ''}) + // registerOutput(coreExtensionPointTypes.component, Component) + return { Component, title: config.title ?? '' }; }, }); @@ -258,13 +278,14 @@ const StyledBox = container.createExtension({ configSchema: z.object({}), }, }, - mountTypeRef: coreExtensionPointTypes.component, + mountTypeRef: gridItemExtensionPointTypeRef, factory: ({ id, points }) => { - return () => { + const Component = () => { const [style] = useExtensionInstanceChildren(id, points.style); return
Styled box
; }; + return { Component, title: 'derp' }; }, }); @@ -318,24 +339,24 @@ export function Experiment1() { id: 'layout', mount: 'root/default', // Maybe can omit /default here? config: {}, - extension: SplitLayout, + extension: SplitGridLayout, }, { id: 'red', mount: 'layout/top', - config: { color: 'red' }, + config: { color: 'red', title: 'RED' }, extension: Box, }, { id: 'green', mount: 'layout/top', - config: { color: 'green' }, + config: { color: 'green', title: 'GREEN' }, extension: Box, }, { id: 'blue', mount: 'layout/bottom', - config: { color: 'blue' }, + config: { color: 'blue', title: 'BLUE' }, extension: Box, }, { @@ -350,6 +371,12 @@ export function Experiment1() { config: { color: 'purple' }, extension: BoxStyle, }, + // { + // id: 'catalogPage', + // mount: 'core/routes', + // config: { path: '/catalog' }, + // extension: Route, + // }, ]); return ( @@ -368,6 +395,17 @@ export function Experiment1() { ); } +/** + * Continued exploration: + * + * - routing + * - dynamic extension points + * - mount point config + * - declarative mixed with code, e.g. + * - lazy loading + * - defaults + */ + /* // graphiql-plugin