sidebar + dark theme

This commit is contained in:
Kirill Zhumarin 2026-01-15 09:11:01 +00:00
parent aa2063fcb1
commit 90804cccdc
29 changed files with 609 additions and 166 deletions

View file

@ -1,23 +1,30 @@
<!DOCTYPE html>
<html lang="en" data-bs-theme="light">
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=2.0, user-scalable=yes" />
<meta name="theme-color" content="#000000" />
<link rel="shortcut icon" type="image/ico" href="/src/assets/favicon.ico" />
<title>Siemens Dev Tools</title>
<script>
(function () {
const media = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
const themeChange = () => {
document.documentElement.setAttribute('data-bs-theme', media.matches ? 'dark' : 'light');
};
if (media) {
media.addEventListener('change', themeChange, false);
themeChange();
<style>
html[data-bs-theme="dark"] {
color-scheme: dark;
}
html[data-bs-theme="light"] {
color-scheme: light;
}
</style>
<script>
try {
let theme = JSON.parse(localStorage.getItem('bootstrapTheme') ?? '"system"');
if (theme === "system") {
const media = window.matchMedia('(prefers-color-scheme: dark)');
theme = media.matches ? 'dark' : 'light';
}
document.documentElement.dataset.bsTheme = theme;
} catch (e) {
console.error(e);
}
})();
</script>
</head>
<body>

View file

@ -19,6 +19,7 @@
"vite-plugin-solid-svg": "^0.8.1"
},
"dependencies": {
"@material-design-icons/svg": "^0.14.15",
"@solid-primitives/context": "^0.3.2",
"@solidjs/router": "^0.15.4",
"@suid/types": "^0.8.0",
@ -30,6 +31,7 @@
"bootstrap-icons": "^1.13.1",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"es-toolkit": "^1.43.0",
"highlight.js": "^11.11.1",
"sass": "^1.97.2",
"solid-bootstrap": "^1.0.21",

16
pnpm-lock.yaml generated
View file

@ -8,6 +8,9 @@ importers:
.:
dependencies:
'@material-design-icons/svg':
specifier: ^0.14.15
version: 0.14.15
'@solid-primitives/context':
specifier: ^0.3.2
version: 0.3.2(solid-js@1.9.10)
@ -41,6 +44,9 @@ importers:
date-fns:
specifier: ^3.6.0
version: 3.6.0
es-toolkit:
specifier: ^1.43.0
version: 1.43.0
highlight.js:
specifier: ^11.11.1
version: 11.11.1
@ -341,6 +347,9 @@ packages:
'@jridgewell/trace-mapping@0.3.31':
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
'@material-design-icons/svg@0.14.15':
resolution: {integrity: sha512-6nbjwGwyJnphwQUscJAYqw1Tk6+W8KvsgOAeyVgzIFXVsHfgX5XyplTUcZ29wbcTUysMMyCUi1LYpmFKA/e61g==}
'@nothing-but/utils@0.17.0':
resolution: {integrity: sha512-TuCHcHLOqDL0SnaAxACfuRHBNRgNJcNn9X0GiH5H3YSDBVquCr3qEIG3FOQAuMyZCbu9w8nk2CHhOsn7IvhIwQ==}
@ -834,6 +843,9 @@ packages:
resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
engines: {node: '>= 0.4'}
es-toolkit@1.43.0:
resolution: {integrity: sha512-SKCT8AsWvYzBBuUqMk4NPwFlSdqLpJwmy6AP322ERn8W2YLIB6JBXnwMI2Qsh2gfphT3q7EKAxKb23cvFHFwKA==}
esbuild@0.27.2:
resolution: {integrity: sha512-HyNQImnsOC7X9PMNaCIeAm4ISCQXs5a5YasTXVliKv4uuBo1dKrG0A+uQS8M5eXjVMnLg3WgXaKvprHlFJQffw==}
engines: {node: '>=18'}
@ -1419,6 +1431,8 @@ snapshots:
'@jridgewell/resolve-uri': 3.1.2
'@jridgewell/sourcemap-codec': 1.5.5
'@material-design-icons/svg@0.14.15': {}
'@nothing-but/utils@0.17.0': {}
'@parcel/watcher-android-arm64@2.5.1':
@ -1867,6 +1881,8 @@ snapshots:
has-tostringtag: 1.0.2
hasown: 2.0.2
es-toolkit@1.43.0: {}
esbuild@0.27.2:
optionalDependencies:
'@esbuild/aix-ppc64': 0.27.2

View file

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="2.5 3.5 11 9">
<path fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5m0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5"></path>
</svg>

After

Width:  |  Height:  |  Size: 308 B

View file

@ -1,34 +0,0 @@
import { ParentProps, Component } from "solid-js";
import { A, useMatch } from "@solidjs/router";
import { Container } from 'solid-bootstrap';
import { Navbar } from 'solid-bootstrap';
import { Nav } from 'solid-bootstrap';
import { resolveURL } from '@/utils';
const HeaderLink: Component<ParentProps<{ href: string }>> = (props) => {
const match = useMatch(() => resolveURL(props.href));
return (
<Nav.Link as={A} {...props} active={!!match()}>
{props.children}
</Nav.Link>
);
};
export const Header: Component = () => {
return (
<Navbar expand="lg" class="bg-body-tertiary">
<Container fluid="xxl">
<Navbar.Brand as={A} href="/">Dev Tools</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav class="me-auto">
<HeaderLink href="/swilib"><i class="bi bi-box-fill"></i> Swilib</HeaderLink>
<HeaderLink href="/re"><i class="bi bi-hammer"></i> RE files</HeaderLink>
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
);
};

View file

@ -1,13 +1,58 @@
/* @refresh reload */
import { ParentComponent } from "solid-js";
import { Header } from "@/components/Header";
import { Container } from "solid-bootstrap";
import { createSignal, onCleanup, onMount, ParentComponent, Show } from "solid-js";
import { Header } from "@/components/Layout/Header";
import { Container, Offcanvas } from "solid-bootstrap";
import { Sidebar } from "@/components/Layout/Sidebar/Sidebar";
import { ThemeProvider } from "@/context/ThemeProvider";
export const App: ParentComponent = (props) => {
return <>
<Header />
<Container fluid="xxl" class="p-2">
{props.children}
</Container>
</>;
const [sidebarIsOffcanvas, setSidebarOffcanvas] = createSignal(false);
const [sidebarIsOpen, setSidebarOpen] = createSignal(false);
const handleSidebarHide = () => {
setSidebarOpen(false);
};
onMount(() => {
const handleWindowResize = () => {
const width = window.innerWidth;
setSidebarOffcanvas(width <= 1200);
setSidebarOpen(false);
};
window.addEventListener('resize', handleWindowResize);
handleWindowResize();
onCleanup(() => window.removeEventListener('resize', handleWindowResize));
});
return (
<ThemeProvider>
<Header
showSidebarToggleButton={sidebarIsOffcanvas()}
onSidebarToggle={() => setSidebarOpen((prev) => !prev)}
/>
<Container fluid class="p-0">
<div class="d-flex flex-row gap-1">
<Show when={sidebarIsOffcanvas()} fallback={
<Sidebar />
}>
<Offcanvas
show={sidebarIsOpen()}
style={{ width: 'auto' }}
onHide={handleSidebarHide}
restoreFocus={false}
>
<Offcanvas.Body class="p-0">
<Sidebar offcanvas={true} />
</Offcanvas.Body>
</Offcanvas>
</Show>
<main class="flex-fill p-3 pt-3">
{props.children}
</main>
</div>
</Container>
</ThemeProvider>
);
};

View file

@ -0,0 +1,35 @@
.header {
--bs-navbar-padding-y: 0.2rem;
display: flex;
align-items: center;
justify-content: space-between;
height: var(--bs-header-height);
padding: 0 0.5rem;
position: sticky;
top: 0;
z-index: 1020;
background: var(--bs-body-bg);
border-bottom: 1px solid var(--bs-content-separator);
&__title {
font-size: 1.25rem;
font-weight: 500;
color: var(--bs-primary-color);
text-decoration: none;
padding: 0 0.5rem;
}
&__button {
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
padding: 0.5rem;
cursor: pointer;
font-size: 2rem;
}
}

View file

@ -0,0 +1,47 @@
import './Header.scss';
import { Component, Match, Show, Switch } from "solid-js";
import { A } from "@solidjs/router";
import MenuIcon from '@/assets/icons/menu.svg';
import BrightnessIcon from '@material-design-icons/svg/outlined/brightness_medium.svg';
import BedtimeIcon from '@material-design-icons/svg/outlined/bedtime.svg';
import LightModeIcon from '@material-design-icons/svg/outlined/light_mode.svg';
import { useTheme } from "@/context/ThemeProvider";
interface HeaderProps {
showSidebarToggleButton: boolean;
onSidebarToggle?: () => void;
}
export const Header: Component<HeaderProps> = (props) => {
const { theme, switchTheme } = useTheme();
return (
<div class="header">
<Show when={props.showSidebarToggleButton}>
<button class="header__button" onClick={() => props.onSidebarToggle?.()}>
<MenuIcon class="fs-4" />
</button>
</Show>
<A href={"/"} class="header__title">
Dev Tools
</A>
<button class="header__button" onClick={() => switchTheme()}>
<Switch>
<Match when={theme() == 'light'}>
<LightModeIcon class="fs-4" />
</Match>
<Match when={theme() == 'dark'}>
<BedtimeIcon class="fs-4" />
</Match>
<Match when={theme() == 'system'}>
<BrightnessIcon class="fs-4" />
</Match>
</Switch>
</button>
</div>
);
};

View file

@ -15,10 +15,10 @@ export const Root: Component = () => {
return (
<ErrorBoundary fallback={showAppError}>
<Router root={App} base={import.meta.env.BASE_URL}>
<Route path="/" component={() => <Navigate href={() => "/swilib"} />} />
<Route path="/swilib" component={SwilibSummaryPage} />
<Route path="/swilib/phone" component={SwilibPage} />
<Route path="/re" component={ReFilesPage} />
<Route path="/" component={() => <Navigate href={() => "/swilib/analysis/summary"} />} />
<Route path="/swilib/analysis/summary" component={SwilibSummaryPage} />
<Route path="/swilib/analysis/target" component={SwilibPage} />
<Route path="/re/symbols" component={ReFilesPage} />
</Router>
</ErrorBoundary>
);

View file

@ -0,0 +1,62 @@
.sidebar {
height: calc(100dvh - var(--bs-header-height));
width: 280px;
flex-shrink: 0;
background: var(--bs-body-bg);
border-right: 1px solid var(--bs-content-separator);
padding-top: 0.5rem;
position: sticky;
top: var(--bs-header-height);
&--offcanvas {
height: auto;
border-right: none;
position: static;
}
&__section {
margin-bottom: 0.35rem;
}
&__section-title {
text-transform: uppercase;
color: var(--bs-secondary-color);
letter-spacing: 0.04em;
padding: 0.35rem 1rem;
}
&__link {
position: relative;
display: flex;
align-items: center;
column-gap: 8px;
padding: 0.35rem 1rem 0.35rem 2rem;
color: var(--bs-body-color);
text-decoration: none;
transition:
background-color 0.15s ease,
color 0.15s ease;
&:hover:not(&--active) {
text-decoration: none;
background-color: var(--sidebar-link-hover-bg);
}
&--active {
background-color: var(--sidebar-link-active-bg);
color: var(--sidebar-link-active-color);
font-weight: 400;
}
}
&__label {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
}

View file

@ -0,0 +1,55 @@
import "./Sidebar.scss";
import { Component, For } from "solid-js";
import { SidebarLink, SidebarLinkProps } from "@/components/Layout/Sidebar/SidebarLink";
import clsx from "clsx";
interface SidebarSection {
title: string;
links: Array<SidebarLinkProps>
}
interface SidebarProps {
offcanvas?: boolean
}
export const Sidebar: Component<SidebarProps> = (props) => {
const sections: SidebarSection[] = [
{
title: "Functions library",
links: [
{ label: "Swilib analysis", href: "/swilib/analysis/summary", icon: "bi bi-activity" },
{ label: "Check swilib.vkp", href: "/swilib/check", icon: "bi bi-file-earmark-check" },
{ label: "Merge swilib.vkp", href: "/swilib/merge", icon: "bi bi-arrow-left-right" }
]
},
{
title: "Reverse engineering",
links: [
{ label: "Patterns finder", href: "/re/ptr89", icon: "bi bi-search" },
{ label: "Download symbols", href: "/re/symbols", icon: "bi bi-download" }
]
},
{
title: "Database",
links: [
{ label: "Patches map", href: "/db/patches-map", icon: "bi bi-diagram-3" },
{ label: "Memory map", href: "/db/memory-map", icon: "bi bi-grid-3x3-gap" }
]
}
];
return (
<aside class={clsx("sidebar", props.offcanvas && "sidebar--offcanvas")}>
<For each={sections}>{(section) =>
<section class="sidebar__section">
<div class="sidebar__section-title">{section.title}</div>
<For each={section.links}>{(link) =>
<SidebarLink {...link} />
}</For>
</section>
}</For>
</aside>
);
};

View file

@ -0,0 +1,23 @@
import { Component } from "solid-js";
import { useMatch } from "@solidjs/router";
import { resolveURL } from "@/utils";
import clsx from "clsx";
export interface SidebarLinkProps {
label: string;
href: string;
icon: string;
}
export const SidebarLink: Component<SidebarLinkProps> = (props) => {
const match = useMatch(() => resolveURL(props.href));
return (
<a
class={clsx("sidebar__link", match() && "sidebar__link--active")}
href={props.href}
>
<i class={`bi ${props.icon} sidebar__icon`}/>
<span class="sidebar__label">{props.label}</span>
</a>
);
};

View file

@ -7,15 +7,15 @@ interface SwilibEntryTypeBadgeProps {
export const SwilibEntryTypeBadge: Component<SwilibEntryTypeBadgeProps> = (props) => {
return (
<Switch fallback={<i class="bi bi-x-circle"></i>}>
<Switch fallback={<i class="bi bi-x-circle me-2"></i>}>
<Match when={props.value == SwilibEntryType.FUNCTION}>
<i class="bi bi-c-circle-fill text-muted"></i>
<i class="bi bi-c-circle-fill text-muted me-2"></i>
</Match>
<Match when={props.value == SwilibEntryType.POINTER}>
<i class="bi bi-arrow-up-right-circle text-muted"></i>
<i class="bi bi-arrow-up-right-circle text-muted me-2"></i>
</Match>
<Match when={props.value == SwilibEntryType.VALUE}>
<i class="bi bi-hash text-muted"></i>
<i class="bi bi-hash text-muted me-2"></i>
</Match>
</Switch>
);

View file

@ -10,14 +10,14 @@ interface SwilibTargetsTabsProps {
export const SwilibTargetsTabs: Component<SwilibTargetsTabsProps> = (props) => {
return (
<Show when={props.devices} fallback={<div style="min-height: 48px"></div>}>
<div class="d-flex justify-content-between">
<div class="d-flex column-gap-3 flex-wrap">
<For each={props.devices}>{(device) =>
<A
class="text-center text-decoration-none"
classList={{
'fw-bold': props.selected === device.target
}}
href={`/swilib/phone/?target=${device.target}`}
href={`/swilib/analysis/target/?target=${device.target}`}
title={`Swilib info for ${device.model}`}
>
<small>{device.model}</small><br />

View file

@ -0,0 +1,75 @@
import {
Accessor,
createContext,
createEffect,
createSignal,
onCleanup,
onMount,
ParentComponent,
useContext
} from "solid-js";
import { ThemeType } from "@/store/globalSettingsStore";
import { makePersistedSignal } from "@/utils/makePersistedSignal";
interface ThemeContext {
theme: Accessor<ThemeType>;
effectiveTheme: Accessor<ThemeType>;
switchTheme: () => void;
}
export const ThemeContext = createContext<ThemeContext>();
export const ThemeProvider: ParentComponent = (props) => {
const [effectiveTheme, setEffectiveTheme] = createSignal<ThemeType>("light");
const [theme, setTheme] = makePersistedSignal(
createSignal<ThemeType>("system"),
{ name: "bootstrapTheme" }
);
const [count, setCount] = createSignal(0);
onMount(() => {
const media = window.matchMedia('(prefers-color-scheme: dark)');
const handleThemeChange = () => {
if (theme() == "system") {
setEffectiveTheme(media.matches ? 'dark' : 'light');
} else {
setEffectiveTheme(theme());
}
};
media.addEventListener('change', handleThemeChange);
handleThemeChange();
createEffect(handleThemeChange);
onCleanup(() => media.removeEventListener('change', handleThemeChange));
});
createEffect(() => document.documentElement.dataset.bsTheme = effectiveTheme());
return (
<ThemeContext.Provider value={{
theme,
effectiveTheme,
switchTheme: () => {
if (theme() == "system") {
setCount(0);
setTheme(effectiveTheme() == "dark" ? "light" : "dark");
} else {
if (count() == 2) {
setTheme("system");
} else {
setTheme(effectiveTheme() == "dark" ? "light" : "dark");
}
}
setCount((prev) => prev + 1);
}
}}>
{props.children}
</ThemeContext.Provider>
);
};
export function useTheme() {
const value = useContext(ThemeContext);
if (!value)
throw new Error("useTheme must be used within a <ThemeProvider>");
return value;
}

View file

@ -53,6 +53,7 @@ $info: #0aa7c7;
@import "bootstrap/scss/utilities/api";
// 8. Add additional custom code here
body {
overflow-y: scroll;
}
@ -62,16 +63,14 @@ body {
}
.table-sticky-header {
thead {
thead tr {
position: sticky;
top: -1px;
}
thead {
top: calc(var(--bs-header-height) - 1px);
background-color: var(--bs-tertiary-bg);
z-index: 3;
box-shadow: 0 1px 0 var(--bs-table-border-color);
}
th {
thead th {
background-color: var(--bs-tertiary-bg);
}
}
@ -85,13 +84,46 @@ body {
cursor: pointer;
}
:root {
--bs-header-height: 47px;
}
/* Light theme fixes */
@include color-mode(light) {
--bs-content-separator: #dfe0df;
--sidebar-link-active-bg: #e9f2fe;
--sidebar-link-active-color: #1868db;
--sidebar-link-hover-bg: #f0f1f2;
.dropdown-menu {
--bs-dropdown-link-hover-bg: #e9ecef;
}
}
/* Dark theme fixes */
@include color-mode(dark) {
--bs-body-bg: #1f1f21;
--bs-tertiary-bg: #303134;
--bs-content-separator: #38393c;
--sidebar-link-active-bg: #1c2b42;
--sidebar-link-active-color: #669df1;
--sidebar-link-hover-bg: #242528;
table {
--bs-table-border-color: #4b4d51;
}
/* Fix text colors */
--bs-primary: #6da7fe;
--bs-danger-rgb: 224, 82, 96;
--bs-primary-rgb: 109, 167, 254;
--bs-info-rgb: 11, 171, 203;
--bs-success-rgb: 32, 172, 107;
--bs-secondary-rgb: 140, 148, 155;
/* Fix table rows */
.table-danger {
@ -195,4 +227,10 @@ body {
}
}
svg {
width: 1em;
height: 1em;
fill: currentColor;
}
@import "bootstrap-icons/font/bootstrap-icons.css";

View file

@ -1,6 +1,6 @@
import { Component, createResource, createSignal, For, Show } from 'solid-js';
import { A, useSearchParams } from '@solidjs/router';
import { Button, Form, Spinner } from 'solid-bootstrap';
import { Component, createMemo, createResource, createSignal, For, Show } from 'solid-js';
import { useSearchParams } from '@solidjs/router';
import { Button, Dropdown, Form, Spinner } from 'solid-bootstrap';
import { SwilibTargetsTabs } from '@/components/Swilib/SwilibTargetsTabs';
import { useSwilibTableOptionsStore } from "@/store/swilibTableOptionsStore";
import {
@ -33,6 +33,25 @@ const SwilibPage: Component = () => {
setTableOptions("filterByType", e.currentTarget.value);
};
const downloadLinks = createMemo(() => ([
{
label: <>V-Klay patch <b>.vkp</b></>,
href: `${BACKEND_URL}/api/swilib/download/${target()}/swilib_${target()}.vkp`
},
{
label: <>Binary library <b>.blib</b></>,
href: `${BACKEND_URL}/api/swilib/download/${target()}/swilib_${target()}.blib`
},
{
label: <>Ghidra symbols <b>.txt</b></>,
href: `${BACKEND_URL}/api/swilib/download/${target()}/symbols-${target()}.txt`
},
{
label: <>IDA Pro symbols <b>.idc</b></>,
href: `${BACKEND_URL}/api/swilib/download/${target()}/symbols-${target()}.idc`
},
]));
return <>
<div class="mb-2">
<SwilibTargetsTabs selected={target()} devices={devices()} />
@ -79,7 +98,11 @@ const SwilibPage: Component = () => {
/>
</div>
<Button variant="outline-primary" onClick={() => setTableOptions("globalCollapsed", (prev) => !prev)}>
<Button
size="sm"
variant="outline-primary"
onClick={() => setTableOptions("globalCollapsed", (prev) => !prev)}
>
<Show when={!tableOptions.globalCollapsed}>
<i class="bi bi-eye-slash"></i> Collapse all
</Show>
@ -125,23 +148,22 @@ const SwilibPage: Component = () => {
/>
</div>
<div class="d-flex flex-row mb-3">
<Button
class="me-3" as={A as any} variant="outline-success" size="sm"
href={`${BACKEND_URL}/api/swilib/download/${target()}/swilib_${target()}.vkp`}
>
<i class="bi bi-download"></i> Download <b>.vkp</b>
</Button>
<div class="d-flex flex-row mb-3 gap-2">
<Dropdown>
<Dropdown.Toggle variant="outline-success" size="sm">
<i class="bi bi-download"></i> Download as …
</Dropdown.Toggle>
<Dropdown.Menu>
<For each={downloadLinks()}>{(link) => <>
<Dropdown.Item href={link.href}>
<i class="bi bi-download"></i> {link.label}
</Dropdown.Item>
</>}</For>
</Dropdown.Menu>
</Dropdown>
<Button
class="me-3" as={A as any} variant="outline-success" size="sm"
href={`${BACKEND_URL}/api/swilib/download/${target()}/swilib_${target()}.blib`}
>
<i class="bi bi-download"></i> Download <b>swi.blib</b>
</Button>
<Button
class="me-3" as={A as any} variant="outline-primary" size="sm" target="_blank" rel="noopener"
as={"a"} variant="outline-primary" size="sm" target="_blank" rel="noopener"
href={`https://patches.kibab.com/patches/details.php5?id=${targetAnalysis()?.patchId}`}
>
<i class="bi bi-browser-chrome"></i> Open on Kibab
@ -161,20 +183,6 @@ const SwilibPage: Component = () => {
</Show>
<Show when={resourcesState.isReady}>
<Show when={targetAnalysis()!.statistic.bad > 0}>
<div class="alert alert-danger" role="alert">
Swilib has <b>{targetAnalysis()!.statistic.bad}</b> fatal errors!!!
<Button
variant="outline-danger ms-3"
size="sm"
onClick={() => setTableOptions("filterByType", "errors")}
hidden={tableOptions.filterByType == 'errors'}
>
Show bad functions
</Button>
</div>
</Show>
<SwilibStatistic statistic={targetAnalysis()!.statistic} />
<For each={groups()}>{(file) =>

View file

@ -9,24 +9,27 @@ interface SwilibStatisticProps {
export const SwilibStatistic: Component<SwilibStatisticProps> = (props) => {
const getPercent = (v: number) => (v / props.statistic.total * 100).toFixed(0);
return (
<div class="mb-3">
<div class="d-flex mb-3 gap-2">
<Badge
title="Good functions."
bg="success fs-6"
title="Good functions"
bg="success"
class="fs-6"
>
OK: {props.statistic.good} | {getPercent(props.statistic.good)}%
</Badge>
{' '}
<Badge
title="Bad functions."
bg="danger fs-6"
title="Bad functions"
bg="danger"
class="fs-6"
hidden={props.statistic.bad == 0}
>
BAD: {props.statistic.bad} | {getPercent(props.statistic.bad)}%
</Badge>
{' '}
<Badge
title="Missing functions."
bg="warning text-dark fs-6"
title="Missing functions"
bg="warning"
class="fs-6 text-dark"
hidden={props.statistic.missing == 0}
>
MISS: {props.statistic.missing}| {getPercent(props.statistic.missing)}%
</Badge>

View file

@ -60,7 +60,7 @@ export const SwilibTable: Component<SwilibTableProps> = (props) => {
</h4>
<table
class="table table-bordered table-hover table-sticky-header"
style={{width: "100%", "max-width": "900px"}}
style={{"width": "100%", "max-width": "900px"}}
hidden={isCollapsed()}
>
<thead class="thead-dark">

View file

@ -42,8 +42,14 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
return '';
});
const handleClick = () => props.onSelect?.(props.entry, props.targetEntry);
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Enter' || event.key === ' ')
handleClick();
};
return (
<tr class={rowColor()} onClick={() => props.onSelect?.(props.entry, props.targetEntry)}>
<tr class={rowColor()} onClick={handleClick} onKeyDown={handleKeyDown} tabindex="0" role="button">
<td class={clsx(!props.entry.name && 'text-muted')}>
{formatId(props.entry.id)}
</td>
@ -53,19 +59,16 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
<td class={clsx(!props.entry.name && 'text-muted')}>
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryTypeBadge value={props.entry.type}/>
&nbsp;&nbsp;
<SwilibEntryName signature={props.entry.name}/>
<SwilibEntryTypeBadge value={props.entry.type} />
<SwilibEntryName signature={props.entry.name} />
</div>
<SwilibEntryBadges value={props.entry.flags}/>
<SwilibEntryBadges value={props.entry.flags} />
</div>
<Show when={tableOptions.showOldNames}>
{props.entry.aliases.map((aliasName) =>
<div>
<i class="bi bi-info-square"></i>
&nbsp;&nbsp;
<small class="text-muted">Old name:</small>
&nbsp;
<i class="bi bi-info-square me-2"></i>
<small class="text-muted">Old name:</small>{' '}
<small>{aliasName}</small>
</div>
)}

View file

@ -31,9 +31,10 @@ export const SwilibEntryModal: Component<SwilibEntryModalProps> = (props) => {
return (
<Modal size="lg" centered show={showModal()} onHide={() => setShowModal(false)} onExited={props.onHide}>
<Modal.Header closeButton>
<Modal.Title>
<b>ID:</b> {formatId(props.entry.id)}, <b>offset:</b> {formatId(props.entry.id * 4)}
&nbsp;&nbsp;
<Modal.Title class="d-flex align-items-center">
<span class="me-3">
<b>ID:</b> {formatId(props.entry.id)}, <b>offset:</b> {formatId(props.entry.id * 4)}
</span>
<SwilibEntryBadges value={props.entry.flags}/>
</Modal.Title>
</Modal.Header>

View file

@ -17,7 +17,7 @@ const SwilibSummaryPage: Component = () => {
const [selectedEntry, setSelectedEntry] = createSignal<SummarySwilibAnalysisEntry>();
return <>
<div class="mb-3">
<div class="mb-2">
<div class="mb-2">
<SwilibTargetsTabs devices={devices()} />
</div>
@ -43,7 +43,11 @@ const SwilibSummaryPage: Component = () => {
/>
</div>
<Button variant="outline-primary" onClick={() => setTableOptions("globalCollapsed", (prev) => !prev)}>
<Button
variant="outline-primary"
size="sm"
onClick={() => setTableOptions("globalCollapsed", (prev) => !prev)}
>
<Show when={!tableOptions.globalCollapsed}>
<i class="bi bi-eye-slash"></i> Collapse all
</Show>
@ -54,7 +58,7 @@ const SwilibSummaryPage: Component = () => {
</div>
</div>
<div class="d-flex flex-row mb-3">
<div class="d-flex flex-row mb-2">
<span class="me-3"><i class="bi bi-globe"></i> Show coverage:</span>
<Form.Check
inline
@ -91,7 +95,8 @@ const SwilibSummaryPage: Component = () => {
</Show>
<Show when={resourcesState.isReady}>
<div class="alert alert-info" role="alert">
<div class="text-secondary mb-2">
<span class="bi bi-info-circle"></span> {' '}
Next free ID: <b>{formatId(summaryAnalysis()!.nextId)}</b>
</div>

View file

@ -1,6 +1,6 @@
import { Component, createEffect, createMemo, For, on } from "solid-js";
import { TableSortButton } from "@/components/TableSortButton";
import { SummarySwilibAnalysisEntry, SWILIB_PLATFORMS, SummarySwilibAnalysis } from "@/api/swilib";
import { SummarySwilibAnalysis, SummarySwilibAnalysisEntry, SWILIB_PLATFORMS } from "@/api/swilib";
import { useSwilibTableOptionsStore } from "@/store/swilibTableOptionsStore";
import { SwilibTableRow } from "@/pages/SwilibSummary/SwilibTableRow";
@ -40,7 +40,7 @@ export const SwilibTable: Component<SwilibTableProps> = (props) => {
</h4>
<table
class="table table-bordered table-hover table-sticky-header"
style={{width: "100%", "max-width": "900px"}}
style={{"width": "100%", "max-width": "900px"}}
hidden={isCollapsed()}
>
<thead class="thead-dark">

View file

@ -20,8 +20,14 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
return props.entry.coverage;
});
const handleClick = () => props.onSelect?.(props.entry);
const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Enter' || event.key === ' ')
handleClick();
};
return (
<tr class="cursor-pointer" onClick={() => props.onSelect?.(props.entry)}>
<tr class="cursor-pointer" onClick={handleClick} onKeyDown={handleKeyDown} tabindex="0" role="button">
<td classList={{'text-muted': props.entry.name == null}}>
{formatId(props.entry.id)}
</td>
@ -29,18 +35,15 @@ export const SwilibTableRow: Component<SwilibTableRowProps> = (props) => {
<td classList={{'text-muted': props.entry.name == null}}>
<div class="d-flex justify-content-between align-items-center">
<div>
<SwilibEntryTypeBadge value={props.entry.type}/>
&nbsp;&nbsp;
<SwilibEntryName signature={props.entry.name}/>
<SwilibEntryTypeBadge value={props.entry.type} />
<SwilibEntryName signature={props.entry.name} />
</div>
<SwilibEntryBadges value={props.entry.flags}/>
</div>
<Show when={tableOptions.showOldNames}>{props.entry.aliases.map((aliasName) =>
<div>
<i class="bi bi-info-square"></i>
&nbsp;&nbsp;
<small class="text-muted">Old name:</small>
&nbsp;
<i class="bi bi-info-square me-2"></i>
<small class="text-muted">Old name:</small>{' '}
<small>{aliasName}</small>
</div>
)}</Show>

View file

@ -0,0 +1,13 @@
import { makePersistedStore } from "@/utils/makePersistedStore";
import { createStore } from "solid-js/store";
import { createRoot } from "solid-js";
export type ThemeType = "light" | "dark" | "system";
const globalSettingsStore = createRoot(() =>
makePersistedStore(createStore({
theme: "system" as ThemeType,
}), { name: 'globalSettings' })
);
export const useGlobalSettingsStore = () => globalSettingsStore;

View file

@ -1,9 +1,9 @@
import { makePersisted } from "@/utils/makePersisted";
import { makePersistedStore } from "@/utils/makePersistedStore";
import { createStore } from "solid-js/store";
import { createRoot } from "solid-js";
const tableOptionsStore = createRoot(() =>
makePersisted(createStore({
makePersistedStore(createStore({
showOldNames: true,
showEntryOffset: false,
showOriginalSymbol: false,

View file

@ -1,9 +1,9 @@
import { PersistentOptions, makePersisted } from '@/utils/makePersisted';
import { PersistentStoreOptions, makePersistedStore } from '@/utils/makePersistedStore';
import { createRoot } from 'solid-js';
import { SetStoreFunction, createStore } from 'solid-js/store';
export interface CreateStoreWithApiOptions<S> {
persist?: PersistentOptions<S>;
persist?: PersistentStoreOptions<S>;
}
export function createStoreWithApi<S extends object, A>(
@ -13,7 +13,7 @@ export function createStoreWithApi<S extends object, A>(
): () => [store: S, api: A] {
const [store, setStore] = createRoot(() => {
return options?.persist
? makePersisted(createStore<S>(initialData()), options.persist)
? makePersistedStore(createStore<S>(initialData()), options.persist)
: createStore<S>(initialData());
});
const api = createApi(store, setStore);

View file

@ -0,0 +1,36 @@
import { Setter, Signal } from "solid-js";
import { debounce } from "es-toolkit";
export interface PersistentSignalOptions {
name: string;
storage?: Storage;
serialize?: (data: any) => string;
deserialize?: (data: string) => any;
}
export function makePersistedSignal<T>(signal: Signal<T>, options: PersistentSignalOptions): Signal<T> {
const {
name,
storage = localStorage,
serialize = JSON.stringify,
deserialize = JSON.parse,
} = options;
const storedValue = storage.getItem(name);
if (storedValue !== null) {
const deserialized = deserialize(storedValue);
signal[1](deserialized);
}
const updateStorage = debounce(() => {
const serialized = serialize(signal[0]());
storage.setItem(name, serialized);
}, 0);
const setWithPersistence = (...args: any) => {
(signal[1] as any)(...args);
updateStorage();
};
return [signal[0], setWithPersistence as Setter<T>];
}

View file

@ -1,24 +1,25 @@
import { SetStoreFunction, Store, reconcile, unwrap } from 'solid-js/store';
import { debounce } from "es-toolkit";
export interface PersistentOptions<T> {
export type PersistentStore<T> = [get: Store<T>, set: SetStoreFunction<T>];
interface PersistentStoreInternal {
version: number;
state: unknown;
}
export interface PersistentStoreOptions<T> {
name: string;
storage?: Storage;
version?: number;
serialize?: (data: unknown) => string | undefined | null;
deserialize?: (data: unknown) => string | undefined | null;
serialize?: (data: any) => string;
deserialize?: (data: string) => any;
migrate?: (persistedState: T, version: number) => T;
merge?: (persistedState: T, currentState: T) => T;
skipLoad?: boolean;
}
interface PersistentInternal {
version: number;
state: unknown;
}
export type PersistentStore<T> = [get: Store<T>, set: SetStoreFunction<T>];
export function makePersisted<T>(store: [Store<T>, SetStoreFunction<T>], options: PersistentOptions<T>): PersistentStore<T> {
export function makePersistedStore<T>(store: [Store<T>, SetStoreFunction<T>], options: PersistentStoreOptions<T>): PersistentStore<T> {
const {
name,
storage = localStorage,
@ -32,7 +33,7 @@ export function makePersisted<T>(store: [Store<T>, SetStoreFunction<T>], options
const storedValue = skipLoad ? null : storage.getItem(name);
if (storedValue !== null) {
const parsed = deserialize(storedValue) as PersistentInternal;
const parsed = deserialize(storedValue) as PersistentStoreInternal;
if (parsed != null && parsed.version !== null) {
const typedState = parsed.state as T;
if (parsed.version !== version) {
@ -44,17 +45,13 @@ export function makePersisted<T>(store: [Store<T>, SetStoreFunction<T>], options
}
}
const updateStorage = () => {
const updateStorage = debounce(() => {
const serialized = serialize({
version,
state: unwrap(store[0]) as unknown,
} as PersistentInternal);
if (serialized != null) {
storage.setItem(name, serialized);
} else {
storage.removeItem(name);
}
};
} as PersistentStoreInternal);
storage.setItem(name, serialized);
}, 0);
const setWithPersistence: SetStoreFunction<T> = (...args: any) => {
(store[1] as any)(...args);