Skip to content

Commit

Permalink
feat: dark mode prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
wodeni committed Dec 30, 2023
1 parent d984392 commit c308c53
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/A.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode } from "react";
export default ({ href, children }: { href: string; children: ReactNode }) => {
return (
<a
className={`underline decoration-primary/50 decoration-2 cursor-pointer hover:decoration-primary ease-in-out duration-100`}
className={`underline decoration-primary/50 dark:decoration-primary/70 decoration-2 cursor-pointer hover:decoration-primary hover:decoration-3 ease-in-out duration-100`}
href={href}
>
{children}
Expand Down
116 changes: 84 additions & 32 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Logo from "./Logo";
import penroseLogo from "./assets/penrose.svg";
import Balls from "./Balls";
import Papers, { Paper } from "./Papers";
import { ReactNode, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import { HashLink } from "react-router-hash-link";
import news from "./News";
import A from "./A";
Expand All @@ -27,8 +27,11 @@ const NewsFeed = () => {
({ time }) => time.getUTCFullYear() >= today.getUTCFullYear() - 1
)
.map(({ time, msg }, i) => (
<div className="py-2 text-icon md:text-sm" key={`news-${i}`}>
<div className="w-fit bg-[#eee] rounded py-px px-1">
<div
className="py-2 text-icon md:text-sm dark:text-neutral-300"
key={`news-${i}`}
>
<div className="w-fit bg-[#eee] rounded py-px px-1 dark:bg-zinc-600">
{time.toLocaleString("default", {
month: "long",
year: "numeric",
Expand Down Expand Up @@ -58,7 +61,7 @@ export const Copy = ({
return (
<div>
<span
className={`underline decoration-primary/50 decoration-2 cursor-pointer hover:decoration-primary ease-in-out duration-100`}
className={`underline decoration-primary/50 dark:decoration-primary/70 decoration-2 cursor-pointer hover:decoration-primary hover:decoration-3 ease-in-out duration-100`}
onClick={handleClick}
>
{children}
Expand All @@ -85,26 +88,22 @@ const Publications = () => (
}: Paper) => (
<div key={id} className="my-4">
<a href={pdf}>
<span className="text-lg font-semibold cursor-pointer">
<span className="text-lg font-semibold dark:font-normal cursor-pointer">
{title}
</span>
</a>
<br />
<span className="text-base">
<span className="text-base font-light">
{authors
.map((a) => (coauthors?.includes(a) ? `${a}*` : a))
.map((a) =>
a === "Wode Ni" || a === "Wode Ni*" ? <strong>{a}</strong> : a
)
.map((a, i) => (
<>
<li className={`inline`} key={`id-author-${i}`}>
{a}
</li>
{i !== authors.length - 1 && (
<span key={`author-comma-${i}`}>, </span>
)}
</>
<span key={`${id}-author-${i}`}>
<li className={`inline`}>{a}</li>
{i !== authors.length - 1 && <span>, </span>}
</span>
))}
</span>
.{/* <br /> */}{" "}
Expand Down Expand Up @@ -154,13 +153,22 @@ const Hero = ({ className }: { className?: string }) => (
</div>
);

const DarkToggle = () => (
<div className="mx-1 w-6 h-6 text-xl flex cursor-pointer justify-center hover:opacity-50 ease-in-out duration-200 justify-self-center">
<MdDarkMode fill={theme.colors.icon} />
const DarkToggle = ({ toggleDark }: { toggleDark: () => void }) => (
<div
className="mx-1 w-6 h-6 text-xl flex cursor-pointer justify-center hover:opacity-50 ease-in-out duration-200 justify-self-center"
onClick={toggleDark}
>
<MdDarkMode className="fill-icon dark:fill-icon-dark" />
</div>
);

const Socials = ({ className }: { className?: string }) => (
const Socials = ({
className,
toggleDark,
}: {
className?: string;
toggleDark: () => void;
}) => (
<div
className={`${className} flex items-start md:items-top md:ml-auto mb-0 color-primary`}
>
Expand All @@ -169,7 +177,7 @@ const Socials = ({ className }: { className?: string }) => (
<GitHub />
<Email />
<Office />
{/* <DarkToggle /> */}
<DarkToggle toggleDark={toggleDark} />
</div>
);

Expand All @@ -185,21 +193,21 @@ const Icon = ({ url, icon }: { url: string; icon: ReactNode }) => (
const Office = () => (
<Icon
url="https://goo.gl/maps/Zp92ofs6ze3y8hc19"
icon={<MdLocationPin fill={theme.colors.icon} />}
icon={<MdLocationPin className="fill-icon dark:fill-icon-dark" />}
/>
);

const Twitter = () => (
<Icon
url="https://twitter.com/wodenimoni"
icon={<FaTwitter fill={theme.colors.icon} />}
icon={<FaTwitter className="fill-icon dark:fill-icon-dark" />}
/>
);

const GitHub = () => (
<Icon
url="https://github.com/wodeni"
icon={<FaGithub fill={theme.colors.icon} />}
icon={<FaGithub className="fill-icon dark:fill-icon-dark" />}
/>
);

Expand All @@ -211,7 +219,10 @@ const CV = () => (
);

const Email = () => (
<Icon url="mailto:[email protected]" icon={<MdEmail fill={theme.colors.icon} />} />
<Icon
url="mailto:[email protected]"
icon={<MdEmail className="fill-icon dark:fill-icon-dark" />}
/>
);

const Text = ({
Expand All @@ -221,7 +232,9 @@ const Text = ({
className?: string;
children: ReactNode;
}) => (
<p className={`${className} font-sans font-extralight text-lg my-2`}>
<p
className={`${className} font-sans font-extralight text-lg my-2 dark:text-neutral-100`}
>
{children}
</p>
);
Expand All @@ -237,24 +250,27 @@ const Section = ({
return (
<div id={id} className="my-4 md:my-8">
<span className="font-bold text-3xl tracking-tight curosr-pointer relative group">
<svg height={30} className="absolute z-[-1] w-full translate-y-1">
<svg height={30} className="absolute w-full translate-y-1">
<rect
x={0}
y={0}
width={5}
height={50}
fill={theme.colors.primary}
className="group-hover:opacity-30 group-hover:scale-x-400 transition-transform transform"
className="group-hover:opacity-30 group-hover:scale-x-400 transition-transform transform fill-primary"
></rect>
<rect
x={0}
y={0}
width={5}
height={50}
fill={theme.colors.primary}
className="fill-primary"
></rect>
</svg>
<HashLink className="ml-[10px] w-full" smooth to={`/#${id}`}>
<HashLink
className="ml-[10px] w-full dark:text-neutral-100"
smooth
to={`/#${id}`}
>
{header}
</HashLink>
</span>
Expand All @@ -264,17 +280,51 @@ const Section = ({
};

const App: React.FC = () => {
const [darkMode, setDarkMode] = useState(
window.matchMedia("(prefers-color-scheme: dark)").matches
);
const toggleDark = () => {
setDarkMode(!darkMode);
};

function updateTheme() {
if (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {
setDarkMode(true);
} else {
// Otherwise, remove it
setDarkMode(false);
}
}

useEffect(() => {
// Add an event listener to react to changes in the system's color scheme
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", updateTheme);
});

useEffect(() => {
document.documentElement.classList.toggle("dark", darkMode);
}, [darkMode]);

return (
<div className="font-sans md:grid md:grid-cols-3 m-4 md:m-10 max-w-screen-xl">
<div
className={
"font-sans md:grid md:grid-cols-3 p-4 md:p-10 max-w-screen-xl dark:bg-zinc-800 dark:text-neutral-100"
}
>
<Hero className="md:col-span-2" />
<Socials className="mt-8" />
<Socials className="mt-8" toggleDark={toggleDark} />
<Text className="md:col-span-2 mt-8">
I'm Nimo. I build ergonomic digital tools to make difficult things feel
simple.
</Text>
<div className="max-w-screen-md md:col-span-2">
<Section header={"Research"}>
<Text>
<Text className="">
I am a Ph.D. candidate at Carnegie Mellon University, School of
Computer Science, advised by{" "}
<A href="http://pact.cs.cmu.edu/koedinger.html">Ken Koedinger</A>{" "}
Expand All @@ -288,12 +338,14 @@ const App: React.FC = () => {
name="Edgeworth"
desc="Diagrammatic problem generation by program mutation."
link="https://github.com/penrose/penrose/tree/main/packages/edgeworth"
dark={darkMode}
></Project>
<Project
name="Penrose"
desc="Create beautiful diagrams just by typing math notation in plain text."
link="https://penrose.cs.cmu.edu/"
logo={penroseLogo}
dark={darkMode}
></Project>
</div>
</Section>
Expand Down
2 changes: 1 addition & 1 deletion src/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default ({ className }: { className: string }) => (
xmlns="http://www.w3.org/2000/svg"
>
<path
className="fill-icontext"
className="fill-icontext dark:fill-icontext-dark"
d="M76.875 5.3125L65.25 51H54.2188L48.0312 27C47.9062 26.5417 47.7396 25.8438 47.5312 24.9062C47.3229 23.9688 47.1042 22.9479 46.875 21.8438C46.6458 20.7188 46.4375 19.6667 46.25 18.6875C46.0833 17.6875 45.9688 16.8958 45.9062 16.3125C45.8438 16.8958 45.7188 17.6771 45.5312 18.6562C45.3646 19.6354 45.1667 20.6771 44.9375 21.7812C44.7292 22.8854 44.5208 23.9167 44.3125 24.875C44.1042 25.8333 43.9375 26.5625 43.8125 27.0625L37.6562 51H26.6562L15 5.3125H24.5312L30.375 30.25C30.5417 31 30.7292 31.8958 30.9375 32.9375C31.1667 33.9792 31.3854 35.0729 31.5938 36.2188C31.8229 37.3438 32.0208 38.4375 32.1875 39.5C32.375 40.5417 32.5104 41.4479 32.5938 42.2188C32.6979 41.4271 32.8333 40.5104 33 39.4688C33.1667 38.4062 33.3438 37.3333 33.5312 36.25C33.7396 35.1458 33.9479 34.125 34.1562 33.1875C34.3646 32.25 34.5521 31.4896 34.7188 30.9062L41.375 5.3125H50.5312L57.1875 30.9062C57.3333 31.4688 57.5 32.2292 57.6875 33.1875C57.8958 34.125 58.1042 35.1458 58.3125 36.25C58.5208 37.3542 58.7083 38.4375 58.875 39.5C59.0625 40.5417 59.1979 41.4479 59.2812 42.2188C59.4271 41.1771 59.625 39.9167 59.875 38.4375C60.1458 36.9375 60.4271 35.4479 60.7188 33.9688C61.0312 32.4896 61.3021 31.25 61.5312 30.25L67.3438 5.3125H76.875ZM107.225 33.4688C107.225 36.3854 106.829 38.9688 106.037 41.2188C105.267 43.4688 104.131 45.375 102.631 46.9375C101.152 48.4792 99.3604 49.6458 97.2562 50.4375C95.1729 51.2292 92.8187 51.625 90.1937 51.625C87.7354 51.625 85.475 51.2292 83.4125 50.4375C81.3708 49.6458 79.5896 48.4792 78.0687 46.9375C76.5687 45.375 75.4021 43.4688 74.5687 41.2188C73.7562 38.9688 73.35 36.3854 73.35 33.4688C73.35 29.5938 74.0375 26.3125 75.4125 23.625C76.7875 20.9375 78.7458 18.8958 81.2875 17.5C83.8292 16.1042 86.8604 15.4062 90.3812 15.4062C93.6521 15.4062 96.5479 16.1042 99.0687 17.5C101.61 18.8958 103.6 20.9375 105.037 23.625C106.496 26.3125 107.225 29.5938 107.225 33.4688ZM83.0687 33.4688C83.0687 35.7604 83.3187 37.6875 83.8187 39.25C84.3187 40.8125 85.1 41.9896 86.1625 42.7812C87.225 43.5729 88.6104 43.9688 90.3187 43.9688C92.0062 43.9688 93.3708 43.5729 94.4125 42.7812C95.475 41.9896 96.2458 40.8125 96.725 39.25C97.225 37.6875 97.475 35.7604 97.475 33.4688C97.475 31.1562 97.225 29.2396 96.725 27.7188C96.2458 26.1771 95.475 25.0208 94.4125 24.25C93.35 23.4792 91.9646 23.0938 90.2562 23.0938C87.7354 23.0938 85.9021 23.9583 84.7562 25.6875C83.6312 27.4167 83.0687 30.0104 83.0687 33.4688ZM122.003 51.625C118.107 51.625 114.93 50.1042 112.471 47.0625C110.034 44 108.815 39.5104 108.815 33.5938C108.815 27.6146 110.055 23.0938 112.534 20.0312C115.013 16.9479 118.253 15.4062 122.253 15.4062C123.919 15.4062 125.388 15.6354 126.659 16.0938C127.93 16.5521 129.023 17.1667 129.94 17.9375C130.878 18.7083 131.669 19.5729 132.315 20.5312H132.628C132.503 19.8646 132.346 18.8854 132.159 17.5938C131.992 16.2812 131.909 14.9375 131.909 13.5625V2.375H141.471V51H134.159L132.315 46.4688H131.909C131.305 47.4271 130.544 48.3021 129.628 49.0938C128.732 49.8646 127.659 50.4792 126.409 50.9375C125.159 51.3958 123.69 51.625 122.003 51.625ZM125.346 44.0312C127.95 44.0312 129.784 43.2604 130.846 41.7188C131.93 40.1562 132.503 37.8125 132.565 34.6875V33.6562C132.565 30.2604 132.044 27.6667 131.003 25.875C129.961 24.0625 128.023 23.1562 125.19 23.1562C123.086 23.1562 121.44 24.0625 120.253 25.875C119.065 27.6875 118.471 30.3021 118.471 33.7188C118.471 37.1354 119.065 39.7083 120.253 41.4375C121.461 43.1667 123.159 44.0312 125.346 44.0312ZM159.446 15.4062C162.675 15.4062 165.457 16.0312 167.79 17.2812C170.123 18.5104 171.925 20.3021 173.196 22.6562C174.467 25.0104 175.103 27.8854 175.103 31.2812V35.9062H152.571C152.675 38.5938 153.478 40.7083 154.978 42.25C156.498 43.7708 158.603 44.5312 161.29 44.5312C163.519 44.5312 165.561 44.3021 167.415 43.8438C169.269 43.3854 171.175 42.6979 173.134 41.7812V49.1562C171.405 50.0104 169.592 50.6354 167.696 51.0312C165.821 51.4271 163.54 51.625 160.853 51.625C157.353 51.625 154.248 50.9792 151.54 49.6875C148.853 48.3958 146.738 46.4271 145.196 43.7812C143.675 41.1354 142.915 37.8021 142.915 33.7812C142.915 29.6979 143.603 26.3021 144.978 23.5938C146.373 20.8646 148.311 18.8229 150.79 17.4688C153.269 16.0938 156.155 15.4062 159.446 15.4062ZM159.509 22.1875C157.655 22.1875 156.113 22.7812 154.884 23.9688C153.675 25.1562 152.978 27.0208 152.79 29.5625H166.165C166.144 28.1458 165.884 26.8854 165.384 25.7812C164.905 24.6771 164.175 23.8021 163.196 23.1562C162.238 22.5104 161.009 22.1875 159.509 22.1875ZM61.2812 155H48.9688L29.0938 120.438H28.8125C28.8958 121.875 28.9688 123.323 29.0312 124.781C29.0938 126.24 29.1562 127.698 29.2188 129.156C29.2812 130.594 29.3438 132.042 29.4062 133.5V155H20.75V109.312H32.9688L52.8125 143.531H53.0312C52.9896 142.115 52.9375 140.708 52.875 139.312C52.8125 137.917 52.75 136.521 52.6875 135.125C52.6458 133.729 52.6042 132.333 52.5625 130.938V109.312H61.2812V155ZM75.1937 120.062V155H65.6625V120.062H75.1937ZM70.4437 106.375C71.8604 106.375 73.0792 106.708 74.1 107.375C75.1208 108.021 75.6312 109.24 75.6312 111.031C75.6312 112.802 75.1208 114.031 74.1 114.719C73.0792 115.385 71.8604 115.719 70.4437 115.719C69.0062 115.719 67.7771 115.385 66.7562 114.719C65.7562 114.031 65.2562 112.802 65.2562 111.031C65.2562 109.24 65.7562 108.021 66.7562 107.375C67.7771 106.708 69.0062 106.375 70.4437 106.375Z"
/>
<path
Expand Down
13 changes: 8 additions & 5 deletions src/Project.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import theme from "./theme";
export default ({
name,
desc,
link,
logo,
dark,
}: {
dark?: boolean;
name: string;
desc: string;
link: string;
Expand All @@ -13,17 +14,19 @@ export default ({
return (
<a href={link}>
<div
className="rounded drop-shadow-md hover:drop-shadow-xl w-full h-36 lg:h-48 bg-right"
className="rounded drop-shadow-md hover:drop-shadow-xl w-full h-36 lg:h-48 bg-right bg-white dark:shadow-none dark:bg-zinc-700 dark:rounded-lg dark:border-primary"
style={{
backgroundImage: `
linear-gradient(to right, rgba(255, 255, 255, 1), 80%, rgba(255, 255, 255, 0)),
backgroundImage: dark
? ``
: `
linear-gradient(to right, rgba(255, 255, 255, 1), 80%, rgba(255, 255, 255, 0)),
url(${logo})`,
backgroundPosition: "left",
backgroundSize: "250% 200%",
backgroundPositionX: "20%",
}}
>
<div className="text-3xl font-medium w-7/10 px-6 lg:py-6 text-primary/70">
<div className="text-3xl font-medium w-7/10 px-6 lg:py-6 text-primary/70 dark:text-primary">
{name}
</div>
<div className="text-lg font-extralight w-7/10 px-6 py-4 lg:py-6">
Expand Down
5 changes: 0 additions & 5 deletions src/theme.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
export default {
colors: {
primary: "#C559F4",
// primary: "#2C1EF1",
icon: "#999",
},
sizes: {
icon: 100,
},
};
15 changes: 9 additions & 6 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: "class",
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {
scale: {
400: "40",
},
},
colors: {
primary: "#C559F4",
// primary: "#2C1EF1",
icon: "#999",
icontext: "#1E1E1E",
colors: {
primary: "#C559F4",
// primary: "#2C1EF1",
icon: "#999",
"icon-dark": "#bbb",
icontext: "#1E1E1E",
"icontext-dark": "#fff",
},
},
},
plugins: [],
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1773,10 +1773,10 @@ three-stdlib@^2.22.10, three-stdlib@^2.23.4:
potpack "^1.0.1"
zstddec "^0.0.2"

three@^0.148.0:
version "0.148.0"
resolved "https://registry.yarnpkg.com/three/-/three-0.148.0.tgz#b6f62f9c84227f8d51c151bf17b67984ded8e4d7"
integrity sha512-8uzVV+qhTPi0bOFs/3te3RW6hb3urL8jYEl6irjCWo/l6sr8MPNMcClFev/MMYeIxr0gmDcoXTy/8LXh/LXkfw==
three@^0.152.1:
version "0.152.2"
resolved "https://registry.yarnpkg.com/three/-/three-0.152.2.tgz#2ee0f2c504d31a4bc29b45495c12bded9fda7bfc"
integrity sha512-Ff9zIpSfkkqcBcpdiFo2f35vA9ZucO+N8TNacJOqaEE6DrB0eufItVMib8bK8Pcju/ZNT6a7blE1GhTpkdsILw==

tiny-inflate@^1.0.3:
version "1.0.3"
Expand Down

0 comments on commit c308c53

Please sign in to comment.