feat: redesign landing to match site styling (#55)

### Explanation

_No response_

### Issue

_No response_

### Attestations

- [ ] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [ ] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [ ] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [ ] I have pinned the dependencies to a specific patch version.

### Style

- [ ] I have run the linter and resolved any errors.
- [ ] My pull request uses an appropriate title, matching the conventional commit standards.
- [ ] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [ ] My contribution adds new code, and I have added tests to cover it.
- [ ] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [ ] All new and existing tests pass locally with my changes.
- [ ] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

_No response_

Reviewed-on: https://codeberg.org/nhcarrigan/portfolio/pulls/55
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
Naomi Carrigan 2024-11-29 19:04:39 +00:00 committed by Naomi the Technomancer
parent 3f49460965
commit 12c81a7d40
3 changed files with 87 additions and 64 deletions

View File

@ -7,61 +7,99 @@ import Image from "next/image";
import React, { type JSX } from "react"; import React, { type JSX } from "react";
import { NavItems } from "../config/NavItems"; import { NavItems } from "../config/NavItems";
const generateRandomColor = (): string => {
return `#${Math.floor(Math.random() * 16_777_215).toString(16).
padStart(6, "0")}`;
};
const getLuminance = (hexColor: string): number => {
const r = Number.parseInt(hexColor.slice(1, 3), 16);
const g = Number.parseInt(hexColor.slice(3, 5), 16);
const b = Number.parseInt(hexColor.slice(5, 7), 16);
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
const a: [number, number, number] = [ r, g, b ].map((v) => {
const w = v / 255;
return w <= 0.039_28
? w / 12.92
: Math.pow((w + 0.055) / 1.055, 2.4);
}) as [number, number, number];
const rl = a[0] * 0.2126;
const gl = a[1] * 0.7152;
const bl = a[2] * 0.0722;
return rl + gl + bl;
};
const adjustColorLuminosity
= (hexColor: string, luminosityChange: number): string => {
let r = Number.parseInt(hexColor.slice(1, 3), 16);
let g = Number.parseInt(hexColor.slice(3, 5), 16);
let b = Number.parseInt(hexColor.slice(5, 7), 16);
r = Math.round(r * luminosityChange);
g = Math.round(g * luminosityChange);
b = Math.round(b * luminosityChange);
r = Math.min(255, Math.max(0, r));
g = Math.min(255, Math.max(0, g));
b = Math.min(255, Math.max(0, b));
return `#${
r.toString(16).padStart(2, "0")
}${g.toString(16).padStart(2, "0")
}${b.toString(16).padStart(2, "0")}`;
};
const generateColorPair = (): { background: string; color: string } => {
const backgroundColor = generateRandomColor();
const backgroundLuminance = getLuminance(backgroundColor);
const textColor = backgroundLuminance > 0.5 ?
adjustColorLuminosity(backgroundColor, 0) :
adjustColorLuminosity(backgroundColor, 5);
return {
background: backgroundColor,
color: textColor,
};
};
/** /**
* Renders the main React component. * Renders the main React component.
* @returns A JSX element. * @returns A JSX element.
*/ */
const Home = (): JSX.Element => { const Home = (): JSX.Element => {
return ( return (
<div> <main className="w-4/5 text-center max-w-4xl m-auto mt-16 mb-16 rounded-lg">
<div <h1 className="text-4xl mb-2">{`Naomi Carrigan`}</h1>
className="absolute top-0 right-[33vw] z-100 <Image
w-[100vh] h-[100vh] rotate-90 hidden lg:block" alt="Naomi Carrigan"
> className="rounded-full m-auto"
<svg className="absolute" viewBox="0 0 500 500"> height={200}
<path src="https://cdn.nhcarrigan.com/profile.png"
d="M0,100 C150,200 350,0 500,100 L500,00 L0,0 Z" width={200}
style={{ fill: "var(--foreground)", stroke: "none" }} />
></path> <p className="text-2xl">{`Software Engineer | Community Manager | VTuber`}</p>
</svg> {NavItems.map((item, index) => {
</div> const { background, color } = generateColorPair();
<main className="grid grid-cols-[2fr,1fr] min-h-screen"> return (
<section <a
className="bg-[--background] text-[--foreground] className="flex max-w-[300px] w-[95%] m-auto justify-between
flex flex-col items-left justify-center text-left pl-5" items-center border-solid border-2 rounded-3xl h-14 p-8 my-4"
> href={item.href}
<h1 className="text-4xl mb-2">{`Naomi Carrigan`}</h1> key={item.href}
<Image rel="noreferrer"
alt="Naomi Carrigan" style={{
className="rounded-full" background: background,
height={200} borderColor: color,
src="https://cdn.nhcarrigan.com/profile.png" color: color,
width={200} }}
/> target="_blank"
<p className="text-3xl">{`Software Engineer`}</p> >
<p className="text-3xl">{`Community Manager`}</p> {index % 2 === 1
</section> ? "🩷"
<section : "🩵"} {item.text}
className="bg-[--foreground] text-[--background] </a>
flex flex-col items-center justify-center" );
> })}
{NavItems.map((item, index) => { </main>
return (
<a
className="block py-2 px-4 text-2xl
hover:bg-[--background] hover:text-[--foreground]"
href={item.href}
key={item.href}
>
{index % 2 === 1
? "🩷"
: "🩵"} {item.text}
</a>
);
})}
</section>
</main>
</div>
); );
}; };

View File

@ -7,7 +7,6 @@
import { faComments } from "@fortawesome/free-solid-svg-icons"; import { faComments } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Crisp } from "crisp-sdk-web"; import { Crisp } from "crisp-sdk-web";
import { usePathname } from "next/navigation";
import Script from "next/script"; import Script from "next/script";
import React, { type JSX } from "react"; import React, { type JSX } from "react";
@ -20,12 +19,6 @@ export const Footer = (): JSX.Element | null => {
if (typeof window !== "undefined") { if (typeof window !== "undefined") {
Crisp.configure("5398ce41-4ceb-4e31-9049-4c784a70179a"); Crisp.configure("5398ce41-4ceb-4e31-9049-4c784a70179a");
} }
const pathname = usePathname();
const isRootPath = pathname === "/";
if (isRootPath) {
return null;
}
return ( return (
<div <div
className="fixed w-full bottom-0 z-50 flex className="fixed w-full bottom-0 z-50 flex

View File

@ -12,7 +12,6 @@ import {
} from "@fortawesome/free-solid-svg-icons"; } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import Image from "next/image"; import Image from "next/image";
import { usePathname } from "next/navigation";
import React, { type JSX, useState, useEffect, useCallback } from "react"; import React, { type JSX, useState, useEffect, useCallback } from "react";
import { NavItems } from "../config/NavItems"; import { NavItems } from "../config/NavItems";
import { Rule } from "./rule"; import { Rule } from "./rule";
@ -49,13 +48,6 @@ export const Navigation = (): JSX.Element | null => {
setIsDarkMode(!isDarkMode); setIsDarkMode(!isDarkMode);
}, [ isDarkMode ]); }, [ isDarkMode ]);
const pathname = usePathname();
const isRootPath = pathname === "/";
if (isRootPath) {
return null;
}
return ( return (
<div className="fixed w-full top-0 z-50"> <div className="fixed w-full top-0 z-50">
<nav <nav