Compare commits

..

47 Commits

Author SHA1 Message Date
46e96043fb sort pic 2023-03-14 19:01:16 -07:00
e2a8c3edf4 promote faves to 6 stars 2023-03-13 21:48:45 -07:00
0db6029fd2
clean up 2023-03-11 02:03:34 -08:00
be5464fa1d better image alt text 2023-03-11 01:04:23 -08:00
f375043b49 metadata updates 2023-03-11 01:04:08 -08:00
5df63bf44a fix gallery image autoscroll, hide hashes on recently published section (and plumb linkstate) 2023-03-11 00:53:16 -08:00
c574a31ba2 add secret debug helper 2023-03-11 00:46:14 -08:00
8e669720bd don't smooth scroll image hashes on gallery 2023-03-11 00:31:33 -08:00
ea37aa680c Merge branch 'scrolling-stuff' into main 2023-03-11 00:13:01 -08:00
44f0b7be9f improve debug display 2023-03-11 00:12:39 -08:00
5dadfb6f14 improve debug display 2023-03-11 00:07:08 -08:00
08dc0d3143 keywords updates to images 2023-03-11 00:00:37 -08:00
abc7717a25 nav improvements + debug helper buttons on gallery 2023-03-11 00:00:30 -08:00
5760b436d2 remove smooth scroll and allow gallery image to scroll self 2023-03-10 18:14:16 -08:00
f15f8213b2 integrate gatsby shouldUpdateScroll api 2023-03-10 18:04:54 -08:00
713aa58b77 investigating other approaches to removing page hash
TODO: look at https://github.com/gatsbyjs/gatsby/issues/19401
2023-03-09 22:58:26 -08:00
a3ff9f6cbe removeHash on touchmove /shrug 2023-03-09 22:26:06 -08:00
6fc8c166a0 fix keyword picker re-attaching hashes to links 2023-03-09 21:47:32 -08:00
d24ffecf7c fix deselect in keyword picker 2023-03-09 21:31:54 -08:00
46ba7780d7 Merge branch 'recent-images' into main 2023-03-09 21:23:38 -08:00
fa2a639dbb fix hash nav stuff 2023-03-09 21:23:23 -08:00
f21fc5efd1 fix scroll bug? 2023-03-09 21:15:39 -08:00
6d68510745 Add burnt flower pic, rearrange a few others 2023-03-09 20:53:38 -08:00
5dcc5920c4 fix navigation behavior and homepage layout 2023-03-09 20:53:20 -08:00
5f7ceabf20 improve keyword picker behavior 2023-03-09 19:12:13 -08:00
303f20eb93 remove two computer pics, improve debug view in gallery, bugfixes 2023-03-09 19:00:44 -08:00
3ed93b14ed
circle pic 2023-03-08 20:41:51 -08:00
0f54e1bc5c WIP use links for KeywordsPicker 2023-03-08 08:51:55 -08:00
fa815460d9 remove mx hack 2023-03-08 08:48:15 -08:00
a90ec328f6 store sort and filter keys exclusively in url 2023-03-08 08:36:42 -08:00
8effec79b1 slightly shift gallery left to line up with name on nav - idk if I like it 2023-03-08 08:24:26 -08:00
77df8418c8 scroll works but is jank in chrome 2023-03-08 08:24:26 -08:00
d55c29e24a better failure logging 2023-03-08 08:24:26 -08:00
29d6c7dbf0 add snowy mnt pic 2023-03-08 08:24:26 -08:00
3f465e8693 add datePublished fallback 2023-03-08 08:24:26 -08:00
a86f3a9967 add a few new images 2023-03-08 08:24:26 -08:00
bd2eac1ef3 lower contrast on gallery controls 2023-03-08 08:24:26 -08:00
b6f6476170 TODO: use gatsby navigate() and location prop for all location based stuff. maybe ditch image hashes? maybe gallery image goes back on escape instead of to image hash
also pass proper linking params to recently published
2023-03-08 08:24:26 -08:00
80169f1803 WIP history and such not quite working (404ing) 2023-03-08 08:24:26 -08:00
5aae745c04 always push state 2023-03-08 08:24:26 -08:00
4bc81d9cce improves scroll hash and history behavior (smooth scroll) 2023-03-08 08:24:26 -08:00
cc8fa20531 ...fix sort bug 2023-03-08 08:24:26 -08:00
35e6211170 WIP working on sorting recently published by capture date when published in batches 2023-03-08 08:24:26 -08:00
660b231d44 add a few images and attempt singleRow masonry gallery
update gpu pics

add can pic
2023-03-08 08:24:26 -08:00
3116cc197d add "recently updated" section to gallery 2023-03-08 08:24:26 -08:00
663e0cb15b update lfsconfig 2023-03-07 22:44:20 -08:00
81a45159ed always point lfs at my git host 2023-03-07 22:44:20 -08:00
46 changed files with 919 additions and 310 deletions

Binary file not shown.

BIN
data/gallery/DSC00003.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC00015.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC00159-2.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC00512.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC01832.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC02538-2.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC03049.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC03401.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC04122.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC05702.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC06124.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC06515.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC06719.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC06803.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC08086.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC08103.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC08222.jpg (Stored with Git LFS) Normal file

Binary file not shown.

BIN
data/gallery/DSC08263.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC08588.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC09447.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC09453.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/DSC09454.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/_DSC6060.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/_DSC6062.jpg (Stored with Git LFS)

Binary file not shown.

BIN
data/gallery/_DSC6066.jpg (Stored with Git LFS)

Binary file not shown.

View File

@ -14,6 +14,25 @@ export const onRouteUpdate = function () {
window.plausible("pageview"); window.plausible("pageview");
} }
}; };
// docs say you can return a scroll position from this fn, but that's a bold-faced lie
export const shouldUpdateScroll = ({
prevRouterProps,
routerProps: { location },
pathname,
}) => {
if (pathname.startsWith('/photogallery/') && pathname !== '/photogallery/' ) {
return false;
}
if (prevRouterProps?.location.pathname === pathname) {
return false;
}
if (pathname === "/photogallery/" && location.hash.length) {
return false;
}
return true;
}
// import * as React from 'react'; // import * as React from 'react';
// import { MDXProvider } from '@mdx-js/react'; // import { MDXProvider } from '@mdx-js/react';

View File

@ -10,9 +10,9 @@ import sharp from "sharp";
import { Palette } from "node-vibrant/lib/color"; import { Palette } from "node-vibrant/lib/color";
import { performance } from "perf_hooks"; import { performance } from "perf_hooks";
import util from 'node:util'; import util from "node:util";
import { exec as _exec } from "child_process"; import { exec as _exec } from "child_process";
const exec = util.promisify(_exec) const exec = util.promisify(_exec);
// const path = require("path"); // const path = require("path");
// const Vibrant = require("node-vibrant"); // const Vibrant = require("node-vibrant");
@ -119,7 +119,7 @@ function transformMetaToNodeData(
vibrantData: Palette, vibrantData: Palette,
imagePath: string, imagePath: string,
{ r, g, b }: { r: number; b: number; g: number }, { r, g, b }: { r: number; b: number; g: number },
datePublished: string, datePublished: string
) { ) {
const vibrant = vibrantData ? processColors(vibrantData, imagePath) : null; const vibrant = vibrantData ? processColors(vibrantData, imagePath) : null;
const vibrantHue = vibrantData.Vibrant!.getHsl()[0] * 360; const vibrantHue = vibrantData.Vibrant!.getHsl()[0] * 360;
@ -180,18 +180,34 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({
const { createNodeField } = actions; const { createNodeField } = actions;
if (node.internal.type === "File" && node.sourceInstanceName === "gallery") { if (node.internal.type === "File" && node.sourceInstanceName === "gallery") {
const { stdout: datePublished, stderr } = await exec(`git log --diff-filter=A --follow --format=%aI -1 -- ${node.absolutePath}`) const { stdout: datePublished, stderr } = await exec(
`git log --diff-filter=A --follow --format=%aI -1 -- ${node.absolutePath}`
);
if (stderr.length) { if (stderr.length) {
console.error('something went wrong checking publish date: ', stderr); console.error("something went wrong checking publish date: ", stderr);
} }
const metaData = await exifr.parse(node.absolutePath as string, { let metaData;
iptc: true, try {
xmp: true, metaData = await exifr.parse(node.absolutePath as string, {
// icc: true iptc: true,
}); xmp: true,
// icc: true
});
} catch (e) {
console.error(`something wen wrong with exifr on image ${node.base}`, e);
throw e;
}
const sharpImage = sharp(node.absolutePath as string); let sharpImage: sharp.Sharp;
try {
sharpImage = sharp(node.absolutePath as string);
} catch (e) {
console.error(`something wen wrong with sharp on image ${node.base}`, e);
throw e;
}
const { dominant } = await sharpImage.stats(); const { dominant } = await sharpImage.stats();
const resizedImage = await sharpImage const resizedImage = await sharpImage
.resize({ .resize({
@ -213,7 +229,8 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({
vibrantData, vibrantData,
node.absolutePath as string, node.absolutePath as string,
dominant, dominant,
datePublished // if datePublished is empty, image has not been committed to git yet and is thus brand new
datePublished.length ? datePublished.replace("\n", "") : new Date().toISOString()
), ),
}); });
} }

View File

@ -41,6 +41,7 @@
"gatsby-source-filesystem": "^5.0.0", "gatsby-source-filesystem": "^5.0.0",
"gatsby-transformer-sharp": "^5.0.0", "gatsby-transformer-sharp": "^5.0.0",
"kebab-case": "^1.0.1", "kebab-case": "^1.0.1",
"lodash.debounce": "^4.0.8",
"node-iptc": "^1.0.5", "node-iptc": "^1.0.5",
"node-vibrant": "3.1.6", "node-vibrant": "3.1.6",
"postcss": "^8.4.19", "postcss": "^8.4.19",
@ -60,6 +61,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/chroma-js": "^2.1.4", "@types/chroma-js": "^2.1.4",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "^18.8.3", "@types/node": "^18.8.3",
"@types/ramda": "^0.28.15", "@types/ramda": "^0.28.15",
"@types/react": "^18.0.21", "@types/react": "^18.0.21",

View File

@ -63,6 +63,15 @@ const GalleryImage = ({ data, location: { state } }) => {
setIsClient(true); setIsClient(true);
}, []); }, []);
useEffect(() => {
setTimeout(() => {
window.scrollTo({
top: 180,
behavior: 'smooth'
});
}, 50);
}, [image.base]);
const nextIndex = const nextIndex =
sortedImageList && currentIndex < sortedImageList.length sortedImageList && currentIndex < sortedImageList.length
? currentIndex + 1 ? currentIndex + 1
@ -135,7 +144,7 @@ const GalleryImage = ({ data, location: { state } }) => {
locationString = location.join(", "); locationString = location.join(", ");
} }
const vibrant = getVibrant(image, true); const vibrant = getVibrant(image, true);
const BLEND = 'hsl' const BLEND = "hsl";
const darkAccent = chroma const darkAccent = chroma
.mix(vibrant.Vibrant, "hsla(216, 0%, 90%, 1)", 0.6, BLEND) .mix(vibrant.Vibrant, "hsla(216, 0%, 90%, 1)", 0.6, BLEND)
.hex(); .hex();
@ -145,7 +154,7 @@ const GalleryImage = ({ data, location: { state } }) => {
ar > 1 ar > 1
? "flex-col" ? "flex-col"
: "portrait:mx-auto landscape:mx-5 landscape:flex-row-reverse portrait:flex-col"; : "portrait:mx-auto landscape:mx-5 landscape:flex-row-reverse portrait:flex-col";
const verticalPad = ar > 1 ? "250px" : "100px"; const verticalPad = ar > 1 ? "180px" : "20px";
const shutterSpeed = React.useMemo( const shutterSpeed = React.useMemo(
() => () =>

View File

@ -1,44 +1,37 @@
import * as React from "react"; import * as React from "react";
import classNames from "classnames"; import classNames from "classnames";
import Checkmark from "@spectrum-icons/workflow/Checkmark"; import { Link } from "gatsby";
interface KeywordsPickerProps { interface KeywordsPickerProps {
keywords: string[]; keywords: string[];
value: string | null; value: string | null;
onChange: (val: string | null) => void; getHref: (value: string | null, selected: boolean) => string;
onPick: (value: string | null) => void;
} }
const KeywordsPicker = ({ keywords, value, onChange }: KeywordsPickerProps) => { const KeywordsPicker = ({ keywords, value, getHref, onPick }: KeywordsPickerProps) => {
return ( return (
<div className="mx-2 mt-2"> <div className="mx-2 mt-2">
<span className="text-xs text-black"> <span className="text-xs text-black">Collections</span>
Collections
</span>
<ul className="flex gap-1 flex-wrap mt-1 mb-2"> <ul className="flex gap-1 flex-wrap mt-1 mb-2">
{keywords.map((keyword) => { {keywords.map((keyword) => {
const selected = value === keyword; const selected = value === keyword;
return ( return (
<li key={keyword}> <li key={keyword}>
<button <Link
className={classNames( className={classNames(
`py-[5px] px-3 rounded-full text-sm`, `py-[5px] px-3 rounded-full text-sm block`,
`text-black border border-black`, `text-black border border-gray-400`,
selected selected
? "bg-transparentblack font-bold" ? "bg-black/10 font-bold"
: `bg-white : `bg-white
hover:bg-transparentblack` hover:bg-black/10`
)} )}
onClick={() => (selected ? onChange(null) : onChange(keyword))} onClick={() => onPick(keyword)}
type="button" replace={false}
to={getHref(keyword, selected)}
> >
{keyword}{" "} {keyword}{" "}
{/* {selected && ( </Link>
<Checkmark
UNSAFE_className="mx-1"
UNSAFE_style={{ width: "15px" }}
aria-hidden="true"
/>
)} */}
</button>
</li> </li>
); );
})} })}

View File

@ -92,7 +92,7 @@ function Option({ item, state }: OptionProps) {
<li <li
{...optionProps} {...optionProps}
className={`p-2 outline-none cursor-default flex items-center justify-between ${text} text-sm ${ className={`p-2 outline-none cursor-default flex items-center justify-between ${text} text-sm ${
isFocused ? "bg-transparentblack" : "" isFocused ? "bg-black/10" : ""
} ${isSelected ? "font-bold" : ""}`} } ${isSelected ? "font-bold" : ""}`}
ref={ref} ref={ref}
> >

View File

@ -23,7 +23,7 @@ interface MasonryGalleryProps {
[breakpoint: string]: number; [breakpoint: string]: number;
}; };
debugHue?: boolean; debugHue?: boolean;
debugRating?: boolean; dataFn?: (image: GalleryImage) => string[] | null;
linkState?: object; linkState?: object;
showPalette?: boolean; showPalette?: boolean;
singleRow?: boolean; singleRow?: boolean;
@ -33,7 +33,7 @@ const MasonryGallery = ({
images: _images, images: _images,
aspectsByBreakpoint: aspectTargetsByBreakpoint, aspectsByBreakpoint: aspectTargetsByBreakpoint,
debugHue, debugHue,
debugRating, dataFn,
linkState, linkState,
showPalette, showPalette,
singleRow, singleRow,
@ -47,13 +47,8 @@ const MasonryGallery = ({
[aspectTargetsByBreakpoint] [aspectTargetsByBreakpoint]
); );
// const { observe, currentBreakpoint } = useDimensions({
// breakpoints,
// });
const { breakpoint } = useBreakpoint(breakpoints, "xs"); const { breakpoint } = useBreakpoint(breakpoints, "xs");
// const breakpoint = currentBreakpoint.length ? currentBreakpoint : "xs";
const galleryWidth = `calc(100vw - ${ const galleryWidth = `calc(100vw - ${
breakpoint === "xs" || breakpoint === "sm" ? "32" : "160" breakpoint === "xs" || breakpoint === "sm" ? "32" : "160"
}px)`; }px)`;
@ -64,48 +59,38 @@ const MasonryGallery = ({
) as number[]; ) as number[];
const targetAspect = aspectTargetsByBreakpoint[breakpoint]; const targetAspect = aspectTargetsByBreakpoint[breakpoint];
const rows = React.useMemo( const rows = React.useMemo(() => {
() => const _rows: Row[] = [{ aspect: 0, startIndex: 0, images: 0 }];
R.pipe(
R.reduce( for (const currentAspect of aspectRatios) {
(acc, currentAspect: number): Row[] => { const currentRow = _rows[_rows.length - 1];
const currentRow = acc.pop()!; const currentDiff = Math.abs(targetAspect - currentRow.aspect);
const currentDiff = Math.abs(targetAspect - currentRow.aspect); const diffIfImageIsAddedToCurrentRow = Math.abs(
const diffIfImageIsAddedToCurrentRow = Math.abs( targetAspect - (currentRow.aspect + currentAspect)
targetAspect - (currentRow.aspect + currentAspect) );
);
// add image to current row if it gets us closer to our target aspect ratio // does adding current image to our row get us closer to our target aspect ratio?
if (currentDiff > diffIfImageIsAddedToCurrentRow) { if (currentDiff > diffIfImageIsAddedToCurrentRow) {
return [ currentRow.aspect += currentAspect;
...acc, currentRow.images += 1;
{ // _rows.push(currentRow);
aspect: currentRow.aspect + currentAspect, continue;
images: currentRow.images + 1, }
startIndex: currentRow.startIndex,
}, if (singleRow) {
]; break;
} }
// no-op instead of starting a new row
if (singleRow) { // start a new row
return [currentRow]; _rows.push({
} aspect: currentAspect,
// start a new row images: 1,
return [ startIndex: currentRow.startIndex + currentRow.images,
...acc, });
currentRow, }
{
aspect: currentAspect, return R.indexBy(R.prop("startIndex"), _rows);
images: 1, }, [aspectRatios, targetAspect, singleRow]);
startIndex: currentRow.startIndex + currentRow.images,
} as Row,
];
},
[{ aspect: 0, startIndex: 0, images: 0 }] as Row[]
),
R.indexBy(R.prop("startIndex"))
)(aspectRatios),
[aspectRatios, targetAspect, singleRow]
);
const sortedImageList = React.useMemo( const sortedImageList = React.useMemo(
() => _images.map((image) => image.base), () => _images.map((image) => image.base),
@ -113,7 +98,7 @@ const MasonryGallery = ({
); );
const images = singleRow ? _images.slice(0, rows[0].images) : _images; const images = singleRow ? _images.slice(0, rows[0].images) : _images;
let cursor = 0; let cursor = 0;
return ( return (
<div <div
@ -134,9 +119,11 @@ const MasonryGallery = ({
} }
const rowAspectRatioSum = currentRow.aspect; const rowAspectRatioSum = currentRow.aspect;
const ar = getAspectRatio(image); const ar = getAspectRatio(image);
let width; let width: string;
let height = `calc(${galleryWidth} / ${rowAspectRatioSum} ${showPalette ? "+ 10px" : "- 10px"})`; let height = `calc(${galleryWidth} / ${rowAspectRatioSum} ${
if (rowAspectRatioSum < targetAspect * 0.66) { showPalette ? "+ 10px" : "- 10px"
})`;
if (rowAspectRatioSum < targetAspect * 0.66 && !singleRow) {
// incomplete row, render stuff at "ideal" sizes instead of filling width // incomplete row, render stuff at "ideal" sizes instead of filling width
width = `calc(calc(100vw - 160px) / ${targetAspect / ar})`; width = `calc(calc(100vw - 160px) / ${targetAspect / ar})`;
height = "unset"; height = "unset";
@ -147,10 +134,12 @@ const MasonryGallery = ({
const vibrant = getVibrant(image); const vibrant = getVibrant(image);
// @ts-ignore // @ts-ignore
const img = getImage(image); const img = getImage(image);
const data = dataFn ? dataFn(image) : null;
return ( return (
<Link <Link
className={classNames("border-8 border-white overflow-hidden")} className="border-8 border-white overflow-hidden relative"
id={image.base} id={singleRow ? undefined : image.base}
key={`${image.base}`} key={`${image.base}`}
state={{ state={{
...linkState, ...linkState,
@ -170,47 +159,68 @@ const MasonryGallery = ({
}} }}
to={`/photogallery/${image.base}/`} to={`/photogallery/${image.base}/`}
> >
{debugRating && ( {data && (
<span className="text-white z-20 absolute bg-black"> <div className="text-white z-20 absolute flex flex-col items-start">
rating: {image.fields?.imageMeta?.meta?.Rating} {data.map((dataString, i) => (
</span> <span
className="bg-black/30 backdrop-blur shadow p-[2px] m-[2px] max-w-full"
key={i}
>
{dataString}
</span>
))}
</div>
)} )}
{img && ( {img && (
<div className={`h-full ${showPalette && "grid grid-rows-[1fr_20px]"}`}> <div
className={`h-full ${
showPalette && "grid grid-rows-[1fr_20px]"
}`}
>
<GatsbyImage <GatsbyImage
alt={getName(image)} alt={
image.fields?.imageMeta?.meta?.Keywords?.length
? `image of ${image.fields?.imageMeta?.meta?.Keywords.join(
" and "
)}. ${getName(image)}`
: getName(image)
}
className="w-full" className="w-full"
image={img} image={img}
objectFit="cover" objectFit="cover"
/> />
{ showPalette && vibrant && <div className="grid grid-cols-6 flex-shrink-0 h-[20px] w-full"> {showPalette && vibrant && (
<div <div className="grid grid-cols-6 flex-shrink-0 h-[20px] w-full">
style={{ background: `rgba(${vibrant.Vibrant?.join(",")})` }} <div
></div> style={{
<div background: `rgba(${vibrant.Vibrant?.join(",")})`,
style={{ }}
background: `rgb(${vibrant.LightVibrant?.join(",")})`, ></div>
}} <div
></div> style={{
<div background: `rgb(${vibrant.LightVibrant?.join(",")})`,
style={{ }}
background: `rgb(${vibrant.DarkVibrant?.join(",")})`, ></div>
}} <div
></div> style={{
<div background: `rgb(${vibrant.DarkVibrant?.join(",")})`,
style={{ background: `rgb(${vibrant.Muted?.join(",")})` }} }}
></div> ></div>
<div <div
style={{ style={{ background: `rgb(${vibrant.Muted?.join(",")})` }}
background: `rgb(${vibrant.LightMuted?.join(",")})`, ></div>
}} <div
></div> style={{
<div background: `rgb(${vibrant.LightMuted?.join(",")})`,
style={{ }}
background: `rgb(${vibrant.DarkMuted?.join(",")})`, ></div>
}} <div
></div> style={{
</div>} background: `rgb(${vibrant.DarkMuted?.join(",")})`,
}}
></div>
</div>
)}
</div> </div>
)} )}
</Link> </Link>

View File

@ -1,16 +1,17 @@
import React, { useState } from "react"; import React, { useRef, useState } from "react";
import classnames from "classnames"; import classnames from "classnames";
import { Link } from "gatsby"; import { Link, navigate } from "gatsby";
import { Popover } from "react-tiny-popover"; import { Popover } from "react-tiny-popover";
import { StaticImage } from "gatsby-plugin-image";
const navClasses = const navClasses =
"hover:underline hover:bg-transparentblack block p-3 text-black"; "hover:underline hover:bg-black/10 block p-3 text-black flex-shrink-0 whitespace-nowrap";
const ExternalLinks = () => ( const ExternalLinks = () => (
<ul <ul
className={classnames( className={classnames(
"z-30 overflow-hidden bg-vibrant-dark", "z-30 overflow-hidden bg-vibrant-dark",
"rounded shadow border border-vibrant-light" "rounded shadow-lg border border-gray-400"
)} )}
> >
<li> <li>
@ -87,17 +88,56 @@ interface NavProps {
const Nav = ({ internalLinks, className }: NavProps) => { const Nav = ({ internalLinks, className }: NavProps) => {
const [linksMenu, setLinksMenu] = useState(false); const [linksMenu, setLinksMenu] = useState(false);
const faceClicks = useRef(0);
const faceLastClicked = useRef(0);
return ( return (
<nav <nav
className={classnames( className={classnames(
"my-4 flex flex-col-reverse md:flex-row items-center w-full font-sans px-4 md:px-8", "my-4 flex flex-col-reverse md:flex-row",
"justify-between",
"items-center w-full font-sans px-4 md:px-8",
className className
)} )}
> >
<div className="md:flex items-baseline flex-auto"> <div className="flex flex-auto items-center">
<h1 className="font-bold mr-2">Chuck Dries</h1> <div
<h2 className="text-md">Software Engineer & Photographer</h2> className={classnames(
"h-[120px] w-[120px] mr-4 my-5 flex-shrink-0"
)}
onClick={() => {
const prevClick = faceLastClicked.current;
faceLastClicked.current = Date.now();
if (prevClick > 0 && faceLastClicked.current - prevClick > 500) {
console.log('too slow!')
faceClicks.current = 1;
return;
}
if (faceClicks.current === 4) {
navigate("/photogallery/?debug=true");
return;
}
faceClicks.current += 1;
}}
>
<StaticImage
alt="A picture of me"
className="relative"
placeholder="tracedSVG"
src="../images/circle-profile.png"
style={
{
// top: "-70%",
// left: "-50%",
// width: "200%",
}
}
/>
</div>
<div className="items-baseline">
<h1 className="font-bold mr-2">Chuck Dries</h1>
<h2 className="text-md">Software Engineer & Photographer</h2>
</div>
</div> </div>
<div className="flex"> <div className="flex">

View File

@ -48,8 +48,8 @@ export function Select<T extends object>(props: AriaSelectProps<T>) {
/> />
<button <button
{...mergeProps(buttonProps, focusProps)} {...mergeProps(buttonProps, focusProps)}
className={`py-[5px] px-3 w-[150px] flex flex-row items-center justify-between overflow-hidden cursor-default rounded border hover:bg-transparentblack ${ className={`py-[5px] px-3 w-[150px] flex flex-row items-center justify-between overflow-hidden cursor-default rounded border hover:bg-black/10 ${
isFocusVisible ? "border-green-700" : "border-black" isFocusVisible ? "border-green-700" : "border-gray-400"
} ${state.isOpen ? "bg-gray-100" : "bg-white"}`} } ${state.isOpen ? "bg-gray-100" : "bg-white"}`}
ref={ref} ref={ref}
> >

View File

@ -0,0 +1,33 @@
import * as React from 'react';
import {useToggleState} from 'react-stately';
import {AriaToggleButtonProps, useToggleButton} from 'react-aria';
import {useRef} from 'react';
import classNames from 'classnames';
export function ToggleButton(props: AriaToggleButtonProps) {
let ref = useRef(null);
let state = useToggleState(props);
let { buttonProps, isPressed } = useToggleButton(props, state, ref);
return (
<button
{...buttonProps}
className={classNames(buttonProps.className, "py-[3px] px-2 mx-1 rounded")}
ref={ref}
style={{
background: isPressed
? state.isSelected ? 'darkgreen' : 'gray'
: state.isSelected
? 'green'
: 'lightgray',
color: state.isSelected ? 'white' : 'black',
userSelect: 'none',
WebkitUserSelect: 'none',
border: 'none'
}}
>
{props.children}
</button>
);
}

368
src/gatsby-types.d.ts vendored
View File

@ -571,7 +571,7 @@ type FileFieldsFilterInput = {
}; };
type FileFieldsImageMeta = { type FileFieldsImageMeta = {
readonly datePublished: Maybe<Scalars['String']>; readonly datePublished: Maybe<Scalars['Date']>;
readonly dateTaken: Maybe<Scalars['Date']>; readonly dateTaken: Maybe<Scalars['Date']>;
readonly dominantHue: Maybe<ReadonlyArray<Maybe<Scalars['Float']>>>; readonly dominantHue: Maybe<ReadonlyArray<Maybe<Scalars['Float']>>>;
readonly meta: Maybe<FileFieldsImageMetaMeta>; readonly meta: Maybe<FileFieldsImageMetaMeta>;
@ -580,6 +580,14 @@ type FileFieldsImageMeta = {
}; };
type FileFieldsImageMeta_datePublishedArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type FileFieldsImageMeta_dateTakenArgs = { type FileFieldsImageMeta_dateTakenArgs = {
difference: InputMaybe<Scalars['String']>; difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>; formatString: InputMaybe<Scalars['String']>;
@ -597,7 +605,7 @@ type FileFieldsImageMetaFieldSelector = {
}; };
type FileFieldsImageMetaFilterInput = { type FileFieldsImageMetaFilterInput = {
readonly datePublished: InputMaybe<StringQueryOperatorInput>; readonly datePublished: InputMaybe<DateQueryOperatorInput>;
readonly dateTaken: InputMaybe<DateQueryOperatorInput>; readonly dateTaken: InputMaybe<DateQueryOperatorInput>;
readonly dominantHue: InputMaybe<FloatQueryOperatorInput>; readonly dominantHue: InputMaybe<FloatQueryOperatorInput>;
readonly meta: InputMaybe<FileFieldsImageMetaMetaFilterInput>; readonly meta: InputMaybe<FileFieldsImageMetaMetaFilterInput>;
@ -1524,6 +1532,7 @@ type Query = {
readonly allSiteFunction: SiteFunctionConnection; readonly allSiteFunction: SiteFunctionConnection;
readonly allSitePage: SitePageConnection; readonly allSitePage: SitePageConnection;
readonly allSitePlugin: SitePluginConnection; readonly allSitePlugin: SitePluginConnection;
readonly allStaticImage: StaticImageConnection;
readonly directory: Maybe<Directory>; readonly directory: Maybe<Directory>;
readonly file: Maybe<File>; readonly file: Maybe<File>;
readonly imageSharp: Maybe<ImageSharp>; readonly imageSharp: Maybe<ImageSharp>;
@ -1532,6 +1541,7 @@ type Query = {
readonly siteFunction: Maybe<SiteFunction>; readonly siteFunction: Maybe<SiteFunction>;
readonly sitePage: Maybe<SitePage>; readonly sitePage: Maybe<SitePage>;
readonly sitePlugin: Maybe<SitePlugin>; readonly sitePlugin: Maybe<SitePlugin>;
readonly staticImage: Maybe<StaticImage>;
}; };
@ -1599,6 +1609,14 @@ type Query_allSitePluginArgs = {
}; };
type Query_allStaticImageArgs = {
filter: InputMaybe<StaticImageFilterInput>;
limit: InputMaybe<Scalars['Int']>;
skip: InputMaybe<Scalars['Int']>;
sort: InputMaybe<ReadonlyArray<InputMaybe<StaticImageSortInput>>>;
};
type Query_directoryArgs = { type Query_directoryArgs = {
absolutePath: InputMaybe<StringQueryOperatorInput>; absolutePath: InputMaybe<StringQueryOperatorInput>;
accessTime: InputMaybe<DateQueryOperatorInput>; accessTime: InputMaybe<DateQueryOperatorInput>;
@ -1768,6 +1786,46 @@ type Query_sitePluginArgs = {
version: InputMaybe<StringQueryOperatorInput>; version: InputMaybe<StringQueryOperatorInput>;
}; };
type Query_staticImageArgs = {
absolutePath: InputMaybe<StringQueryOperatorInput>;
accessTime: InputMaybe<DateQueryOperatorInput>;
atime: InputMaybe<DateQueryOperatorInput>;
atimeMs: InputMaybe<FloatQueryOperatorInput>;
base: InputMaybe<StringQueryOperatorInput>;
birthTime: InputMaybe<DateQueryOperatorInput>;
birthtime: InputMaybe<DateQueryOperatorInput>;
birthtimeMs: InputMaybe<FloatQueryOperatorInput>;
blksize: InputMaybe<IntQueryOperatorInput>;
blocks: InputMaybe<IntQueryOperatorInput>;
changeTime: InputMaybe<DateQueryOperatorInput>;
children: InputMaybe<NodeFilterListInput>;
ctime: InputMaybe<DateQueryOperatorInput>;
ctimeMs: InputMaybe<FloatQueryOperatorInput>;
dev: InputMaybe<IntQueryOperatorInput>;
dir: InputMaybe<StringQueryOperatorInput>;
ext: InputMaybe<StringQueryOperatorInput>;
extension: InputMaybe<StringQueryOperatorInput>;
id: InputMaybe<StringQueryOperatorInput>;
ino: InputMaybe<IntQueryOperatorInput>;
internal: InputMaybe<InternalFilterInput>;
mode: InputMaybe<IntQueryOperatorInput>;
modifiedTime: InputMaybe<DateQueryOperatorInput>;
mtime: InputMaybe<DateQueryOperatorInput>;
mtimeMs: InputMaybe<FloatQueryOperatorInput>;
name: InputMaybe<StringQueryOperatorInput>;
nlink: InputMaybe<IntQueryOperatorInput>;
parent: InputMaybe<NodeFilterInput>;
prettySize: InputMaybe<StringQueryOperatorInput>;
rdev: InputMaybe<IntQueryOperatorInput>;
relativeDirectory: InputMaybe<StringQueryOperatorInput>;
relativePath: InputMaybe<StringQueryOperatorInput>;
root: InputMaybe<StringQueryOperatorInput>;
size: InputMaybe<IntQueryOperatorInput>;
sourceInstanceName: InputMaybe<StringQueryOperatorInput>;
uid: InputMaybe<IntQueryOperatorInput>;
};
type Site = Node & { type Site = Node & {
readonly buildTime: Maybe<Scalars['Date']>; readonly buildTime: Maybe<Scalars['Date']>;
readonly children: ReadonlyArray<Node>; readonly children: ReadonlyArray<Node>;
@ -2534,6 +2592,312 @@ type SortOrderEnum =
| 'ASC' | 'ASC'
| 'DESC'; | 'DESC';
type StaticImage = Node & {
readonly absolutePath: Maybe<Scalars['String']>;
readonly accessTime: Maybe<Scalars['Date']>;
readonly atime: Maybe<Scalars['Date']>;
readonly atimeMs: Maybe<Scalars['Float']>;
readonly base: Maybe<Scalars['String']>;
readonly birthTime: Maybe<Scalars['Date']>;
readonly birthtime: Maybe<Scalars['Date']>;
readonly birthtimeMs: Maybe<Scalars['Float']>;
readonly blksize: Maybe<Scalars['Int']>;
readonly blocks: Maybe<Scalars['Int']>;
readonly changeTime: Maybe<Scalars['Date']>;
readonly children: ReadonlyArray<Node>;
readonly ctime: Maybe<Scalars['Date']>;
readonly ctimeMs: Maybe<Scalars['Float']>;
readonly dev: Maybe<Scalars['Int']>;
readonly dir: Maybe<Scalars['String']>;
readonly ext: Maybe<Scalars['String']>;
readonly extension: Maybe<Scalars['String']>;
readonly id: Scalars['ID'];
readonly ino: Maybe<Scalars['Int']>;
readonly internal: Internal;
readonly mode: Maybe<Scalars['Int']>;
readonly modifiedTime: Maybe<Scalars['Date']>;
readonly mtime: Maybe<Scalars['Date']>;
readonly mtimeMs: Maybe<Scalars['Float']>;
readonly name: Maybe<Scalars['String']>;
readonly nlink: Maybe<Scalars['Int']>;
readonly parent: Maybe<Node>;
readonly prettySize: Maybe<Scalars['String']>;
readonly rdev: Maybe<Scalars['Int']>;
readonly relativeDirectory: Maybe<Scalars['String']>;
readonly relativePath: Maybe<Scalars['String']>;
readonly root: Maybe<Scalars['String']>;
readonly size: Maybe<Scalars['Int']>;
readonly sourceInstanceName: Maybe<Scalars['String']>;
readonly uid: Maybe<Scalars['Int']>;
};
type StaticImage_accessTimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_atimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_birthTimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_birthtimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_changeTimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_ctimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_modifiedTimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImage_mtimeArgs = {
difference: InputMaybe<Scalars['String']>;
formatString: InputMaybe<Scalars['String']>;
fromNow: InputMaybe<Scalars['Boolean']>;
locale: InputMaybe<Scalars['String']>;
};
type StaticImageConnection = {
readonly distinct: ReadonlyArray<Scalars['String']>;
readonly edges: ReadonlyArray<StaticImageEdge>;
readonly group: ReadonlyArray<StaticImageGroupConnection>;
readonly max: Maybe<Scalars['Float']>;
readonly min: Maybe<Scalars['Float']>;
readonly nodes: ReadonlyArray<StaticImage>;
readonly pageInfo: PageInfo;
readonly sum: Maybe<Scalars['Float']>;
readonly totalCount: Scalars['Int'];
};
type StaticImageConnection_distinctArgs = {
field: StaticImageFieldSelector;
};
type StaticImageConnection_groupArgs = {
field: StaticImageFieldSelector;
limit: InputMaybe<Scalars['Int']>;
skip: InputMaybe<Scalars['Int']>;
};
type StaticImageConnection_maxArgs = {
field: StaticImageFieldSelector;
};
type StaticImageConnection_minArgs = {
field: StaticImageFieldSelector;
};
type StaticImageConnection_sumArgs = {
field: StaticImageFieldSelector;
};
type StaticImageEdge = {
readonly next: Maybe<StaticImage>;
readonly node: StaticImage;
readonly previous: Maybe<StaticImage>;
};
type StaticImageFieldSelector = {
readonly absolutePath: InputMaybe<FieldSelectorEnum>;
readonly accessTime: InputMaybe<FieldSelectorEnum>;
readonly atime: InputMaybe<FieldSelectorEnum>;
readonly atimeMs: InputMaybe<FieldSelectorEnum>;
readonly base: InputMaybe<FieldSelectorEnum>;
readonly birthTime: InputMaybe<FieldSelectorEnum>;
readonly birthtime: InputMaybe<FieldSelectorEnum>;
readonly birthtimeMs: InputMaybe<FieldSelectorEnum>;
readonly blksize: InputMaybe<FieldSelectorEnum>;
readonly blocks: InputMaybe<FieldSelectorEnum>;
readonly changeTime: InputMaybe<FieldSelectorEnum>;
readonly children: InputMaybe<NodeFieldSelector>;
readonly ctime: InputMaybe<FieldSelectorEnum>;
readonly ctimeMs: InputMaybe<FieldSelectorEnum>;
readonly dev: InputMaybe<FieldSelectorEnum>;
readonly dir: InputMaybe<FieldSelectorEnum>;
readonly ext: InputMaybe<FieldSelectorEnum>;
readonly extension: InputMaybe<FieldSelectorEnum>;
readonly id: InputMaybe<FieldSelectorEnum>;
readonly ino: InputMaybe<FieldSelectorEnum>;
readonly internal: InputMaybe<InternalFieldSelector>;
readonly mode: InputMaybe<FieldSelectorEnum>;
readonly modifiedTime: InputMaybe<FieldSelectorEnum>;
readonly mtime: InputMaybe<FieldSelectorEnum>;
readonly mtimeMs: InputMaybe<FieldSelectorEnum>;
readonly name: InputMaybe<FieldSelectorEnum>;
readonly nlink: InputMaybe<FieldSelectorEnum>;
readonly parent: InputMaybe<NodeFieldSelector>;
readonly prettySize: InputMaybe<FieldSelectorEnum>;
readonly rdev: InputMaybe<FieldSelectorEnum>;
readonly relativeDirectory: InputMaybe<FieldSelectorEnum>;
readonly relativePath: InputMaybe<FieldSelectorEnum>;
readonly root: InputMaybe<FieldSelectorEnum>;
readonly size: InputMaybe<FieldSelectorEnum>;
readonly sourceInstanceName: InputMaybe<FieldSelectorEnum>;
readonly uid: InputMaybe<FieldSelectorEnum>;
};
type StaticImageFilterInput = {
readonly absolutePath: InputMaybe<StringQueryOperatorInput>;
readonly accessTime: InputMaybe<DateQueryOperatorInput>;
readonly atime: InputMaybe<DateQueryOperatorInput>;
readonly atimeMs: InputMaybe<FloatQueryOperatorInput>;
readonly base: InputMaybe<StringQueryOperatorInput>;
readonly birthTime: InputMaybe<DateQueryOperatorInput>;
readonly birthtime: InputMaybe<DateQueryOperatorInput>;
readonly birthtimeMs: InputMaybe<FloatQueryOperatorInput>;
readonly blksize: InputMaybe<IntQueryOperatorInput>;
readonly blocks: InputMaybe<IntQueryOperatorInput>;
readonly changeTime: InputMaybe<DateQueryOperatorInput>;
readonly children: InputMaybe<NodeFilterListInput>;
readonly ctime: InputMaybe<DateQueryOperatorInput>;
readonly ctimeMs: InputMaybe<FloatQueryOperatorInput>;
readonly dev: InputMaybe<IntQueryOperatorInput>;
readonly dir: InputMaybe<StringQueryOperatorInput>;
readonly ext: InputMaybe<StringQueryOperatorInput>;
readonly extension: InputMaybe<StringQueryOperatorInput>;
readonly id: InputMaybe<StringQueryOperatorInput>;
readonly ino: InputMaybe<IntQueryOperatorInput>;
readonly internal: InputMaybe<InternalFilterInput>;
readonly mode: InputMaybe<IntQueryOperatorInput>;
readonly modifiedTime: InputMaybe<DateQueryOperatorInput>;
readonly mtime: InputMaybe<DateQueryOperatorInput>;
readonly mtimeMs: InputMaybe<FloatQueryOperatorInput>;
readonly name: InputMaybe<StringQueryOperatorInput>;
readonly nlink: InputMaybe<IntQueryOperatorInput>;
readonly parent: InputMaybe<NodeFilterInput>;
readonly prettySize: InputMaybe<StringQueryOperatorInput>;
readonly rdev: InputMaybe<IntQueryOperatorInput>;
readonly relativeDirectory: InputMaybe<StringQueryOperatorInput>;
readonly relativePath: InputMaybe<StringQueryOperatorInput>;
readonly root: InputMaybe<StringQueryOperatorInput>;
readonly size: InputMaybe<IntQueryOperatorInput>;
readonly sourceInstanceName: InputMaybe<StringQueryOperatorInput>;
readonly uid: InputMaybe<IntQueryOperatorInput>;
};
type StaticImageGroupConnection = {
readonly distinct: ReadonlyArray<Scalars['String']>;
readonly edges: ReadonlyArray<StaticImageEdge>;
readonly field: Scalars['String'];
readonly fieldValue: Maybe<Scalars['String']>;
readonly group: ReadonlyArray<StaticImageGroupConnection>;
readonly max: Maybe<Scalars['Float']>;
readonly min: Maybe<Scalars['Float']>;
readonly nodes: ReadonlyArray<StaticImage>;
readonly pageInfo: PageInfo;
readonly sum: Maybe<Scalars['Float']>;
readonly totalCount: Scalars['Int'];
};
type StaticImageGroupConnection_distinctArgs = {
field: StaticImageFieldSelector;
};
type StaticImageGroupConnection_groupArgs = {
field: StaticImageFieldSelector;
limit: InputMaybe<Scalars['Int']>;
skip: InputMaybe<Scalars['Int']>;
};
type StaticImageGroupConnection_maxArgs = {
field: StaticImageFieldSelector;
};
type StaticImageGroupConnection_minArgs = {
field: StaticImageFieldSelector;
};
type StaticImageGroupConnection_sumArgs = {
field: StaticImageFieldSelector;
};
type StaticImageSortInput = {
readonly absolutePath: InputMaybe<SortOrderEnum>;
readonly accessTime: InputMaybe<SortOrderEnum>;
readonly atime: InputMaybe<SortOrderEnum>;
readonly atimeMs: InputMaybe<SortOrderEnum>;
readonly base: InputMaybe<SortOrderEnum>;
readonly birthTime: InputMaybe<SortOrderEnum>;
readonly birthtime: InputMaybe<SortOrderEnum>;
readonly birthtimeMs: InputMaybe<SortOrderEnum>;
readonly blksize: InputMaybe<SortOrderEnum>;
readonly blocks: InputMaybe<SortOrderEnum>;
readonly changeTime: InputMaybe<SortOrderEnum>;
readonly children: InputMaybe<NodeSortInput>;
readonly ctime: InputMaybe<SortOrderEnum>;
readonly ctimeMs: InputMaybe<SortOrderEnum>;
readonly dev: InputMaybe<SortOrderEnum>;
readonly dir: InputMaybe<SortOrderEnum>;
readonly ext: InputMaybe<SortOrderEnum>;
readonly extension: InputMaybe<SortOrderEnum>;
readonly id: InputMaybe<SortOrderEnum>;
readonly ino: InputMaybe<SortOrderEnum>;
readonly internal: InputMaybe<InternalSortInput>;
readonly mode: InputMaybe<SortOrderEnum>;
readonly modifiedTime: InputMaybe<SortOrderEnum>;
readonly mtime: InputMaybe<SortOrderEnum>;
readonly mtimeMs: InputMaybe<SortOrderEnum>;
readonly name: InputMaybe<SortOrderEnum>;
readonly nlink: InputMaybe<SortOrderEnum>;
readonly parent: InputMaybe<NodeSortInput>;
readonly prettySize: InputMaybe<SortOrderEnum>;
readonly rdev: InputMaybe<SortOrderEnum>;
readonly relativeDirectory: InputMaybe<SortOrderEnum>;
readonly relativePath: InputMaybe<SortOrderEnum>;
readonly root: InputMaybe<SortOrderEnum>;
readonly size: InputMaybe<SortOrderEnum>;
readonly sourceInstanceName: InputMaybe<SortOrderEnum>;
readonly uid: InputMaybe<SortOrderEnum>;
};
type StringQueryOperatorInput = { type StringQueryOperatorInput = {
readonly eq: InputMaybe<Scalars['String']>; readonly eq: InputMaybe<Scalars['String']>;
readonly glob: InputMaybe<Scalars['String']>; readonly glob: InputMaybe<Scalars['String']>;

BIN
src/images/DO01002428.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 KiB

Binary file not shown.

View File

@ -102,8 +102,8 @@ const IndexPage = ({
objectFit={browserIsLandscape ? "cover" : "contain"} objectFit={browserIsLandscape ? "cover" : "contain"}
style={{ style={{
height: screenHeight height: screenHeight
? `${screenHeight - 160}px` ? `${screenHeight - 268}px`
: "calc(100vh-160px)", : "calc(100vh-268px)",
}} }}
/> />
</Link> </Link>

View File

@ -1,8 +1,7 @@
import * as React from "react"; import * as React from "react";
import * as R from "ramda"; import * as R from "ramda";
import { graphql, PageProps } from "gatsby"; import { graphql, Link, navigate, PageProps } from "gatsby";
import { Helmet } from "react-helmet"; import { Helmet } from "react-helmet";
// import { Picker, Item } from "@adobe/react-spectrum";
import MasonryGallery from "../components/MasonryGallery"; import MasonryGallery from "../components/MasonryGallery";
import KeywordsPicker from "../components/KeywordsPicker"; import KeywordsPicker from "../components/KeywordsPicker";
@ -16,6 +15,7 @@ import Nav from "../components/Nav";
import { Item, Select } from "../components/Select"; import { Item, Select } from "../components/Select";
import { Switch } from "../components/Switch"; import { Switch } from "../components/Switch";
import ColorPalette from "@spectrum-icons/workflow/ColorPalette"; import ColorPalette from "@spectrum-icons/workflow/ColorPalette";
import { ToggleButton } from "../components/ToggleButton";
const SORT_KEYS = { const SORT_KEYS = {
hue: ["fields", "imageMeta", "vibrantHue"], hue: ["fields", "imageMeta", "vibrantHue"],
@ -23,55 +23,48 @@ const SORT_KEYS = {
// hue_debug: ["fields", "imageMeta", "dominantHue", 0], // hue_debug: ["fields", "imageMeta", "dominantHue", 0],
hue_debug: ["fields", "imageMeta", "dominantHue", "0"], hue_debug: ["fields", "imageMeta", "dominantHue", "0"],
date: ["fields", "imageMeta", "dateTaken"], date: ["fields", "imageMeta", "dateTaken"],
modified: ["fields", "imageMeta", "datePublished"], datePublished: ["fields", "imageMeta", "datePublished"],
} as const; } as const;
export type GalleryImage = export type GalleryImage =
Queries.GalleryPageQueryQuery["all"]["nodes"][number]; Queries.GalleryPageQueryQuery["all"]["nodes"][number];
function smartCompareDates(key: keyof typeof SORT_KEYS, left: GalleryImage, right: GalleryImage) { function smartCompareDates(
key: keyof typeof SORT_KEYS,
left: GalleryImage,
right: GalleryImage
) {
let diff = compareDates(SORT_KEYS[key], left, right); let diff = compareDates(SORT_KEYS[key], left, right);
console.log("🚀 ~ file: photogallery.tsx:34 ~ smartCompareDates ~ diff:", diff)
if (diff !== 0) { if (diff !== 0) {
return diff; return diff;
} }
console.log('falling back to date')
return compareDates(SORT_KEYS.date, left, right); return compareDates(SORT_KEYS.date, left, right);
} }
const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => { const GalleryPage = ({
const hash = data,
typeof window !== "undefined" ? window.location.hash.replace("#", "") : ""; location,
}: PageProps<Queries.GalleryPageQueryQuery>) => {
const hash = location.hash ? location.hash.replace("#", "") : "";
const [hashCleared, setHashCleared] = React.useState(false); // eslint-disable-line no-unused-vars const params = new URLSearchParams(location.search);
// ^ used just to force a re-render with the cleared hash value (I know, it's a smell for sure) const filterKeyword = params.get("filter");
const [filterKeyword, _setKeyword] = React.useState(null as string | null); const sortKey = params.get("sort") ?? "rating";
const [sortKey, _setSortKey] = React.useState("rating" as string);
const showDebug = const showDebug = Boolean(params.get("debug")?.length);
typeof window !== "undefined" &&
window.location.search.includes("debug=true");
const [showPalette, setShowPalette] = React.useState(false); const [showPalette, setShowPalette] = React.useState(false);
const setKeyword = React.useCallback( const onKeywordPick = React.useCallback((newKeyword: string | null) => {
(newKeyword: string | null) => { if (newKeyword) {
if (newKeyword) { try {
try { window.plausible("Filter Keyword", {
window.plausible("Filter Keyword", { props: { keyword: newKeyword },
props: { keyword: newKeyword }, });
}); } catch (e) {
} catch (e) { // do nothing
// do nothing
}
} }
_setKeyword(newKeyword); }
window.history.replaceState( }, []);
null,
"",
getGalleryPageUrl({ keyword: newKeyword, sortKey }, hash)
);
},
[_setKeyword, sortKey, hash]
);
const setSortKey = React.useCallback( const setSortKey = React.useCallback(
(newSortKey: string) => { (newSortKey: string) => {
@ -82,67 +75,65 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
} catch (e) { } catch (e) {
// do nothing // do nothing
} }
_setSortKey(newSortKey); navigate(
window.history.replaceState( getGalleryPageUrl(
null, { sortKey: newSortKey, keyword: filterKeyword, showDebug },
"", hash
getGalleryPageUrl({ sortKey: newSortKey, keyword: filterKeyword }, hash) )
// { replace: true }
); );
}, },
[_setSortKey, filterKeyword, hash] [filterKeyword, hash, showDebug]
); );
const removeHash = React.useCallback(() => { const removeHash = React.useCallback(() => {
const url = new URL( if (!hash.length) {
typeof window !== "undefined" return;
? window.location.href.toString() }
: "https://chuckdries.com/photogallery/" console.log('remove hash')
navigate(
getGalleryPageUrl({ sortKey, keyword: filterKeyword, showDebug }, ""),
{ replace: true }
); );
window.removeEventListener("scroll", removeHash);
url.hash = ""; }, [hash, sortKey, filterKeyword, showDebug]);
window.history.replaceState(null, "", url.href.toString());
window.removeEventListener("wheel", removeHash);
setHashCleared(true);
}, []);
const scrollIntoView = React.useCallback(() => {
if (!hash) {
return;
}
const el = document.getElementById(hash);
if (!el) {
return;
}
el.scrollIntoView({
block: "center",
});
window.addEventListener("wheel", removeHash);
}, [hash, removeHash]);
React.useEffect(() => { React.useEffect(() => {
const url = new URL(window.location.toString()); // window.addEventListener("scroll", removeHash);
return () => {
const sortKeyFromUrl = url.searchParams.get("sort"); window.removeEventListener("scroll", removeHash);
if (sortKeyFromUrl) { };
_setSortKey(sortKeyFromUrl); }, [removeHash]);
}
const filterKeyFromUrl = url.searchParams.get("filter");
if (filterKeyFromUrl) {
_setKeyword(filterKeyFromUrl);
}
React.useEffect(() => {
// hacky but it works for now // hacky but it works for now
setTimeout(() => { requestAnimationFrame(() => {
// don't scroll into view if user got here with back button // don't scroll into view if user got here with back button or if we just cleared it
scrollIntoView(); if (!hash.length) {
}, 100); return;
}, [setSortKey, setKeyword, scrollIntoView]); }
const el = document.getElementById(hash);
if (!el) {
console.log("⚠failed to find hash");
return;
}
console.log("scrolling into view manually", el.offsetTop);
el.scrollIntoView({
block: hash.startsWith("all") ? "start" : "center",
behavior: hash.startsWith("all") ? "smooth" : "auto",
});
setTimeout(() => {
window.addEventListener("scroll", removeHash);
}, 100);
});
}, [hash, removeHash]);
const images: GalleryImage[] = React.useMemo(() => { const images: GalleryImage[] = React.useMemo(() => {
const sort = const sort =
sortKey === "date" || sortKey === "modified" sortKey === "date" || sortKey === "datePublished"
? R.sort((node1: typeof data["all"]["nodes"][number], node2) => smartCompareDates(sortKey, node1, node2)) ? R.sort((node1: typeof data["all"]["nodes"][number], node2) =>
smartCompareDates(sortKey, node1, node2)
)
: R.sort( : R.sort(
// @ts-ignore // @ts-ignore
R.descend(R.path<GalleryImage>(SORT_KEYS[sortKey])) R.descend(R.path<GalleryImage>(SORT_KEYS[sortKey]))
@ -171,8 +162,50 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
}, [data, sortKey, filterKeyword]); }, [data, sortKey, filterKeyword]);
const recents = React.useMemo(() => { const recents = React.useMemo(() => {
return R.sort((left, right) => smartCompareDates('modified', left, right), data.recents.nodes) return R.sort(
}, [data, 'hi']) (left, right) => smartCompareDates("datePublished", left, right),
data.recents.nodes
);
}, [data]);
const [dbgTags, setDbgTags] = React.useState(false);
const [dbgSortKey, setDbgSortKey] = React.useState(false);
const [dbgName, setDbgName] = React.useState(false);
const dataFn = React.useCallback(
(image: GalleryImage): string[] | null => {
if (!showDebug) {
return null;
}
let data: string[] = [];
if (dbgName) {
data.push(image.base);
}
if (dbgSortKey) {
switch (sortKey) {
case "hue":
case "rating": {
data.push(R.pathOr("x", SORT_KEYS[sortKey], image));
break;
}
case "date":
case "datePublished": {
const date = R.pathOr(null, SORT_KEYS[sortKey], image);
if (date) {
data.push(new Date(date).toLocaleString());
} else {
data.push("x");
}
break;
}
}
}
if (dbgTags) {
data.push(image.fields?.imageMeta?.meta?.Keywords?.join(",") ?? "x");
}
return data;
},
[showDebug, sortKey, dbgName, dbgSortKey, dbgTags]
);
return ( return (
<> <>
@ -205,31 +238,50 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
]} ]}
/> />
</div> </div>
<div className="px-4 md:px-8"> <div className="gradient pb-6">
<h3 id="recently" className="mx-2 font-bold"> <div className="px-4 md:px-8 flex items-baseline">
Recently published <h3 className="mx-2 font-bold" id="recently">
</h3> Recently published
</h3>
{sortKey !== "datePublished" && (
<Link
className="underline cursor-pointer text-gray-500"
to="?sort=datePublished#all"
>
show more
</Link>
)}
</div>
<MasonryGallery
aspectsByBreakpoint={{
xs: 3,
sm: 3,
md: 4,
lg: 4,
xl: 5,
"2xl": 6,
"3xl": 8,
}}
images={recents}
linkState={{
sortKey: 'datePublished',
filterKeyword,
}}
singleRow
/>
</div> </div>
<MasonryGallery <div className="px-4 md:px-8 mt-2 pt-2">
aspectsByBreakpoint={{ <h3 className="mx-2 font-bold" id="all">
xs: 2,
sm: 2,
md: 3,
lg: 4,
xl: 5,
"2xl": 6.1,
"3xl": 8,
}}
images={recents}
singleRow
/>
<div className="px-4 md:px-8 mt-4 pt-2 border-t">
<h3 id="all" className="mx-2 font-bold">
All images All images
</h3> </h3>
</div> </div>
<div className="flex flex-col lg:flex-row lg:items-end justify-between px-4 md:px-8 sm:mx-auto"> <div className="flex flex-col lg:flex-row lg:items-end justify-between px-4 md:px-8 sm:mx-auto">
<KeywordsPicker <KeywordsPicker
getHref={(val, selected) =>
selected
? getGalleryPageUrl({ keyword: null, sortKey, showDebug }, hash)
: getGalleryPageUrl({ keyword: val, sortKey, showDebug }, hash)
}
keywords={[ keywords={[
"Boyce Thompson Arboretum", "Boyce Thompson Arboretum",
"winter", "winter",
@ -239,18 +291,31 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
"landscape", "landscape",
"flowers", "flowers",
"product", "product",
"waterfall", // "waterfall",
"fireworks", // "fireworks",
"panoramic", // "panoramic",
"Portland Japanese Garden", "Portland Japanese Garden",
// "shoot the light", // "shoot the light",
// "sunset", // "sunset",
]} ]}
onChange={setKeyword} onPick={onKeywordPick}
value={filterKeyword} value={filterKeyword}
/> />
<div className="m-2 flex flex-row items-end"> <div className="my-2 mx-2 flex flex-row items-end">
<div className="border border-black rounded mr-2"> {showDebug && (
<div className="mr-2">
<ToggleButton isSelected={dbgName} onChange={setDbgName}>
name
</ToggleButton>
<ToggleButton isSelected={dbgSortKey} onChange={setDbgSortKey}>
sort key
</ToggleButton>
<ToggleButton isSelected={dbgTags} onChange={setDbgTags}>
tags
</ToggleButton>
</div>
)}
<div className="border border-gray-400 rounded mr-2">
<Switch <Switch
isSelected={showPalette} isSelected={showPalette}
onChange={(val) => setShowPalette(val)} onChange={(val) => setShowPalette(val)}
@ -265,12 +330,12 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
</div> </div>
<Select <Select
label="Sort by..." label="Sort by..."
// @ts-ignore // @ts-expect-error React.key, but string is more convenient for the state
onSelectionChange={setSortKey} onSelectionChange={setSortKey}
selectedKey={sortKey} selectedKey={sortKey}
> >
<Item key="rating">Curated</Item> <Item key="rating">Curated</Item>
<Item key="modified">Date published</Item> <Item key="datePublished">Date published</Item>
<Item key="date">Date taken</Item> <Item key="date">Date taken</Item>
<Item key="hue">Hue</Item> <Item key="hue">Hue</Item>
</Select> </Select>
@ -287,8 +352,8 @@ const GalleryPage = ({ data }: PageProps<Queries.GalleryPageQueryQuery>) => {
"2xl": 6.1, "2xl": 6.1,
"3xl": 8, "3xl": 8,
}} }}
dataFn={dataFn}
debugHue={sortKey === "hue_debug"} debugHue={sortKey === "hue_debug"}
debugRating={sortKey === "rating" && showDebug}
images={images} images={images}
linkState={{ linkState={{
sortKey, sortKey,
@ -305,7 +370,7 @@ export const query = graphql`
recents: allFile( recents: allFile(
filter: { sourceInstanceName: { eq: "gallery" } } filter: { sourceInstanceName: { eq: "gallery" } }
sort: { fields: { imageMeta: { datePublished: DESC } } } sort: { fields: { imageMeta: { datePublished: DESC } } }
limit: 7 limit: 10
) { ) {
...GalleryImageFile ...GalleryImageFile
} }

View File

@ -9,6 +9,9 @@
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
:root {
/* scroll-behavior: smooth; */
}
/* .hero * { /* .hero * {
transition: color .2s, background-color .2s; transition: color .2s, background-color .2s;
} */ } */
@ -83,27 +86,15 @@
.gradient { .gradient {
background-image: linear-gradient( background-image: linear-gradient(
180deg, 180deg,
hsl(31deg 24% 44%) 0%, hsla(0deg, 0%, 0%, 0%) 95%,
hsl(27deg 25% 42%) 7%, hsla(0deg, 0%, 0%, 10%) 100%
hsl(22deg 26% 40%) 14%,
hsl(18deg 27% 37%) 21%,
hsl(12deg 28% 35%) 29%,
hsl(9deg 29% 32%) 36%,
hsl(4deg 30% 30%) 43%,
hsl(0deg 31% 27%) 50%,
hsl(0deg 31% 23%) 57%,
hsl(0deg 31% 19%) 64%,
hsl(0deg 32% 15%) 71%,
hsl(0deg 30% 12%) 79%,
hsl(0deg 30% 8%) 86%,
hsl(0deg 30% 4%) 93%,
hsl(0deg 0% 0%) 100%
); );
} }
} }
body { body {
@apply bg-gray-100; @apply bg-gray-100;
overflow: auto;
/* @apply bg-black; */ /* @apply bg-black; */
/* @apply text-white; */ /* @apply text-white; */
} }

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useCallback, useRef } from "react";
import { pathOr } from "ramda"; import { pathOr } from "ramda";
// import kebabCase from 'lodash/kebabCase'; // import kebabCase from 'lodash/kebabCase';
@ -101,11 +101,12 @@ export const getShutterFractionFromExposureTime = (exposureTime: number) => {
interface galleryPageUrlProps { interface galleryPageUrlProps {
keyword: string | null; keyword: string | null;
sortKey: string; sortKey: string | null;
showDebug: boolean;
} }
export const getGalleryPageUrl = ( export const getGalleryPageUrl = (
{ keyword, sortKey }: galleryPageUrlProps, { keyword, sortKey, showDebug }: galleryPageUrlProps,
hash: string hash: string
) => { ) => {
const url = new URL( const url = new URL(
@ -123,12 +124,15 @@ export const getGalleryPageUrl = (
} }
} }
if (sortKey !== undefined) { if (sortKey !== undefined) {
if (sortKey === "rating") { if (sortKey === "rating" || sortKey === null) {
url.searchParams.delete("sort"); url.searchParams.delete("sort");
} else { } else {
url.searchParams.set("sort", sortKey); url.searchParams.set("sort", sortKey);
} }
} }
if (showDebug) {
url.searchParams.set("debug", "true");
}
if (hash) { if (hash) {
url.hash = hash; url.hash = hash;
} }
@ -141,8 +145,34 @@ export function compareDates<T>(
right: T right: T
): number { ): number {
// why tf do my dates have newlines in them?!?! // why tf do my dates have newlines in them?!?!
const date1 = new Date(pathOr("", date_path, left).replace(/\s/g, '')); const date1 = new Date(pathOr("", date_path, left).replace(/\s/g, ""));
const date2 = new Date(pathOr("", date_path, right).replace(/\s/g, '')); const date2 = new Date(pathOr("", date_path, right).replace(/\s/g, ""));
const diff = -1 * (date1.getTime() - date2.getTime()); const diff = -1 * (date1.getTime() - date2.getTime());
return diff; return diff;
} }
/**
* Returns a memoized function that will only call the passed function when it hasn't been called for the wait period
* @param func The function to be called
* @param wait Wait period after function hasn't been called for
* @returns A memoized function that is debounced
*/
export const useDebouncedCallback = (func: Function, wait: number) => {
// Use a ref to store the timeout between renders
// and prevent changes to it from causing re-renders
const timeout = useRef<ReturnType<typeof setTimeout>>();
return useCallback(
(...args: any) => {
const later = () => {
clearTimeout(timeout.current!);
func(...args);
};
clearTimeout(timeout.current ?? undefined);
timeout.current = setTimeout(later, wait);
},
[func, wait]
);
};

View File

@ -4560,6 +4560,22 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/lodash.debounce@npm:^4.0.7":
version: 4.0.7
resolution: "@types/lodash.debounce@npm:4.0.7"
dependencies:
"@types/lodash": "*"
checksum: e873b2d77f89010876baba3437ef826b17221b98948e00b5590828334a481dea1c8f9d28543210e564adc53199584f42c3cb171f8b6c3614fefc0b4e0888679c
languageName: node
linkType: hard
"@types/lodash@npm:*":
version: 4.14.191
resolution: "@types/lodash@npm:4.14.191"
checksum: ba0d5434e10690869f32d5ea49095250157cae502f10d57de0a723fd72229ce6c6a4979576f0f13e0aa9fbe3ce2457bfb9fa7d4ec3d6daba56730a51906d1491
languageName: node
linkType: hard
"@types/lodash@npm:^4.14.53": "@types/lodash@npm:^4.14.53":
version: 4.14.170 version: 4.14.170
resolution: "@types/lodash@npm:4.14.170" resolution: "@types/lodash@npm:4.14.170"
@ -6464,6 +6480,7 @@ __metadata:
"@react-spectrum/provider": ^3.6.0 "@react-spectrum/provider": ^3.6.0
"@spectrum-icons/workflow": ^4.0.4 "@spectrum-icons/workflow": ^4.0.4
"@types/chroma-js": ^2.1.4 "@types/chroma-js": ^2.1.4
"@types/lodash.debounce": ^4.0.7
"@types/node": ^18.8.3 "@types/node": ^18.8.3
"@types/ramda": ^0.28.15 "@types/ramda": ^0.28.15
"@types/react": ^18.0.21 "@types/react": ^18.0.21
@ -6495,6 +6512,7 @@ __metadata:
gatsby-source-filesystem: ^5.0.0 gatsby-source-filesystem: ^5.0.0
gatsby-transformer-sharp: ^5.0.0 gatsby-transformer-sharp: ^5.0.0
kebab-case: ^1.0.1 kebab-case: ^1.0.1
lodash.debounce: ^4.0.8
node-iptc: ^1.0.5 node-iptc: ^1.0.5
node-vibrant: 3.1.6 node-vibrant: 3.1.6
postcss: ^8.4.19 postcss: ^8.4.19