Skip to content

Commit

Permalink
Added animal assets to the About section
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmonisit committed Feb 5, 2024
1 parent 3f4c6a2 commit 7afb984
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
25 changes: 21 additions & 4 deletions app/(landing)/sections/About.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"use client";
import Image from 'next/image';
import clsx from 'clsx';
import { useWindowSize } from '@/app/lib/useWindowSize';

const animalQuality = 50;

function AboutInfo({
children,
Expand All @@ -14,6 +18,10 @@ function AboutInfo({
alt: string;
reverse?: boolean;
}) {
const size = useWindowSize();
/* Defined in tailwind.config.ts file. Probably better to have some common area for constants. */
const TAILWIND_MD_SIZE_DEFINE____REPLACE___LATER____ = 768;

function AboutInfoContent() {
return (
<div
Expand Down Expand Up @@ -41,7 +49,7 @@ function AboutInfo({
},
)}
>
<Image src={imageSrc} width="400" height="400" alt={alt} priority />
<Image src={imageSrc} width="600" height="600" alt={alt} quality={animalQuality} />
</div>
);
}
Expand All @@ -55,6 +63,15 @@ function AboutInfo({
);
}

if (size.width && size.width < TAILWIND_MD_SIZE_DEFINE____REPLACE___LATER____) {
return (
<>
<AboutImage />
<AboutInfoContent />
</>
);
}

return (
<>
<AboutInfoContent />
Expand All @@ -69,7 +86,7 @@ export default function About() {
className="flex h-fit w-full
flex-col flex-wrap bg-gray-200 md:flex-row"
>
<AboutInfo title="WHAT" imageSrc="/landing/python.png" alt="Python">
<AboutInfo title="WHAT" imageSrc="/landing/roar.js.png" alt="Python">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
imperdiet, nibh nec dictum consectetur, lorem nisi Lorem ipsum dolor
Expand All @@ -82,7 +99,7 @@ export default function About() {

<AboutInfo
title="TRACKS"
imageSrc="/landing/python.png"
imageSrc="/landing/bitsprout.png"
alt="Python"
reverse
>
Expand All @@ -97,7 +114,7 @@ export default function About() {
</p>
</AboutInfo>

<AboutInfo title="JOIN US" imageSrc="/landing/python.png" alt="Python">
<AboutInfo title="JOIN US" imageSrc="/landing/pseudoclaw.png" alt="Python">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
imperdiet, nibh nec dictum consectetur, lorem nisi Lorem ipsum dolor
Expand Down
30 changes: 30 additions & 0 deletions app/lib/useWindowSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useEffect, useState } from 'react';

//from https://stackoverflow.com/questions/63406435/how-to-detect-window-size-in-next-js-ssr-using-react-hooks
export function useWindowSize() {
// Initialize state with undefined width/height so server and client renders match
// Learn more here: https://joshwcomeau.com/react/the-perils-of-rehydration/
const [windowSize, setWindowSize] = useState<{
width: number | undefined;
height: number | undefined;
}>({
width: undefined,
height: undefined,
});

useEffect(() => {
function handleResize() {
setWindowSize({
width: window.innerWidth,
height: window.innerHeight,
});
}

window.addEventListener('resize', handleResize);

handleResize();

return () => window.removeEventListener('resize', handleResize);
}, []);
return windowSize;
}
Binary file added public/landing/bitsprout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/landing/pseudoclaw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/landing/roar.js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7afb984

Please sign in to comment.