mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added sample user profile page
This commit is contained in:
parent
aee4b662d5
commit
db9948803a
6 changed files with 60 additions and 45 deletions
|
@ -13,6 +13,10 @@ module.exports = withBundleAnalyzer(
|
|||
source: '/post:id',
|
||||
destination: '/node/:id',
|
||||
},
|
||||
{
|
||||
source: '/~:username',
|
||||
destination: '/profile/:username',
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
|
|
|
@ -29,17 +29,11 @@ const ProfilePageLeft: FC<IProps> = ({ username, profile, isLoading }) => {
|
|||
<div className={styles.name}>
|
||||
{isLoading ? <Placeholder /> : profile?.fullname}
|
||||
</div>
|
||||
`
|
||||
|
||||
<div className={styles.username}>
|
||||
{isLoading ? <Placeholder /> : `~${profile?.username}`}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!!profile?.description && (
|
||||
<Markdown className={styles.description}>
|
||||
{formatText(profile.description)}
|
||||
</Markdown>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1,47 +1,36 @@
|
|||
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<Props> = observer(
|
||||
({
|
||||
match: {
|
||||
params: { username },
|
||||
},
|
||||
}) => {
|
||||
const ProfileLayout: FC<Props> = observer(({ username }) => {
|
||||
const { nodes } = useFlowStore();
|
||||
const { user } = useUser();
|
||||
const { profile, isLoading } = useGetProfile(username);
|
||||
|
||||
usePageCover(user.cover);
|
||||
|
||||
return (
|
||||
<Container className={styles.wrap}>
|
||||
<div className={styles.grid}>
|
||||
<div className={styles.stamp}>
|
||||
<div className={styles.row}>
|
||||
<ProfilePageLeft profile={profile} username={username} isLoading={isLoading} />
|
||||
</div>
|
||||
|
||||
{!!profile?.description && (
|
||||
<div className={styles.row}>
|
||||
<Card className={styles.description}>{profile.description}</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={styles.row}>
|
||||
<ProfilePageStats />
|
||||
<ProfilePageLeft
|
||||
profile={profile}
|
||||
username={username}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -49,7 +38,6 @@ const ProfileLayout: FC<Props> = observer(
|
|||
</div>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
export { ProfileLayout };
|
||||
|
|
|
@ -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 {
|
||||
|
|
27
src/pages/profile/[username].tsx
Normal file
27
src/pages/profile/[username].tsx
Normal file
|
@ -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<ProfilePageProps> = () => {
|
||||
const { query } = useRouter();
|
||||
|
||||
useGlobalLoader();
|
||||
|
||||
return (
|
||||
<FlowProvider>
|
||||
<PageTitle title={getPageTitle('Флоу')} />
|
||||
<ProfileLayout username={query.username as string} />
|
||||
</FlowProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default ProfilePage;
|
Loading…
Add table
Add a link
Reference in a new issue