Skip to content

Commit f17f562

Browse files
committed
update most deps
1 parent a1c1792 commit f17f562

File tree

6 files changed

+1431
-1382
lines changed

6 files changed

+1431
-1382
lines changed

app/routes/resources+/images.tsx

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1+
import { promises as fs } from 'node:fs'
12
import { invariantResponse } from '@epic-web/invariant'
23
import { getImgResponse } from 'openimg/node'
34
import { getDomainUrl } from '#app/utils/misc.tsx'
45
import { getSignedGetRequestInfo } from '#app/utils/storage.server.ts'
56
import { type Route } from './+types/images'
67

8+
let cacheDir: string | null = null
9+
10+
async function getCacheDir() {
11+
if (cacheDir) return cacheDir
12+
13+
let dir = './tests/fixtures/openimg'
14+
if (process.env.NODE_ENV === 'production') {
15+
const exists = await fs
16+
.access('/data')
17+
.then(() => true)
18+
.catch(() => false)
19+
20+
if (exists) {
21+
dir = '/data/images'
22+
}
23+
}
24+
25+
return (cacheDir = dir)
26+
}
27+
728
export async function loader({ request }: Route.LoaderArgs) {
829
const url = new URL(request.url)
930
const searchParams = url.searchParams
@@ -19,10 +40,7 @@ export async function loader({ request }: Route.LoaderArgs) {
1940
getDomainUrl(request),
2041
process.env.AWS_ENDPOINT_URL_S3,
2142
].filter(Boolean),
22-
cacheFolder:
23-
process.env.NODE_ENV === 'production'
24-
? '/data/images'
25-
: './tests/fixtures/openimg',
43+
cacheFolder: await getCacheDir(),
2644
getImgSource: () => {
2745
if (objectKey) {
2846
const { url: signedUrl, headers: signedHeaders } =

app/routes/users+/$username_+/notes.$noteId.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { parseWithZod } from '@conform-to/zod'
33
import { invariantResponse } from '@epic-web/invariant'
44
import { formatDistanceToNow } from 'date-fns'
55
import { Img } from 'openimg/react'
6+
import { useRef, useEffect } from 'react'
67
import { data, Form, Link } from 'react-router'
78
import { z } from 'zod'
89
import { GeneralErrorBoundary } from '#app/components/error-boundary.tsx'
@@ -99,9 +100,26 @@ export default function NoteRoute({
99100
)
100101
const displayBar = canDelete || isOwner
101102

103+
// Add ref for auto-focusing
104+
const sectionRef = useRef<HTMLElement>(null)
105+
106+
// Focus the section when the note ID changes
107+
useEffect(() => {
108+
if (sectionRef.current) {
109+
sectionRef.current.focus()
110+
}
111+
}, [loaderData.note.id])
112+
102113
return (
103-
<div className="absolute inset-0 flex flex-col px-10">
104-
<h2 className="mb-2 pt-12 text-h2 lg:mb-6">{loaderData.note.title}</h2>
114+
<section
115+
ref={sectionRef}
116+
className="absolute inset-0 flex flex-col px-10"
117+
aria-labelledby="note-title"
118+
tabIndex={-1} // Make the section focusable without keyboard navigation
119+
>
120+
<h2 id="note-title" className="mb-2 pt-12 text-h2 lg:mb-6">
121+
{loaderData.note.title}
122+
</h2>
105123
<div className={`${displayBar ? 'pb-24' : 'pb-12'} overflow-y-auto`}>
106124
<ul className="flex flex-wrap gap-5 py-5">
107125
{loaderData.note.images.map((image) => (
@@ -146,7 +164,7 @@ export default function NoteRoute({
146164
</div>
147165
</div>
148166
) : null}
149-
</div>
167+
</section>
150168
)
151169
}
152170

0 commit comments

Comments
 (0)