Skip to content

Commit c3f29cd

Browse files
authored
Merge pull request #14 from openjavaformat/playground-strips
Stack the playground's boxes as strips, in a smaller font
2 parents 342181f + 9070990 commit c3f29cd

3 files changed

Lines changed: 16 additions & 29 deletions

File tree

‎docs/javascripts/playground.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// The Playground page, docs/playground/index.md: formats the code on the left into the pane on the right, in the
1+
// The Playground page, docs/playground/index.md: formats the code of the upper box into the lower one, in the
22
// browser. The formatter is a WebAssembly module, open-java-format.js and open-java-format.js.wasm, which the build
33
// puts next to the page; it is the one the release named by ojf_version carries.
44
//

‎docs/playground/index.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ hide:
88

99
# Playground
1010

11-
Paste Java code on the left and press **Format**. The formatter runs in your browser, compiled to
11+
Paste Java code into the upper box and press **Format**. The formatter runs in your browser, compiled to
1212
WebAssembly from the same release that [the other pages](../get-started/index.md) install: the code is
1313
not sent anywhere, and the result is what the command line would write.
1414

@@ -41,12 +41,6 @@ class Example {
4141
</textarea>
4242
</div>
4343

44-
<div class="ojf-playground__pane">
45-
<label for="ojf-output">open-java-format {{ ojf_version }}</label>
46-
<textarea id="ojf-output" spellcheck="false" wrap="off" readonly></textarea>
47-
<button id="ojf-copy" class="ojf-playground__copy" type="button" hidden>Copy</button>
48-
</div>
49-
5044
<div class="ojf-playground__bar" markdown>
5145

5246
<button id="ojf-format" class="md-button md-button--primary" type="button" disabled>Format</button>
@@ -81,6 +75,12 @@ The formatter did not load. Reload the page to try again, or use the
8175

8276
</div>
8377

78+
<div class="ojf-playground__pane">
79+
<label for="ojf-output">open-java-format {{ ojf_version }}</label>
80+
<textarea id="ojf-output" spellcheck="false" wrap="off" readonly></textarea>
81+
<button id="ojf-copy" class="ojf-playground__copy" type="button" hidden>Copy</button>
82+
</div>
83+
8484
</div>
8585

8686
Thank you to Denis Pavlyuchenko ([@pavlyuchenko_denis](https://t.me/pavlyuchenko_denis) on Telegram),

‎docs/stylesheets/playground.css‎

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* The Playground page, docs/playground/index.md: the code and the result side by side, stacked on a narrow screen.
2-
Colours and fonts are the theme's, so both palettes work. */
1+
/* The Playground page, docs/playground/index.md: the code, the Format bar and the result, one under another, each the
2+
width of the page. Colours and fonts are the theme's, so both palettes work. */
33

44
/* The Playground tab in the header stands out on every page: white on the theme's blue, like the Format button.
55
Its href is relative, ./playground/ or ../playground/, so the selector matches the end. */
@@ -23,13 +23,6 @@
2323
gap: 1rem;
2424
}
2525

26-
/* The theme's own breakpoint for a wide screen. */
27-
@media screen and (min-width: 60em) {
28-
.ojf-playground {
29-
grid-template-columns: 1fr 1fr;
30-
}
31-
}
32-
3326
.ojf-playground__pane {
3427
position: relative;
3528
display: flex;
@@ -45,27 +38,22 @@
4538
.ojf-playground textarea {
4639
box-sizing: border-box;
4740
width: 100%;
48-
height: 45vh;
49-
min-height: 16rem;
41+
/* A strip, low and as wide as the page, which a long line of the formatter's 120 columns fits. Either box can be
42+
pulled taller. */
43+
height: min(30vh, 20rem);
44+
min-height: 10rem;
5045
padding: 0.8em 1.2em;
5146
border: 1px solid var(--md-default-fg-color--lightest);
5247
border-radius: 0.1rem;
5348
background-color: var(--md-code-bg-color);
5449
color: var(--md-code-fg-color);
5550
font-family: var(--md-code-font-family);
56-
font-size: 0.75rem;
51+
font-size: 0.65rem;
5752
line-height: 1.4;
5853
tab-size: 4;
5954
white-space: pre;
6055
overflow: auto;
61-
resize: none;
62-
}
63-
64-
/* Side by side, the panes can take most of the window; stacked, two of them have to fit. */
65-
@media screen and (min-width: 60em) {
66-
.ojf-playground textarea {
67-
height: min(70vh, 40rem);
68-
}
56+
resize: vertical;
6957
}
7058

7159
.ojf-playground textarea:focus {
@@ -91,7 +79,6 @@
9179
}
9280

9381
.ojf-playground__bar {
94-
grid-column: 1 / -1;
9582
display: flex;
9683
flex-wrap: wrap;
9784
align-items: center;

0 commit comments

Comments
 (0)