@dreamlake/dockit 0.2.31 → 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,5 +12,10 @@ export interface PreviewProps {
12
12
  defaultTab?: 'preview' | 'source' | 'data';
13
13
  /** Force a height for the preview pane. */
14
14
  height?: number | string;
15
+ /** `split` shows the source and the live render side by side (source on
16
+ * the left), stacking source above preview when the frame is narrower
17
+ * than 560px. The preview pane is then a size container, so a demo's
18
+ * container queries follow the pane's width. Default `tabs`. */
19
+ layout?: 'tabs' | 'split';
15
20
  }
16
- export declare function Preview({ children, source, dataSource, filename, defaultTab, height, }: PreviewProps): import("react").JSX.Element;
21
+ export declare function Preview({ children, source, dataSource, filename, defaultTab, height, layout, }: PreviewProps): import("react").JSX.Element;
@@ -161,9 +161,12 @@ function Preview({
161
161
  dataSource,
162
162
  filename,
163
163
  defaultTab = "preview",
164
- height
164
+ height,
165
+ layout = "tabs"
165
166
  }) {
166
- const [tab, setTab] = useState(defaultTab);
167
+ const split = layout === "split";
168
+ const [selectedTab, setTab] = useState(defaultTab);
169
+ const tab = split ? "source" : selectedTab;
167
170
  const [copied, setCopied] = useState(false);
168
171
  const [fullscreen, setFullscreen] = useState(false);
169
172
  const [showLines, setShowLines] = useLineNumbers();
@@ -187,7 +190,8 @@ function Preview({
187
190
  "div",
188
191
  {
189
192
  "data-line-numbers": showLines ? "on" : "off",
190
- className: "border border-doc-template-faint bg-doc-template-panel",
193
+ ...split ? { "data-preview-layout": "split" } : null,
194
+ className: "dockit-preview border border-doc-template-faint bg-doc-template-panel",
191
195
  style: fullscreen ? {
192
196
  // Full-viewport overlay. `--color-doc-template-bg` is the page
193
197
  // surface token so the backdrop matches the site in both light
@@ -213,7 +217,7 @@ function Preview({
213
217
  background: "color-mix(in srgb, var(--color-doc-template-ink) 3%, transparent)"
214
218
  },
215
219
  children: [
216
- /* @__PURE__ */ jsx("div", { style: { display: "inline-flex", gap: 2 }, role: "tablist", children: ["preview", "source", ...dataSource ? ["data"] : []].map((t) => {
220
+ split ? /* @__PURE__ */ jsx("span", { style: { ...TAB, color: "var(--color-doc-template-muted)", cursor: "default", display: "inline-flex", alignItems: "center" }, children: "Source · Preview" }) : /* @__PURE__ */ jsx("div", { style: { display: "inline-flex", gap: 2 }, role: "tablist", children: ["preview", "source", ...dataSource ? ["data"] : []].map((t) => {
217
221
  const active = t === tab;
218
222
  return /* @__PURE__ */ jsx(
219
223
  "button",
@@ -285,7 +289,31 @@ function Preview({
285
289
  ]
286
290
  }
287
291
  ),
288
- tab === "preview" ? /* @__PURE__ */ jsxs(
292
+ split ? /* @__PURE__ */ jsxs(
293
+ "div",
294
+ {
295
+ className: "dockit-preview-split",
296
+ style: fullscreen ? { flex: 1, minHeight: 0, overflow: "auto" } : void 0,
297
+ children: [
298
+ /* @__PURE__ */ jsx(
299
+ "div",
300
+ {
301
+ className: "dockit-preview-split-source",
302
+ style: { background: "var(--color-doc-template-code)", minWidth: 0 },
303
+ children: /* @__PURE__ */ jsx(HighlightedSource, { code: source, filename })
304
+ }
305
+ ),
306
+ /* @__PURE__ */ jsx(
307
+ "div",
308
+ {
309
+ className: "dockit-preview-split-render",
310
+ style: { padding: 24, minHeight: 80, minWidth: 0, ...height ? { height } : null },
311
+ children
312
+ }
313
+ )
314
+ ]
315
+ }
316
+ ) : tab === "preview" ? /* @__PURE__ */ jsxs(
289
317
  "div",
290
318
  {
291
319
  ...fullscreen ? { "data-preview-fill": "" } : null,
package/dist/styles.css CHANGED
@@ -468,3 +468,15 @@
468
468
  /* Touch has no hover-away state: leave room so actions never mask code. */
469
469
  [data-code-block]:has(> .dockit-code-controls) > div:last-child { padding-top: 30px; }
470
470
  }
471
+
472
+ /* Preview layout="split": source left, live render right; stacked when the
473
+ frame is narrower than 560px. The render pane is a size container so a
474
+ demo's container queries follow the pane, not the page. */
475
+ .dockit-preview[data-preview-layout='split'] { container: dockit-preview / inline-size; }
476
+ .dockit-preview-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
477
+ .dockit-preview-split-source { border-right: 1px solid var(--color-doc-template-faint); overflow-x: auto; }
478
+ .dockit-preview-split-render { container-type: inline-size; }
479
+ @container dockit-preview (max-width: 560px) {
480
+ .dockit-preview-split { grid-template-columns: minmax(0, 1fr); }
481
+ .dockit-preview-split-source { border-right: 0; border-bottom: 1px solid var(--color-doc-template-faint); }
482
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dockit",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
4
4
  "description": "The DreamLake documentation shell — Vike + React + Tailwind v4 + MDX docs framework with sidebar, TOC, search, and theming",
5
5
  "license": "MIT",
6
6
  "type": "module",