Skip to content

Commit

Permalink
fix fullscreen image view
Browse files Browse the repository at this point in the history
  • Loading branch information
iglooe committed May 8, 2024
1 parent 734c9f8 commit f39ef5c
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 139 deletions.
4 changes: 2 additions & 2 deletions src/app/@modal/(.)img/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FullPageImageView } from "~/common/full-page-image-view"
import { ModalPopup } from "~/views/modal-view"

import { Modal } from "./modal"

Expand All @@ -9,7 +9,7 @@ export default async function PhotoModal({
}) {
return (
<Modal>
<FullPageImageView photoId={photoId} />
<ModalPopup photoId={photoId} />
</Modal>
)
}
4 changes: 2 additions & 2 deletions src/app/_components/title-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export function TitleCard() {
</p>
<div
id="alert-border"
className="flex items-center border-l-4 bg-background p-4"
className="flex items-center bg-transparent p-4"
role="alert"
>
<Icons.alert />
<div className="ms-3 text-sm font-medium text-gray-800 dark:text-gray-300">
<div className="ms-3 text-sm font-medium text-black/90">
This is a demo app!{" "}
<span className="text-sm font-normal">
Image uploads are disabled
Expand Down
6 changes: 3 additions & 3 deletions src/app/img/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FullPageImageView } from "~/common/full-page-image-view"
import { FullscreenView } from "~/views/fullscreen-view"

export default function PhotoModal({
params: { id: photoId },
}: {
params: { id: string }
}) {
return (
<div className="flex size-full min-h-0 min-w-0 overflow-y-hidden">
<FullPageImageView photoId={photoId} />
<div className="flex min-h-0 min-w-0 overflow-y-hidden">
<FullscreenView photoId={photoId} />
</div>
)
}
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default function RootLayout({
<body className={`font-sans ${inter.variable} overflow-hidden`}>
<ScrollArea className="h-screen w-full">
<TopNav />
<main className="flex justify-center p-4">
<main className="flex justify-center">
{children}
{modal}
<div id="modal-root" />
Expand Down
22 changes: 22 additions & 0 deletions src/components/back-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"use client"

import { useRouter } from "next/navigation"

import { Icons } from "./icons"
import { Button } from "./ui/button"

export function BackButton() {
const router = useRouter()
return (
<div className="absolute left-0 top-0 p-2">
<Button
onClick={() => router.back()}
size="icon"
variant="outline"
className="dark rounded-full"
>
<Icons.back className="size-4 text-white md:size-6" />
</Button>
</div>
)
}
5 changes: 3 additions & 2 deletions src/components/exit-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export function ExitButton() {
<Button
onClick={() => router.back()}
size="icon"
className="rounded-full"
variant="outline"
className="dark rounded-full"
>
<Icons.x className="size-6" />
<Icons.x className="size-4 text-white md:size-6" />
</Button>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/fullscreen-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export async function FullscreenButton(props: { photoId: number }) {
href={image.url}
aria-description="full res image url"
>
<Button className="rounded-full" size="icon">
<Icons.link className="h-6 w-6" />
<Button className="dark rounded-full" variant="outline" size="icon">
<Icons.link className="size-4 text-white md:size-6" />
</Button>
</Link>
</div>
Expand Down
126 changes: 2 additions & 124 deletions src/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Aperture,
ArrowLeft,
ArrowRightIcon as ArrowRight,
ExternalLink,
FileSymlink,
Expand All @@ -19,6 +20,7 @@ export const Icons = {
about: FileSymlink,
menu: Menu,
maximize: Maximize,
back: ArrowLeft,
x: X,
mountain: () => (
<svg
Expand Down Expand Up @@ -53,130 +55,6 @@ export const Icons = {
/>
</svg>
),
bridge: () => (
<svg
aria-labelledby="conf-city-title"
fill="black"
role="img"
viewBox="0 0 620 704"
width="620"
height="704"
xmlns="http://www.w3.org/2000/svg"
>
<title id="conf-city-title">
Line drawing of the Golden Gate Bridge in San Francisco.
</title>
<path d="M372.5 299.5L616.5 335" stroke="currentColor" />
<path
d="M370 16.5C429.833 101.833 562.9 284 616.5 330"
stroke="currentColor"
/>
<path
d="M329.5 34.5L325 36L322 38C321.333 38.5 320 39.6 320 40C320 40.4 319.333 41.1667 319 41.5L318.5 45.5V72L322.5 73M329.5 34.5C336.667 34 351.1 33 351.5 33C351.9 33 354 33.3333 355 33.5L356.5 34.5L358 36L358.5 38L358 70L357.5 70.5L354 72L350.5 73.5H330L322.5 73M329.5 34.5L324.5 38L323.5 40.5L322.5 43.5V73"
stroke="currentColor"
/>
<path d="M321 315V397H356.5" stroke="currentColor" />
<path
d="M332 234L329 240L328 241V245H327V251H326.5V261.5L325.5 262V289.5"
stroke="currentColor"
/>
<path
d="M-0.5 158.5L27 171.5L43.5 190L48.5 202L85 218.5L95.5 246.5C98.1667 254.333 103.7 270.6 104.5 273C105.5 276 117 291 119 294.5C121 298 125.5 307 127 310C128.5 313 142 324.5 145 328C147.4 330.8 154.333 338.833 157.5 342.5L164 358C167.5 362 174.9 370.5 176.5 372.5C178.5 375 191 386.5 193.5 390C196 393.5 200.5 403 202 405.5C203.2 407.5 205.5 415 206.5 418.5C207.833 422.833 210.7 432 211.5 434C212.3 436 216.833 451.5 219 459C221.333 464.5 226 476.6 226 481C226 486.5 223.5 497.5 223.5 500C223.5 502.5 222 503 230.5 512.5C239 522 245.5 529.5 247 532C248.2 534 255.5 546.5 259 552.5"
stroke="currentColor"
/>
<path
d="M164 357.5L206 353L237.5 345.5C242.667 345.5 254.5 345.5 260.5 345.5C268 345.5 277.5 342 279.5 341C281.1 340.2 289.5 337 293.5 335.5H305H309.5"
stroke="currentColor"
/>
<path
d="M309.5 314V399.5L306 402V411.5L303 414.5V433H262.5V440.5H420.5V433H381.5L380 416.5H375.5V402L373 400.5L372 184.5L370 15H371V11L369.5 10.5L366 6V3L364.5 1L363.5 2.5L363 6C308.667 47.5 163.6 137.8 18 167"
stroke="currentColor"
/>
<path
d="M352.5 14C347.333 14.6667 334.3 15.8 323.5 15C321.9 12.6 320.5 11 320 10.5V6L318.5 4.5L316.5 6V10C276.667 42 158 116.7 2 159.5"
stroke="currentColor"
/>
<path
d="M313 14V69.5L311.5 71.5V131.5L310 133V207L309 208.5V287"
stroke="currentColor"
/>
<path
d="M321 288.5V261.5H323V250.5H324.5V244H325.5V241L329.5 234.5L334.5 233.5H351L352 237.5L353.5 238.5L354 243L355 244.5V249L355.5 250.5L356 259.5V292.5L355.5 328.5L356.5 330.5V334V397.5"
stroke="currentColor"
/>
<path d="M214 440.5H262.5M420.5 440.5H622" stroke="currentColor" />
<path d="M404 475L427.059 474L453 475" stroke="currentColor" />
<path d="M585 454L594.882 453L606 454" stroke="currentColor" />
<path d="M543 450L552.882 449L564 450" stroke="currentColor" />
<path d="M339 511.5L379.5 508L424 511.5" stroke="currentColor" />
<path d="M339 577L393.318 573L453 577" stroke="currentColor" />
<path d="M453 703L547.818 695L652 703" stroke="currentColor" />
<path d="M460 536L505.741 533L556 536" stroke="currentColor" />
<path d="M508 467L531.347 465L557 467" stroke="currentColor" />
<path d="M315 455L338.347 453L364 455" stroke="currentColor" />
<path d="M449 453L464.247 451L481 453" stroke="currentColor" />
<path d="M252 487L275.347 484L301 487" stroke="currentColor" />
<path
d="M277.5 552.5L209.5 550L109.5 571L46 584.5L9.5 604H-22"
stroke="currentColor"
/>
<path
d="M355.5 318.5L117.5 293M113 286.5L355.5 313.5M373 315L616.5 346.5M373 321L567.5 346.5"
stroke="currentColor"
/>
<path d="M100.5 262L356 293M372.5 295L616 331.5" stroke="currentColor" />
<path
d="M372.5 330L388 328.5L401.5 329.5L411 328.5C413.167 328.5 417.6 328.5 418 328.5C418.4 328.5 423.833 328.167 426.5 328"
stroke="currentColor"
/>
<path
d="M513 440.5V433H568M568 433V346.5H616.5V320H622M568 433H622M591 433V364.5H595.5M604.5 433V364.5H595.5M595.5 364.5V433"
stroke="currentColor"
/>
<path
d="M323 165.5V208L328 209C334.5 209.167 347.6 209.4 348 209C348.4 208.6 350.833 208.5 352 208.5L356.5 204.5V199.5L356 198.5V195.5L357 195V170L355.5 168.5V164.5L355 163V160.5L351.5 156.5H331.5L329 159L326.5 159.5L325.5 161.5L324 162.5V165L323 165.5Z"
stroke="currentColor"
/>
<path
d="M329 159L327.5 162.5V166L326 166.5V171.5L325.5 172.5L326 208.5"
stroke="currentColor"
/>
<path
d="M333.5 92.5L326 93.5L324 95L322.5 96V98V100.5H321V103L319.5 104.5V132L324 134M333.5 92.5H354.5L357 95V97.5L357.5 99V129L356.5 130L356 132L353 133L349.5 134H324M333.5 92.5L327 94.5L326 97L325.5 101.5L324.5 102.5V105.5L324 107V134"
stroke="currentColor"
/>
<path d="M371 87C472.6 225.4 545 303 568.5 324.5" stroke="currentColor" />
<path d="M334.5 34C339 41.1667 350 58.2 358 69" stroke="currentColor" />
<path
d="M326 315.5L334.5 324V329.5L321.5 346M335.5 316.5L340 322L344 317.5M351.5 318L346 324V329.5L356.5 342M340 332.5L328 347.5H352.5L340 332.5Z"
stroke="currentColor"
/>
<path
d="M321 390L334.5 377L334.5 371.5L321 354.5M322 397L340 379L354.5 397M356.5 390L346 377L346 371.5L356.5 359.5M340 368.5L328 353.5L352.5 353.5L340 368.5Z"
stroke="currentColor"
/>
<path d="M325.5 315.5V341" stroke="currentColor" />
<path d="M325.5 360V385.5" stroke="currentColor" />
<path d="M355.5 310.5L123 283.5V270L356 297.5" stroke="currentColor" />
<path d="M372.5 311.5L616.5 344" stroke="currentColor" />
<path d="M86.5 149V222" stroke="currentColor" />
<path d="M122 137V265" stroke="currentColor" />
<path d="M155 124V268" stroke="currentColor" />
<path d="M188 109L188 273" stroke="currentColor" />
<path d="M220 93L220 276.5" stroke="currentColor" />
<path d="M251 77L251 280" stroke="currentColor" />
<path d="M281 60L281 284" stroke="currentColor" />
<path d="M391 46L391 298" stroke="currentColor" />
<path d="M417 82L417 302" stroke="currentColor" />
<path d="M441 115L441 305" stroke="currentColor" />
<path d="M465 147L465 309" stroke="currentColor" />
<path d="M488 178L488 312" stroke="currentColor" />
<path d="M511 208L511 316" stroke="currentColor" />
<path d="M532 235L532 319" stroke="currentColor" />
<path d="M553 261L553 322" stroke="currentColor" />
<path d="M571 282L571 325" stroke="currentColor" />
</svg>
),
alert: () => (
<svg
className="size-4 shrink-0 text-black"
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const buttonVariants = cva(
default: "h-10 px-4 py-2",
sm: "h-9 rounded-none px-3",
lg: "h-11 rounded-none px-8",
icon: "size-12",
icon: "size-10",
},
},
defaultVariants: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/sonner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
return (
<Sonner
theme={theme as ToasterProps["theme"]}
className="toaster group"
className="group"
toastOptions={{
classNames: {
toast:
Expand Down
47 changes: 47 additions & 0 deletions src/views/fullscreen-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Image from "next/image"

import { BackButton } from "~/components/back-button"
import { DeleteButton } from "~/components/delete-button"
import { FullscreenButton } from "~/components/fullscreen-button"
import { getImage } from "~/server/queries"

export async function FullscreenView(props: { photoId: string }) {
// convert the id string to a number
const idAsNumber = Number(props.photoId)
if (Number.isNaN(idAsNumber)) throw new Error("Invalid photo id")

const image = await getImage(idAsNumber)

return (
<div className="relative z-50 flex aspect-[8/5] w-full max-w-full items-center p-4 wide:h-full xl:taller-than-854:h-auto">
{/* Main image */}
<div className="w-full overflow-hidden">
<div className="relative flex items-center justify-center">
<Image
src={image.url}
width={1920}
height={1200}
priority
alt="Next.js Conf image"
/>
<OverlayMenu photoId={props.photoId} />
</div>
</div>
</div>
)
}

async function OverlayMenu(props: { photoId: string }) {
const idAsNumber = Number(props.photoId)
if (Number.isNaN(idAsNumber)) throw new Error("Invalid photo id")

const image = await getImage(idAsNumber)

return (
<>
<FullscreenButton photoId={image.id} />
<DeleteButton photoId={image.id} />
<BackButton />
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExitButton } from "~/components/exit-button"
import { FullscreenButton } from "~/components/fullscreen-button"
import { getImage } from "~/server/queries"

export async function FullPageImageView(props: { photoId: string }) {
export async function ModalPopup(props: { photoId: string }) {
// convert the id string to a number
const idAsNumber = Number(props.photoId)
if (Number.isNaN(idAsNumber)) throw new Error("Invalid photo id")
Expand Down

0 comments on commit f39ef5c

Please sign in to comment.