Skip to content

Commit 3599bd1

Browse files
authored
Playground in docs (#93)
* First small steps to separate out the playground the initial generated code is bad ... and the model gets constatly lost ... so we need to do this step by step * Dialog now working * Polish the standalone look a bit * Finally * First example with dialog playground
1 parent be74193 commit 3599bd1

14 files changed

Lines changed: 1351 additions & 930 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import {
2+
DialogPlayground,
3+
type DialogPlaygroundProps,
4+
} from "@stackables/bridge-playground";
5+
// Import playground styles - the docs-site custom.css overrides the base layer
6+
// to prevent it from breaking Starlight layout
7+
import "@stackables/bridge-playground/style.css";
8+
9+
/**
10+
* A button that opens a modal with MiniPlayground.
11+
* Used in documentation to provide interactive examples.
12+
*/
13+
export default function MiniPlaygroundModal(props: DialogPlaygroundProps) {
14+
// not-content prevents Starlight's .sl-markdown-content styles (e.g. button
15+
// height overrides, typography resets) from affecting the playground.
16+
return (
17+
<div className="not-content">
18+
<DialogPlayground {...props} />
19+
</div>
20+
);
21+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Playground } from "@stackables/bridge-playground";
1+
import { App } from "@stackables/bridge-playground";
22
import "@stackables/bridge-playground/style.css";
33

44
export default function PlaygroundWrapper() {
5-
return <Playground />;
5+
return <App />;
66
}

packages/docs-site/src/content/docs/reference/30-wiring-routing.mdx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: How to move data from sources to targets, build nested payloads, an
44
---
55

66
import { Aside } from "@astrojs/starlight/components";
7+
import MiniPlaygroundModal from "../../../components/MiniPlaygroundModal.tsx";
78

89
Wires are the fundamental building blocks of The Bridge. They define the exact paths data takes as it flows through your graph.
910

@@ -32,6 +33,49 @@ o.country = "Germany"
3233
3334
```
3435

36+
<MiniPlaygroundModal
37+
client:load
38+
bridge={`
39+
version 1.5
40+
41+
const lorem = {
42+
"ipsum": "dolor sit amet",
43+
"consetetur": 8.9
44+
}
45+
46+
bridge Query.greet {
47+
48+
# witnout alias
49+
50+
with const
51+
52+
# with alias
53+
54+
with input as inp
55+
with output as o
56+
57+
# Pull value from input node
58+
59+
o.nameFromInput <- inp.name
60+
61+
# Constants
62+
63+
o.constNumer = 7.7
64+
o.constString = "just a string"
65+
66+
# Bridge variables also need pulling
67+
68+
o.constFromConst <- const.lorem
69+
}
70+
`}
71+
72+
inputJson={`{
73+
"name": "Hello Bridge"
74+
}`}
75+
76+
autoRun={true}
77+
/>
78+
3579
## 2. Path Scoping Blocks (Nested Objects)
3680

3781
When you are wiring deeply nested JSON objects (like a complex REST API request body), repeating long path prefixes over and over becomes tedious and difficult to read.

packages/docs-site/src/styles/custom.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
@layer theme, base, starlight, catppuccin, components, utilities;
2+
@import "tailwindcss";
3+
/* Source playground components for Tailwind to detect their classes */
4+
/* @source "../../../playground/src"; */
5+
@source "../components";
6+
7+
@theme {
8+
/* Monospace font stack for code editors - same as playground */
9+
--font-mono:
10+
"JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
11+
12+
/* Custom accent colors from playground */
13+
--color-sky-badge: #164e63;
14+
--color-sky-trace: #1e3a5f;
15+
}
16+
17+
/* Override Tailwind's base layer to prevent it breaking Starlight's layout */
18+
@layer base {
19+
html,
20+
body {
21+
/* Reset to auto to let Starlight control layout */
22+
height: auto;
23+
}
24+
}
25+
126
/* Widen the default content column (Starlight default: 45rem / 720px) */
227
/* :root {
328
--sl-content-width: 55rem;

packages/docs-site/worker-configuration.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable */
22
// Generated by Wrangler by running `wrangler types` (hash: e41227086db6ad8bb19b68d77b165868)
3-
// Runtime types generated with workerd@1.20260305.0 2026-02-24 global_fetch_strictly_public,nodejs_compat
3+
// Runtime types generated with workerd@1.20260301.1 2026-02-24 global_fetch_strictly_public,nodejs_compat
44
declare namespace Cloudflare {
55
interface GlobalProps {
66
mainModule: typeof import("./dist/_worker.js/index");
@@ -3328,6 +3328,12 @@ declare abstract class Performance {
33283328
get timeOrigin(): number;
33293329
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
33303330
now(): number;
3331+
/**
3332+
* The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
3333+
*
3334+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
3335+
*/
3336+
toJSON(): object;
33313337
}
33323338
// AI Search V2 API Error Interfaces
33333339
interface AiSearchInternalError extends Error {

packages/playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"private": true,
44
"type": "module",
55
"exports": {
6-
".": "./src/Playground.tsx",
6+
".": "./src/index.ts",
77
"./style.css": "./src/index.css"
88
},
99
"scripts": {

0 commit comments

Comments
 (0)