From 9fabab50dc7f19608ab9bf22f5395484b12666ea Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 11 Dec 2024 09:53:34 +0100 Subject: [PATCH 01/11] Doc: ui/build explain custom build script --- pkgs/webview-ui/app/gtk.webview.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkgs/webview-ui/app/gtk.webview.js b/pkgs/webview-ui/app/gtk.webview.js index a768e1b5e..aa99534ef 100644 --- a/pkgs/webview-ui/app/gtk.webview.js +++ b/pkgs/webview-ui/app/gtk.webview.js @@ -1,3 +1,12 @@ +/** + * This script generates a custom index.html file for the webview UI. + * It reads the manifest.json file generated by Vite and uses it to generate the HTML file. + * It also processes the CSS files to rewrite the URLs in the CSS files to match the new location of the assets. + * The script is run after the Vite build is complete. + * + * This is necessary because the webview UI is loaded from the local file system and the URLs in the CSS files need to be rewritten to match the new location of the assets. + * The generated index.html file is then used as the entry point for the webview UI. + */ import fs from "node:fs"; import postcss from "postcss"; import path from "node:path"; @@ -43,7 +52,7 @@ fs.readFile(manifestPath, { encoding: "utf8" }, (err, data) => { console.log(`Rewriting CSS url(): ${asset.url} to ${res}`); return res; }, - }), + }) ) .process(css, { from: `dist/${cssEntry}`, From dd723440862641f5c094caad1c29db275767e1b7 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 11 Dec 2024 11:31:28 +0100 Subject: [PATCH 02/11] UI: fix responsive sidebar --- pkgs/webview-ui/app/gtk.webview.js | 2 +- .../src/components/Sidebar/SidebarHeader.tsx | 44 ++++++++++--------- .../components/Sidebar/SidebarListItem.tsx | 2 +- .../app/src/components/Sidebar/index.tsx | 4 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pkgs/webview-ui/app/gtk.webview.js b/pkgs/webview-ui/app/gtk.webview.js index aa99534ef..e75eecc12 100644 --- a/pkgs/webview-ui/app/gtk.webview.js +++ b/pkgs/webview-ui/app/gtk.webview.js @@ -52,7 +52,7 @@ fs.readFile(manifestPath, { encoding: "utf8" }, (err, data) => { console.log(`Rewriting CSS url(): ${asset.url} to ${res}`); return res; }, - }) + }), ) .process(css, { from: `dist/${cssEntry}`, diff --git a/pkgs/webview-ui/app/src/components/Sidebar/SidebarHeader.tsx b/pkgs/webview-ui/app/src/components/Sidebar/SidebarHeader.tsx index ecac8e546..0c4d5457b 100644 --- a/pkgs/webview-ui/app/src/components/Sidebar/SidebarHeader.tsx +++ b/pkgs/webview-ui/app/src/components/Sidebar/SidebarHeader.tsx @@ -1,27 +1,20 @@ -import { createSignal, Show } from "solid-js"; - +import { createSignal } from "solid-js"; import { Typography } from "@/src/components/Typography"; import { SidebarFlyout } from "./SidebarFlyout"; +import "./css/sidebar.css"; -interface SidebarHeader { +interface SidebarProps { clanName: string; + showFlyout?: () => boolean; } -export const SidebarHeader = (props: SidebarHeader) => { - const { clanName } = props; - - const [showFlyout, toggleFlyout] = createSignal(false); - - function handleClick() { - toggleFlyout(!showFlyout()); - } - - const renderClanProfile = () => ( +const ClanProfile = (props: SidebarProps) => { + return (
{ color="primary" inverted={true} > - {clanName.slice(0, 1).toUpperCase()} + {props.clanName.slice(0, 1).toUpperCase()}
); +}; - const renderClanTitle = () => ( +const ClanTitle = (props: SidebarProps) => { + return ( { color="primary" inverted={true} > - {clanName} + {props.clanName} ); +}; + +export const SidebarHeader = (props: SidebarProps) => { + const [showFlyout, toggleFlyout] = createSignal(false); + + function handleClick() { + toggleFlyout(!showFlyout()); + } return ( diff --git a/pkgs/webview-ui/app/src/components/Sidebar/SidebarListItem.tsx b/pkgs/webview-ui/app/src/components/Sidebar/SidebarListItem.tsx index 189b5cffe..eb0b848b6 100644 --- a/pkgs/webview-ui/app/src/components/Sidebar/SidebarListItem.tsx +++ b/pkgs/webview-ui/app/src/components/Sidebar/SidebarListItem.tsx @@ -14,7 +14,7 @@ export const SidebarListItem = (props: SidebarListItem) => {