@@ -15,13 +15,14 @@ import { useTheme } from "../../components/ThemeProvider";
1515const Topbar = ( { username} ) => {
1616 const toast = useToast ( ) ;
1717 const router = useRouter ( ) ;
18+ const { themeColors } = useTheme ( ) ;
1819 return (
19- < Flex align = "center" w = "100%" h = "81px" p = { 3 } borderBottom = "1px solid" borderColor = "gray.300" shadow = "base" >
20+ < Flex align = "center" w = "100%" h = "81px" p = { 3 } borderBottom = "1px solid" borderColor = { themeColors . topbarBorder } shadow = "base" bg = { themeColors . sidebarBg } >
2021 < Avatar src = "" marginEnd = { 3 } />
2122 < Heading size = "md" flex = { 1 } > { username } </ Heading >
22- < Button bg = "white" color = "red.500"
23+ < Button bg = { themeColors . newChatButtonBg } color = { themeColors . newChatButtonColor }
2324 marginEnd = "2" p = { 4 } shadow = "xl"
24- _hover = { { bg : "red.100" , cursor : "pointer" } }
25+ _hover = { { bg : themeColors . newChatButtonHover , cursor : "pointer" } }
2526 onClick = { async ( ) => {
2627 console . log ( 'Before redirect' ) ;
2728 router . push ( '/' ) ;
@@ -38,6 +39,7 @@ const Topbar = ({username}) => {
3839
3940const Bottombar = ( { id, user} ) => {
4041 const [ input , setInput ] = useState ( "" ) ;
42+ const { themeColors } = useTheme ( ) ;
4143 const sendMessage = async ( e ) => {
4244 e . preventDefault ( ) ;
4345 if ( input . length > 0 ) {
@@ -51,9 +53,9 @@ const Bottombar = ({id, user}) => {
5153 }
5254
5355 return (
54- < FormControl display = "flex" borderTop = "1px solid" borderTopColor = "gray.200" p = { 3 } onSubmit = { sendMessage } as = "form" shadow = "base" >
56+ < FormControl display = "flex" borderTop = "1px solid" borderTopColor = { themeColors . topbarBorder } p = { 3 } onSubmit = { sendMessage } as = "form" shadow = "base" bg = { themeColors . sidebarBg } >
5557 < Input placeholder = "Type a message..." marginEnd = { 3 } autoComplete = "off" shadow = "xl"
56- onChange = { e => setInput ( e . target . value ) } value = { input } bgColor = "white" />
58+ onChange = { e => setInput ( e . target . value ) } value = { input } bgColor = { themeColors . background } color = { themeColors . text } />
5759 < IconButton icon = { < ArrowRightIcon /> } shadow = "xl" size = "md" color = "white" type = "submit" bgColor = "#1E293B" _hover = { { bgColor : "none" , color : "none" , cursor : "pointer" } } />
5860 </ FormControl >
5961 )
@@ -69,12 +71,14 @@ export default function Chat () {
6971 const q = query ( collection ( db , `chats/${ id } /messages` ) , orderBy ( 'timestamp' ) ) ;
7072 const [ messages ] = useCollectionData ( q ) ;
7173 const [ chat ] = useDocumentData ( doc ( db , "chats" , id ) ) ;
74+
75+ const { darkMode, themeColors } = useTheme ( ) ;
7276
7377 const getMessages = ( ) => messages ?. map ( msg => {
7478 const sender = msg . sender === user . email ;
7579
7680 return (
77- < Flex key = { Math . random ( ) } shadow = { sender ? "lg" : "xl" } alignSelf = { sender ? "flex-start" : "flex-end" } bg = { sender ? "white" : "#1E293B" } borderRadius = "lg" w = "fit-content" minWidth = "50px" p = { 3 } m = { 1 } color = { sender ? "black" : "white" } >
81+ < Flex key = { Math . random ( ) } shadow = { sender ? "lg" : "xl" } alignSelf = { sender ? "flex-start" : "flex-end" } bg = { sender ? themeColors . messageSenderBg : themeColors . messageReceiverBg } borderRadius = "lg" w = "fit-content" minWidth = "50px" p = { 3 } m = { 1 } color = { sender ? themeColors . text : "white" } >
7882 < Text > { msg . text } </ Text >
7983 </ Flex >
8084 )
@@ -89,16 +93,13 @@ export default function Chat () {
8993 } , 100 )
9094 } , [ messages ] )
9195
92- // Get theme from context
93- const { darkMode } = useTheme ( ) ;
94-
9596 return (
9697 < Flex h = "100vh" >
9798 < Head >
9899 < title > Comms</ title >
99100 </ Head >
100101 < Sidebar />
101- < Flex flex = { 1 } direction = "column" onClick = { ( ) => getMessages ( ) } bgColor = { darkMode ? "gray.900" : "white" } >
102+ < Flex flex = { 1 } direction = "column" onClick = { ( ) => getMessages ( ) } bgColor = { themeColors . background } >
102103 < Topbar username = { getOtherEmail ( chat ?. users , user ) } />
103104 < Flex flex = { 1 } direction = "column" pt = { 4 } px = { 4 } overflowY = "auto" sx = { { scrollbarWidth : "none" } } >
104105 { getMessages ( ) }
0 commit comments