From db9948803a44a658b897d47550c337bcd3138746 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Sun, 14 Aug 2022 18:04:33 +0700 Subject: [PATCH] added sample user profile page --- next.config.js | 4 ++ .../profile/ProfilePageLeft/index.tsx | 8 +-- .../ProfilePageLeft/styles.module.scss | 2 +- src/layouts/ProfileLayout/index.tsx | 60 ++++++++----------- src/layouts/ProfileLayout/styles.module.scss | 4 +- src/pages/profile/[username].tsx | 27 +++++++++ 6 files changed, 60 insertions(+), 45 deletions(-) create mode 100644 src/pages/profile/[username].tsx diff --git a/next.config.js b/next.config.js index 21793361..306a0017 100644 --- a/next.config.js +++ b/next.config.js @@ -13,6 +13,10 @@ module.exports = withBundleAnalyzer( source: '/post:id', destination: '/node/:id', }, + { + source: '/~:username', + destination: '/profile/:username', + } ]; }, diff --git a/src/containers/profile/ProfilePageLeft/index.tsx b/src/containers/profile/ProfilePageLeft/index.tsx index 00d92acf..a5360f1e 100644 --- a/src/containers/profile/ProfilePageLeft/index.tsx +++ b/src/containers/profile/ProfilePageLeft/index.tsx @@ -29,17 +29,11 @@ const ProfilePageLeft: FC = ({ username, profile, isLoading }) => {
{isLoading ? : profile?.fullname}
- ` +
{isLoading ? : `~${profile?.username}`}
- - {!!profile?.description && ( - - {formatText(profile.description)} - - )} ); }; diff --git a/src/containers/profile/ProfilePageLeft/styles.module.scss b/src/containers/profile/ProfilePageLeft/styles.module.scss index 549e9694..b94b662c 100644 --- a/src/containers/profile/ProfilePageLeft/styles.module.scss +++ b/src/containers/profile/ProfilePageLeft/styles.module.scss @@ -2,6 +2,7 @@ .wrap { @include outer_shadow; + @include blur; padding: $gap $gap $gap * 2; box-sizing: border-box; @@ -9,7 +10,6 @@ align-items: stretch; justify-content: stretch; flex-direction: column; - background: $content_bg_light; height: 100%; border-radius: $radius; } diff --git a/src/layouts/ProfileLayout/index.tsx b/src/layouts/ProfileLayout/index.tsx index 579fb6c7..10753618 100644 --- a/src/layouts/ProfileLayout/index.tsx +++ b/src/layouts/ProfileLayout/index.tsx @@ -1,55 +1,43 @@ -import React, { FC } from 'react'; +import { FC } from 'react'; import { observer } from 'mobx-react-lite'; -import { RouteComponentProps } from 'react-router'; -import { Card } from '~/components/containers/Card'; +import { usePageCover } from '~/components/containers/PageCoverProvider/usePageCover'; import { FlowGrid } from '~/components/flow/FlowGrid'; import { Container } from '~/containers/main/Container'; import { ProfilePageLeft } from '~/containers/profile/ProfilePageLeft'; -import { ProfilePageStats } from '~/containers/profile/ProfilePageStats'; import { useUser } from '~/hooks/auth/useUser'; import { useGetProfile } from '~/hooks/profile/useGetProfile'; import { useFlowStore } from '~/store/flow/useFlowStore'; import styles from './styles.module.scss'; -type Props = RouteComponentProps<{ username: string }> & {}; +type Props = { username: string }; -const ProfileLayout: FC = observer( - ({ - match: { - params: { username }, - }, - }) => { - const { nodes } = useFlowStore(); - const { user } = useUser(); - const { profile, isLoading } = useGetProfile(username); +const ProfileLayout: FC = observer(({ username }) => { + const { nodes } = useFlowStore(); + const { user } = useUser(); + const { profile, isLoading } = useGetProfile(username); - return ( - -
-
-
- -
+ usePageCover(user.cover); - {!!profile?.description && ( -
- {profile.description} -
- )} - -
- -
+ return ( + +
+
+
+
- -
- - ); - } -); + + +
+
+ ); +}); export { ProfileLayout }; diff --git a/src/layouts/ProfileLayout/styles.module.scss b/src/layouts/ProfileLayout/styles.module.scss index 8b4de5f9..5684cc64 100644 --- a/src/layouts/ProfileLayout/styles.module.scss +++ b/src/layouts/ProfileLayout/styles.module.scss @@ -1,9 +1,10 @@ -@import "src/styles/variables"; +@import 'src/styles/variables'; .wrap { display: grid; grid-template-columns: auto; grid-column-gap: $gap; + margin-top: $page_top_offset; } .grid { @@ -12,6 +13,7 @@ .row { margin-bottom: $gap; + height: 100%; } .description { diff --git a/src/pages/profile/[username].tsx b/src/pages/profile/[username].tsx new file mode 100644 index 00000000..418d75eb --- /dev/null +++ b/src/pages/profile/[username].tsx @@ -0,0 +1,27 @@ +import React, { FC } from 'react'; + +import { useRouter } from 'next/router'; +import { RouteComponentProps } from 'react-router'; + +import { PageTitle } from '~/components/common/PageTitle'; +import { useGlobalLoader } from '~/hooks/dom/useGlobalLoader'; +import { ProfileLayout } from '~/layouts/ProfileLayout'; +import { FlowProvider } from '~/utils/providers/FlowProvider'; +import { getPageTitle } from '~/utils/ssr/getPageTitle'; + +type ProfilePageProps = RouteComponentProps<{ username: string }>; + +const ProfilePage: FC = () => { + const { query } = useRouter(); + + useGlobalLoader(); + + return ( + + + + + ); +}; + +export default ProfilePage;