mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added sample user profile page (#133)
This commit is contained in:
parent
aee4b662d5
commit
7638bdd1ad
6 changed files with 60 additions and 45 deletions
|
@ -13,6 +13,10 @@ module.exports = withBundleAnalyzer(
|
||||||
source: '/post:id',
|
source: '/post:id',
|
||||||
destination: '/node/:id',
|
destination: '/node/:id',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
source: '/~:username',
|
||||||
|
destination: '/profile/:username',
|
||||||
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -29,17 +29,11 @@ const ProfilePageLeft: FC<IProps> = ({ username, profile, isLoading }) => {
|
||||||
<div className={styles.name}>
|
<div className={styles.name}>
|
||||||
{isLoading ? <Placeholder /> : profile?.fullname}
|
{isLoading ? <Placeholder /> : profile?.fullname}
|
||||||
</div>
|
</div>
|
||||||
`
|
|
||||||
<div className={styles.username}>
|
<div className={styles.username}>
|
||||||
{isLoading ? <Placeholder /> : `~${profile?.username}`}
|
{isLoading ? <Placeholder /> : `~${profile?.username}`}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!!profile?.description && (
|
|
||||||
<Markdown className={styles.description}>
|
|
||||||
{formatText(profile.description)}
|
|
||||||
</Markdown>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
@include outer_shadow;
|
@include outer_shadow;
|
||||||
|
@include blur;
|
||||||
|
|
||||||
padding: $gap $gap $gap * 2;
|
padding: $gap $gap $gap * 2;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -9,7 +10,6 @@
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
justify-content: stretch;
|
justify-content: stretch;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: $content_bg_light;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,47 +1,36 @@
|
||||||
import React, { FC } from 'react';
|
import { FC } from 'react';
|
||||||
|
|
||||||
import { observer } from 'mobx-react-lite';
|
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 { FlowGrid } from '~/components/flow/FlowGrid';
|
||||||
import { Container } from '~/containers/main/Container';
|
import { Container } from '~/containers/main/Container';
|
||||||
import { ProfilePageLeft } from '~/containers/profile/ProfilePageLeft';
|
import { ProfilePageLeft } from '~/containers/profile/ProfilePageLeft';
|
||||||
import { ProfilePageStats } from '~/containers/profile/ProfilePageStats';
|
|
||||||
import { useUser } from '~/hooks/auth/useUser';
|
import { useUser } from '~/hooks/auth/useUser';
|
||||||
import { useGetProfile } from '~/hooks/profile/useGetProfile';
|
import { useGetProfile } from '~/hooks/profile/useGetProfile';
|
||||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
|
|
||||||
type Props = RouteComponentProps<{ username: string }> & {};
|
type Props = { username: string };
|
||||||
|
|
||||||
const ProfileLayout: FC<Props> = observer(
|
const ProfileLayout: FC<Props> = observer(({ username }) => {
|
||||||
({
|
|
||||||
match: {
|
|
||||||
params: { username },
|
|
||||||
},
|
|
||||||
}) => {
|
|
||||||
const { nodes } = useFlowStore();
|
const { nodes } = useFlowStore();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { profile, isLoading } = useGetProfile(username);
|
const { profile, isLoading } = useGetProfile(username);
|
||||||
|
|
||||||
|
usePageCover(user.cover);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className={styles.wrap}>
|
<Container className={styles.wrap}>
|
||||||
<div className={styles.grid}>
|
<div className={styles.grid}>
|
||||||
<div className={styles.stamp}>
|
<div className={styles.stamp}>
|
||||||
<div className={styles.row}>
|
<div className={styles.row}>
|
||||||
<ProfilePageLeft profile={profile} username={username} isLoading={isLoading} />
|
<ProfilePageLeft
|
||||||
</div>
|
profile={profile}
|
||||||
|
username={username}
|
||||||
{!!profile?.description && (
|
isLoading={isLoading}
|
||||||
<div className={styles.row}>
|
/>
|
||||||
<Card className={styles.description}>{profile.description}</Card>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className={styles.row}>
|
|
||||||
<ProfilePageStats />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -49,7 +38,6 @@ const ProfileLayout: FC<Props> = observer(
|
||||||
</div>
|
</div>
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
export { ProfileLayout };
|
export { ProfileLayout };
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
@import "src/styles/variables";
|
@import 'src/styles/variables';
|
||||||
|
|
||||||
.wrap {
|
.wrap {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto;
|
grid-template-columns: auto;
|
||||||
grid-column-gap: $gap;
|
grid-column-gap: $gap;
|
||||||
|
margin-top: $page_top_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid {
|
.grid {
|
||||||
|
@ -12,6 +13,7 @@
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
margin-bottom: $gap;
|
margin-bottom: $gap;
|
||||||
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.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