-
Notifications
You must be signed in to change notification settings - Fork 0
New book open animation. #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| "use client" | ||
|
|
||
| import React, { useState } from "react" | ||
| import { BookStickerInstruction } from "@/components/book-sticker-instruction" | ||
| import { Button } from "@/components/ui/button" | ||
| import { RefreshCw } from "lucide-react" | ||
|
|
||
| export default function BookInstructionShowcasePage() { | ||
| const [code, setCode] = useState("ABCD-1234") | ||
| const [key, setKey] = useState(0) | ||
|
|
||
| const regenerate = () => { | ||
| const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | ||
| let newCode = "" | ||
| for (let i = 0; i < 4; i++) newCode += chars.charAt(Math.floor(Math.random() * chars.length)) | ||
| newCode += "-" | ||
| for (let i = 0; i < 4; i++) newCode += chars.charAt(Math.floor(Math.random() * chars.length)) | ||
| setCode(newCode) | ||
| setKey((prev) => prev + 1) | ||
| } | ||
|
|
||
| return ( | ||
| <div className="min-h-screen bg-stone-100 p-8 flex flex-col items-center justify-center space-y-12"> | ||
| <div className="max-w-2xl text-center space-y-4"> | ||
| <h1 className="text-4xl font-serif font-bold text-stone-800"> | ||
| Tracking Instruction Showcase | ||
| </h1> | ||
| <p className="text-stone-600">Visualizing the "Inside Cover" instruction component.</p> | ||
| </div> | ||
|
|
||
| <div className="w-full max-w-md bg-white p-8 rounded-xl shadow-xl border border-stone-200"> | ||
| <h2 className="text-xl font-bold text-center mb-6 text-stone-700">Component Demo</h2> | ||
|
|
||
| {/* The component under test */} | ||
| <BookStickerInstruction | ||
| code={code} | ||
| coverUrl="http://books.google.com/books/content?id=B1hSG45JCX4C&printsec=frontcover&img=1&zoom=1&source=gbs_api" | ||
|
||
| /> | ||
|
|
||
| <div className="mt-8 flex justify-center"> | ||
| <Button onClick={regenerate} variant="outline" className="gap-2"> | ||
| <RefreshCw className="w-4 h-4" /> | ||
| Generate New Code | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,266 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "use client" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useState, useEffect } from "react" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Check, Copy } from "lucide-react" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { motion, AnimatePresence } from "framer-motion" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { motion, AnimatePresence } from "framer-motion" | |
| import { motion } from "framer-motion" |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The as any type assertions used here to bypass TypeScript's strict variant typing are not ideal. Consider using proper type definitions or defining a more specific type for the transition object. This pattern appears twice (lines 46 and 55) and can hide potential type errors.
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback image URL /images/placeholder-cover.jpg may not exist. Consider either ensuring this asset exists in the public directory, or handling the case where no cover is provided more gracefully (e.g., showing a generic placeholder component).
| // Fallback cover if none provided | |
| const finalCoverUrl = coverUrl || "/images/placeholder-cover.jpg" | |
| // Fallback cover if none provided: use an inline SVG data URL so it always exists | |
| const placeholderCoverSvg = | |
| 'data:image/svg+xml;utf8,' + | |
| encodeURIComponent( | |
| `<svg xmlns="http://www.w3.org/2000/svg" width="400" height="600" viewBox="0 0 400 600"> | |
| <defs> | |
| <linearGradient id="grad" x1="0" y1="0" x2="1" y2="1"> | |
| <stop offset="0%" stop-color="#f5f5f4"/> | |
| <stop offset="100%" stop-color="#e7e5e4"/> | |
| </linearGradient> | |
| </defs> | |
| <rect width="400" height="600" fill="url(#grad)" rx="24" ry="24"/> | |
| <rect x="36" y="60" width="328" height="36" fill="#a8a29e" opacity="0.35" rx="6"/> | |
| <rect x="36" y="116" width="328" height="20" fill="#a8a29e" opacity="0.2" rx="4"/> | |
| <rect x="36" y="146" width="260" height="20" fill="#a8a29e" opacity="0.2" rx="4"/> | |
| <rect x="36" y="176" width="220" height="20" fill="#a8a29e" opacity="0.2" rx="4"/> | |
| <rect x="36" y="230" width="328" height="260" fill="#d6d3d1" opacity="0.35" rx="12"/> | |
| <text x="50%" y="520" text-anchor="middle" font-family="system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif" font-size="20" fill="#78716c"> | |
| Book cover | |
| </text> | |
| </svg>` | |
| ) | |
| const finalCoverUrl = coverUrl || placeholderCoverSvg |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable finalCoverUrl.
| // Fallback cover if none provided | |
| const finalCoverUrl = coverUrl || "/images/placeholder-cover.jpg" |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing alt text for the book cover image. The alt attribute should provide meaningful description of the book cover for accessibility purposes, not just "Book Cover". Consider using the book title or description if available.
| alt="Book Cover" | |
| alt="Illustrated book cover" |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coverUrl is used directly in an img src without validation. Consider adding error handling for failed image loads (e.g., using the onError event) to prevent broken image displays and provide a better user experience.
| className="w-full h-full opacity-90 mix-blend-overlay" | |
| className="w-full h-full opacity-90 mix-blend-overlay" | |
| onError={(e) => { | |
| e.currentTarget.style.display = "none" | |
| }} |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an external texture URL from transparenttextures.com creates a dependency on a third-party service. If this service goes down, the texture will fail to load. Consider hosting the texture locally or inlining it as a data URI for better reliability.
| <div className="absolute inset-0 bg-[url('https://www.transparenttextures.com/patterns/leather.png')] opacity-30 mix-blend-multiply" /> | |
| <div className="absolute inset-0 bg-[radial-gradient(circle_at_20%_20%,rgba(0,0,0,0.15),transparent_50%),radial-gradient(circle_at_80%_80%,rgba(0,0,0,0.2),transparent_55%)] opacity-30 mix-blend-multiply" /> |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copy button and code text are only accessible via hover (group-hover/code). This creates accessibility issues for keyboard-only users and touch device users who cannot hover. Consider making the copy button always visible or providing an alternative interaction method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused variable key.