Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Playground] Resize panels #1204

Merged
merged 13 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@sindresorhus/slugify": "^1.1.2",
"@spectrum-web-components/shared": "^0.47.2",
"@spectrum-web-components/split-view": "^0.47.2",
"@types/deep-equal": "^1.0.4",
"@types/jquery": "^3.5.31",
"@types/jqueryui": "^1.12.23",
Expand Down
2 changes: 2 additions & 0 deletions source/assets/js/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import debounce from 'lodash/debounce';
import {Logger, OutputStyle, Syntax, compileString, info} from 'sass';

import {displayForConsoleLog} from './playground/console-utils.js';
import setUpSplitView from './playground/split-view.js';

import {
changeSyntax,
Expand All @@ -29,6 +30,7 @@ type Timer = undefined | number;
const MICROINTERACTION_RESET_TIME = 3000;

function setupPlayground(): void {
setUpSplitView();
const hash = location.hash.slice(1);
const hashState = deserializeState(hash);

Expand Down
17 changes: 17 additions & 0 deletions source/assets/js/playground/split-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {SplitView} from '@spectrum-web-components/split-view';
import '@spectrum-web-components/split-view/sp-split-view.js';

/**
* Make split views responsive and stack vertically on narrow screens.
*/
export default function setUpSplitView(): void {
// 60em = --sl-breakpoint--large
const mql = window.matchMedia('(max-width: 60em');
const topSplit = document.querySelector('.sl-c-playground') as SplitView;

function updateLayout(event: MediaQueryListEvent | MediaQueryList): void {
if (topSplit) topSplit.vertical = event.matches;
}
updateLayout(mql);
mql.addEventListener('change', updateLayout);
}
29 changes: 17 additions & 12 deletions source/assets/sass/components/_playground.scss
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,27 @@ $playground-base-colors: (

// Playground Editor area
.sl-c-playground {
--mod-splitview-gripper-width: 100%;
--mod-splitview-gripper-height: 100%;
--mod-splitview-gripper-border-width-horizontal: 0;
--mod-splitview-gripper-border-width-vertical: 0;
--mod-splitview-handle-width: var(--sl-gutter);
--mod-splitview-handle-background-color: var(--sl-color--code-divider);
--mod-splitview-handle-background-color-down: var(--sl-color--code-divider);
--mod-splitview-handle-background-color-focus: var(--sl-color--code-divider-active);
--mod-splitview-handle-background-color-hover: var(--sl-color--code-divider);
--sl-block-margin--callout: 0;
--sl-block-padding--callout: var(--sl-gutter--quarter);
--sl-color--button--tab: var(--sl-color--action-dark);

display: grid;
gap: var(--sl-gutter);
grid-template:
'sass' 1fr
'css' auto
'debug' auto / 100%;

@include config.sl-breakpoint--large {
// magic numbers, the layout is well balanced with these proportions
grid-template:
'sass css' minmax(20ex, 1fr)
'sass debug' minmax(0, 40%) / 1fr 1fr;
height: 100%;
overflow: inherit;
}
}

.sl-c-playground__panel {
container: playground-panel / inline-size;
display: grid;
overflow: inherit;
grid-template:
Expand All @@ -147,6 +146,12 @@ $playground-base-colors: (
'editor-code' 1fr / 1fr;
}

@container playground-panel (inline-size < 50ch) {
.sl-c-playground__editor-tabbar {
flex-wrap: wrap;
}
}

.sl-c-playground__panel-content {
grid-area: editor-code;
overflow: hidden auto;
Expand Down Expand Up @@ -361,7 +366,7 @@ $playground-base-colors: (
&.sl-c-button--icon {
--sl-background--button: transparent;
--sl-background--button-state: transparent;
--sl-block-padding--button: 0;
--sl-block-padding--button: var(--sl-gutter--half);
--sl-color--button: var(--sl-color--text-medium-dark);
--sl-color--button-state: var(--sl-color--action-dark);

Expand Down
2 changes: 2 additions & 0 deletions source/assets/sass/config/color/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ $sl-color--code-base: #066;
$sl-color--code-cool: #458;
$sl-color--code-dark: black;
$sl-color--code-highlight-light: rgba($sl-color--warning-light, 0.2);
$sl-color--code-divider: var(--sl-color--white);
$sl-color--code-divider-active: var(--sl-color--link-action);

// Playground Status
$sl-color--code-error: #cf0254;
Expand Down
Loading