import { justTestApp } from '@just-web/app/testing' import React from 'react' import { tersify } from 'tersify' import { mapKey } from 'type-plus' import { createJustAppContext } from '../contexts/create_just_app_context.js' import type { JustReactApp } from '../contexts/just_app_context.js' import { reactGizmo } from '../gizmos/react_gizmo.js' import { useJustAppContext } from '../hooks/use_just_app_context.js' import { type ValueGizmo, valueGizmoFn } from './value_gizmo.js' /** * Normally you would not create the `app`/`incubator` at load time. * * You typically should create your app at runtime. * So that you can use some runtime information to construct the app, * like passing different options to each gizmo functions. * * Doing it at load time is possible, but not recommended. */ const app2 = justTestApp({ name: 'app 2' }) .with(valueGizmoFn({ value: 50 })) .with(reactGizmo) /** * Define the app type based on what the app needs, * and how it is composed in runtime. */ type JustApp2 = JustReactApp & ValueGizmo export const App2Context = createJustAppContext() export function activate() { return app2.create((app) => app.react.providers.register(({ children }) => {children}) ) } export function App2Info({ title }: { title?: string }) { const app = useJustAppContext(App2Context) return (
{title &&

{title}

}

App 2 Info

The app 2 contains the following info:

{mapKey(app, (key) => (

{key}: {tersify(app![key], { maxLength: 50 })}

))}
) }