From 28377d7af6b2bd24b30e9742aaed7b9b807bd12a Mon Sep 17 00:00:00 2001 From: Lucas Homer Date: Thu, 6 Feb 2020 20:02:18 -0800 Subject: [PATCH] updating styles and ui cleanup for FAQ page --- client/src/components/Faq.js | 48 ++++++++++++++++++++---------- client/src/components/FaqItem.js | 50 ++++++++++++++++++++++---------- client/src/components/FaqList.js | 15 ++++++++-- 3 files changed, 80 insertions(+), 33 deletions(-) diff --git a/client/src/components/Faq.js b/client/src/components/Faq.js index 1cacf7d80..d7d2f14e6 100644 --- a/client/src/components/Faq.js +++ b/client/src/components/Faq.js @@ -6,9 +6,25 @@ import { AddButton, EditButton } from "./Buttons"; import FaqList from "./FaqList"; import Container from "@material-ui/core/Container"; +import Typography from "@material-ui/core/Typography"; import { Link } from "react-router-dom"; +import { makeStyles } from "@material-ui/core"; + +const useStyles = makeStyles(() => ({ + title: { + margin: "2rem", + }, + buttonsContainer: { + display: "flex", + justifyContent: "space-between", + }, + link: { + textDecoration: "none", + }, +})); const Faq = () => { + const classes = useStyles(); const [faqs, setFaqs] = useState([]); const { t, i18n } = useTranslation("faq"); const [message, setMessage] = useState("FAQs are loading..."); @@ -25,7 +41,7 @@ const Faq = () => { try { let twoLetterLanguage = i18n.language.slice(0, 2); const fetchedFaqs = await faqService.getAllByLanguage({ - language: twoLetterLanguage + language: twoLetterLanguage, }); if (fetchedFaqs.length > 0) { let sorted = fetchedFaqs; @@ -33,7 +49,7 @@ const Faq = () => { sorted = fetchedFaqs.sort( (a, b) => a.identifier.slice(0, a.identifier.indexOf(":")) - - b.identifier.slice(0, b.identifier.indexOf(":")) + b.identifier.slice(0, b.identifier.indexOf(":")), ); } setFaqs(sorted); @@ -73,8 +89,8 @@ const Faq = () => { 1 + firstIdentifier.slice( firstIdentifier.indexOf(":"), - firstIdentifier.length - ) + firstIdentifier.length, + ), }; atSecondIndex = { ...currentFaqs[order - 2], @@ -82,8 +98,8 @@ const Faq = () => { Number(order) + secondIdentifier.slice( secondIdentifier.indexOf(":"), - secondIdentifier.length - ) + secondIdentifier.length, + ), }; currentFaqs[order - 1] = atSecondIndex; currentFaqs[order - 2] = atFirstIndex; @@ -98,8 +114,8 @@ const Faq = () => { 1 + firstIdentifier.slice( firstIdentifier.indexOf(":"), - firstIdentifier.length - ) + firstIdentifier.length, + ), }; atSecondIndex = { ...currentFaqs[order], @@ -107,8 +123,8 @@ const Faq = () => { Number(order) + secondIdentifier.slice( secondIdentifier.indexOf(":"), - secondIdentifier.length - ) + secondIdentifier.length, + ), }; currentFaqs[order - 1] = atSecondIndex; currentFaqs[order] = atFirstIndex; @@ -121,14 +137,16 @@ const Faq = () => { }; return ( - -

{t("title")}

+ + + {t("title")} + {user => user && user.isAdmin && ( - <> - +
+ { onClick={onReorderClick} color={reorder ? "secondary" : "primary"} /> - +
) }
diff --git a/client/src/components/FaqItem.js b/client/src/components/FaqItem.js index c5b43fc58..235ccbe47 100644 --- a/client/src/components/FaqItem.js +++ b/client/src/components/FaqItem.js @@ -3,26 +3,39 @@ import { Link } from "react-router-dom"; import { makeStyles } from "@material-ui/styles"; import { UserContext } from "./user-context"; import { EditButton, MoveUpButton, MoveDownButton } from "./Buttons"; +import { Typography } from "@material-ui/core"; const useStyles = makeStyles({ edit: { - marginBottom: "10px", + marginBottom: "2rem", border: "10px solid #FAEBD7", "& h4, h6, div": { fontSize: "1rem", - margin: "0.5rem" - } + margin: "0.5rem", + }, + }, + readOnly: { + marginBottom: "2rem", }, editBar: { display: "flex", alignItems: "center", - justifyContent: "space-around", - backgroundColor: "rgb(249, 192, 88)", - height: "2.5rem" + justifyContent: "space-between", + backgroundColor: "rgb(241, 241, 241)", }, hide: { - display: "none" - } + display: "none", + }, + link: { + textDecoration: "none", + }, + identifier: { + height: "100%", + marginLeft: "1rem", + }, + faqText: { + padding: "1rem", + }, }); const FaqItem = ({ faq, reorder, reorderFaqs, faqLength }) => { @@ -31,7 +44,7 @@ const FaqItem = ({ faq, reorder, reorderFaqs, faqLength }) => { const identifier = faq.identifier.includes(":") ? faq.identifier.slice( faq.identifier.indexOf(":") + 1, - faq.identifier.length + faq.identifier.length, ) : faq.identifier; const order = @@ -39,13 +52,15 @@ const FaqItem = ({ faq, reorder, reorderFaqs, faqLength }) => { faq.identifier.slice(0, faq.identifier.indexOf(":")); return ( -
  • +
  • {user => user && user.isAdmin && (
    -

    Identifier: {identifier}

    + + {identifier} + {reorder ? ( <> { /> ) : ( - - + + )}
    ) }
    -

    {faq.question}

    -
    +
    + {faq.question} + +
  • ); }; diff --git a/client/src/components/FaqList.js b/client/src/components/FaqList.js index 9359bb814..29a9022fc 100644 --- a/client/src/components/FaqList.js +++ b/client/src/components/FaqList.js @@ -4,17 +4,26 @@ import { makeStyles } from "@material-ui/styles"; import FaqItem from "./FaqItem"; const useStyles = makeStyles({ + readOnly: { + listStyle: "none", + padding: "0", + display: "flex", + flexDirection: "column", + }, edit: { listStyle: "none", - fontSize: "2rem" - } + fontSize: "2rem", + padding: "0", + display: "flex", + flexDirection: "column", + }, }); const FaqList = ({ faqs, message, reorder, reorderFaqs }) => { const classes = useStyles(); return faqs.length ? ( -
      +
        {faqs.map(faq => (