Feat: Frontend hardening
This commit is contained in:
@@ -1,4 +1,21 @@
|
||||
// Path: Frontend/src/entry-client.tsx
|
||||
|
||||
// @refresh reload
|
||||
import type { JSX } from "solid-js";
|
||||
import { mount, StartClient } from "@solidjs/start/client";
|
||||
|
||||
mount(() => <StartClient />, document.getElementById("app")!);
|
||||
const getAppRoot = (): HTMLElement => {
|
||||
const appRoot = document.getElementById("app");
|
||||
|
||||
if (!(appRoot instanceof HTMLElement)) {
|
||||
throw new Error("App root element '#app' was not found.");
|
||||
}
|
||||
|
||||
return appRoot;
|
||||
};
|
||||
|
||||
const mountApp = (): void => {
|
||||
mount((): JSX.Element => <StartClient />, getAppRoot());
|
||||
};
|
||||
|
||||
mountApp();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Path: Frontend/src/entry-server.tsx
|
||||
|
||||
// @refresh reload
|
||||
import type { JSX } from "solid-js";
|
||||
import { createHandler, StartServer } from "@solidjs/start/server";
|
||||
|
||||
const themeBootstrapScript = `
|
||||
@@ -19,22 +20,32 @@ const themeBootstrapScript = `
|
||||
})();
|
||||
`;
|
||||
|
||||
export default createHandler(() => (
|
||||
<StartServer
|
||||
document={({ assets, children, scripts }) => (
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<script innerHTML={themeBootstrapScript} />
|
||||
{assets}
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">{children}</div>
|
||||
{scripts}
|
||||
</body>
|
||||
</html>
|
||||
)}
|
||||
/>
|
||||
));
|
||||
type DocumentRenderProps = {
|
||||
assets?: JSX.Element;
|
||||
children?: JSX.Element;
|
||||
scripts?: JSX.Element;
|
||||
};
|
||||
|
||||
const renderDocument = ({ assets, children, scripts }: DocumentRenderProps): JSX.Element => {
|
||||
return (
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<script innerHTML={themeBootstrapScript} />
|
||||
{assets}
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">{children}</div>
|
||||
{scripts}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
};
|
||||
|
||||
const serverHandler = createHandler((): JSX.Element => {
|
||||
return <StartServer document={renderDocument} />;
|
||||
});
|
||||
|
||||
export default serverHandler;
|
||||
|
||||
2
Frontend/src/global.d.ts
vendored
2
Frontend/src/global.d.ts
vendored
@@ -1 +1,3 @@
|
||||
// Path: Frontend/src/global.d.ts
|
||||
|
||||
/// <reference types="@solidjs/start/env" />
|
||||
|
||||
@@ -16,7 +16,7 @@ export const resolvePreferredTheme = (): Theme => {
|
||||
|
||||
export const getDocumentTheme = (): Theme => (document.documentElement.getAttribute("data-theme") === "dark" ? "dark" : "light");
|
||||
|
||||
export const setTheme = (theme: Theme) => {
|
||||
export const setTheme = (theme: Theme): void => {
|
||||
document.documentElement.setAttribute("data-theme", theme);
|
||||
localStorage.setItem(THEME_STORAGE_KEY, theme);
|
||||
};
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
// Path: Frontend/src/lib/icons/index.ts
|
||||
|
||||
export { Bell, Check, ChevronDown, ChevronLeft, ChevronRight, Folder, FolderOpen, Home, LayoutGrid, MoreHorizontal, Plus, Search, Settings, User, X } from "lucide-solid";
|
||||
export { default as Bell } from "lucide-solid/icons/bell";
|
||||
export { default as ChevronDown } from "lucide-solid/icons/chevron-down";
|
||||
export { default as Folder } from "lucide-solid/icons/folder";
|
||||
export { default as Home } from "lucide-solid/icons/house";
|
||||
export { default as LayoutGrid } from "lucide-solid/icons/layout-grid";
|
||||
export { default as Plus } from "lucide-solid/icons/plus";
|
||||
export { default as Search } from "lucide-solid/icons/search";
|
||||
export { default as Settings } from "lucide-solid/icons/settings";
|
||||
export { default as User } from "lucide-solid/icons/user";
|
||||
|
||||
Reference in New Issue
Block a user