diff --git a/src/components/bookmarks/item.jsx b/src/components/bookmarks/item.jsx index 560bcb1ae..5f4e53897 100644 --- a/src/components/bookmarks/item.jsx +++ b/src/components/bookmarks/item.jsx @@ -6,10 +6,10 @@ export default function Item({ bookmark }) { diff --git a/src/components/revalidate.jsx b/src/components/revalidate.jsx new file mode 100644 index 000000000..9e436fa2e --- /dev/null +++ b/src/components/revalidate.jsx @@ -0,0 +1,17 @@ +import { MdRefresh } from "react-icons/md"; + +export default function Revalidate() { + const revalidate = () => { + fetch("/api/revalidate").then((res) => { + if (res.ok) { + window.location.reload(); + } + }); + }; + + return ( +
+ revalidate()} className="text-theme-800 dark:text-theme-200 w-6 h-6 cursor-pointer" /> +
+ ); +} diff --git a/src/components/services/item.jsx b/src/components/services/item.jsx index 4cb5a055b..55b32362a 100644 --- a/src/components/services/item.jsx +++ b/src/components/services/item.jsx @@ -28,7 +28,7 @@ export default function Item({ service }) {
{service.icon && ( diff --git a/src/components/theme-toggle.jsx b/src/components/theme-toggle.jsx index da29d9d2c..ecbb17620 100644 --- a/src/components/theme-toggle.jsx +++ b/src/components/theme-toggle.jsx @@ -1,10 +1,5 @@ import { useContext } from "react"; -import { - MdDarkMode, - MdLightMode, - MdToggleOff, - MdToggleOn, -} from "react-icons/md"; +import { MdDarkMode, MdLightMode, MdToggleOff, MdToggleOn } from "react-icons/md"; import { ThemeContext } from "utils/theme-context"; diff --git a/src/components/widgets/resources/cpu.jsx b/src/components/widgets/resources/cpu.jsx index 87c1847c7..c57609a67 100644 --- a/src/components/widgets/resources/cpu.jsx +++ b/src/components/widgets/resources/cpu.jsx @@ -2,6 +2,7 @@ import useSWR from "swr"; import { FiCpu } from "react-icons/fi"; import { BiError } from "react-icons/bi"; import { useTranslation } from "react-i18next"; +import UsageBar from "./usage-bar"; export default function Cpu() { const { t } = useTranslation(); @@ -41,14 +42,7 @@ export default function Cpu() {
{t("common.number", { value: data.cpu.usage, style: "unit", unit: "percent", maximumFractionDigits: 0 })}
-
-
-
+
); diff --git a/src/components/widgets/resources/disk.jsx b/src/components/widgets/resources/disk.jsx index 47ec977c7..e055b8f79 100644 --- a/src/components/widgets/resources/disk.jsx +++ b/src/components/widgets/resources/disk.jsx @@ -2,6 +2,7 @@ import useSWR from "swr"; import { FiHardDrive } from "react-icons/fi"; import { BiError } from "react-icons/bi"; import { useTranslation } from "react-i18next"; +import UsageBar from "./usage-bar"; export default function Disk({ options }) { const { t } = useTranslation(); @@ -44,14 +45,7 @@ export default function Disk({ options }) { {t("common.bytes", { value: data.drive.totalGb * 1024 * 1024 * 1024 })} {t("resources.total")} -
-
-
+
); diff --git a/src/components/widgets/resources/memory.jsx b/src/components/widgets/resources/memory.jsx index 5a7c227e1..f5615ee78 100644 --- a/src/components/widgets/resources/memory.jsx +++ b/src/components/widgets/resources/memory.jsx @@ -2,6 +2,7 @@ import useSWR from "swr"; import { FaMemory } from "react-icons/fa"; import { BiError } from "react-icons/bi"; import { useTranslation } from "react-i18next"; +import UsageBar from "./usage-bar"; export default function Memory() { const { t } = useTranslation(); @@ -44,14 +45,7 @@ export default function Memory() { {t("common.bytes", { value: data.memory.usedMemMb * 1024 * 1024 })} {t("resources.used")} -
-
-
+
); diff --git a/src/components/widgets/resources/usage-bar.jsx b/src/components/widgets/resources/usage-bar.jsx new file mode 100644 index 000000000..2e9671a7e --- /dev/null +++ b/src/components/widgets/resources/usage-bar.jsx @@ -0,0 +1,12 @@ +export default function UsageBar({ percent }) { + return ( +
+
+
+ ); +} diff --git a/src/components/widgets/search/search.jsx b/src/components/widgets/search/search.jsx index 6341ee65c..1b3258ed1 100644 --- a/src/components/widgets/search/search.jsx +++ b/src/components/widgets/search/search.jsx @@ -52,19 +52,33 @@ export default function Search({ options }) { return (
-
+
setQuery(s.currentTarget.value)} required + autoCapitalize="off" + autoCorrect="off" + autoComplete="off" /> ); diff --git a/src/pages/_document.jsx b/src/pages/_document.jsx index 2a2626c2d..b6182fffe 100644 --- a/src/pages/_document.jsx +++ b/src/pages/_document.jsx @@ -11,7 +11,7 @@ export default function Document() { rel="stylesheet" /> - +
diff --git a/src/pages/api/revalidate.js b/src/pages/api/revalidate.js new file mode 100644 index 000000000..49d933d43 --- /dev/null +++ b/src/pages/api/revalidate.js @@ -0,0 +1,8 @@ +export default async function handler(req, res) { + try { + await res.revalidate("/"); + return res.json({ revalidated: true }); + } catch (err) { + return res.status(500).send("Error revalidating"); + } +} diff --git a/src/pages/index.jsx b/src/pages/index.jsx index fac28690f..ea50fc71d 100644 --- a/src/pages/index.jsx +++ b/src/pages/index.jsx @@ -6,6 +6,8 @@ import dynamic from "next/dynamic"; import ServicesGroup from "components/services/group"; import BookmarksGroup from "components/bookmarks/group"; import Widget from "components/widget"; +import Revalidate from "components/revalidate"; +import { getSettings } from "utils/config"; import { ColorProvider } from "utils/color-context"; import { ThemeProvider } from "utils/theme-context"; @@ -19,18 +21,34 @@ const ColorToggle = dynamic(() => import("components/color-toggle"), { const rightAlignedWidgets = ["weatherapi", "openweathermap", "weather", "search"]; -export default function Home() { +export async function getStaticProps() { + const settings = await getSettings(); + + return { + props: { + settings, + }, + }; +} +export default function Home({ settings }) { const { data: services } = useSWR("/api/services"); const { data: bookmarks } = useSWR("/api/bookmarks"); const { data: widgets } = useSWR("/api/widgets"); + const wrappedStyle = {}; + if (settings.background) { + wrappedStyle.backgroundImage = `url(${settings.background})`; + wrappedStyle.backgroundSize = "cover"; + } + return ( - Welcome + {settings.title || "Homepage"} -
+
+
{widgets && ( <> @@ -69,6 +87,7 @@ export default function Home() {
+
diff --git a/src/styles/theme.css b/src/styles/theme.css index e33fcf835..57be35b37 100644 --- a/src/styles/theme.css +++ b/src/styles/theme.css @@ -1,3 +1,16 @@ +.theme-white { + --color-50: 255 255 255; + --color-100: 255 255 255; + --color-200: 255 255 255; + --color-300: 255 255 255; + --color-400: 255 255 255; + --color-500: 60 60 60; + --color-600: 255 255 255; + --color-700: 40 40 40; + --color-800: 255 255 255; + --color-900: 255 255 255; +} + .theme-slate { --color-50: 248 250 252; --color-100: 241 245 249;