Skip to content

Commit 9aa8b6d

Browse files
committed
Themes & more
1 parent 074a5db commit 9aa8b6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3253
-1713
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
dist
66
node_modules
77
playwright-report
8-
test-results
8+
test-results
9+
.esbuild-serve

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ recommend that a file or class name and description of purpose be included on
179179
the same “printed page” as the copyright notice for easier identification within
180180
third-party archives.
181181

182-
Copyright [yyyy] [name of copyright owner]
182+
Copyright 2026, Regular Layout Authors
183183

184184
Licensed under the Apache License, Version 2.0 (the "License");
185185
you may not use this file except in compliance with the License.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Add the `<regular-layout>` custom element to your HTML:
3737

3838
```html
3939
<regular-layout>
40-
<div slot="main">Main content</div>
41-
<div slot="sidebar">Sidebar content</div>
40+
<div name="main">Main content</div>
41+
<div name="sidebar">Sidebar content</div>
4242
</regular-layout>
4343
```
4444

@@ -67,7 +67,7 @@ Create repositionable panels using `<regular-layout-frame>`:
6767

6868
```html
6969
<regular-layout>
70-
<regular-layout-frame slot="main">
70+
<regular-layout-frame name="main">
7171
Main content
7272
</regular-layout-frame>
7373
</regular-layout>

build.mjs renamed to build.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { execSync } from "node:child_process";
1414

1515
const watch = process.argv.includes("--watch");
1616

17-
function generateDeclarations() {
17+
function generateDeclarations(): void {
1818
console.log("Generating TypeScript declaration files...");
1919
execSync(
2020
"pnpm tsc --project tsconfig.json",
@@ -24,7 +24,7 @@ function generateDeclarations() {
2424
console.log("Declaration files generated!");
2525
}
2626

27-
const browserConfig = {
27+
const browserConfig: esbuild.BuildOptions = {
2828
entryPoints: ["src/index.ts"],
2929
bundle: true,
3030
minify: true,
@@ -37,13 +37,13 @@ const browserConfig = {
3737
metafile: true,
3838
};
3939

40-
function formatBytes(bytes) {
40+
function formatBytes(bytes: number): string {
4141
if (bytes < 1024) return `${bytes} B`;
4242
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
4343
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
4444
}
4545

46-
async function build() {
46+
async function build(): Promise<void> {
4747
if (watch) {
4848
const browserContext = await esbuild.context(browserConfig);
4949
await browserContext.watch();

deploy.mjs

Lines changed: 0 additions & 77 deletions
This file was deleted.

deploy.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2+
// ░░░░░░░░▄▀░█▀▄░█▀▀░█▀▀░█░█░█░░░█▀█░█▀▄░░░░░█░░░█▀█░█░█░█▀█░█░█░▀█▀░▀▄░░░░░░░░
3+
// ░░░░░░░▀▄░░█▀▄░█▀▀░█░█░█░█░█░░░█▀█░█▀▄░▀▀▀░█░░░█▀█░░█░░█░█░█░█░░█░░░▄▀░░░░░░░
4+
// ░░░░░░░░░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░▀░░░░░▀▀▀░▀░▀░░▀░░▀▀▀░▀▀▀░░▀░░▀░░░░░░░░░
5+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
6+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
7+
// ┃ * Copyright (c) 2026, the Regular Layout Authors. This file is part * ┃
8+
// ┃ * of the Regular Layout library, distributed under the terms of the * ┃
9+
// ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
10+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
11+
12+
import * as esbuild from "esbuild";
13+
import {
14+
copyFileSync,
15+
readdirSync,
16+
readFileSync,
17+
writeFileSync,
18+
} from "node:fs";
19+
import { join } from "node:path";
20+
21+
const ROOT_DIR = process.cwd();
22+
const EXAMPLES_DIR = join(ROOT_DIR, "examples");
23+
24+
async function deploy(): Promise<void> {
25+
console.log("Building examples for deployment...");
26+
27+
// Build the examples bundle
28+
const result = await esbuild.build({
29+
entryPoints: [join(EXAMPLES_DIR, "index.ts")],
30+
bundle: true,
31+
minify: true,
32+
minifyWhitespace: true,
33+
minifyIdentifiers: true,
34+
outfile: join(ROOT_DIR, "index.js"),
35+
platform: "browser",
36+
format: "esm",
37+
sourcemap: true,
38+
metafile: true,
39+
});
40+
41+
if (result.metafile) {
42+
console.log("\nBundle Size:");
43+
for (const [file, info] of Object.entries(result.metafile.outputs)) {
44+
const bytes = info.bytes;
45+
const size =
46+
bytes < 1024
47+
? `${bytes} B`
48+
: bytes < 1024 * 1024
49+
? `${(bytes / 1024).toFixed(2)} KB`
50+
: `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
51+
console.log(` ${file}: ${size}`);
52+
}
53+
}
54+
55+
// Copy HTML file and update paths
56+
console.log("\nCopying HTML file...");
57+
const htmlContent = readFileSync(join(EXAMPLES_DIR, "index.html"), "utf-8");
58+
const updatedHtml = htmlContent
59+
.replace(
60+
'<script type="module" src="/.esbuild-serve/index.js"></script>',
61+
'<script type="module" src="./index.js"></script>',
62+
)
63+
.replace(/href="\.\.\/themes\//g, 'href="./');
64+
65+
writeFileSync(join(ROOT_DIR, "index.html"), updatedHtml);
66+
67+
// Copy CSS file
68+
console.log("\nCopying CSS file...");
69+
copyFileSync(join(EXAMPLES_DIR, "index.css"), join(ROOT_DIR, "index.css"));
70+
71+
// Copy layout.json
72+
console.log("\nCopying layout configuration...");
73+
copyFileSync(
74+
join(EXAMPLES_DIR, "layout.json"),
75+
join(ROOT_DIR, "layout.json"),
76+
);
77+
78+
// Copy theme files
79+
console.log("\nCopying theme files...");
80+
const themesDir = join(ROOT_DIR, "themes");
81+
const themeFiles = readdirSync(themesDir);
82+
83+
for (const file of themeFiles) {
84+
if (file.endsWith(".css")) {
85+
copyFileSync(join(themesDir, file), join(ROOT_DIR, file));
86+
console.log(` Copied ${file}`);
87+
}
88+
}
89+
}
90+
91+
deploy().catch((error) => {
92+
console.error("Deploy failed:", error);
93+
process.exit(1);
94+
});

examples/index.css

Lines changed: 36 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1+
/* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
2+
* ░░░░░░░░▄▀░█▀▄░█▀▀░█▀▀░█░█░█░░░█▀█░█▀▄░░░░░█░░░█▀█░█░█░█▀█░█░█░▀█▀░▀▄░░░░░░░░
3+
* ░░░░░░░▀▄░░█▀▄░█▀▀░█░█░█░█░█░░░█▀█░█▀▄░▀▀▀░█░░░█▀█░░█░░█░█░█░█░░█░░░▄▀░░░░░░░
4+
* ░░░░░░░░░▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▀░▀░▀░▀░░░░░▀▀▀░▀░▀░░▀░░▀▀▀░▀▀▀░░▀░░▀░░░░░░░░░
5+
* ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
6+
* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
7+
* ┃ * Copyright (c) 2026, the Regular Layout Authors. This file is part * ┃
8+
* ┃ * of the Regular Layout library, distributed under the terms of the * ┃
9+
* ┃ * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * ┃
10+
* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
11+
*/
12+
113
body {
14+
margin: 0px;
215
font-family: "ui-monospace", "SFMono-Regular", "SF Mono", "Menlo", "Consolas", "Liberation Mono", monospace;
316
}
417

18+
header {
19+
padding: 0 12px;
20+
gap: 12px;
21+
display: flex;
22+
align-items: center;
23+
height: 36px;
24+
}
25+
526
/* Layout */
627
regular-layout {
728
overflow: hidden;
@@ -10,104 +31,25 @@ regular-layout {
1031
left: 0;
1132
right: 0;
1233
bottom: 0;
34+
padding: 3px;
35+
/* padding: 12px; */
36+
37+
/*
38+
`regular-layout` supports the CSS `gap` property, but the "absolute"
39+
mode overlay will not respect it (because there is no `gap` positioning
40+
for absolutely positioned elements), leading to slightly off-center
41+
drag/drop overlays. As "absolute" mode is required for CSS transitions
42+
to work (making the smooth animation), you will need to use `margin`
43+
instead of `gap` if you want smooth overlay animations _and_ correctly
44+
positioned overlays.
45+
*/
46+
47+
/* margin: 3px; */
48+
/* gap: 6px; */
1349
}
1450

1551
/* Frame */
1652
regular-layout-frame {
17-
--titlebar-height: 24px;
1853
position: relative;
1954
box-sizing: border-box;
20-
margin: 3px;
21-
border-radius: 0 0 6px 6px;
22-
border: 1px solid #666;
23-
box-shadow: 0px 6px 6px -4px rgba(150, 150, 180);
24-
}
25-
26-
regular-layout-frame::part(titlebar) {
27-
display: flex;
28-
align-items: stretch;
29-
margin-left: -1px;
30-
margin-right: -1px;
31-
margin-bottom: 0px;
32-
}
33-
34-
regular-layout-frame::part(tab) {
35-
display: flex;
36-
flex: 1 1 150px;
37-
align-items: center;
38-
font-size: 10px;
39-
padding: 0 8px;
40-
cursor: pointer;
41-
max-width: 150px;
42-
text-overflow: ellipsis;
43-
border: 1px solid #666;
44-
border-radius: 6px 6px 0 0;
45-
opacity: 0.5;
46-
}
47-
48-
regular-layout-frame::part(active-tab) {
49-
opacity: 1;
50-
}
51-
52-
/* Frame in Overlay Mode */
53-
regular-layout-frame.overlay {
54-
background-color: rgba(0, 0, 0, 0.2) !important;
55-
border: 1px dashed rgb(0, 0, 0);
56-
border-radius: 6px;
57-
margin: 0;
58-
box-shadow: none;
59-
transition:
60-
top 0.1s ease-in-out,
61-
height 0.1s ease-in-out,
62-
width 0.1s ease-in-out,
63-
left 0.1s ease-in-out;
64-
}
65-
66-
regular-layout-frame::part(container) {
67-
display: none;
6855
}
69-
70-
regular-layout-frame:not(.overlay)::part(container) {
71-
display: revert;
72-
}
73-
74-
/* Colors */
75-
regular-layout :nth-child(8n+1),
76-
regular-layout :nth-child(8n+1)::part(tab) {
77-
background-color: #ffadadff;
78-
}
79-
80-
regular-layout :nth-child(8n+2),
81-
regular-layout :nth-child(8n+2)::part(tab) {
82-
background-color: #ffd6a5ff;
83-
}
84-
85-
regular-layout :nth-child(8n+3),
86-
regular-layout :nth-child(8n+3)::part(tab) {
87-
background-color: #fdffb6ff;
88-
}
89-
90-
regular-layout :nth-child(8n+4),
91-
regular-layout :nth-child(8n+4)::part(tab) {
92-
background-color: #caffbfff;
93-
}
94-
95-
regular-layout :nth-child(8n+5),
96-
regular-layout :nth-child(8n+5)::part(tab) {
97-
background-color: #9bf6ffff;
98-
}
99-
100-
regular-layout :nth-child(8n+6),
101-
regular-layout :nth-child(8n+6)::part(tab) {
102-
background-color: #a0c4ffff;
103-
}
104-
105-
regular-layout :nth-child(8n+7),
106-
regular-layout :nth-child(8n+7)::part(tab) {
107-
background-color: #bdb2ffff;
108-
}
109-
110-
regular-layout :nth-child(8n+8),
111-
regular-layout :nth-child(8n+8)::part(tab) {
112-
background-color: #ffc6ffff;
113-
}

0 commit comments

Comments
 (0)