Skip to content

Commit 4317dc5

Browse files
committed
🏵️ Feat: Theme Settings UI
1 parent 6511bd0 commit 4317dc5

File tree

5 files changed

+61
-10
lines changed

5 files changed

+61
-10
lines changed

app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Contact from "@/world/contact";
1111
import { useAutoHideNav } from "@/world/settings";
1212
import { ToggleAutoHideNav } from "@/world/settings/toggleAutoHideNav";
1313
import Settings from "@/world/settings";
14+
import { ThemeSwitchRadio } from "@/world/settings/toggleThemes";
1415

1516
export default function Application() {
1617
useBlobity({
@@ -46,6 +47,7 @@ export default function Application() {
4647
toggleAutoHideNav={toggleAutoHideNav}
4748
isAutoHideNavEnabled={isAutoHideNavEnabled}
4849
/>
50+
<ThemeSwitchRadio />
4951
</Settings>
5052
<Projects />
5153
<Skills />

world/navigation.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import Link from "next/link";
33
import { ReactNode } from "react";
44
import { useState, useEffect } from "react";
55
import { smoothScroll } from "@/world/smoothScroll";
6-
import { ThemeSwitchNav } from "@/world/themeswitch";
76

87
/* ===================== SMOOTH TRAVEL TO DESTINATION ===================== */
98

@@ -52,7 +51,7 @@ export default function FastTravel({ isAutoHideEnabled }: FastTravelProps) {
5251

5352
return (
5453
<nav
55-
className={`fixed bottom-0 sm:bottom-6 left-0 right-0 mx-auto flex items-center justify-center gap-1 sm:rounded-xl border-0 sm:border-2 border-gray-500 bg-neutral-950 px-1 py-1 sm:w-[383.3px] md:p-2 lg:w-fit z-10 transition-transform duration-500 ${ isVisible ? "translate-y-0" : "translate-y-20" }`}
54+
className={`fixed bottom-0 sm:bottom-6 left-0 right-0 mx-auto flex items-center justify-center gap-1 sm:rounded-xl border-0 sm:border-2 border-gray-500 bg-neutral-950 px-1 py-1 sm:w-[383.3px] md:p-2 lg:w-fit z-10 transition-transform duration-500 ${isVisible ? "translate-y-0" : "translate-y-20"}`}
5655
>
5756
<NavItem href="#home" label="Fast Travel to Home">
5857
Home
@@ -69,8 +68,6 @@ export default function FastTravel({ isAutoHideEnabled }: FastTravelProps) {
6968
<NavItem href="#contact" label="Fast Travel to Postal Service">
7069
Contact
7170
</NavItem>
72-
73-
<ThemeSwitchNav />
7471
</nav>
7572
);
7673
}

world/settings.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ export default function Settings({ children }: SettingsProps) {
6060
<section id="settings">
6161
<button
6262
onClick={open}
63-
className="absolute sm:fixed right-5 top-5"
63+
className="absolute sm:fixed right-3 top-3 sm:right-5 sm:top-5"
6464
data-blobity-magnetic="false"
6565
>
66-
<h3 className="m-0 p-0 text-gray-500">
67-
<FontAwesomeIcon icon={faGear} />
66+
<h3 className="m-0 p-0 text-gray-400">
67+
<FontAwesomeIcon className="p-2" icon={faGear} />
6868
</h3>
6969
</button>
7070

@@ -91,7 +91,7 @@ export default function Settings({ children }: SettingsProps) {
9191
<div className="flex min-h-full items-center justify-center p-4">
9292
<DialogPanel
9393
transition
94-
className="w-full max-w-md rounded-xl bg-white/70 dark:bg-white/20 p-6 backdrop-blur-xl duration-300 ease-out data-[closed]:transform-[scale(95%)] data-[closed]:opacity-0"
94+
className="w-full max-w-md rounded-xl bg-white/70 dark:bg-white/20 p-6 backdrop-blur-2xl duration-300 ease-out data-[closed]:transform-[scale(95%)] data-[closed]:opacity-0"
9595
>
9696
<Button
9797
className="float-right"
@@ -102,7 +102,10 @@ export default function Settings({ children }: SettingsProps) {
102102
<FontAwesomeIcon icon={faXmark} />
103103
</h3>
104104
</Button>
105-
<h3 className="mb-8">Portfolio Settings</h3>
105+
<h3 className="mb-8">
106+
<FontAwesomeIcon className="me-2" icon={faGear} />
107+
Settings
108+
</h3>
106109
{children}
107110
</DialogPanel>
108111
</div>

world/settings/toggleAutoHideNav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const ToggleAutoHideNav = ({
1515
checked={isAutoHideEnabled}
1616
onChange={toggleAutoHide}
1717
className="group inline-flex h-6 w-11 items-center rounded-full
18-
bg-gray-400 dark:bg-gray-500 transition data-[checked]:bg-blue-600 dark:data-[checked]:bg-yellow-200"
18+
bg-gray-600 dark:bg-gray-400 transition data-[checked]:bg-blue-600 dark:data-[checked]:bg-yellow-200"
1919
data-blobity-magnetic="false"
2020
data-blobity-radius="15"
2121
>

world/themeswitch.tsx renamed to world/settings/toggleThemes.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,52 @@ export const ThemeSwitchNav = () => {
5656
</button>
5757
);
5858
};
59+
60+
import { Radio, RadioGroup } from "@headlessui/react";
61+
import { faCircleCheck } from "@fortawesome/free-solid-svg-icons";
62+
63+
const plans = [
64+
{
65+
value: "system",
66+
name: "System Theme",
67+
desc: "Based on your system/browser settings",
68+
},
69+
{ value: "light", name: "Light Mode", desc: "Prepare to blow your eyes out" },
70+
{ value: "dark", name: "Dark Mode", desc: "Finally, comfort in the dark" },
71+
];
72+
73+
export function ThemeSwitchRadio() {
74+
const [mounted, setMounted] = useState(false);
75+
const { theme, setTheme } = useTheme();
76+
useEffect(() => {
77+
setMounted(true);
78+
}, []);
79+
if (!mounted) {
80+
return null;
81+
}
82+
return (
83+
<RadioGroup value={theme} onChange={(e) => setTheme(e)} aria-label="Themes">
84+
<h5 className="mt-4">Themes</h5>
85+
{plans.map((plan) => (
86+
<Radio
87+
key={plan.value}
88+
value={plan.value}
89+
className="group relative flex cursor-pointer rounded-lg bg-white/5 my-2 py-3 px-5 text-white shadow-md transition focus:outline-none data-[focus]:outline-1 data-[focus]:outline-white data-[checked]:bg-white/20"
90+
>
91+
<div className="flex w-full items-center justify-between">
92+
<div>
93+
<p className="m-0 font-bold group-data-[checked]:text-blue-800 dark:group-data-[checked]:text-yellow-200">
94+
{plan.name}
95+
</p>
96+
<p className="text-xs m-0">{plan.desc}</p>
97+
</div>
98+
<FontAwesomeIcon
99+
icon={faCircleCheck}
100+
className="size-6 text-blue-800 dark:text-yellow-200 opacity-0 transition group-data-[checked]:opacity-100"
101+
/>
102+
</div>
103+
</Radio>
104+
))}
105+
</RadioGroup>
106+
);
107+
}

0 commit comments

Comments
 (0)