Skip to content

Commit 1d54a0e

Browse files
authored
fix: FIT-155: Improve playground inline preview styles within docs (#7614)
1 parent 5368279 commit 1d54a0e

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

docs/themes/v2/source/css/styles.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,8 @@ code.hljs {
23272327
#main-preview iframe {
23282328
width: 100%;
23292329
margin: 1em 0;
2330+
border: 1px var(--color-gray-300) solid;
2331+
border-radius: .75rem;
23302332
}
23312333

23322334
.page-type-playground .content-markdown {

docs/themes/v2/source/js/code-blocks-enhancements.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function encodeConfig(text) {
1818
return encodeURIComponent(normalizeNewlines(text));
1919
}
2020

21-
function editorIframe(config, modal, id) {
21+
function editorIframe(config, modal, id, inline = false) {
2222
// generate new iframe
2323
const iframeTemplate = `<iframe id="render-editor-${id}" class="api-render-editor" style="display:none"></iframe>`;
2424

@@ -34,7 +34,7 @@ function editorIframe(config, modal, id) {
3434

3535
const templateValue = encodeConfig(config);
3636

37-
iframe.src = `${getLabelStudioPlaygroundUrl()}?config=${templateValue}&mode=preview`;
37+
iframe.src = `${getLabelStudioPlaygroundUrl()}?config=${templateValue}&mode=${inline ? "preview-inline" : "preview"}`;
3838
}
3939

4040
function showRenderEditor(config) {
@@ -106,7 +106,7 @@ function showRenderEditor(config) {
106106

107107
const inlinePlayground = document.querySelector("#main-preview");
108108

109-
if (inlinePlayground) editorIframe(code, inlinePlayground);
109+
if (inlinePlayground) editorIframe(code, inlinePlayground, true);
110110
};
111111

112112
const enhanceCodeBlocks = (codeBlock) => {

web/apps/playground/src/atoms/configAtoms.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export const showPreviewAtom = atom<boolean>(true);
1111
export const sampleTaskAtom = atom<any>({});
1212
export const annotationAtom = atom<any>([]);
1313
export const modeAtom = atom<"preview" | "editor" | "">("editor");
14-
export const displayModeAtom = atom<"preview" | "all">(() => {
14+
export const displayModeAtom = atom<"preview" | "preview-inline" | "all">(() => {
1515
const params = getQueryParams();
1616
const mode = params.get("mode");
1717
if (mode === "preview") return "preview";
18+
if (mode === "preview-inline") return "preview-inline";
1819
return "all";
1920
});

web/apps/playground/src/components/PlaygroundApp/PlaygroundApp.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ export const PlaygroundApp = () => {
119119
>
120120
<ToastProvider>
121121
{/* Minimal top bar */}
122-
{displayMode !== "preview" && <TopBar />}
122+
{!displayMode.startsWith("preview") && <TopBar />}
123123
{/* Editor/Preview split */}
124124
<div className="flex flex-1 min-h-0 min-w-0 relative">
125125
{/* Editor Panel */}
126-
{displayMode !== "preview" && <EditorPanel editorWidth={editorWidth} />}
126+
{!displayMode.startsWith("preview") && <EditorPanel editorWidth={editorWidth} />}
127127
{/* Resizable Divider */}
128-
{displayMode !== "preview" && (
128+
{!displayMode.startsWith("preview") && (
129129
<div
130130
className="w-2 cursor-col-resize bg-neutral-emphasis hover:bg-primary-border active:bg-primary-border transition-colors duration-100 z-10"
131131
onMouseDown={(e: MouseEvent) => {

web/apps/playground/src/components/PreviewPanel/PreviewPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export const PreviewPanel: FC<PreviewPanelProps> = memo(
8484
settings: {
8585
forceBottomPanel: true,
8686
collapsibleBottomPanel: true,
87-
defaultCollapsedBottomPanel: displayMode === "all",
87+
// Default collapsed in all,preview-inline, but not in preview
88+
defaultCollapsedBottomPanel: displayMode !== "preview",
8889
fullscreen: false,
8990
},
9091
onStorageInitialized: (LS: any) => {

0 commit comments

Comments
 (0)