feat(venus): use AFFiNE header stanard header

This commit is contained in:
tzhangchi 2022-09-01 15:51:55 +08:00
parent e5d74deb98
commit 317fdb35a8
3 changed files with 95 additions and 132 deletions

View File

@ -1,18 +1,13 @@
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Box, Button, Grid, Typography } from '@mui/joy'; import { Box, Grid, Typography } from '@mui/joy';
import Option from '@mui/joy/Option';
import Select from '@mui/joy/Select';
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { useMediaQuery } from '@mui/material'; import { useMediaQuery } from '@mui/material';
import 'github-markdown-css'; import 'github-markdown-css';
import AboutText from './about.mdx'; import AboutText from './about.mdx';
import { AFFiNEFooter, AFFiNEImage } from './Common'; import { AFFiNEFooter, AFFiNEHeader, AFFiNEImage } from './Common';
import { options } from './i18n';
import KeepUpdate from './keeupdate.png'; import KeepUpdate from './keeupdate.png';
export const AboutUs = () => { export const AboutUs = () => {
const matches = useMediaQuery('(max-width: 1024px)'); const matches = useMediaQuery('(max-width: 1024px)');
const navigate = useNavigate(); const navigate = useNavigate();
@ -23,58 +18,7 @@ export const AboutUs = () => {
}; };
return ( return (
<> <>
<Grid <AFFiNEHeader />
container
spacing={2}
sx={{
maxWidth: '1280px',
margin: 'auto',
}}
>
<Grid xs={6}>
<Button
size="lg"
variant="plain"
onClick={() => navigate('/')}
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
>
AFFiNE
</Button>
</Grid>
<Grid xs={6} sx={{ display: 'flex', justifyContent: 'right' }}>
<Button
onClick={() => {
window.open('https://blog.affine.pro');
}}
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
size="lg"
>
Blog
</Button>
<Select defaultValue="en" onChange={changeLanguage}>
{options.map(option => (
<Option key={option.value} value={option.value}>
{option.text}
</Option>
))}
</Select>
</Grid>
</Grid>
<Grid xs={12} sx={{ display: 'flex', marginTop: '4vh!important' }}> <Grid xs={12} sx={{ display: 'flex', marginTop: '4vh!important' }}>
<Box <Box
sx={{ sx={{

View File

@ -6,16 +6,13 @@ import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { Box, Button, Grid, Typography } from '@mui/joy'; import { Box, Button, Grid, Typography } from '@mui/joy';
import Option from '@mui/joy/Option';
import Select from '@mui/joy/Select';
import { styled } from '@mui/joy/styles'; import { styled } from '@mui/joy/styles';
import { LogoIcon } from '@toeverything/components/icons'; import { LogoIcon } from '@toeverything/components/icons';
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { useMediaQuery } from '@mui/material'; import { useMediaQuery } from '@mui/material';
import CollaborationImage from './collaboration.png'; import CollaborationImage from './collaboration.png';
import { AFFiNEFooter, AFFiNEImage } from './Common'; import { AFFiNEFooter, AFFiNEHeader, AFFiNEImage } from './Common';
import { options } from './i18n';
import { GitHub } from './Icons'; import { GitHub } from './Icons';
import PageImage from './page.png'; import PageImage from './page.png';
import ShapeImage from './shape.png'; import ShapeImage from './shape.png';
@ -220,71 +217,7 @@ export function App() {
}; };
return ( return (
<> <>
<Grid <AFFiNEHeader />
container
spacing={2}
sx={{
maxWidth: '1280px',
margin: 'auto',
}}
>
<Grid xs={6}>
<Button
size="lg"
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
>
AFFiNE
</Button>
</Grid>
<Grid xs={6} sx={{ display: 'flex', justifyContent: 'right' }}>
<GitHub flat />
<Button
onClick={() => window.open('https://blog.affine.pro')}
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
size="lg"
>
Blog
</Button>
<Button
onClick={() => navigate('/aboutus')}
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
size="lg"
>
About Us
</Button>
<Select defaultValue="en" onChange={changeLanguage}>
{options.map(option => (
<Option key={option.value} value={option.value}>
{option.text}
</Option>
))}
</Select>
</Grid>
</Grid>
<Grid xs={12} sx={{ display: 'flex', marginTop: '12vh!important' }}> <Grid xs={12} sx={{ display: 'flex', marginTop: '12vh!important' }}>
<Box <Box
sx={{ sx={{

View File

@ -1,12 +1,20 @@
/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/naming-convention */
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { Box, Button, Grid, Typography } from '@mui/joy';
import Option from '@mui/joy/Option';
import Select from '@mui/joy/Select';
import { styled } from '@mui/joy/styles';
// eslint-disable-next-line no-restricted-imports
import { useMediaQuery } from '@mui/material';
import GitHubIcon from '@mui/icons-material/GitHub'; import GitHubIcon from '@mui/icons-material/GitHub';
import RedditIcon from '@mui/icons-material/Reddit'; import RedditIcon from '@mui/icons-material/Reddit';
import TelegramIcon from '@mui/icons-material/Telegram'; import TelegramIcon from '@mui/icons-material/Telegram';
import { Box, Button, Grid, Typography } from '@mui/joy'; import { options } from './i18n';
import { styled } from '@mui/joy/styles';
// eslint-disable-next-line no-restricted-imports
import { useTranslation } from 'react-i18next';
import { DiscordIcon, GitHub } from './Icons'; import { DiscordIcon, GitHub } from './Icons';
// eslint-disable-next-line no-restricted-imports
import LogoImage from './logo.png'; import LogoImage from './logo.png';
export const AFFiNEImage = styled('img')({ export const AFFiNEImage = styled('img')({
@ -333,3 +341,81 @@ export const AFFiNEFooter = ({
</> </>
); );
}; };
export const AFFiNEHeader = () => {
const matches = useMediaQuery('(max-width: 1024px)');
const navigate = useNavigate();
const { i18n } = useTranslation();
const changeLanguage = (event: any) => {
i18n.changeLanguage(event);
};
return (
<Grid
container
spacing={2}
sx={{
maxWidth: '1280px',
margin: 'auto',
}}
>
<Grid xs={6}>
<Button
size="lg"
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
onClick={() => navigate('/')}
>
AFFiNE
</Button>
</Grid>
<Grid xs={6} sx={{ display: 'flex', justifyContent: 'right' }}>
<GitHub flat />
<Button
onClick={() => window.open('https://blog.affine.pro')}
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
size="lg"
>
Blog
</Button>
<Button
onClick={() => navigate('/aboutus')}
variant="plain"
sx={{
padding: matches ? '0' : '0 0.5em',
':hover': { backgroundColor: 'unset' },
fontSize: '24px',
'@media (max-width: 1024px)': {
fontSize: '16px',
},
}}
size="lg"
>
About Us
</Button>
<Select defaultValue="en" onChange={changeLanguage}>
{options.map(option => (
<Option key={option.value} value={option.value}>
{option.text}
</Option>
))}
</Select>
</Grid>
</Grid>
);
};