export interface CustomJsxExample { id: string; title: string; description: string; template: string; requests: readonly Record[]; } export const customJsxExamples: readonly CustomJsxExample[] = [ { id: "simple-metric", title: "Simple metric", description: "A compact status and metric display with no nested requests.", template: ` {data.name} {data.status} {data.value} `, requests: [], }, { id: "pokedex-detail", title: "Pokédex detail list", description: "Paginates the list and fetches details only for visible Pokémon.", template: ` Pokédex {data.results.map((pokemon) => {pokemon.name} {(detail, meta) => {detail.types.map((entry) => {entry.type.name})} HP {detail.stats[0].base_stat} · HTTP {meta.status} } )} `, requests: [ { id: "pokemon-detail", kind: "query", method: "GET", pathTemplate: "/api/v2/pokemon/{name}", parameters: { name: "string" }, auth: "none", minimumBoardPermission: "view", cacheTtlSeconds: 300, }, ], }, { id: "stocks-dashboard", title: "Stocks dashboard", description: "Responsive portfolio values and chart with parent refresh.", template: ` Portfolio {data.holdings.map((stock) => {stock.symbol} 0 ? "green" : "red"} /> )} `, requests: [], }, { id: "navidrome-player", title: "Navidrome mini-player", description: "Media controls backed by named actions with explicit permissions.", template: ` {data.album} {data.title} {data.artist} `, requests: [ { id: "previous", kind: "action", method: "POST", pathTemplate: "/api/player/previous", parameters: {}, auth: "inherit", minimumBoardPermission: "modify", }, { id: "toggle-playback", kind: "action", method: "POST", pathTemplate: "/api/player/toggle", parameters: {}, auth: "inherit", minimumBoardPermission: "modify", }, { id: "next", kind: "action", method: "POST", pathTemplate: "/api/player/next", parameters: {}, auth: "inherit", minimumBoardPermission: "modify", }, { id: "shuffle", kind: "action", method: "PUT", pathTemplate: "/api/player/shuffle", parameters: { enabled: "boolean" }, bodyTemplate: { enabled: { $param: "enabled" } }, auth: "inherit", minimumBoardPermission: "modify", }, ], }, { id: "pokedex-interactive", title: "Interactive Pokédex", description: "A full-featured Pokédex with paginated list, detail SubFetch, type badges, stats with progress bars, moves grid, and evolution chain. Exercises filter(Boolean), pop(), find, reduce, sort, replaceAll, padStart, arithmetic, and nested SubFetch.", template: ` P Pokédex Pokémon discovered {data.results.map((pokemon, index) => #{String(index + 1).padStart(4, "0")} {pokemon.name.replaceAll("-", " ")} Details {(detail, meta) =>
{detail.name}
{detail.types.map((entry) => {entry.type.name} )} Height Weight Base XP{detail.base_experience || "—"} {detail.abilities.map((entry) => {entry.ability.name.replaceAll("-", " ")}{entry.is_hidden ? " ·H" : ""} )}
Stats Moves {detail.stats.map((entry) => {entry.stat.name.replaceAll("-", " ")} {entry.base_stat} )} Total {detail.stats.reduce((sum, s) => sum + s.base_stat, 0)} {detail.moves.slice(0, 30).map((entry) => {entry.move.name.replaceAll("-", " ")} )} Status: {meta.status}
}
)}
`, requests: [ { id: "pokemon-detail", kind: "query", method: "GET", pathTemplate: "/api/v2/pokemon/{name}", parameters: { name: "string" }, auth: "none", minimumBoardPermission: "view", cacheTtlSeconds: 3600, }, ], }, { id: "smart-home-control", title: "Smart-home control", description: "A stateful light control with an explicit destructive confirmation.", template: ` Living room {data.state} `, requests: [ { id: "set-light", kind: "action", method: "PUT", pathTemplate: "/api/lights/living-room", parameters: { state: "string" }, bodyTemplate: { state: { $param: "state" } }, auth: "inherit", minimumBoardPermission: "modify", }, { id: "delete-scene", kind: "action", method: "DELETE", pathTemplate: "/api/scenes/living-room", parameters: {}, auth: "inherit", minimumBoardPermission: "full", }, ], }, ];