From e3b32fd791cac6e1bcceca1e3da3ce99179eea43 Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Fri, 10 Nov 2023 22:32:56 -0500 Subject: [PATCH] improved dashboard design + blurred icons based on personal preferences --- components/DashboardItem.tsx | 6 +- components/LinkCard.tsx | 4 +- .../users/userId/updateUserById.ts | 1 + pages/settings/account.tsx | 5 +- pages/settings/appearance.tsx | 126 +++++++++++++++--- pages/settings/billing.tsx | 2 +- pages/settings/delete.tsx | 2 +- .../migration.sql | 2 + prisma/schema.prisma | 2 + 9 files changed, 117 insertions(+), 33 deletions(-) create mode 100644 prisma/migrations/20231110154938_add_blurred_favicons_field/migration.sql diff --git a/components/DashboardItem.tsx b/components/DashboardItem.tsx index 38d6c16..d891398 100644 --- a/components/DashboardItem.tsx +++ b/components/DashboardItem.tsx @@ -9,8 +9,8 @@ type Props = { export default function dashboardItem({ name, value, icon }: Props) { return ( -
-
+
+
{name}

-

+

{value}

diff --git a/components/LinkCard.tsx b/components/LinkCard.tsx index 55b5d1b..5cc8a1b 100644 --- a/components/LinkCard.tsx +++ b/components/LinkCard.tsx @@ -165,7 +165,7 @@ export default function LinkCard({ link, count, className }: Props) { onClick={() => router.push("/links/" + link.id)} className="flex items-start cursor-pointer gap-5 sm:gap-10 h-full w-full p-5" > - {url && ( + {url && account.blurredFavicons && ( { e.stopPropagation(); }} - className="flex items-center gap-1 max-w-full w-fit my-3 hover:opacity-70 duration-100" + className="flex items-center gap-1 max-w-full w-fit my-1 hover:opacity-70 duration-100" > -
+
diff --git a/pages/settings/appearance.tsx b/pages/settings/appearance.tsx index 2ddde66..32d7473 100644 --- a/pages/settings/appearance.tsx +++ b/pages/settings/appearance.tsx @@ -2,37 +2,119 @@ import SettingsLayout from "@/layouts/SettingsLayout"; import { useTheme } from "next-themes"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faSun, faMoon } from "@fortawesome/free-solid-svg-icons"; +import { useState, useEffect } from "react"; +import { faClose } from "@fortawesome/free-solid-svg-icons"; +import useAccountStore from "@/store/account"; +import { AccountSettings } from "@/types/global"; +import { toast } from "react-hot-toast"; +import TextInput from "@/components/TextInput"; +import { resizeImage } from "@/lib/client/resizeImage"; +import ProfilePhoto from "@/components/ProfilePhoto"; +import SubmitButton from "@/components/SubmitButton"; +import React from "react"; +import Checkbox from "@/components/Checkbox"; export default function Appearance() { const { theme, setTheme } = useTheme(); + const submit = async () => { + setSubmitLoader(true); + + const load = toast.loading("Applying..."); + + const response = await updateAccount({ + ...user, + }); + + toast.dismiss(load); + + if (response.ok) { + toast.success("Settings Applied!"); + } else toast.error(response.data as string); + setSubmitLoader(false); + }; + + const [submitLoader, setSubmitLoader] = useState(false); + + const { account, updateAccount } = useAccountStore(); + + const [user, setUser] = useState( + !objectIsEmpty(account) + ? account + : ({ + // @ts-ignore + id: null, + name: "", + username: "", + email: "", + emailVerified: null, + blurredFavicons: null, + image: "", + isPrivate: true, + // @ts-ignore + createdAt: null, + whitelistedUsers: [], + } as unknown as AccountSettings) + ); + + function objectIsEmpty(obj: object) { + return Object.keys(obj).length === 0; + } + + useEffect(() => { + if (!objectIsEmpty(account)) setUser({ ...account }); + }, [account]); + return ( -

Select Theme

-
-
setTheme("dark")} - > - -

Dark Theme

+
+
+

Select Theme

+
+
setTheme("dark")} + > + +

Dark Theme

- {/*
*/} + {/*
*/} +
+
setTheme("light")} + > + +

Light Theme

+ {/*
*/} +
+
-
setTheme("light")} - > - -

Light Theme

- {/*
*/} + +
+ + setUser({ ...user, blurredFavicons: !user.blurredFavicons }) + } + />
+ +
); diff --git a/pages/settings/billing.tsx b/pages/settings/billing.tsx index 953d1ee..75c0fd8 100644 --- a/pages/settings/billing.tsx +++ b/pages/settings/billing.tsx @@ -11,7 +11,7 @@ export default function Billing() { return ( -
+

To manage/cancel your subsciption, visit the{" "}