Skip to content

Commit

Permalink
small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alii committed Jan 15, 2024
1 parent 0afc45c commit caa1e25
Show file tree
Hide file tree
Showing 8 changed files with 367 additions and 271 deletions.
Binary file modified bun.lockb
Binary file not shown.
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,47 @@
"lint": "next lint"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.6",
"@types/common-tags": "^1.8.2",
"@tailwindcss/forms": "^0.5.7",
"@types/common-tags": "^1.8.4",
"@types/cookie": "^0.6.0",
"@types/jsonwebtoken": "^9.0.5",
"@types/jwa": "^2.0.0",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^9.0.3",
"autoprefixer": "^10.4.15",
"danger": "^11.2.8",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"postcss": "^8.4.29",
"prettier": "^3.0.3",
"prettier-plugin-tailwindcss": "^0.5.6",
"sharp": "^0.32.5",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
"@types/jwa": "^2.0.3",
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"@types/uuid": "^9.0.7",
"autoprefixer": "^10.4.16",
"danger": "^11.3.1",
"eslint": "8.56.0",
"eslint-config-next": "14.0.4",
"postcss": "^8.4.33",
"prettier": "^3.2.2",
"prettier-plugin-tailwindcss": "^0.5.11",
"sharp": "^0.33.2",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3"
},
"dependencies": {
"@marsidev/react-turnstile": "^0.3.1",
"@otters/monzo": "^2.1.1",
"@marsidev/react-turnstile": "^0.4.1",
"@otters/monzo": "^2.1.2",
"alistair": "^1.5.6",
"bwitch": "^0.1.3",
"clsx": "^2.0.0",
"clsx": "^2.1.0",
"common-tags": "^1.8.2",
"cookie": "^0.6.0",
"dayjs": "^1.11.9",
"dayjs": "^1.11.10",
"dotenv": "^16.3.1",
"envsafe": "^2.0.3",
"framer-motion": "^10.16.4",
"framer-motion": "^10.18.0",
"jsonwebtoken": "^9.0.2",
"jwa": "^2.0.0",
"next": "^13.5.6",
"next": "^14.0.4",
"nextkit": "^3.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.11.0",
"use-lanyard": "^1.5.1",
"uuid": "^9.0.0",
"zod": "^3.22.2"
"react-icons": "^5.0.1",
"use-lanyard": "^1.5.2",
"uuid": "^9.0.1",
"zod": "^3.22.4"
}
}
20 changes: 20 additions & 0 deletions src/components/stats.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {useMemo} from 'react';
import {useFirstEverLoad, useVisitCounts} from '../hooks/use-first-ever-load';

export function Stats() {
const [stats] = useFirstEverLoad();
const [visits] = useVisitCounts();

const firstEverLoadTime = useMemo(() => new Date(stats.time), [stats.time]);

return (
<div className="m-4 mx-auto max-w-2xl rounded-md bg-blue-900 p-4 py-12">
<p>
You first visited my website on {firstEverLoadTime.toLocaleDateString()} at{' '}
{firstEverLoadTime.toLocaleTimeString()} and on this first visit, you were on the{' '}
{stats.path} page. Since then, you have visited {visits - 1} more times.{' '}
{visits > 1 && 'Thanks for coming back!'}
</p>
</div>
);
}
20 changes: 20 additions & 0 deletions src/hooks/use-first-ever-load.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {useLocalStorage} from 'alistair/hooks';
import {useRouter} from 'next/router';

export function useFirstEverLoad() {
const router = useRouter();

return useLocalStorage('user:first-ever-load', () => {
return {
path: router.pathname,
time: Date.now(),
query: router.query,
};
});
}

export function useVisitCounts() {
return useLocalStorage('user:visit-counts', () => {
return 1;
});
}
11 changes: 11 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import type {AppProps} from 'next/app';
import {Newsreader} from 'next/font/google';
import font from 'next/font/local';
import Head from 'next/head';
import {useEffect} from 'react';
import {Toaster} from 'react-hot-toast';
import {useFirstEverLoad, useVisitCounts} from '../hooks/use-first-ever-load';

const title = Newsreader({
subsets: ['latin'],
Expand All @@ -18,6 +20,14 @@ const body = font({
});

export default function App({Component, pageProps}: AppProps) {
useFirstEverLoad();

const [_, set] = useVisitCounts();

useEffect(() => {
set(x => x + 1);
}, [set]);

return (
<>
<style jsx global>
Expand All @@ -36,6 +46,7 @@ export default function App({Component, pageProps}: AppProps) {
</Head>

<Component {...pageProps} />

<Toaster />
</>
);
Expand Down
26 changes: 26 additions & 0 deletions src/pages/experiments/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Link from 'next/link';

export default function ExperimentsList() {
return (
<div className="mx-auto max-w-prose space-y-8 px-6 py-24">
<p>This is a list of random experiments I've built on this website. There's not a lot here</p>

<ul className="list-outside list-disc space-y-4 [&_a:hover]:underline [&_a]:text-blue-400">
<li>
<Link href="/experiments/morphing-shapes">Morphing Shapes</Link>
<p className="text-sm">
Animating and shifting divs using just css transitions and JS to initiate them
</p>
</li>

<li>
<Link href="/monzo/dashboard">Monzo Dashboard</Link>
<p className="text-sm">
Using the Monzo API to display personal account details. Unfortunately, the Monzo API
requires me to manually add users, so if you want access, contact me.
</p>
</li>
</ul>
</div>
);
}
Loading

1 comment on commit caa1e25

@vercel
Copy link

@vercel vercel bot commented on caa1e25 Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.