From 793b408e3ff1e90c1d513096d47cdf2e8336afdb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 1 Apr 2026 12:56:23 -0500 Subject: [PATCH] Fix encrypted letter envelope to show back (mailing) side first The envelope previously showed flap-like V-fold lines on both sides, which doesn't match how real envelopes work. Now the default view shows the back/mailing side with sender name top-left and recipient name centered, then flipping reveals the front with the triangular flap and wax seal, and clicking opens the flap to reveal the Nushu ciphertext. --- src/components/EncryptedLetterContent.tsx | 154 ++++++++++++---------- 1 file changed, 88 insertions(+), 66 deletions(-) diff --git a/src/components/EncryptedLetterContent.tsx b/src/components/EncryptedLetterContent.tsx index aa42d083..e36568b5 100644 --- a/src/components/EncryptedLetterContent.tsx +++ b/src/components/EncryptedLetterContent.tsx @@ -4,9 +4,9 @@ * Public display for kind 8211 encrypted letters. Instead of showing raw * ciphertext, renders a 3D interactive envelope: * - * 1. Back (default) — sealed envelope with sender & recipient names in script font - * 2. Flip — click to flip envelope over (CSS 3D transform) - * 3. Open — click again to open, revealing Nushu script representation of the ciphertext + * 1. Back (default) — mailing side: sender top-left, recipient centered + * 2. Flip — click to flip to the front (flap side) with wax seal + * 3. Open — click again to open the flap, revealing Nushu script ciphertext * * Nushu (Unicode U+1B170-U+1B2FF) is a real historical secret women's script * from China — visible, beautiful, unreadable. It represents modern encryption @@ -69,16 +69,18 @@ function ciphertextToNushu(ciphertext: string, maxChars = 36): string { // Participant display // --------------------------------------------------------------------------- -function NameLabel({ pubkey, prefix }: { pubkey: string; prefix: string }) { +function NameLabel({ pubkey, prefix, size = 'md' }: { pubkey: string; prefix?: string; size?: 'sm' | 'md' | 'lg' }) { const author = useAuthor(pubkey); const metadata = author.data?.metadata; const displayName = getDisplayName(metadata, pubkey); const profileUrl = useProfileUrl(pubkey, metadata); + const fontSize = size === 'lg' ? '1.6rem' : size === 'sm' ? '0.95rem' : '1.15rem'; + if (author.isLoading) { return ( - {prefix} + {prefix && {prefix}} ); @@ -86,13 +88,13 @@ function NameLabel({ pubkey, prefix }: { pubkey: string; prefix: string }) { return ( - {prefix} + {prefix && {prefix}} e.stopPropagation()} className="font-semibold truncate hover:underline transition-colors" - style={{ fontFamily: "'Caveat', 'Pacifico', cursive", fontSize: '1.15rem' }} + style={{ fontFamily: "'Caveat', 'Pacifico', cursive", fontSize }} > {displayName} @@ -211,9 +213,9 @@ export function EncryptedLetterContent({ event, compact, className }: EncryptedL }} aria-label={ state === 'back' - ? 'Sealed envelope — click to flip' + ? 'Envelope back — click to flip to the front' : state === 'front' - ? 'Click to open the envelope' + ? 'Sealed envelope — click to open the flap' : 'Encrypted letter — click to close' } > @@ -225,7 +227,7 @@ export function EncryptedLetterContent({ event, compact, className }: EncryptedL aspectRatio: compact ? '16 / 9' : '4 / 3', }} > - {/* ========================= BACK FACE ========================= */} + {/* ============= BACK FACE (mailing side — shown first) ============= */}
- {/* V-fold lines */} - - - - - - - - {/* Wax seal in center */} -
-
- -
+ {/* Sender — top-left (return address, smaller) */} +
+
- {/* Names — sender top-left, recipient bottom-right */} -
-
- -
- {!compact && ( -
- -
- )} + {/* Recipient — centered (mailing address, larger) */} +
+
{/* Subtle shadow edges */} @@ -297,7 +270,7 @@ export function EncryptedLetterContent({ event, compact, className }: EncryptedL />
- {/* ========================= FRONT FACE ========================= */} + {/* ============= FRONT FACE (flap side — shown after flip) ============= */}
- {/* Flap */} -
- + {/* Paper texture */} +
+ + {/* V-fold crease lines (bottom corners only — top is covered by the flap) */} + + + + + + {/* Flap — triangular top portion that opens upward */} +
+ - - - + + + + {/* Flap body */} + {/* Crease line */}
- {/* Letter content area — slides up when opened */} + {/* Wax seal — centered */} +
+
+ +
+
+ + {/* Letter content area — slides up when flap is opened */}
- {/* Inner letter sheet — flex column so the notice always stays visible */} + {/* Inner letter sheet */}
- {/* Nushu ciphertext — scrollable with bottom fade hint */} + {/* Nushu ciphertext */}

{nushuText}

- {/* Sticky fade hint at the bottom */} + {/* Fade hint */}
- {/* Encrypted message notice — always visible */} + {/* Encrypted message notice */}