Skip to content
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ for screen readers, and animation between layouts (off when the system asks for

Colours and sizes come from custom properties (`--mp-bg`, `--mp-surface`, `--mp-header-bg`,
`--mp-border`, `--mp-text`, `--mp-muted`, `--mp-accent`, `--mp-drop`, and so on) set on
`.mp-workspace` or any ancestor.
`.mp-workspace` or any ancestor. The default colours follow the page's `color-scheme`: set
`color-scheme: light dark` on the root to follow the system, or `light` or `dark` to fix it.

The core can be used without React: `computeLayout(state, size, options)` returns rectangles for
every stack, panel and splitter, `dropTargetAt` says where a dragged panel would land, and
Expand Down
1 change: 1 addition & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>mdbase panels demo</title>
<style>
:root { color-scheme: light dark; }
html, body, #app { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, sans-serif; }
.shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdbase-dev/panels",
"version": "0.3.1",
"version": "0.4.0",
"description": "A workspace of panels for the web: tabs, splits and side regions over a layout document, with panels that keep their identity.",
"license": "MIT",
"repository": {
Expand Down
14 changes: 8 additions & 6 deletions src/styles.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* Theme with custom properties on .mp-workspace or any ancestor. Every colour has a default
* for light and dark, so the workspace is usable unstyled.
* Theme with custom properties on .mp-workspace or any ancestor. The defaults sit on the root
* with no specificity, so a value set anywhere above the workspace wins over them. Each colour
* has a light and a dark default, chosen by the page's color-scheme.
*/
.mp-workspace {
:where(:root) {
--mp-bg: light-dark(#f4f4f2, #18181a);
--mp-surface: light-dark(#ffffff, #202023);
--mp-header-bg: light-dark(#ececea, #1b1b1e);
Expand All @@ -11,13 +12,14 @@
--mp-muted: light-dark(#6b6b70, #9a9aa2);
--mp-accent: light-dark(#2f6fde, #7aa7ff);
--mp-tab-hover: light-dark(rgb(0 0 0 / 5%), rgb(255 255 255 / 6%));
--mp-drop: color-mix(in srgb, var(--mp-accent) 22%, transparent);
--mp-shadow: 0 8px 28px rgb(0 0 0 / 22%);
--mp-radius: 6px;
--mp-font: inherit;
--mp-tab-max-width: 220px;
--mp-splitter-hit: 9px;
}

.mp-workspace {
position: relative;
width: 100%;
height: 100%;
Expand All @@ -27,7 +29,6 @@
background: var(--mp-bg);
color: var(--mp-text);
font: var(--mp-font);
color-scheme: light dark;
isolation: isolate;
}

Expand Down Expand Up @@ -209,7 +210,8 @@
z-index: 4;
border: 2px solid var(--mp-accent);
border-radius: var(--mp-radius);
background: var(--mp-drop);
/* Derived here rather than on the root, so it follows an --mp-accent set further down. */
background: var(--mp-drop, color-mix(in srgb, var(--mp-accent) 22%, transparent));
pointer-events: none;
transition:
left 90ms ease-out,
Expand Down