Skip to content

Commit 02aed87

Browse files
committed
extend the playground
1 parent 7c58a23 commit 02aed87

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

sites/postcss-preset-env/playground.njk

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ description: Play with PostCSS Preset Env in your browser
5353
<option value="bottom-to-top">bottom to top</option>
5454
</select>
5555
</fieldset>
56+
57+
<fieldset>
58+
<label for="enableClientSidePolyfills">enable client-side polyfills</label>
59+
<input type="checkbox" name="enableClientSidePolyfills" id="enableClientSidePolyfills">
60+
</fieldset>
5661
</div>
5762

58-
<div id="input-editor" class="editor"></div>
59-
<div id="config-editor" class="editor" data-preset-env-version="{{ presetVersionPlayground }}"></div>
60-
<div id="output-editor" class="editor"></div>
63+
<div class="editors">
64+
<div id="input-editor" class="editor"></div>
65+
<div id="config-editor" class="editor" data-preset-env-version="{{ presetVersionPlayground }}"></div>
66+
<div id="output-editor" class="editor"></div>
67+
</div>
6168
</div>
6269
</main>
6370
{% endblock %}

sites/postcss-preset-env/src/static/css/pages/_playground.css

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,21 @@
88
}
99

1010
.editors-container {
11+
display: grid;
12+
width: 100%;
13+
grid-template-rows: max-content minmax(0, 1fr);
14+
grid-template-columns: 100%;
15+
gap: var(--space-20);
16+
17+
@media (--from-wide) {
18+
height: calc(100vh - var(--heading-size-from-medium));
19+
}
20+
}
21+
22+
.editors {
1123
display: grid;
1224
gap: var(--space-20);
1325
grid-template-areas:
14-
"controls"
1526
"input"
1627
"output"
1728
"config";
@@ -20,23 +31,21 @@
2031

2132
@media (--from-wide) {
2233
grid-template-areas:
23-
"controls controls"
2434
"input output"
2535
"config output";
26-
grid-template-rows: 80px calc(65% - 60px) calc(35% - 60px);
36+
grid-template-rows: minmax(0, 65%) minmax(0, 35%);
2737
grid-template-columns: calc(50% - var(--space-10)) calc(50% - var(--space-10));
28-
height: calc(100vh - var(--heading-size-from-medium));
38+
height: 100%;
2939
}
3040

31-
@media (width >= 1440px) {
32-
grid-template-rows: 40px calc(65% - 40px) calc(35% - 40px);
41+
@media (width >=1440px) {
42+
grid-template-rows: minmax(0, 65%) minmax(0, 35%);
3343
}
3444
}
3545

3646
#controls {
3747
background-color: #282c34;
3848
color: white;
39-
grid-area: controls;
4049
padding-inline: var(--space-10);
4150

4251
@media (--from-medium) {

sites/postcss-preset-env/src/static/js/playground.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const currentConfig = stateAtLoad.config ?? {
3838
browsers: ['> 0.2% and not dead'],
3939
minimumVendorImplementations: 0,
4040
stage: 2,
41+
enableClientSidePolyfills: false,
4142
logical: {
4243
inlineDirection: 'left-to-right',
4344
blockDirection: 'top-to-bottom',
@@ -110,6 +111,10 @@ function renderConfig(config) {
110111
delete copy.logical.blockDirection;
111112
}
112113

114+
if (!copy.enableClientSidePolyfills) {
115+
delete copy.enableClientSidePolyfills;
116+
}
117+
113118
if (Object.keys(copy.logical).length === 0) {
114119
delete copy.logical;
115120
}
@@ -250,15 +255,17 @@ let controls = {
250255
preserve: document.getElementById('preserve'),
251256
inlineDirection: document.getElementById('inlineDirection'),
252257
blockDirection: document.getElementById('blockDirection'),
258+
enableClientSidePolyfills: document.getElementById('enableClientSidePolyfills'),
253259
};
254260

255261
{
256262
controls.browsers.value = currentConfig.browsers.join(', ');
257263
controls.minimumVendorImplementations.value = currentConfig.minimumVendorImplementations.toString();
258264
controls.inlineDirection.value = currentConfig.logical.inlineDirection;
259265
controls.blockDirection.value = currentConfig.logical.blockDirection;
260-
261266
controls.stage.value = currentConfig.stage.toString();
267+
controls.enableClientSidePolyfills.checked = !!currentConfig.enableClientSidePolyfills;
268+
262269
if (currentConfig.preserve === true) {
263270
controls.preserve.value = 'true';
264271
} else if (currentConfig.preserve === false) {
@@ -280,6 +287,7 @@ for (const control of Object.values(controls)) {
280287
currentConfig.browsers = controls.browsers.value.split(',').filter((x) => !!x);
281288
currentConfig.minimumVendorImplementations = parseInt(controls.minimumVendorImplementations.value || '0', 10);
282289
currentConfig.stage = parseInt(controls.stage.value || '0', 10);
290+
currentConfig.enableClientSidePolyfills = controls.enableClientSidePolyfills.checked;
283291

284292
if (typeof preserve !== 'undefined') {
285293
currentConfig.preserve = preserve;

0 commit comments

Comments
 (0)