From 36b7d267233b59f585eb37ec6b1fd9594867bb78 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 17 Aug 2022 03:04:06 +0200 Subject: [PATCH] feat(frontend): add /u/[user] --- frontend/components/BlueLink.tsx | 14 +++++ frontend/components/Card.tsx | 28 +++++++++ frontend/components/FieldCard.tsx | 64 +++++++++++++++++++++ frontend/components/Navigation.tsx | 6 +- frontend/lib/fetch.ts | 8 ++- frontend/next.config.js | 12 +++- frontend/pages/_app.tsx | 4 ++ frontend/pages/api/hello.ts | 13 ----- frontend/pages/u/[user]/index.tsx | 92 ++++++++++++++++++++++++++++++ 9 files changed, 222 insertions(+), 19 deletions(-) create mode 100644 frontend/components/BlueLink.tsx create mode 100644 frontend/components/Card.tsx create mode 100644 frontend/components/FieldCard.tsx delete mode 100755 frontend/pages/api/hello.ts create mode 100644 frontend/pages/u/[user]/index.tsx diff --git a/frontend/components/BlueLink.tsx b/frontend/components/BlueLink.tsx new file mode 100644 index 0000000..706ebe4 --- /dev/null +++ b/frontend/components/BlueLink.tsx @@ -0,0 +1,14 @@ +import Link from "next/link"; + +export type Props = { + to: string; + children?: React.ReactNode; +}; + +export default function BlueLink({ to, children }: Props) { + return ( + + {children} + + ); +} diff --git a/frontend/components/Card.tsx b/frontend/components/Card.tsx new file mode 100644 index 0000000..92189ff --- /dev/null +++ b/frontend/components/Card.tsx @@ -0,0 +1,28 @@ +import React, { ReactNode } from "react"; + +export type Props = { + children?: ReactNode | undefined; + title: string; + draggable?: boolean; + footer?: ReactNode | undefined; +}; + +export default function Card({ title, draggable, children, footer }: Props) { + return ( +
+

+ {title} +

+
{children}
+ {footer && ( +
+ {footer} +
+ )} +
+ ); +} diff --git a/frontend/components/FieldCard.tsx b/frontend/components/FieldCard.tsx new file mode 100644 index 0000000..29711ea --- /dev/null +++ b/frontend/components/FieldCard.tsx @@ -0,0 +1,64 @@ +import { + HeartFill, + HandThumbsUp, + HandThumbsDown, + People, + EmojiLaughing, +} from "react-bootstrap-icons"; +import BlueLink from "./BlueLink"; + +import Card from "./Card"; +import type { Field } from "../lib/types"; + +function linkPronoun(input: string) { + if (input.includes(" ") || input.split("/").length !== 5) + return {input}; + + const [sub, obj, possDet, possPro, reflexive] = input.split("/"); + + return ( + + + {sub}/{obj}/{possDet} + + + ); +} + +export default function FieldCard({ + field, + draggable, +}: { + field: Field; + draggable?: boolean; +}) { + return ( + + {field.favourite?.map((entry) => ( +

+ {linkPronoun(entry)} +

+ ))} + {field.okay?.length !== 0 && ( +

+ {field.okay!.join(", ")} +

+ )} + {field.jokingly?.length !== 0 && ( +

+ {field.jokingly!.join(", ")} +

+ )} + {field.friends_only?.length !== 0 && ( +

+ {field.friends_only!.join(", ")} +

+ )} + {field.avoid?.length !== 0 && ( +

+ {field.avoid!.join(", ")} +

+ )} +
+ ); +} diff --git a/frontend/components/Navigation.tsx b/frontend/components/Navigation.tsx index 5463b8a..9f29cfc 100644 --- a/frontend/components/Navigation.tsx +++ b/frontend/components/Navigation.tsx @@ -72,8 +72,10 @@ export default function Navigation() {
- - + + + +