Skip to content

Commit 27075cc

Browse files
authored
Merge pull request #12672 from CesiumGS/sandcastle-resize
Add resizing panels to Sandcastle
2 parents 852f7ef + d89959b commit 27075cc

File tree

3 files changed

+44
-38
lines changed

3 files changed

+44
-38
lines changed

packages/sandcastle/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"dependencies": {
1818
"@itwin/itwinui-react": "^5.0.0-alpha.14",
1919
"@monaco-editor/react": "^4.7.0",
20+
"allotment": "^1.20.4",
2021
"monaco-editor": "^0.52.2",
2122
"pako": "^2.1.0",
2223
"prettier": "^3.5.3",

packages/sandcastle/src/App.css

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
height: 100vh;
44
display: grid;
55
grid-template:
6-
"toolbar toolbar"
7-
"code viewer"
8-
"gallery gallery";
9-
grid-template-columns: 50% 50%;
10-
/* Monaco needs a defined height for dynamic resizing to work */
11-
--toolbar-height: 2.5rem;
12-
grid-template-rows:
13-
var(--toolbar-height) calc(100% - var(--toolbar-height) - 150px)
14-
150px;
6+
"toolbar"
7+
"center"
8+
"gallery";
9+
grid-template-rows: max-content auto 150px;
10+
}
11+
12+
.split-view {
13+
/* These control the styling of the Allotment dividers */
14+
--focus-border: var(--ids-color-border-accent-base);
15+
--separator-border: var(--ids-color-border-neutral-base);
1516
}
1617

1718
.toolbar {
@@ -32,22 +33,18 @@
3233
}
3334

3435
.editor-container {
35-
grid-area: code;
3636
display: flex;
3737
flex-direction: column;
38+
height: 100%;
3839

3940
section {
40-
border-top: 1px solid grey;
41+
border-top: 1px solid var(--ids-color-border-neutral-base);
4142
flex-shrink: 1;
42-
/* Monaco needs a defined height for dynamic resizing to work */
43-
--tabs-height: 1.5rem;
44-
height: calc(100% - var(--tabs-height)) !important;
4543
}
4644
}
4745

4846
.viewer-bucket {
49-
grid-area: viewer;
50-
width: 50vw;
47+
height: 100%;
5148
background-color: white;
5249
background-image: var(--_rings), var(--_gradient);
5350
--_rings: repeating-radial-gradient(
@@ -71,6 +68,6 @@
7168

7269
.gallery {
7370
grid-area: gallery;
74-
border-top: 1px solid grey;
71+
border-top: 1px solid var(--ids-color-border-neutral-base);
7572
background: var(--ids-color-bg-page-depth);
7673
}

packages/sandcastle/src/App.tsx

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { useCallback, useEffect, useReducer, useRef, useState } from "react";
2+
import { Allotment } from "allotment";
3+
import "allotment/dist/style.css";
24
import "./App.css";
35

46
import { Button, Root } from "@itwin/itwinui-react/bricks";
@@ -319,27 +321,33 @@ Sandcastle.addToolbarMenu(${variableName});`,
319321
{versionString && <pre>Commit: {versionString.substring(0, 7)}</pre>}
320322
<Button onClick={() => setDarkTheme(!darkTheme)}>Swap Theme</Button>
321323
</div>
322-
<SandcastleEditor
323-
ref={editorRef}
324-
darkTheme={darkTheme}
325-
onJsChange={(value: string = "") =>
326-
dispatch({ type: "setCode", code: value })
327-
}
328-
onHtmlChange={(value: string = "") =>
329-
dispatch({ type: "setHtml", html: value })
330-
}
331-
onRun={() => dispatch({ type: "runSandcastle" })}
332-
js={codeState.code}
333-
html={codeState.html}
334-
/>
335-
<div className="viewer-bucket">
336-
<Bucket
337-
code={codeState.committedCode}
338-
html={codeState.committedHtml}
339-
runNumber={codeState.runNumber}
340-
highlightLine={(lineNumber) => highlightLine(lineNumber)}
341-
/>
342-
</div>
324+
<Allotment>
325+
<Allotment.Pane minSize={400}>
326+
<SandcastleEditor
327+
ref={editorRef}
328+
darkTheme={darkTheme}
329+
onJsChange={(value: string = "") =>
330+
dispatch({ type: "setCode", code: value })
331+
}
332+
onHtmlChange={(value: string = "") =>
333+
dispatch({ type: "setHtml", html: value })
334+
}
335+
onRun={() => dispatch({ type: "runSandcastle" })}
336+
js={codeState.code}
337+
html={codeState.html}
338+
/>
339+
</Allotment.Pane>
340+
<Allotment.Pane minSize={400}>
341+
<div className="viewer-bucket">
342+
<Bucket
343+
code={codeState.committedCode}
344+
html={codeState.committedHtml}
345+
runNumber={codeState.runNumber}
346+
highlightLine={(lineNumber) => highlightLine(lineNumber)}
347+
/>
348+
</div>
349+
</Allotment.Pane>
350+
</Allotment>
343351
<div className="gallery">
344352
<Gallery
345353
demos={galleryItems}

0 commit comments

Comments
 (0)