|
| 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 | +} |
0 commit comments