theme backgrounds

This commit is contained in:
incognitotgt 2024-04-14 19:08:34 -04:00
parent 30efd8c990
commit c0272a798d
No known key found for this signature in database
GPG key ID: D229D19A500C60B0
10 changed files with 63 additions and 22 deletions

View file

@ -3,7 +3,7 @@
"private": true, "private": true,
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "concurrently \"vite\" \"bare-server-node --port 8080\"", "dev": "concurrently \"vite\" \"tsx server.ts\"",
"build": "vite build", "build": "vite build",
"bstart": "npm run build && tsx server.ts", "bstart": "npm run build && tsx server.ts",
"start": "tsx server.ts", "start": "tsx server.ts",

View file

@ -1,13 +1,13 @@
import { createContext } from "preact"; import { createContext } from "preact";
import { useContext, useEffect, useState } from "preact/hooks"; import { useContext, useEffect, useState } from "preact/hooks";
export type Theme = type Theme =
| "main" | "main"
| "hacker" | "hacker"
| "catppuccin-mocha" | "catppuccin-mocha"
| "catppuccin-macchiato" | "catppuccin-macchiato"
| "catppuccin-frappe" | "catppuccin-frappe"
| "catppuccin-latte"; | "catppuccin-latte";
export const themes: Theme[] = [ const themes: Theme[] = [
"main", "main",
"hacker", "hacker",
"catppuccin-mocha", "catppuccin-mocha",

View file

@ -34,17 +34,19 @@ export default function App() {
const particlesLoaded = (container) => { const particlesLoaded = (container) => {
console.log(container); console.log(container);
}; };
const bgImage: string | undefined = localStorage.getItem("background");
return ( return (
<ThemeProvider> <ThemeProvider>
<div class="w-srceen h-screen"> <div class="h-screen w-screen">
{window.location.origin === "https://nebulaproxy.io" && <Meta />} {window.location.origin === "https://nebulaproxy.io" && <Meta />}
{/* {window.location.origin === "http://localhost:8080" && <Meta />} */} {/* {window.location.origin === "http://localhost:8080" && <Meta />} */}
<Suspense fallback={<LoadSuspense />}> <Suspense fallback={<LoadSuspense />}>
<div className="absolute z-20 h-full w-full"> <div className="absolute z-20 h-full w-full">
<Routes /> <Routes />
</div> </div>
<div className="z-10 h-full w-full bg-primary"> <div
className={`z-10 h-full w-full bg-primary ${bgImage && `bg-[url(${bgImage})] bg-cover`}`}
>
{init && particlesUrl !== "none" && ( {init && particlesUrl !== "none" && (
<Particles <Particles
id="tsparticles" id="tsparticles"

View file

@ -72,7 +72,10 @@
"select": "Select", "select": "Select",
"particles": "Particles", "particles": "Particles",
"particlesDesc": "Choose a particles wallpaper", "particlesDesc": "Choose a particles wallpaper",
"particlesNone": "None" "particlesNone": "None",
"background": "Background",
"backgroundDesc": "Choose a background image",
"backgroundNone": "None"
}, },
"httpProxy": { "httpProxy": {
"title": "(Advanced) HTTP Proxy", "title": "(Advanced) HTTP Proxy",

View file

@ -69,9 +69,13 @@
"theme": { "theme": {
"title": "Mirar", "title": "Mirar",
"subtitle": "Elige una mirada para que tus ojos no nos odienn", "subtitle": "Elige una mirada para que tus ojos no nos odienn",
"select": "Seleccionar",
"particles": "Partículas", "particles": "Partículas",
"particlesDesc": "Elige un fondo de pantalla de partículas", "particlesDesc": "Elige un fondo de pantalla de partículas",
"particlesNone": "Ninguna" "particlesNone": "Ninguna",
"background": "Fondo",
"backgroundDesc": "Elige una imagen de fondo",
"backgroundNone": "Ninguna"
}, },
"httpProxy": { "httpProxy": {
"title": "Proxy HTTP (avanzado)", "title": "Proxy HTTP (avanzado)",

View file

@ -69,9 +69,13 @@
"theme": { "theme": {
"title": "壁紙", "title": "壁紙",
"subtitle": "お好みの壁紙を選択してください", "subtitle": "お好みの壁紙を選択してください",
"select": "選択する",
"particles": "パーティクル", "particles": "パーティクル",
"particlesDesc": "パーティクルの種類を選択してください", "particlesDesc": "パーティクルの種類を選択してください",
"particlesNone": "なし" "particlesNone": "なし",
"background": "背景",
"backgroundDesc": "背景画像を選択してください",
"backgroundNone": "なし"
}, },
"httpProxy": { "httpProxy": {
"title": "HTTPプロキシ (上級者向け)", "title": "HTTPプロキシ (上級者向け)",

View file

@ -1,3 +1,4 @@
import { useRef } from "preact/hooks";
import { motion } from "framer-motion"; import { motion } from "framer-motion";
import { tabContentVariant, settingsPageVariant } from "./Variants"; import { tabContentVariant, settingsPageVariant } from "./Variants";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@ -5,6 +6,7 @@ import Dropdown from "./Dropdown";
import ThemeDropdown from "./ThemeDropdown"; import ThemeDropdown from "./ThemeDropdown";
function Customization({ id, active }) { function Customization({ id, active }) {
const bgInput = useRef<HTMLInputElement>(null);
const { t } = useTranslation(); const { t } = useTranslation();
const particles = [ const particles = [
@ -43,6 +45,31 @@ function Customization({ id, active }) {
</div> </div>
<Dropdown storageKey="particles" options={particles} refresh={true} /> <Dropdown storageKey="particles" options={particles} refresh={true} />
</div> </div>
<div className="flex h-64 w-80 flex-col flex-wrap content-center items-center rounded-lg border border-input-border-color bg-lighter p-2 text-center">
<div className="p-2 text-3xl font-bold text-input-text">
{t("settings.theme.background")}
</div>
<div className="text-md p-4 font-bold text-input-text">
{t("settings.theme.backgroundDesc")}
</div>
<input
ref={bgInput}
className="font-roboto h-14 rounded-2xl border border-input-border-color bg-input p-2 text-center text-xl text-input-text placeholder:text-input-text"
defaultValue={localStorage.getItem("background")}
placeholder={t("settings.theme.backgroundNone")}
/>
<button
onClick={() => {
if (bgInput) {
localStorage.setItem("background", bgInput.current.value);
window.location.reload();
}
}}
className="font-roboto mt-2 flex h-4 w-36 cursor-pointer flex-row items-center justify-center rounded-xl border border-input-border-color bg-input p-5 text-center text-lg text-input-text"
>
{t("settings.theme.select")}
</button>
</div>
</motion.div> </motion.div>
</motion.div> </motion.div>
); );

View file

@ -7,8 +7,8 @@ import { Radon } from "./pages/Radon";
import { Settings } from "./pages/Settings/"; import { Settings } from "./pages/Settings/";
import { AboutBlank } from "./AboutBlank"; import { AboutBlank } from "./AboutBlank";
import { Faq } from "./pages/Faq"; import { Faq } from "./pages/Faq";
import { registerRemoteListener } from "@mercuryworkshop/bare-mux"; // import { registerRemoteListener } from "@mercuryworkshop/bare-mux";
import { setTransport } from './util/transports'; import { setTransport } from "./util/transports";
import "./style.css"; import "./style.css";
import "./i18n"; import "./i18n";
@ -19,15 +19,13 @@ export default function Routes() {
"/wisp/"; // @TODO Japan - US ping "/wisp/"; // @TODO Japan - US ping
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
console.log("am bout to bus");
navigator.serviceWorker.ready.then(async (sw) => { navigator.serviceWorker.ready.then(async (sw) => {
//await registerRemoteListener(sw.active!) //await registerRemoteListener(sw.active!)
setTransport(); setTransport();
}); });
navigator.serviceWorker navigator.serviceWorker.register("/sw.js", {
.register("/sw.js", {
scope: "/~/" scope: "/~/"
}) });
} }
return ( return (
<LocationProvider> <LocationProvider>

View file

@ -120,9 +120,7 @@
--active-color: #8839ef !important; --active-color: #8839ef !important;
} }
} }
body {
background-color: var(--background-primary) !important;
}
.font-inter { .font-inter {
font-family: "Inter", sans-serif; font-family: "Inter", sans-serif;
font-weight: 300; font-weight: 300;

View file

@ -59,10 +59,15 @@ export default defineConfig({
rewrite: (path) => path.replace(/^\/bare\//, "") rewrite: (path) => path.replace(/^\/bare\//, "")
}, },
"/wisp/": { "/wisp/": {
target: "http://localhost:3000/", target: "http://localhost:8080/wisp/",
changeOrigin: true, changeOrigin: true,
ws: true, ws: true,
rewrite: (path) => path.replace(/^\/wisp\//, "") rewrite: (path) => path.replace(/^\/wisp\//, "")
},
"/search": {
target: "http://localhost:8080/search",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/search/, "")
} }
} }
} }