From f61f582a9b003c89636b692b1014683ac913440e Mon Sep 17 00:00:00 2001 From: rsandb Date: Tue, 10 Jan 2023 18:48:14 -0600 Subject: [PATCH] Integrate Dashboard with Messages/Styling Changes --- website/src/components/FlaggableElement.tsx | 6 +- website/src/components/Header/UserMenu.tsx | 2 - .../src/components/Loading/LoadingScreen.jsx | 16 ++---- .../components/Messages/MessageTableEntry.tsx | 35 ++++++------ .../Messages/MessageWithChildren.tsx | 55 ++++++++++--------- website/src/components/SideMenuLayout.tsx | 2 +- website/src/components/Tasks/Task.tsx | 2 +- website/src/pages/messages/[id]/index.tsx | 35 +++++++----- website/src/pages/messages/index.tsx | 6 +- website/src/styles/globals.css | 1 + 10 files changed, 86 insertions(+), 74 deletions(-) diff --git a/website/src/components/FlaggableElement.tsx b/website/src/components/FlaggableElement.tsx index a7157c4a..c4b28735 100644 --- a/website/src/components/FlaggableElement.tsx +++ b/website/src/components/FlaggableElement.tsx @@ -34,6 +34,8 @@ interface textFlagLabels { } export const FlaggableElement = (props) => { + const backgroundColor = useColorModeValue("gray.200", "gray.700"); + const [isEditing, setIsEditing] = useBoolean(); const flaggable_labels = props.flaggable_labels; const TEXT_LABEL_FLAGS = @@ -93,10 +95,10 @@ export const FlaggableElement = (props) => { > {props.children} - +
- diff --git a/website/src/components/Header/UserMenu.tsx b/website/src/components/Header/UserMenu.tsx index c5ca92bd..2f59efb1 100644 --- a/website/src/components/Header/UserMenu.tsx +++ b/website/src/components/Header/UserMenu.tsx @@ -22,14 +22,12 @@ export function UserMenu() { href: "/dashboard", desc: "Dashboard", icon: FiLayout, - //For future use }, { name: "Account Settings", href: "/account", desc: "Account Settings", icon: FiSettings, - //For future use }, ]; return ( diff --git a/website/src/components/Loading/LoadingScreen.jsx b/website/src/components/Loading/LoadingScreen.jsx index 3595b3c4..4674acf7 100644 --- a/website/src/components/Loading/LoadingScreen.jsx +++ b/website/src/components/Loading/LoadingScreen.jsx @@ -1,18 +1,14 @@ -import { Progress } from "@chakra-ui/react"; -import { useColorMode } from "@chakra-ui/react"; +import { Box, Progress, Text } from "@chakra-ui/react"; export const LoadingScreen = ({ text = "Loading..." } = {}) => { - const { colorMode } = useColorMode(); - const mainClasses = colorMode === "light" ? "bg-slate-300 text-gray-800" : "bg-slate-900 text-white"; - return ( -
+ {text && ( -
-
{text}
-
+ + {text} + )} -
+ ); }; diff --git a/website/src/components/Messages/MessageTableEntry.tsx b/website/src/components/Messages/MessageTableEntry.tsx index e9e8775a..6b02e3f5 100644 --- a/website/src/components/Messages/MessageTableEntry.tsx +++ b/website/src/components/Messages/MessageTableEntry.tsx @@ -1,6 +1,5 @@ -import { Avatar, HStack, LinkBox, useColorModeValue } from "@chakra-ui/react"; +import { Avatar, HStack, LinkBox, LinkOverlay, useColorModeValue } from "@chakra-ui/react"; import { boolean } from "boolean"; -import NextLink from "next/link"; import { FlaggableElement } from "src/components/FlaggableElement"; import type { ValidLabel } from "src/types/Task"; @@ -15,22 +14,24 @@ interface MessageTableEntryProps { valid_labels: ValidLabel[]; } export function MessageTableEntry(props: MessageTableEntryProps) { - const { item, idx, valid_labels } = props; - const bgColor = useColorModeValue(idx % 2 === 0 ? "bg-slate-800" : "bg-black", "bg-sky-900"); + const { item, valid_labels } = props; + const backgroundColor = useColorModeValue("gray.50", "gray.800"); return ( - - - - - - {item.text} - - - - +
+ + + + + + {item.text} + + + +
); } diff --git a/website/src/components/Messages/MessageWithChildren.tsx b/website/src/components/Messages/MessageWithChildren.tsx index 7e604dfa..1cd287b6 100644 --- a/website/src/components/Messages/MessageWithChildren.tsx +++ b/website/src/components/Messages/MessageWithChildren.tsx @@ -1,4 +1,4 @@ -import { Box, CircularProgress, Flex, HStack, StackDivider, StackProps, Text, TextProps } from "@chakra-ui/react"; +import { Box, CircularProgress, Stack, StackProps, Text, TextProps, useColorModeValue } from "@chakra-ui/react"; import { boolean } from "boolean"; import { useState } from "react"; import { MessageTableEntry } from "src/components/Messages/MessageTableEntry"; @@ -6,8 +6,9 @@ import fetcher from "src/lib/fetcher"; import useSWR from "swr"; const MessageHeaderProps: TextProps = { - align: "center", fontSize: "xl", + fontWeight: "bold", + fontFamily: "Inter", py: "2", }; @@ -15,7 +16,6 @@ const MessageStackProps: StackProps = { spacing: "2", alignItems: "start", justifyContent: "center", - divider: , }; interface MessageWithChildrenProps { @@ -26,6 +26,9 @@ interface MessageWithChildrenProps { } export function MessageWithChildren(props: MessageWithChildrenProps) { + const backgroundColor = useColorModeValue("white", "gray.700"); + const childBackgroundColor = useColorModeValue("gray.200", "gray.800"); + const { id, depth, maxDepth, isOnlyChild = true } = props; const [message, setMessage] = useState(null); @@ -60,40 +63,42 @@ export function MessageWithChildren(props: MessageWithChildrenProps) { <> {message && ( <> - {isFirst ? "Message" : depth === 1 ? "Children" : "Ancestor"} - - - - - + + + {isFirst ? "Message" : depth === 1 ? "Children" : "Ancestor"} + + + - + )} {children && Array.isArray(children) && children.length > 0 ? ( renderRecursive ? ( - - {children.map((item, idx) => ( - - - - ))} - + + + {children.map((item, idx) => ( + + + + ))} + + ) : ( <> {isFirstOrOnly ? "Children" : "Ancestor"} - + {children.map((item, idx) => ( - + ))} - + ) ) : ( diff --git a/website/src/components/SideMenuLayout.tsx b/website/src/components/SideMenuLayout.tsx index ae8cfbc2..d69b64d4 100644 --- a/website/src/components/SideMenuLayout.tsx +++ b/website/src/components/SideMenuLayout.tsx @@ -16,7 +16,7 @@ export const SideMenuLayout = (props: SideMenuLayoutProps) => { - {props.children} + {props.children} ); diff --git a/website/src/components/Tasks/Task.tsx b/website/src/components/Tasks/Task.tsx index e95fe3e2..fccea5eb 100644 --- a/website/src/components/Tasks/Task.tsx +++ b/website/src/components/Tasks/Task.tsx @@ -10,7 +10,7 @@ export const Task = ({ tasks, trigger, mutate }) => { const task = tasks[0].task; const { colorMode } = useColorMode(); - const mainBgClasses = colorMode === "light" ? "bg-slate-300 text-gray-800" : "bg-slate-900 text-white"; + const mainBgClasses = colorMode === "light" ? "bg-slate-300 text-gray-900" : "bg-slate-900 text-white"; const { trigger: sendRejection } = useSWRMutation("/api/reject_task", poster, { onSuccess: async () => { diff --git a/website/src/pages/messages/[id]/index.tsx b/website/src/pages/messages/[id]/index.tsx index 933c7508..173b38c8 100644 --- a/website/src/pages/messages/[id]/index.tsx +++ b/website/src/pages/messages/[id]/index.tsx @@ -1,6 +1,7 @@ -import { Box, Container, Text, useColorModeValue } from "@chakra-ui/react"; +import { Box, Text, useColorModeValue } from "@chakra-ui/react"; import Head from "next/head"; import { useState } from "react"; +import { getDashboardLayout } from "src/components/Layout"; import { LoadingScreen } from "src/components/Loading/LoadingScreen"; import { MessageTableEntry } from "src/components/Messages/MessageTableEntry"; import { MessageWithChildren } from "src/components/Messages/MessageWithChildren"; @@ -8,7 +9,7 @@ import fetcher from "src/lib/fetcher"; import useSWR from "swr"; const MessageDetail = ({ id }) => { - const mainBg = useColorModeValue("bg-slate-300", "bg-slate-900"); + const backgroundColor = useColorModeValue("white", "gray.700"); const [parent, setParent] = useState(null); @@ -22,7 +23,11 @@ const MessageDetail = ({ id }) => { }); if (isLoadingParent) { - return ; + return ( + + + + ); } return ( <> @@ -33,23 +38,26 @@ const MessageDetail = ({ id }) => { content="Conversational AI for everyone. An open source project to create a chat enabled GPT LLM run by LAION and contributors around the world." /> -
- + + {parent && ( <> - - Parent - - - + + + Parent + + + {" "} + + )} - - + + -
+ ); }; @@ -59,4 +67,5 @@ MessageDetail.getInitialProps = async ({ query }) => { return { id }; }; +MessageDetail.getLayout = (page) => getDashboardLayout(page); export default MessageDetail; diff --git a/website/src/pages/messages/index.tsx b/website/src/pages/messages/index.tsx index ed48d47b..dd5df7da 100644 --- a/website/src/pages/messages/index.tsx +++ b/website/src/pages/messages/index.tsx @@ -40,10 +40,10 @@ const MessagesDashboard = () => { Messages - Open Assistant - + - Most recent messages + Recent messages { - Your most recent messages + Your recent messages