Skip to content

Commit

Permalink
code homepage blog basic
Browse files Browse the repository at this point in the history
  • Loading branch information
ddthien-coder committed Sep 3, 2022
1 parent e200ae6 commit e89ae1b
Show file tree
Hide file tree
Showing 13 changed files with 484 additions and 75 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"eslint-plugin-react": "^7.31.1",
"eslint-plugin-react-hooks": "^4.6.0",
"gh-pages": "^4.0.0",
"markdown-to-jsx": "^7.1.7",
"node-sass": "^7.0.1",
"prettier": "^2.7.1"
},
Expand Down
47 changes: 47 additions & 0 deletions src/components/footer/UIFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';

function Copyright() {
return (
<Typography variant="body2" color="text.secondary" align="center">
{'Copyright © '}
<Link color="inherit" href="https://devteamvietnam.github.io/shdsvn.com/">
SHDSVN
</Link>{' '}
{new Date().getFullYear()}
{'.'}
</Typography>
);
}

interface FooterProps {
description: string;
title: string;
}

export class UIFooter extends React.Component<FooterProps> {
render(): React.ReactNode {
const { description, title } = this.props;
return (
<Box component="footer" sx={{ bgcolor: 'background.paper', py: 6 }}>
<Container maxWidth="lg">
<Typography variant="h6" align="center" gutterBottom>
{title}
</Typography>
<Typography
variant="subtitle1"
align="center"
color="text.secondary"
component="p"
>
{description}
</Typography>
<Copyright />
</Container>
</Box>
);
}
}
97 changes: 49 additions & 48 deletions src/components/header/UIHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React, { Component } from 'react';

import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import IconButton from '@mui/material/IconButton';
import SearchIcon from '@mui/icons-material/Search';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import Button from '@mui/material/Button';

import logo from '../../assets/images/logo.svg';

import '../header/style.scss';

interface HeaderProps {
sections: ReadonlyArray<{
sections: Array<{
title: string;
url: string;
description: string;
}>;
title: string;
}
Expand All @@ -24,52 +25,52 @@ export class UIHeader extends Component<HeaderProps> {

return (
<React.Fragment>
<Toolbar sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Typography
component="h1"
variant="h5"
color="inherit"
align="left"
noWrap
mt={1}
sx={{ flex: 1 }}
>
{title}
</Typography>
<Typography
component="h1"
variant="h5"
color="inherit"
align="left"
noWrap
mt={1}
sx={{ flex: 1 }}
>
<img src={logo} className="App-logo-header" alt="logo" />
</Typography>
<IconButton>
<SearchIcon />
</IconButton>
</Toolbar>
<Toolbar
component="nav"
variant="dense"
sx={{ justifyContent: 'space-between', overflowX: 'auto' }}
>
{sections.map(section => (
<Link
color="primary"
rel="noopener"
underline="none"
key={section.title}
variant="body2"
href={section.url}
sx={{ p: 2, flexShrink: 0 }}
<AppBar position="relative">
<Toolbar sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Typography
component="h1"
variant="h5"
color="inherit"
align="left"
noWrap
mt={1}
sx={{ flex: 1 }}
>
{section.title}
</Link>
))}
</Toolbar>
{title}
</Typography>
<Typography
component="h1"
variant="h5"
color="inherit"
align="left"
noWrap
mt={1}
sx={{ flex: 1 }}
>
<img src={logo} className="App-logo-header" alt="logo" />
</Typography>
<Button variant="outlined" size="small"></Button>
</Toolbar>
<Toolbar
component="nav"
variant="dense"
sx={{ justifyContent: 'center', overflowX: 'auto' }}
>
{sections.map(section => (
<Link
color="inherit"
rel="noopener"
underline="none"
key={section.title}
variant="body1"
href={section.url}
sx={{ p: 2, flexShrink: 0 }}
>
{section.title}
</Link>
))}
</Toolbar>
</AppBar>
</React.Fragment>
);
}
Expand Down
50 changes: 50 additions & 0 deletions src/components/markdown/UIMarkdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as React from 'react';
import ReactMarkdown from 'markdown-to-jsx';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';
import Box from '@mui/material/Box';

function MarkdownListItem(props: any) {
return <Box component="li" sx={{ mt: 1, typography: 'body1' }} {...props} />;
}

const options = {
overrides: {
h1: {
component: Typography,
props: {
gutterBottom: true,
variant: 'h4',
component: 'h1'
}
},
h2: {
component: Typography,
props: { gutterBottom: true, variant: 'h6', component: 'h2' }
},
h3: {
component: Typography,
props: { gutterBottom: true, variant: 'subtitle1' }
},
h4: {
component: Typography,
props: {
gutterBottom: true,
variant: 'caption',
paragraph: true
}
},
p: {
component: Typography,
props: { paragraph: true }
},
a: { component: Link },
li: {
component: MarkdownListItem
}
}
};

export default function Markdown(props: any) {
return <ReactMarkdown options={options} {...props} />;
}
52 changes: 52 additions & 0 deletions src/components/posts/UIFeaturedPost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as React from 'react';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
import Card from '@mui/material/Card';
import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';

interface FeaturedPostProps {
post: {
date: string;
description: string;
image: string;
imageLabel: string;
title: string;
};
}

export class UIFeaturedPost extends React.Component<FeaturedPostProps> {
render() {
const { post } = this.props;

return (
<Grid item xs={12} md={6}>
<CardActionArea component="a" href="#">
<Card elevation={2} sx={{ display: 'flex' }}>
<CardContent sx={{ flex: 1 }}>
<Typography component="h2" variant="h5">
{post.title}
</Typography>
<Typography variant="subtitle1" color="text.secondary">
{post.date}
</Typography>
<Typography variant="subtitle1" paragraph>
{post.description}
</Typography>
<Typography variant="subtitle1" color="primary">
Continue reading...
</Typography>
</CardContent>
<CardMedia
component="img"
sx={{ width: 160, display: { xs: 'none', sm: 'block' } }}
image={post.image}
alt={post.imageLabel}
/>
</Card>
</CardActionArea>
</Grid>
);
}
}
38 changes: 38 additions & 0 deletions src/components/posts/UIMainPost.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';
import Grid from '@mui/material/Grid';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import Markdown from '../markdown/UIMarkdown';

interface MainProps {
posts: Array<string>;
title: string;
}

export class UIMainPost extends React.Component<MainProps> {
render(): React.ReactNode {
const { posts, title } = this.props;
return (
<Grid
item
xs={12}
md={8}
sx={{
'& .markdown': {
py: 3
}
}}
>
<Typography variant="h6" gutterBottom>
{title}
</Typography>
<Divider />
{posts.map(post => (
<Markdown className="markdown" key={post.substring(0, 40)}>
{post}
</Markdown>
))}
</Grid>
);
}
}
67 changes: 67 additions & 0 deletions src/components/sidebar/UISidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import * as React from 'react';
import Grid from '@mui/material/Grid';
import Stack from '@mui/material/Stack';
import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import Link from '@mui/material/Link';

interface SidebarProps {
archives: Array<{
url: string;
title: string;
}>;
description: string;
social: Array<{
icon: React.ElementType;
name: string;
}>;
title: string;
}

export class UISideBar extends React.Component<SidebarProps> {
render() {
const { archives, description, social, title } = this.props;
return (
<Grid item xs={12} md={4}>
<Paper elevation={2} sx={{ p: 3, bgcolor: 'grey.200' }}>
<Typography variant="h5" gutterBottom>
{title}
</Typography>
<Typography>{description}</Typography>
</Paper>
<Typography variant="h5" gutterBottom sx={{ p: 3 }}>
Archives
{archives.map(archive => (
<Link
display="block"
variant="body1"
underline="none"
href={archive.url}
key={archive.title}
>
{archive.title}
</Link>
))}
</Typography>
<Typography variant="h6" gutterBottom sx={{ p: 3 }}>
Social
{social.map(network => (
<Link
display="block"
variant="body1"
underline="none"
href="#"
key={network.name}
sx={{ mb: 0.5 }}
>
<Stack direction="row" spacing={1} alignItems="center">
<network.icon />
<span>{network.name}</span>
</Stack>
</Link>
))}
</Typography>
</Grid>
);
}
}
Loading

0 comments on commit e89ae1b

Please sign in to comment.