-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d98733
commit cf6f952
Showing
20 changed files
with
263 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { appWindow } from "@tauri-apps/api/window"; | ||
import { useEffect } from "react"; | ||
import { useRecoilState } from "recoil"; | ||
import { PlutoLibState } from "../state/PlutoLib.state"; | ||
|
||
export const Titlebar = () => { | ||
const [plutoState, setPlutoState] = useRecoilState(PlutoLibState); | ||
|
||
useEffect(() => { | ||
document | ||
.getElementById("titlebar-minimize") | ||
?.addEventListener("click", () => appWindow.minimize()); | ||
document | ||
.getElementById("titlebar-maximize") | ||
?.addEventListener("click", () => appWindow.toggleMaximize()); | ||
document | ||
.getElementById("titlebar-close") | ||
?.addEventListener("click", () => appWindow.close()); | ||
}, []); | ||
|
||
return ( | ||
<div | ||
data-tauri-drag-region | ||
className="h-[38px] flex items-center justify-between" | ||
style={plutoState?.Theme.getClassName("title-bar")} | ||
> | ||
<div className="left"></div> | ||
<div className="middle"></div> | ||
<div className="right flex"> | ||
<div className="px-2 bg-white" id="titlebar-minimize"> | ||
<img | ||
src="https://api.iconify.design/mdi:window-minimize.svg" | ||
alt="minimize" | ||
/> | ||
</div> | ||
<div className="px-2 bg-white" id="titlebar-maximize"> | ||
<img | ||
src="https://api.iconify.design/mdi:window-maximize.svg" | ||
alt="maximize" | ||
/> | ||
</div> | ||
<div className="px-2 bg-white" id="titlebar-close"> | ||
<img src="https://api.iconify.design/mdi:close.svg" alt="close" /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { THEME_AVAILABILITY } from "./theming/Theme.types"; | ||
import { ThemeManager } from "./theming/ThemeManager"; | ||
|
||
export class PlutoLib { | ||
Theme!: ThemeManager; | ||
|
||
constructor() { | ||
this.Theme = new ThemeManager({ theme_id: THEME_AVAILABILITY.PLUTO_DARK }); | ||
} | ||
} | ||
|
||
export const pluto_lib = new PlutoLib(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { LibModuleState, ModuleStatus } from "../types/generic"; | ||
|
||
interface ThemeState extends LibModuleState {} | ||
export interface ThemeState extends LibModuleState {} | ||
|
||
export const theme_state: ThemeState = { | ||
export const default_theme_state: ThemeState = { | ||
module_id: "modules/theme", | ||
status: ModuleStatus.OFF, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,55 @@ | ||
import { ModuleStatus } from "../types/generic"; | ||
import { default_theme_state, ThemeState } from "./Theme.state"; | ||
import { | ||
ThemeElement, | ||
ThemeManagerConfig, | ||
THEME_AVAILABILITY, | ||
} from "./Theme.types"; | ||
import { theme_reader } from "./_utils"; | ||
|
||
const DEFAULT_CONFIG: ThemeManagerConfig = { | ||
theme_id: THEME_AVAILABILITY.PLUTO_DARK, | ||
}; | ||
|
||
export class ThemeManager { | ||
private config: ThemeManagerConfig; | ||
private theme_elements: ThemeElement[]; | ||
state: ThemeState; | ||
config: ThemeManagerConfig; | ||
|
||
theme_elements!: ThemeElement[]; | ||
|
||
constructor(config: ThemeManagerConfig = DEFAULT_CONFIG) { | ||
this.config = { ...config }; | ||
|
||
this.theme_elements = []; | ||
|
||
this.state = { ...default_theme_state }; | ||
|
||
this.state.status = ModuleStatus.INITIALIZING; | ||
|
||
this.on_theme_init(); | ||
} | ||
|
||
private on_theme_init() {} | ||
private async on_theme_init() { | ||
const elements: any = await theme_reader(this.config); | ||
|
||
if (!elements) { | ||
this.state.status = ModuleStatus.FAILED; | ||
return; | ||
} | ||
|
||
this.theme_elements = elements; | ||
|
||
this.state.status = ModuleStatus.RUNNING; | ||
} | ||
|
||
public getClassName(id: string): ThemeElement { | ||
public getClassName(id: string) { | ||
const theme_element = this.theme_elements.find((x) => x.id === id); | ||
|
||
if (!theme_element) { | ||
throw new Error("Requesting theme for non-configured element"); | ||
console.warn("Requesting theme for non-configured element"); | ||
return {}; | ||
} | ||
|
||
return theme_element; | ||
return theme_element.defaultThemeSettings; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
import { fs } from "@tauri-apps/api"; | ||
import { ThemeElement, ThemeManagerConfig } from "./Theme.types"; | ||
import { BaseDirectory } from "@tauri-apps/api/fs"; | ||
import { | ||
FSThemeJSON, | ||
ThemeElement, | ||
ThemeManagerConfig, | ||
THEME_AVAILABILITY, | ||
} from "./Theme.types"; | ||
|
||
export const theme_reader = async ( | ||
config: ThemeManagerConfig | ||
): Promise<Record<string, ThemeElement>> => { | ||
return {}; | ||
): Promise<ThemeElement[]> => { | ||
const filePath = `themes/[${THEME_AVAILABILITY[config.theme_id]}].json`; | ||
console.info("Attempting Load From " + filePath); | ||
|
||
let data!: FSThemeJSON; | ||
|
||
try { | ||
const raw = await fs.readTextFile(filePath, { | ||
dir: BaseDirectory.Resource, | ||
}); | ||
|
||
const fsThemeData: FSThemeJSON = JSON.parse(raw); | ||
|
||
if (fsThemeData) { | ||
data = fsThemeData; | ||
} | ||
} catch (e) { | ||
console.error(e); | ||
throw new Error("Error Loading Theme From Path: " + filePath); | ||
} | ||
|
||
if (!data) { | ||
return []; | ||
} else { | ||
return data.elements; | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import ReactDOM from "react-dom/client"; | ||
|
||
import { RecoilRoot } from "recoil"; | ||
|
||
import "./index.css"; | ||
import "./styles/titlebar.css"; | ||
|
||
import App from "./App"; | ||
|
||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( | ||
<App /> | ||
<RecoilRoot> | ||
<App /> | ||
</RecoilRoot> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { atom } from "recoil"; | ||
import { PlutoLib } from "../lib/PlutoLib"; | ||
|
||
export const PlutoLibState = atom<PlutoLib | null>({ | ||
key: "pluto_lib_state", | ||
default: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* .titlebar { | ||
height: 38px; | ||
background: #329ea3; | ||
user-select: none; | ||
display: flex; | ||
justify-content: flex-end; | ||
align-items: center; | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
} | ||
.titlebar-button { | ||
display: inline-flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 30px; | ||
height: 30px; | ||
} | ||
.titlebar-button:hover { | ||
background: #5bbec3; | ||
} */ |
Oops, something went wrong.