import { TempstreamJSX, Templatable } from "tempstream"; import { BaseContext } from "koa"; import { StatefulPage } from "@sealcode/sealgen"; import html from "../html.js"; import { registry } from "../jdd-components/components.js"; import { render, simpleJDDContext } from "@sealcode/jdd"; export const actionName = "Components"; const actions = {} as const; type State = { component: string; args: Record; }; export default new (class ComponentsPage extends StatefulPage { actions = actions; getInitialState() { return { component: "", args: {} }; } wrapInLayout(ctx: BaseContext, content: Templatable): Templatable { return html(ctx, "Components", content); } render(ctx: BaseContext, state: State, inputs: Record) { const all_components = registry.getAll(); const component = registry.get(state.component) || Object.values(all_components)[0]; return (
{JSON.stringify(state)}
Parameters {Object.entries(component.getArguments()).map(([arg_name, arg]) => (
))}
Preview {render( registry, [{ component_name: state.component, args: state.args }], simpleJDDContext )}
); } })();