Skip to content

Commit be68a40

Browse files
committed
add frontend/
1 parent d0367ec commit be68a40

File tree

16 files changed

+1512
-14
lines changed

16 files changed

+1512
-14
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "dreamlandjs"]
2+
path = dreamlandjs
3+
url = https://github.com/MercuryWorkshop/dreamlandjs

dreamlandjs

Submodule dreamlandjs added at 992d4ca

frontend/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

frontend/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS</title>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script type="module" src="/src/main.tsx"></script>
13+
</body>
14+
</html>

frontend/package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "aboutproxy-2",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"preview": "vite preview"
10+
},
11+
"devDependencies": {
12+
"typescript": "~5.8.3",
13+
"vite": "^6.3.5"
14+
},
15+
"dependencies": {
16+
"@iconify/types": "^2.0.0",
17+
"@ktibow/iconset-material-symbols": "^0.0.1749705809",
18+
"dreamland": "workspace:dreamland"
19+
}
20+
}

frontend/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

frontend/src/browser.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { createState, type Stateful } from "dreamland/core";
2+
import { ThemeVars, type Theme } from "./ui/theme";
3+
import { Tab, Tabs } from "./tabs";
4+
5+
class StatefulClass {
6+
constructor(state: Stateful<any>) {
7+
return state;
8+
}
9+
}
10+
11+
export class Browser extends StatefulClass {
12+
built: boolean = false;
13+
14+
theme: Theme;
15+
constructor(state: Stateful<any>) {
16+
super(state);
17+
18+
this.theme = {
19+
frame_bg: [40, 40, 40],
20+
toolbar_bg: [60, 60, 60],
21+
toolbar_button_fg: [199, 199, 199],
22+
toolbar_fg: [199, 199, 199],
23+
24+
inactive_tab_bg: [40, 40, 40],
25+
inactive_tab_fg: [199, 199, 199],
26+
active_tab_fg: [227, 227, 227],
27+
28+
button_bg: [60, 60, 60],
29+
30+
ntp_bg: [60, 60, 60],
31+
ntp_fg: [232, 234, 237],
32+
ntp_link_fg: [138, 180, 248],
33+
34+
omnibox_bg: [40, 40, 40],
35+
omnibox_fg: [227, 227, 227],
36+
37+
bookmark_fg: [199, 199, 199],
38+
};
39+
}
40+
41+
build(): HTMLElement {
42+
if (this.built) throw new Error("already built");
43+
this.built = true;
44+
45+
return (
46+
<div>
47+
<ThemeVars colors={use(this.theme)} />
48+
<Tabs />
49+
</div>
50+
);
51+
}
52+
}
53+
54+
export function createBrowser(): Browser {
55+
let browser = new Browser(createState({}));
56+
Object.setPrototypeOf(browser, Browser.prototype);
57+
return browser;
58+
}

frontend/src/main.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import "./style.css";
2+
3+
import { createBrowser } from "./browser";
4+
5+
let app = document.getElementById("app")!;
6+
7+
let browser = createBrowser();
8+
(self as any).browser = browser;
9+
10+
try {
11+
let built = browser.build();
12+
built.id = "app";
13+
14+
app.replaceWith(built);
15+
} catch (e) {
16+
let err = e as any;
17+
app.replaceWith(
18+
document.createTextNode(
19+
`Error mounting: ${"message" in err ? err.message : err}`
20+
)
21+
);
22+
}

frontend/src/style.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
body,
2+
html,
3+
#app {
4+
width: 100vw;
5+
height: 100vh;
6+
margin: 0;
7+
padding: 0;
8+
overflow: hidden;
9+
}
10+
11+
* {
12+
box-sizing: border-box;
13+
}

0 commit comments

Comments
 (0)