From dadb688c50400c15ca86aafbd4c84904c4fa5c5b Mon Sep 17 00:00:00 2001 From: ramvignesh-b Date: Sun, 26 Apr 2026 00:55:19 +0530 Subject: [PATCH] refactor: modularize envelope reveal and logo components for easier usage across the site --- frontend/src/components/Logo.tsx | 20 +-- .../src/components/reader/EnvelopeReveal.tsx | 155 +++++++++--------- frontend/src/index.css | 95 +++++------ frontend/src/pages/Reader.tsx | 28 ++-- 4 files changed, 147 insertions(+), 151 deletions(-) diff --git a/frontend/src/components/Logo.tsx b/frontend/src/components/Logo.tsx index 672c2cb..d7874a6 100644 --- a/frontend/src/components/Logo.tsx +++ b/frontend/src/components/Logo.tsx @@ -1,26 +1,26 @@ import { DotIcon } from "@phosphor-icons/react"; import "@fontsource/knewave/400.css"; -export default function Logo() { +export default function Logo({ scale = 2 }) { return ( - -  Pi +  Pi -  Ku +  Ku - + ); } diff --git a/frontend/src/components/reader/EnvelopeReveal.tsx b/frontend/src/components/reader/EnvelopeReveal.tsx index 1ca6118..beaebed 100644 --- a/frontend/src/components/reader/EnvelopeReveal.tsx +++ b/frontend/src/components/reader/EnvelopeReveal.tsx @@ -8,6 +8,7 @@ export interface EnvelopeRevealProps { date?: string; onRevealComplete: () => void; ignite: boolean; + isFlip?: boolean; } export function EnvelopeReveal({ @@ -15,9 +16,14 @@ export function EnvelopeReveal({ date, onRevealComplete, ignite, + isFlip, }: EnvelopeRevealProps) { const [revealLetter, setRevealLetter] = useState(false); - const [isFlipped, setIsFlipped] = useState(false); + const [isFlipped, setIsFlipped] = useState(!!isFlip); + + useEffect(() => { + setIsFlipped(!!isFlip); + }, [isFlip]); const [burn, setBurn] = useState<{ width: number; height: number }>({ width: 0, @@ -27,7 +33,10 @@ export function EnvelopeReveal({ const flapCheckbox = useRef(null); useEffect(() => { - if (!ignite) return; + if (!ignite) { + setBurn({ width: 0, height: 0 }); + return; + } const burnInterval = setInterval(() => { setBurn((prev) => ({ width: prev.width + 4, height: prev.height + 6 })); }, 100); @@ -43,90 +52,86 @@ export function EnvelopeReveal({ }; return ( -
-
+ <> +
-
- -
- Seal flapCheckbox.current?.click()} - onKeyDown={() => flapCheckbox.current?.click()} + - - -
-
-
- + Seal flapCheckbox.current?.click()} + onKeyDown={() => flapCheckbox.current?.click()} + /> + id="letter" + className={`absolute mx-auto transition-all peer-has-checked:delay-800 peer-has-checked:duration-1000 duration-1000 mt-2 h-55 w-105 bg-paper peer-has-checked:-mt-12 hover:-mt-24 cursor-pointer ${revealLetter ? "duration-1000 peer-has-checked:duration-3000 w-screen max-w-4xl h-screen z-101 -translate-y-90" : "peer-has-checked:z-1"}`} + onClick={handleClick} + > + +
+
+
+ +
{ignite && ( -
+
)} -
+ ); } diff --git a/frontend/src/index.css b/frontend/src/index.css index a6ea54f..d2a940c 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -2,73 +2,60 @@ @plugin "daisyui"; @plugin "daisyui/theme" { - name: "piku"; - default: true; - prefersdark: true; - color-scheme: dark; + name: "piku"; + default: true; + prefersdark: true; + color-scheme: dark; - /* ── Base surfaces ── */ - --color-base-100: oklch(14% 0.012 35); /* was 0.018 hue 50 */ - --color-base-200: oklch(18% 0.014 33); - --color-base-300: oklch(22% 0.016 32); - --color-base-content: oklch( - 82% 0.02 70 - ); /* aged parchment, not crisp white */ + --color-base-100: oklch(14% 0.012 35); + --color-base-200: oklch(18% 0.014 33); + --color-base-300: oklch(22% 0.016 32); + --color-base-content: oklch(82% 0.02 70); - /* ── Primary: old lamp gold — warm, incandescent ── */ - --color-primary: oklch(67% 0.11 78); - --color-primary-content: oklch(15% 0.03 70); + --color-primary: oklch(67% 0.11 78); + --color-primary-content: oklch(15% 0.03 70); - /* ── Secondary: dusty plum ── */ - --color-secondary: oklch(48% 0.08 305); - --color-secondary-content: oklch(92% 0.01 305); + --color-secondary: oklch(48% 0.08 305); + --color-secondary-content: oklch(92% 0.01 305); - /* ── Accent: muted lavender-clay ── */ - --color-accent: oklch(55% 0.06 325); - --color-accent-content: oklch(18% 0.03 295); + --color-accent: oklch(55% 0.06 325); + --color-accent-content: oklch(18% 0.03 295); - /* ── Neutral: warm stone ── */ - --color-neutral: oklch(28% 0.02 45); - --color-neutral-content: oklch(80% 0.015 60); + --color-neutral: oklch(28% 0.02 45); + --color-neutral-content: oklch(80% 0.015 60); - /* ── Semantic — desaturated, no alarm ── */ - --color-info: oklch(60% 0.07 240); - --color-info-content: oklch(95% 0.01 240); - --color-success: oklch(60% 0.08 150); - --color-success-content: oklch(16% 0.03 150); - --color-warning: oklch(68% 0.08 72); /* honey, not caution-sign amber */ - --color-warning-content: oklch(18% 0.03 60); - --color-error: oklch(55% 0.1 22); - --color-error-content: oklch(92% 0.01 22); + --color-info: oklch(60% 0.07 240); + --color-info-content: oklch(95% 0.01 240); + --color-success: oklch(60% 0.08 150); + --color-success-content: oklch(16% 0.03 150); + --color-warning: oklch(68% 0.08 72); + --color-warning-content: oklch(18% 0.03 60); + --color-error: oklch(55% 0.1 22); + --color-error-content: oklch(92% 0.01 22); - /* ── Shape ── */ - --radius-selector: 0.5rem; - --radius-field: 0.375rem; - --radius-box: 0.5rem; + --radius-selector: 0.5rem; + --radius-field: 0.375rem; + --radius-box: 0.5rem; - /* ── Effects ── */ - --depth: 1; - --noise: 0.03; + --depth: 1; + --noise: 0.03; - /* ── Border ── */ - --border: 1px; + --border: 1px; } @theme { - --font-display: "Playwrite HR Lijeva Variable", cursive; - --font-sans: "Jost Variable", sans-serif; - --font-serif: "Playfair Display Variable", serif; - --color-glass-bg: rgba( - 28, - 22, - 16, - 0.45 - ); /* slightly deeper to match new base */ - --shadow-warm: 0 20px 50px -12px rgba(30, 20, 12, 0.6); - --radius-xl: 1.5rem; - --color-paper: oklch(97% 0.008 80); + --font-display: "Playwrite HR Lijeva Variable", cursive; + --font-sans: "Jost Variable", sans-serif; + --font-serif: "Playfair Display Variable", serif; + --color-glass-bg: rgba(28, + 22, + 16, + 0.45); + --shadow-warm: 0 20px 50px -12px rgba(30, 20, 12, 0.6); + --radius-xl: 1.5rem; + --color-paper: oklch(97% 0.008 80); } .glass-card { - @apply bg-glass-bg backdrop-blur-xl border border-white/5 shadow-warm rounded-xl; + @apply bg-glass-bg backdrop-blur-xl border border-white/5 shadow-warm rounded-xl; } diff --git a/frontend/src/pages/Reader.tsx b/frontend/src/pages/Reader.tsx index 3f9a38b..ef09c98 100644 --- a/frontend/src/pages/Reader.tsx +++ b/frontend/src/pages/Reader.tsx @@ -244,23 +244,27 @@ export default function Reader() {
{revealState === "sealed" && ( - setRevealState("revealed")} - ignite={ignite} - /> +
+
+ setRevealState("revealed")} + ignite={ignite} + /> +
+
)}
@@ -275,7 +279,7 @@ export default function Reader() { /> {revealState === "revealed" && ( -
+