From f030b5ae1f896df7e3bce1c16b8379648612cc5e Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Sat, 26 Mar 2022 01:37:47 -0700 Subject: [PATCH] rendering contact sidebar --- doc/api.oa3 | 3 ++ net/web/src/App.js | 4 +- net/web/src/AppContext/useAppContext.hook.js | 6 ++- net/web/src/User/Profile/Profile.styled.js | 9 ++-- .../src/User/SideBar/Contacts/Cards/Cards.jsx | 30 +++++++++-- .../SideBar/Contacts/Cards/Cards.styled.js | 12 +++++ .../Contacts/Cards/Registry/Registry.jsx | 13 +++++ .../Cards/Registry/Registry.styled.js | 11 ++++ .../SideBar/Contacts/Channels/Channels.jsx | 3 +- .../Contacts/Channels/Channels.styled.js | 11 ++++ .../src/User/SideBar/Contacts/Contacts.jsx | 52 ++++++++++++++++--- .../User/SideBar/Contacts/Contacts.styled.jsx | 7 ++- net/web/src/User/SideBar/SideBar.styled.js | 2 - 13 files changed, 140 insertions(+), 23 deletions(-) create mode 100644 net/web/src/User/SideBar/Contacts/Cards/Cards.styled.js create mode 100644 net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.jsx create mode 100644 net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.styled.js create mode 100644 net/web/src/User/SideBar/Contacts/Channels/Channels.styled.js diff --git a/doc/api.oa3 b/doc/api.oa3 index 27908ac1..06814f86 100644 --- a/doc/api.oa3 +++ b/doc/api.oa3 @@ -3016,6 +3016,9 @@ components: - channel - card properties: + account: + type: integer + format: int64 profile: type: integer format: int64 diff --git a/net/web/src/App.js b/net/web/src/App.js index 63813e15..d1bcfea3 100644 --- a/net/web/src/App.js +++ b/net/web/src/App.js @@ -12,10 +12,10 @@ function App() { return ( -
+
-
+
} /> diff --git a/net/web/src/AppContext/useAppContext.hook.js b/net/web/src/AppContext/useAppContext.hook.js index 2ede0f39..05d0d3f2 100644 --- a/net/web/src/AppContext/useAppContext.hook.js +++ b/net/web/src/AppContext/useAppContext.hook.js @@ -51,6 +51,7 @@ export function useAppContext() { const profileRevision = useRef(null); const groups = useRef(new Map()); + const delay = useRef(2); const ws = useRef(null); const revision = useRef(null); @@ -69,7 +70,7 @@ export function useAppContext() { profileRevision.current = null; groupRevision.current = null; groups.current = new Map(); - setState(null); + setState({}); } const userActions = { @@ -156,8 +157,9 @@ export function useAppContext() { ws.current.onopen = () => {} ws.current.onerror = () => {} setWebsocket(token); + delay.current += 1; } - }, 2000) + }, delay.current * 1000) } ws.current.onopen = () => { ws.current.send(JSON.stringify({ AppToken: token })) diff --git a/net/web/src/User/Profile/Profile.styled.js b/net/web/src/User/Profile/Profile.styled.js index 4ac1cb0b..38ec5f40 100644 --- a/net/web/src/User/Profile/Profile.styled.js +++ b/net/web/src/User/Profile/Profile.styled.js @@ -28,6 +28,9 @@ export const ProfileWrapper = styled.div` text-align: center; font-size: 2em; font-weight: bold; + display: flex; + align-items: center; + justify-content: center; } .close { @@ -38,9 +41,9 @@ export const ProfileWrapper = styled.div` .container { display: flex; flex-direction: row; - padding: 1em; - margin-top: 32px; + padding: 32px; width: 100%; + overflow: scroll } .profile { @@ -64,7 +67,7 @@ export const ProfileWrapper = styled.div` } .search { - padding-right: 16px; + padding-right: 6px; } .logo { diff --git a/net/web/src/User/SideBar/Contacts/Cards/Cards.jsx b/net/web/src/User/SideBar/Contacts/Cards/Cards.jsx index 82df4300..cb1c1bd4 100644 --- a/net/web/src/User/SideBar/Contacts/Cards/Cards.jsx +++ b/net/web/src/User/SideBar/Contacts/Cards/Cards.jsx @@ -1,6 +1,30 @@ -import React from 'react' +import React, { useEffect } from 'react' +import { CardsWrapper } from './Cards.styled'; +import { Drawer } from 'antd'; +import { Registry } from './Registry/Registry'; -export function Cards() { - return
CARDS
+export function Cards({ showRegistry }) { + + useEffect(() => { + console.log("HERE", showRegistry); + }, [showRegistry]); + + return ( + + + + + + + + ) } diff --git a/net/web/src/User/SideBar/Contacts/Cards/Cards.styled.js b/net/web/src/User/SideBar/Contacts/Cards/Cards.styled.js new file mode 100644 index 00000000..403ecc31 --- /dev/null +++ b/net/web/src/User/SideBar/Contacts/Cards/Cards.styled.js @@ -0,0 +1,12 @@ +import { Button } from 'antd'; +import styled from 'styled-components'; + +export const CardsWrapper = styled.div` + position: relative; + height: calc(100vh - 143px); + width: 100%; + overflow: hidden; + text-align: center; + border-radius: 2px; +`; + diff --git a/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.jsx b/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.jsx new file mode 100644 index 00000000..1bff3baa --- /dev/null +++ b/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.jsx @@ -0,0 +1,13 @@ +import React from 'react'; +import { RegistryWrapper } from './Registry.styled'; +import { Input } from 'antd'; + +export function Registry() { + return ( + + + + + ); +} + diff --git a/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.styled.js b/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.styled.js new file mode 100644 index 00000000..890dd2b2 --- /dev/null +++ b/net/web/src/User/SideBar/Contacts/Cards/Registry/Registry.styled.js @@ -0,0 +1,11 @@ +import styled from 'styled-components'; + +export const RegistryWrapper = styled.div` + position: relative; + width: 100%; + padding-left: 8px; + padding-right: 8px; + text-align: center; +`; + + diff --git a/net/web/src/User/SideBar/Contacts/Channels/Channels.jsx b/net/web/src/User/SideBar/Contacts/Channels/Channels.jsx index f9c77075..19b1128a 100644 --- a/net/web/src/User/SideBar/Contacts/Channels/Channels.jsx +++ b/net/web/src/User/SideBar/Contacts/Channels/Channels.jsx @@ -1,6 +1,7 @@ import React from 'react' +import { ChannelsWrapper } from './Channels.styled'; export function Channels() { - return
CHANNELS
+ return } diff --git a/net/web/src/User/SideBar/Contacts/Channels/Channels.styled.js b/net/web/src/User/SideBar/Contacts/Channels/Channels.styled.js new file mode 100644 index 00000000..ead6aa44 --- /dev/null +++ b/net/web/src/User/SideBar/Contacts/Channels/Channels.styled.js @@ -0,0 +1,11 @@ +import styled from 'styled-components'; + +export const ChannelsWrapper = styled.div` + position: relative; + height: calc(100vh - 143px); + width: 100%; + overflow: hidden; + text-align: center; + border-radius: 2px; +`; + diff --git a/net/web/src/User/SideBar/Contacts/Contacts.jsx b/net/web/src/User/SideBar/Contacts/Contacts.jsx index 5f864e92..a2c94507 100644 --- a/net/web/src/User/SideBar/Contacts/Contacts.jsx +++ b/net/web/src/User/SideBar/Contacts/Contacts.jsx @@ -1,25 +1,61 @@ import { Avatar, Image } from 'antd'; -import React from 'react' -import { ContactsWrapper } from './Contacts.styled'; +import React, { useState, useEffect, useRef } from 'react' +import { ContactsWrapper, AddButton } from './Contacts.styled'; import { useContacts } from './useContacts.hook'; -import { Tabs } from 'antd'; +import { Tabs, Button, Tooltip } from 'antd'; import { Cards } from './Cards/Cards'; import { Channels } from './Channels/Channels'; +import { UserAddOutlined, CommentOutlined } from '@ant-design/icons'; const { TabPane } = Tabs; export function Contacts() { const { state, actions } = useContacts() + const [addButton, setAddButton] = useState(<>); + const [showRegistry, setShowRegistry] = useState(false); + let registry = useRef(false); + + const onShowRegistry = () => { + registry.current = !registry.current; + setShowRegistry(registry.current); + } + + const addUser = ( + + onShowRegistry()} icon={} /> + + ) + + const addConversation = ( + + } /> + + ) + + const onTab = (key) => { + registry.current = false; + setShowRegistry(false); + if (key === "contact") { + setAddButton(addUser); + } + else { + setAddButton(addConversation); + } + } + + useEffect(() => { + setAddButton(addUser); + }, []); return ( - - - + > + + - - + + diff --git a/net/web/src/User/SideBar/Contacts/Contacts.styled.jsx b/net/web/src/User/SideBar/Contacts/Contacts.styled.jsx index e0730d0c..404be906 100644 --- a/net/web/src/User/SideBar/Contacts/Contacts.styled.jsx +++ b/net/web/src/User/SideBar/Contacts/Contacts.styled.jsx @@ -2,8 +2,11 @@ import { Button } from 'antd'; import styled from 'styled-components'; export const ContactsWrapper = styled.div` - padding: 16px; width: 100%; - flex-grow: 1; background-color: #f6f5ed; + padding-top: 16px; +`; + +export const AddButton = styled(Button)` + border-radius: 8px; `; diff --git a/net/web/src/User/SideBar/SideBar.styled.js b/net/web/src/User/SideBar/SideBar.styled.js index f63de2f5..0696630a 100644 --- a/net/web/src/User/SideBar/SideBar.styled.js +++ b/net/web/src/User/SideBar/SideBar.styled.js @@ -7,6 +7,4 @@ export const SideBarWrapper = styled.div` min-width: 200px; border-right: 1px solid #8fbea7; background-color: #8fbea7; - display: flex; - flex-direction: column; `;