From 24b6e7ed5210c7b66908c82717ef6410c32d24be Mon Sep 17 00:00:00 2001 From: Myles Date: Tue, 11 Jun 2024 15:15:03 -0400 Subject: [PATCH 1/4] Improved column spacing, Mobile feedback, & sundry fixes --- app/components/Article/article.css | 18 ++++++-- app/components/Article/index.tsx | 62 ++++++++++++++++------------ app/components/Button/button.css | 4 +- app/components/Button/index.tsx | 11 ++++- app/components/Chatbot/index.tsx | 14 +++++-- app/components/Chatbot/widgit.css | 23 ++++++----- app/components/Feedback/feedback.css | 5 ++- app/root.tsx | 2 +- app/routes/categories.$.tsx | 7 +++- 9 files changed, 95 insertions(+), 51 deletions(-) diff --git a/app/components/Article/article.css b/app/components/Article/article.css index c0e60b3f..5e93cded 100644 --- a/app/components/Article/article.css +++ b/app/components/Article/article.css @@ -192,6 +192,18 @@ article .banner h3 .title { padding-left: 10px; } +.footer-comtainer .edited-container { + display: flex; + align-items: center; + gap: var(--spacing-16); +} + +.footer-comtainer .feeback-container { + display: flex; + flex-direction: column; + gap: var(--spacing-12); +} + @media (min-width: 780px) { article .link-popup { position: absolute; @@ -212,15 +224,15 @@ article .banner h3 .title { padding: 0; } article .footer-comtainer { - flex-direction: row; - flex-wrap: wrap; + flex-direction: column; + align-items: start; } article .link-popup { width: 100%; } article .footer-comtainer > div:nth-child(-n + 2) { - flex: 1 1; + margin-right: var(--spacing-12s); } article { margin: 0; diff --git a/app/components/Article/index.tsx b/app/components/Article/index.tsx index ec051960..cf7fa41e 100644 --- a/app/components/Article/index.tsx +++ b/app/components/Article/index.tsx @@ -9,10 +9,13 @@ import {tagUrl} from '~/routesMapper' import type {Glossary, Question, Banner as BannerType} from '~/server-utils/stampy' import Contents from './Contents' import './article.css' +import useIsMobile from '~/hooks/isMobile' const isLoading = ({text}: Question) => !text || text === 'Loading...' const ArticleFooter = (question: Question) => { + const mobile = useIsMobile() + const date = question.updatedAt && new Date(question.updatedAt).toLocaleDateString('en-GB', { @@ -23,33 +26,38 @@ const ArticleFooter = (question: Question) => { return ( !isLoading(question) && (
- {date &&
{`Updated ${date}`}
} - - - - - logFeedback({ - message, - option, - type: 'bot', - question: question.title || '', - answer: question.text || '', - }) - } - options={['Unclear', 'Too wordy', 'Confusing', 'Incorrect', 'Other']} - upHint="This page was helpful" - downHint="This page was unhelpful" - /> +
+ {date &&
{`Updated ${date}`}
} + + + +
+
+ {mobile &&

Was this page helpful?

} + + logFeedback({ + message, + option, + type: 'bot', + question: question.title || '', + answer: question.text || '', + }) + } + options={['Unclear', 'Too wordy', 'Confusing', 'Incorrect', 'Other']} + upHint="This page was helpful" + downHint="This page was unhelpful" + /> +
) ) diff --git a/app/components/Button/button.css b/app/components/Button/button.css index 0f4a5060..783d45da 100644 --- a/app/components/Button/button.css +++ b/app/components/Button/button.css @@ -232,8 +232,8 @@ align-items: center; padding: 7px; gap: var(--spacing-4); - min-width: min-content; - min-height: min-content; + max-width: min-content; + height: min-content; } .tooltip::after { diff --git a/app/components/Button/index.tsx b/app/components/Button/index.tsx index 2183cfdd..dbba0dbc 100644 --- a/app/components/Button/index.tsx +++ b/app/components/Button/index.tsx @@ -1,6 +1,7 @@ import {ReactNode} from 'react' import {Link} from '@remix-run/react' import './button.css' +import useIsMobile from '~/hooks/isMobile' type ButtonProps = { action?: string | (() => void) @@ -22,6 +23,8 @@ const Button = ({ active = false, props, }: ButtonProps) => { + const mobile = useIsMobile() + const classes = [ (secondary && 'button-secondary') || 'button', className, @@ -45,7 +48,9 @@ const Button = ({ {...props} > {children} - {secondary && tooltip && !disabled &&

{tooltip}

} + {secondary && tooltip && !disabled && !mobile && ( +

{tooltip}

+ )} ) } @@ -58,7 +63,9 @@ const Button = ({ {...props} > {children} - {secondary && tooltip && !disabled &&

{tooltip}

} + {secondary && tooltip && !disabled && !mobile && ( +

{tooltip}

+ )} ) } diff --git a/app/components/Chatbot/index.tsx b/app/components/Chatbot/index.tsx index 19aa754b..994ae7e8 100644 --- a/app/components/Chatbot/index.tsx +++ b/app/components/Chatbot/index.tsx @@ -14,6 +14,7 @@ import {questionUrl} from '~/routesMapper' import {Question} from '~/server-utils/stampy' import {useSearch} from '~/hooks/useSearch' import Input from '~/components/Input' +import useIsMobile from '~/hooks/isMobile' const MIN_SIMILARITY = 0.85 @@ -36,6 +37,7 @@ const QuestionInput = ({ const [question, setQuestion] = useState(initial || '') const {results, search, clear} = useSearch(1) const clickDetectorRef = useOutsideOnClick(() => handleChange('')) + const mobile = useIsMobile() const handleAsk = (val: string) => { clear() @@ -57,7 +59,10 @@ const QuestionInput = ({ return (
{results.length > 0 ? ( @@ -86,7 +91,7 @@ const QuestionInput = ({
{fixed &&
} -
+
{' '} Stampy can be inaccurate. Always verify its sources.
@@ -157,7 +162,7 @@ const Followups = ({title, followups, onSelect, className}: FollowupsProps) => { {items?.map(({text, pageid}, i) => (