From 0703a802ffb6af2724efdcb696f1c51aaa6693d1 Mon Sep 17 00:00:00 2001 From: nmemmert Date: Mon, 11 May 2026 12:06:57 -0400 Subject: [PATCH] Refine Q&A share feedback and top back-to-site link --- src/App.css | 49 ++++++++++++++++++++++++++++++++++++ src/components/QASection.tsx | 42 ++++++++++++++++++++++++++----- 2 files changed, 85 insertions(+), 6 deletions(-) diff --git a/src/App.css b/src/App.css index 6c27a75..c090969 100644 --- a/src/App.css +++ b/src/App.css @@ -3274,6 +3274,33 @@ border-top: 1px solid rgba(201, 168, 76, 0.2); } +.qa-top-nav { + display: flex; + justify-content: flex-start; + margin-top: 0.85rem; + margin-bottom: 0.9rem; +} + +.qa-back-to-site { + display: inline-flex; + align-items: center; + border: 1px solid rgba(201, 168, 76, 0.3); + color: #d8c395; + text-decoration: none; + border-radius: 999px; + padding: 0.35rem 0.72rem; + font-size: 0.77rem; + letter-spacing: 0.05em; + text-transform: uppercase; + background: rgba(201, 168, 76, 0.06); +} + +.qa-back-to-site:hover { + color: #f0ddb3; + background: rgba(201, 168, 76, 0.14); + border-color: rgba(201, 168, 76, 0.45); +} + .qa-filters { display: flex; flex-direction: column; @@ -3702,6 +3729,13 @@ background: rgba(201, 168, 76, 0.14); } +.qa-share-feedback { + margin: -0.42rem 1rem 0.65rem; + color: #d8c392; + font-size: 0.76rem; + letter-spacing: 0.01em; +} + .qa-no-results { text-align: center; padding: 2rem; @@ -3817,6 +3851,16 @@ gap: 0.62rem; } + .qa-top-nav { + margin-top: 0.65rem; + margin-bottom: 0.72rem; + } + + .qa-back-to-site { + font-size: 0.73rem; + padding: 0.3rem 0.62rem; + } + .qa-card-face { padding: 0.15rem 0.82rem 0.86rem; } @@ -3825,6 +3869,11 @@ padding: 0 0.82rem 0.62rem; } + .qa-share-feedback { + margin: -0.38rem 0.82rem 0.62rem; + font-size: 0.74rem; + } + .qa-question-text { font-size: 0.97rem; line-height: 1.45; diff --git a/src/components/QASection.tsx b/src/components/QASection.tsx index 8572b73..e5aaf3b 100644 --- a/src/components/QASection.tsx +++ b/src/components/QASection.tsx @@ -215,6 +215,7 @@ export default function QASection() { const [engagement, setEngagement] = useState({}) const [expandedCompactAnswers, setExpandedCompactAnswers] = useState>({}) const [copiedQuestionId, setCopiedQuestionId] = useState(null) + const [copiedFacebookCaptionId, setCopiedFacebookCaptionId] = useState(null) const [loading, setLoading] = useState(true) const resultsTopRef = useRef(null) @@ -428,14 +429,31 @@ export default function QASection() { incrementEngagement(question.id, 'shares') } - const shareToFacebook = (id: string) => { - const url = getSocialUrl(id) + const shareToFacebook = async (question: DecoratedQuestion) => { + const url = getSocialUrl(question.id) + const answerSnippet = question.answer.replace(/\s+/g, ' ').trim() + const caption = [ + `Question: ${question.question}`, + `Answer: ${answerSnippet.length > 240 ? `${answerSnippet.slice(0, 237)}...` : answerSnippet}`, + 'What are your thoughts?' + ].join('\n\n') + + try { + await navigator.clipboard.writeText(caption) + setCopiedFacebookCaptionId(question.id) + window.setTimeout(() => { + setCopiedFacebookCaptionId(curr => (curr === question.id ? null : curr)) + }, 2500) + } catch { + window.prompt('Copy this caption and paste it into your post:', caption) + } + window.open( `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`, '_blank', 'noopener,noreferrer,width=600,height=500' ) - incrementEngagement(id, 'shares') + incrementEngagement(question.id, 'shares') } const formatDate = (value?: string) => { @@ -475,6 +493,9 @@ export default function QASection() { return (
+

Questions & Answers

@@ -638,6 +659,8 @@ export default function QASection() { const relatedQuestions = getRelatedQuestions(question) const isFocused = focusedQuestionId === question.id const isExpandedInCompact = expandedCompactAnswers[question.id] === true + const facebookCaptionCopied = copiedFacebookCaptionId === question.id + const linkCopied = copiedQuestionId === question.id const answerText = compactMode && !isExpandedInCompact ? truncateAnswer(question.answer) : question.answer @@ -672,15 +695,22 @@ export default function QASection() { type="button" aria-label="Share on Facebook" className="qa-social-btn qa-social-btn--fb" - onClick={() => shareToFacebook(question.id)} + onClick={() => shareToFacebook(question)} > - Share + {facebookCaptionCopied ? 'Caption copied' : 'Share'}
+ {(facebookCaptionCopied || linkCopied) && ( +

+ {facebookCaptionCopied + ? 'Caption copied. Paste it into your Facebook post text box.' + : 'Direct link copied to clipboard.'} +

+ )}
A