Skip to content

Commit

Permalink
Accidentally spent 3 hours trying to figure out out to use InView and…
Browse files Browse the repository at this point in the history
… only logged on hour!
  • Loading branch information
ofluffydev committed Jul 3, 2024
1 parent 6b9297b commit 74fec01
Show file tree
Hide file tree
Showing 18 changed files with 460 additions and 188 deletions.
43 changes: 24 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,45 @@
},
"dependencies": {
"lucide-react": "^0.400.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.22.3",
"react-router-dom": "^6.22.3"
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router": "^6.24.0",
"react-router-dom": "^6.24.0"
},
"devDependencies": {
"@eslint/compat": "^1.1.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.6.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.0.0",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"@types/jest": "^29.5.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"autoprefixer": "^10.4.19",
"eslint": "^9.6.0",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"globals": "^15.7.0",
"jest": "^29.0.0",
"eslint": "^8.56.0",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"globals": "^15.8.0",
"jest": "^29.7.0",
"postcss": "^8.4.39",
"sass": "^1.74.1",
"react-intersection-observer": "^9.10.3",
"sass": "^1.77.6",
"sitemap-ts": "^1.7.3",
"tailwindcss": "^3.4.4",
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0",
"vite": "^5.2.0",
"vite": "^5.3.2",
"vite-plugin-sitemap": "^0.6.2"
},
"keywords": [
"TODO: Add relevant keywords"
"portfolio",
"website",
"blog",
"services",
"work"
],
"homepage": "https://kadenfrisk.com",
"bugs": {
Expand Down
12 changes: 6 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import Footer from "./components/layout/Footer";

export default function App() {
return (<div className="app">
<Header/>
<main className="main-content">
<Outlet/>
</main>
<Footer/>
</div>)
<Header/>
<main className="main-content">
<Outlet/>
</main>
<Footer/>
</div>)
}
38 changes: 29 additions & 9 deletions src/components/Fallback.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
function Fallback() {
return (
<div>
<h1>Container element not found!</h1>
<h2>Make sure the container element exists in the HTML file.</h2>
<p>If you are a user of the website, and refreshing the page doesn't fix this, please contact me at
[email protected]</p>
</div>
)
import {renderToString} from "react-dom/server";
import {FC} from "react";

/**
* Interface defining the props for the Fallback component.
* @interface
* @property {string} supportEmail - The email address to contact for support.
*/
interface FallbackProps {
supportEmail: string;
}

/**
* Fallback component rendered when a container element is not found.
* This component is server-side rendered to a string.
*
* @param {FallbackProps} props - The props for the Fallback component.
* @returns {string} The HTML string of the Fallback component.
*/
export const Fallback: FC<FallbackProps> = ({supportEmail}) => {
const html = <div>
<h1>Container element not found!</h1>
<h2>Make sure the container element exists in the HTML file.</h2>
<p>If you are a user of the website, and refreshing the page doesn't fix this, please contact me at
{supportEmail}</p>
</div>

return renderToString(html);
}

export default Fallback;
36 changes: 0 additions & 36 deletions src/components/home/Hero.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/layout/router.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {createBrowserRouter} from "react-router-dom";
import App from "../../App";
import ErrorPage from "../ErrorPage";
import Home from "../../pages/Home";
import Contact from "../../pages/Contact";
import About from "../../pages/About";
import Services from "../../pages/Services";
import ErrorPage from "../../fluffy-pack/components/ErrorPage.tsx";

const router = createBrowserRouter([{
element: <App/>, errorElement: <ErrorPage/>, children: [{
Expand Down
1 change: 1 addition & 0 deletions src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const
COMPANY_NAME = 'Kaden Frisk',
WEBSITE_TITLE = 'Kaden Frisk',
EMAIL = '[email protected]',
SUPPORT_EMAIL = '[email protected]',
GITHUB = 'https://github.com/ofluffydev',
NAV_LINKS = [
{path: '/', label: 'Home'},
Expand Down
67 changes: 67 additions & 0 deletions src/fluffy-pack/components/AboutMe.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {ArrowRight, Book, Briefcase, Code} from 'lucide-react';
import {FC, ReactElement} from "react";
import {InView} from "react-intersection-observer";

/**
* Props for the AboutMe component.
* @prop {string} name - The name of the person.
* @prop {string[]} roles - An array of roles or titles.
* @prop {string} [tinyText] - Optional small introductory text.
* @prop {string} [shortDescription] - Optional short description about the person.
* @prop {string} buttonText - Text for the main action button.
*/
interface AboutMeProps {
name: string;
roles: string[];
tinyText?: string;
shortDescription?: string;
buttonText: string;
}

/**
* A functional component to display information about a person, including their name, roles, and a short description.
* It also showcases projects, services, and courses with a call-to-action button.
*
* @param {AboutMeProps} props - The props for the component.
* @returns {ReactElement} The AboutMe component.
*/
const AboutMe: FC<AboutMeProps> = ({
name, roles, tinyText, shortDescription, buttonText
}: AboutMeProps): ReactElement => (
<div className="bg-gradient-to-r from-blue-500 to-purple-600 text-white py-20">
<div className="container mx-auto px-4">
<InView>
{({ inView, ref}) => (
<p ref={ref} className={inView? 'animated-list-item' : ''}>{tinyText}</p>
)}
</InView>
<h1 className="animated-list-item text-4xl md:text-6xl font-bold mb-4">{name}</h1>
<p className="animated-list-item text-xl md:text-2xl mb-8">{roles.map((role, index) => <span
key={index}>{role}{index < roles.length - 1 ? ', ' : ''}</span>)}</p>

<div className="animated-list-item grid md:grid-cols-3 gap-8 mb-12">
<div className="animated-list-item flex items-center">
<Code className="animated-list-item mr-2"/>
<span>Showcasing My Projects</span>
</div>
<div className="animated-list-item flex items-center">
<Briefcase className="animated-list-item mr-2"/>
<span>Offering Web Services</span>
</div>
<div className="animated-list-item flex items-center">
<Book className="animated-list-item mr-2"/>
<span>Free Programming Courses</span>
</div>
</div>

<p className="animated-list-item text-lg mb-8">{shortDescription}</p>

<button
className="bg-white text-blue-600 px-6 py-3 rounded-full font-semibold flex items-center hover:bg-blue-100 transition-colors">
{buttonText}
<ArrowRight className="ml-2"/>
</button>
</div>
</div>);

export default AboutMe;
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,27 @@ export default function ErrorPage() {

if (isRouteErrorResponse(error)) {
if (error.status === 404) {
return (
<div id="error-page">
return (<div id="error-page">
<h1>404 Not Found</h1>
<p>The page you are looking for does not exist.</p>
<Link to="/">Return Home</Link>
<p>
<i>{error.data}</i>
</p>
</div>
);
</div>);
}

return (
<div id="error-page">
return (<div id="error-page">
<h1>Oops!</h1>
<p>Sorry, an unexpected error has occurred.</p>
<p>
<i>{error.statusText || error.data}</i>
</p>
</div>
);
</div>);
}

return (
<div id="error-page">
return (<div id="error-page">
<h1>Oops!</h1>
<p>Sorry, an unexpected error has occurred.</p>
</div>
);
</div>);
}
39 changes: 39 additions & 0 deletions src/fluffy-pack/components/FadeIn.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { ReactNode, forwardRef } from 'react';
import useFadeInOnScroll from "../hooks/fluffy-hooks.tsx";

interface FadeInProps {
children: ReactNode;
delay?: number;
threshold?: number;
}

const FadeIn = forwardRef<HTMLDivElement, FadeInProps>(
({ children, delay = 0, threshold = 0.1 }, forwardedRef) => {
const [internalRef, isVisible] = useFadeInOnScroll(threshold, delay);

const setRefs = (element: HTMLDivElement | null) => {
(internalRef as React.MutableRefObject<HTMLDivElement | null>).current = element;

if (typeof forwardedRef === 'function') {
forwardedRef(element);
} else if (forwardedRef) {
(forwardedRef).current = element;
}
};

return (
<div
ref={setRefs}
className={`transition-opacity duration-1000 ease-out ${
isVisible ? 'opacity-100' : 'opacity-0'
}`}
>
{children}
</div>
);
}
);

FadeIn.displayName = 'FadeIn';

export default FadeIn;
38 changes: 38 additions & 0 deletions src/fluffy-pack/components/Hero.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {ReactElement} from "react";

/**
* `Hero` component props definition.
*/
interface HeroProps {
/** Text to display as the main greeting or welcome message. */
welcomeText: string;
/** Text to display as a secondary message or information. */
secondaryText: string;
}

/**
* Renders a Hero section with a dynamic background gradient and text.
*
* This component displays a full-screen hero section with a colorful, animated background gradient.
* It shows a welcome message and a secondary text, both of which are customizable through props.
*
* @param {HeroProps} props - The props for the Hero component.
* @returns {ReactElement} The Hero section as a React element.
*/
const Hero = ({welcomeText, secondaryText}: HeroProps): ReactElement => {
return (<div className="relative h-screen flex items-center justify-center overflow-hidden">
<div
className="absolute inset-0 bg-gradient-to-r from-purple-500 via-pink-500 to-red-500 animate-gradient-x"></div>

<div className="relative z-10 text-center">
<h1 className="text-6xl font-bold text-white mb-4 animated-list-item">
{welcomeText}
</h1>
<p className="text-xl text-white animate-fade-in-up animated-list-item ">
{secondaryText}
</p>
</div>
</div>);
};

export default Hero;
Loading

0 comments on commit 74fec01

Please sign in to comment.