From 68939f5e10b13f6c883db2354f0bfe339f3359fb Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 3 Jan 2023 00:07:10 +0100 Subject: [PATCH] feat: slightly improve card layout + edit profile page --- frontend/components/Button.tsx | 10 ++++-- frontend/components/Card.tsx | 4 +-- frontend/components/Editable.tsx | 51 ++++++++++++++++-------------- frontend/components/PersonPage.tsx | 14 +++----- frontend/pages/edit/profile.tsx | 7 ++-- 5 files changed, 46 insertions(+), 40 deletions(-) diff --git a/frontend/components/Button.tsx b/frontend/components/Button.tsx index 74cb7c6..ab0518f 100644 --- a/frontend/components/Button.tsx +++ b/frontend/components/Button.tsx @@ -10,6 +10,7 @@ export interface Props { onClick?: MouseEventHandler; style?: ButtonStyle; bold?: boolean; + disabled?: boolean; noRound?: boolean; children?: ReactNode; } @@ -33,10 +34,11 @@ function PrimaryButton(props: Props) { return ( @@ -47,10 +49,11 @@ function SuccessButton(props: Props) { return ( @@ -61,10 +64,11 @@ function DangerButton(props: Props) { return ( diff --git a/frontend/components/Card.tsx b/frontend/components/Card.tsx index 92189ff..60710f7 100644 --- a/frontend/components/Card.tsx +++ b/frontend/components/Card.tsx @@ -9,7 +9,7 @@ export type Props = { export default function Card({ title, draggable, children, footer }: Props) { return ( -
+

{children}
{footer && ( -
+
{footer}
)} diff --git a/frontend/components/Editable.tsx b/frontend/components/Editable.tsx index d38c79c..7c4ab7b 100644 --- a/frontend/components/Editable.tsx +++ b/frontend/components/Editable.tsx @@ -48,11 +48,28 @@ export function EditableCard(props: EditableCardProps) { const [input, setInput] = useState(""); const footer = ( -
- - +
+
+ setInput(e.target.value)} /> + +
+
+ + +
); @@ -76,7 +93,7 @@ export function EditableCard(props: EditableCardProps) { choice == PronounChoice.favourite ? "bg-slate-500" : "bg-slate-600" - } hover:bg-slate-400 p-2`} + } text-white hover:bg-slate-400 p-2`} > @@ -87,7 +104,7 @@ export function EditableCard(props: EditableCardProps) { choice == PronounChoice.okay ? "bg-slate-500" : "bg-slate-600" - } hover:bg-slate-400 p-2`} + } text-white hover:bg-slate-400 p-2`} > @@ -98,7 +115,7 @@ export function EditableCard(props: EditableCardProps) { choice == PronounChoice.jokingly ? "bg-slate-500" : "bg-slate-600" - } hover:bg-slate-400 p-2`} + } text-white hover:bg-slate-400 p-2`} > @@ -109,7 +126,7 @@ export function EditableCard(props: EditableCardProps) { choice == PronounChoice.friendsOnly ? "bg-slate-500" : "bg-slate-600" - } hover:bg-slate-400 p-2`} + } text-white hover:bg-slate-400 p-2`} > @@ -120,7 +137,7 @@ export function EditableCard(props: EditableCardProps) { choice == PronounChoice.avoid ? "bg-slate-500" : "bg-slate-600" - } hover:bg-slate-400 p-2`} + } text-white hover:bg-slate-400 p-2`} > @@ -135,20 +152,6 @@ export function EditableCard(props: EditableCardProps) { ); })} -
  • - setInput(e.target.value)} /> - -
  • ); diff --git a/frontend/components/PersonPage.tsx b/frontend/components/PersonPage.tsx index 97a8586..5620741 100644 --- a/frontend/components/PersonPage.tsx +++ b/frontend/components/PersonPage.tsx @@ -260,15 +260,11 @@ function FieldCard({ }) { return ( - {labelStatusOrder.map((status, i) => ( - x.status === status) - .map((x) => x.display())} - /> - ))} + {labelStatusOrder.map((status, i) => + field.labels + .filter((x) => x.status === status) + .map((x) => ) + )} ); } diff --git a/frontend/pages/edit/profile.tsx b/frontend/pages/edit/profile.tsx index 87ef663..e7dbe25 100644 --- a/frontend/pages/edit/profile.tsx +++ b/frontend/pages/edit/profile.tsx @@ -63,9 +63,12 @@ export default function Index() { const addField = () => { if (fields.length >= 25) return; - const lastId = fields[fields.length - 1]?.id ?? 0; + const lastId = fields[fields.length - 1]?.id ?? -1; - setFields([...fields, { id: lastId + 1, name: "", pronouns: {} }]); + setFields([ + ...fields, + { id: lastId + 1, name: `Field #${lastId + 2}`, pronouns: {} }, + ]); }; useEffect(() => {