diff --git a/components/TagBox/TagBox.module.css b/components/TagBox/TagBox.module.css new file mode 100644 index 0000000..7cc9300 --- /dev/null +++ b/components/TagBox/TagBox.module.css @@ -0,0 +1,36 @@ +.main { + width: 40%; + height: 1000px; + font-family: "Roboto", sans-serif; +} + +.banner { + display: flex; + flex-direction: row; + background-color: #17475f; + align-items: center; + padding: 10px; + color: white; + border-radius: 15px; + justify-content: space-between; + height: 140px; +} + +.tagtray { + display: flex; + width: 100%; + justify-content: center; + flex-direction: row; + margin: 10px 5px; +} + +.positive { + display: flex; + flex-direction: column; + align-items: center; +} +.negative { + display: flex; + flex-direction: column; + align-items: center; +} diff --git a/components/TagBox/TagBox.tsx b/components/TagBox/TagBox.tsx new file mode 100644 index 0000000..c45cffe --- /dev/null +++ b/components/TagBox/TagBox.tsx @@ -0,0 +1,172 @@ +import { Fab, TextField } from "@mui/material"; +import TagField from "components/TagField/TagField"; +import styles from "./TagBox.module.css"; +import ArrowForwardIosIcon from "@mui/icons-material/ArrowForwardIos"; +import { use, useEffect, useState } from "react"; + +const BannerText = [ + "1/4 VISUAL TEST", + "2/4 USABILITY TEST", + "3/4 CONTENT/MEDIA TEST", + "4/4 FUNCTIONALITY/RESPONSIVE TEST", +]; + +const BannerDesc = [ + "Information and user interface components must be presentable to users in ways they can perceive.", + "User interface components and navigation must be operable.", + "Information and the operation of user interface must be understandable.", + "Maximize compatibility with current and future user agents, including assistive technologies.", +]; + +const PTags = [ + [ + "Clear", + "Bright", + "Bold", + "Crisp", + "Eye-catching", + "Attractive", + "Colorful", + ], + [ + "Intuitive", + "Efficient", + "User-friendly", + "Responsive", + "Streamlined", + "Consistent", + "Accessible", + ], + [ + "Clear", + "Simple", + "Easy", + "Understandable", + "Plain", + "Illustrated", + "Straightforward", + ], + [ + "Compatible", + "Durable", + "Flexible", + "Adaptable", + "Reliable", + "Resilient", + "Accessible", + ], +]; +const NTags = [ + [ + "Dull", + "Faded", + "Blurred", + "Dim", + "Confusing", + "Unattractive", + "Poorly designed", + ], + [ + "Confusing", + "Unresponsive", + "Slow", + "Clumsy", + "Inconsistent", + "Unintuitive", + "Inaccessible", + ], + [ + "Complicated", + "Confusing", + "Vague", + "Unclear", + "Misleading", + "Inconsistent", + "Complex", + ], + [ + "Fragile", + "Incompatible", + "Limited", + "Unreliable", + "Ineffective", + "Unadaptable", + "Inaccessible", + ], +]; + +const TagBox = (props: { stage: number }) => { + const [selectedTags, setSelectedTags] = useState([] as string[]); + const [NTagsArr, setNTags] = useState([] as string[]); + const [PTagsArr, setPTags] = useState([] as string[]); + useEffect(() => { + setSelectedTags(() => [...PTagsArr, ...NTagsArr]); + }, [PTagsArr, NTagsArr]); + + const handlePTagChange = (tags: string[]) => { + setPTags(tags); + }; + const handleNTagChange = (tags: string[]) => { + setNTags(tags); + }; + return ( +
+
+
+

{BannerText[props.stage] + ":"}

+

{BannerDesc[props.stage]}

+
+ + NEXT + + +
+
+
+

Positive

+ +
+
+

Negative

+ +
+
+ {selectedTags.length !== 0 ? ( +

+ You have selected: + {" " + selectedTags.join(", ")} +

+ ) : ( + "" + )} +
+
+
+

Additional Remarks:

+ +
+
+ ); +}; + +export default TagBox; diff --git a/components/TagField/TagField.tsx b/components/TagField/TagField.tsx new file mode 100644 index 0000000..1197770 --- /dev/null +++ b/components/TagField/TagField.tsx @@ -0,0 +1,77 @@ +import { useEffect, useState } from "react"; +import type { Property } from "csstype"; +import { Tooltip } from "@mui/material"; + +const tagInput = { + backgroundColor: "transparent", + flexGrow: 1, + padding: "0.5em 0", + border: "none", + outline: "none", + fontSize: "16px", + width: "50px", +}; + +const tagContainer = { + border: "2px solid #DDE2E5", + flexWrap: "wrap" as Property.FlexWrap, + padding: "0.5em", + borderRadius: "3px", + width: "100%", + marginTop: "1em", + display: "flex", + alignItems: "center", + gap: "5px", +}; + +interface Props { + onChange: (tags: string[]) => void; + defaultTags: string[]; + isPositive: boolean; +} + +const TagField = ({ onChange, defaultTags, isPositive }: Props) => { + const [tags, setTags] = useState(defaultTags); + const [selectedTags, setSelectedTags] = useState([] as string[]); + useEffect(() => { + onChange(selectedTags); + }, [selectedTags]); + return ( +
+ {tags.map((tags, index) => ( +
{ + if (!selectedTags.includes(tags)) { + setSelectedTags(() => [...selectedTags, tags]); + } else { + setSelectedTags(selectedTags.filter((tag) => tag !== tags)); + } + return; + }} + style={{ + backgroundColor: isPositive ? "#21A25C" : "#E23737", + filter: selectedTags.includes(tags) ? "brightness(1.1)" : "", + display: "inline-block", + padding: "0.3em 0.5em", + border: selectedTags.includes(tags) + ? "5px solid #17475F" + : "5px solid transparent", + borderRadius: "20px", + cursor: "pointer", + }} + key={index} + > + + {tags} + +
+ ))} +
+ ); +}; + +export default TagField; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index e7f3e67..fd39d1e 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -8,11 +8,26 @@ import cx from "classnames"; import Image from "next/image"; import logo from "../../public/inclusion_lab_photo.png"; import { Router, useRouter } from "next/router"; +import { useEffect } from "react"; interface Props {} const Home: NextPage = (props): JSX.Element => { const Router = useRouter(); + + const fetchThing = async () => { + const response = await fetch( + "https://asia-southeast1-starlit-array-328711.cloudfunctions.net/hack4good/api/assessments/twilio", + { mode: "cors" } + ); + const data = await response.json(); + console.log(data); + }; + + useEffect(() => { + fetchThing(); + }, []); + return ( <> diff --git a/src/pages/temp/index.tsx b/src/pages/temp/index.tsx new file mode 100644 index 0000000..1b489f2 --- /dev/null +++ b/src/pages/temp/index.tsx @@ -0,0 +1,5 @@ +import TagBox from "components/TagBox/TagBox"; + +export default function temp() { + return ; +}