From 0e4d2005d8e65337e69252705776067daf1ae508 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Tue, 22 Mar 2022 10:34:11 -0700 Subject: [PATCH] rendering public profile --- net/web/src/Create/Create.jsx | 2 +- net/web/src/Login/Login.jsx | 2 +- net/web/src/User/Profile/Profile.jsx | 55 ++++++++++- net/web/src/User/Profile/Profile.styled.js | 97 +++++++++++++++++-- net/web/src/User/Profile/useProfile.hook.js | 24 ++++- .../src/User/SideBar/Identity/Identity.jsx | 9 +- .../User/SideBar/Identity/Identity.styled.js | 8 +- 7 files changed, 174 insertions(+), 23 deletions(-) diff --git a/net/web/src/Create/Create.jsx b/net/web/src/Create/Create.jsx index 4a0e6927..7427f29b 100644 --- a/net/web/src/Create/Create.jsx +++ b/net/web/src/Create/Create.jsx @@ -24,7 +24,7 @@ export function Create() { Create Account - actions.onLogin()}>Account Sign In + actions.onLogin()}>Account Sign In ) diff --git a/net/web/src/Login/Login.jsx b/net/web/src/Login/Login.jsx index 4aa50391..50043c9e 100644 --- a/net/web/src/Login/Login.jsx +++ b/net/web/src/Login/Login.jsx @@ -28,7 +28,7 @@ export function Login(props) { Sign In - actions.onCreate()} disabled={!state.available}> + actions.onCreate()} disabled={!state.available}> Create Account diff --git a/net/web/src/User/Profile/Profile.jsx b/net/web/src/User/Profile/Profile.jsx index 2316920d..53475775 100644 --- a/net/web/src/User/Profile/Profile.jsx +++ b/net/web/src/User/Profile/Profile.jsx @@ -1,16 +1,63 @@ import React from 'react' -import { ProfileWrapper } from './Profile.styled'; -import { CloseOutlined } from '@ant-design/icons'; +import { ProfileWrapper, CloseButton } from './Profile.styled'; +import { UserOutlined, CloseOutlined, EditOutlined } from '@ant-design/icons'; import { useProfile } from './useProfile.hook'; +import { Button } from 'antd' export function Profile(props) { const { state, actions } = useProfile(); + const Logo = () => { + if (state.imageUrl != null) { + if (state.imageUrl === '') { + return + } + return + } + return <> + } + + const Name = () => { + if (state.name == '' || state.name == null) { + return Name + } + return { state.name } + } + + const Location = () => { + if (state.location == '' || state.location == null) { + return Location + } + return { state.location } + } + + const Description = () => { + if (state.description == '' || state.description == null) { + return Description + } + return { state.description } + } + return ( -
actions.close()}> - +
+
{ state.handle }
+ actions.close()} icon={} /> +
+
+
+ +
+
+ +
+
+
+
+
+
) diff --git a/net/web/src/User/Profile/Profile.styled.js b/net/web/src/User/Profile/Profile.styled.js index b1dc6cd3..2779762f 100644 --- a/net/web/src/User/Profile/Profile.styled.js +++ b/net/web/src/User/Profile/Profile.styled.js @@ -6,16 +6,97 @@ export const ProfileWrapper = styled.div` width: 100%; height: 100%; background-color: #f6f5ed; - border-radius: 8px; + border-radius: 2px; + flex-direction: column; + padding: 16px; + align-items: center; + + .header { + display: flex; + width: 100%; + flex-direction: row; + padding-bottom: 3em; + } + + .title { + flex-grow: 1; + text-align: center; + font-size: 2em; + font-weight: bold; + } .close { - position: absolute; - right: 0px; - padding-right: 16px; - padding-top: 8px; - font-size: 1.5em; - color: #888; + font-size: 24px; + color: #aaaaaa; + } + + .profile { + display: flex; + flex-direction: row; + padding: 1em; + width: 66%; + } + + .logo { + width: 100%; + height: 100%; + width: 200px; + height: 200px; + border: 1px solid #dddddd; + border-radius: 8px; + align-items: center; + cursor: pointer; + display: flex; + justify-content: center; + } + + .avatar { + color: #888888; + font-size: 8em; + justify-content: center; + } + + .logoedit { + align-self: flex-end; + font-size: 16px; + position: relative; + left: -24px; cursor: pointer; } + + .detailedit { + font-size: 16px; + } + + .unset { + font-style: italic; + color: #dddddd; + } + + .details { + padding-left: 2em; + margin-left: 2em; + border-left: 0.5px solid #aaaaaa; + } + + .name { + font-size: 1.5em; + padding-left: 8px; + } + + .location { + font-size: 1.2em; + padding-left: 8px; + } + + .description { + font-size: 1em; + padding-left: 8px; + } `; - + +export const CloseButton = styled(Button)` + font-size: 24px; + color: #aaaaaa; +`; + diff --git a/net/web/src/User/Profile/useProfile.hook.js b/net/web/src/User/Profile/useProfile.hook.js index 286d0a7c..7efa35f6 100644 --- a/net/web/src/User/Profile/useProfile.hook.js +++ b/net/web/src/User/Profile/useProfile.hook.js @@ -4,11 +4,21 @@ import { useNavigate } from "react-router-dom"; export function useProfile() { - const [state, setState] = useState({}); + const [state, setState] = useState({ + name: '', + handle: '', + description: '', + location: '', + imageUrl: null + }); const navigate = useNavigate(); const app = useContext(AppContext); + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + const actions = { close: () => { navigate('/user') @@ -16,6 +26,18 @@ export function useProfile() { }; useEffect(() => { + if (app?.state?.Data?.profile) { + let profile = app.state.Data.profile; + if (profile.image != null) { + updateState({ imageUrl: app.actions.profileImageUrl() }) + } else { + updateState({ imageUrl: '' }) + } + updateState({ name: profile.name }); + updateState({ handle: profile.handle }); + updateState({ description: profile.description }); + updateState({ location: profile.location }); + } }, [app]) return { state, actions }; diff --git a/net/web/src/User/SideBar/Identity/Identity.jsx b/net/web/src/User/SideBar/Identity/Identity.jsx index 22578103..a9223975 100644 --- a/net/web/src/User/SideBar/Identity/Identity.jsx +++ b/net/web/src/User/SideBar/Identity/Identity.jsx @@ -1,6 +1,6 @@ import { Avatar, Image } from 'antd'; import React from 'react' -import { IdentityWrapper } from './Identity.styled'; +import { IdentityWrapper, MenuWrapper } from './Identity.styled'; import { RightOutlined, EditOutlined, UserOutlined } from '@ant-design/icons'; import { useIdentity } from './useIdentity.hook'; import { Menu, Dropdown } from 'antd'; @@ -20,17 +20,14 @@ export function Identity() { } const menu = ( - +
actions.editProfile()}>Edit Profile
- -
actions.editLabels()}>Manage Labels
-
actions.logout()}>Sign Out
-
+ ); return ( diff --git a/net/web/src/User/SideBar/Identity/Identity.styled.js b/net/web/src/User/SideBar/Identity/Identity.styled.js index cf536e32..6e0b8f23 100644 --- a/net/web/src/User/SideBar/Identity/Identity.styled.js +++ b/net/web/src/User/SideBar/Identity/Identity.styled.js @@ -1,4 +1,4 @@ -import { Button } from 'antd'; +import { Menu, Button } from 'antd'; import styled from 'styled-components'; export const IdentityWrapper = styled.div` @@ -57,5 +57,9 @@ export const IdentityWrapper = styled.div` color: #444444; font-weight: bold; } - `; + +export const MenuWrapper = styled(Menu)` + border-radius: 4px; +`; +