add contentinfo page

This commit is contained in:
monoid 2021-01-05 17:42:41 +09:00
parent 1fd3c974e0
commit 1a8b3d5d15
4 changed files with 42 additions and 18 deletions

View File

@ -1,19 +1,26 @@
import React from 'react'; import React from 'react';
import ReactDom from 'react-dom'; import ReactDom from 'react-dom';
import {BrowserRouter, Route} from 'react-router-dom'; import {BrowserRouter, Route, Switch as RouterSwitch} from 'react-router-dom';
import {Headline} from './headline'; import {Headline} from './headline';
import {Gallery} from './gallery'; import {Gallery} from './gallery';
import {ContentInfo} from './contentinfo';
import style from '../css/style.css'; import '../css/style.css';
const FooProfile = ()=><div>test profile</div>;
const App = ()=> ( const App = ()=> (
<BrowserRouter> <BrowserRouter>
<Headline> <Headline>
<Route path="/" exact> <RouterSwitch>
<Gallery></Gallery> <Route path="/" exact component={Gallery}></Route>
</Route> <Route path="/content" component={ContentInfo}>
<Route path="/profile"><div>test profile</div></Route> </Route>
<Route path="/profile" component={FooProfile}>
</Route>
<Route>
<div>404 Not Found</div>
</Route>
</RouterSwitch>
</Headline> </Headline>
</BrowserRouter> </BrowserRouter>
); );

View File

@ -0,0 +1,9 @@
import React from 'react';
import {useHistory, useRouteMatch} from 'react-router-dom';
export const makeContentInfoUrl = (id:number)=>`/content/${id}`;
export const ContentInfo = (props?:{children?:React.ReactNode})=>{
const match = useRouteMatch("/content/:id");
return(<div>{match?.url}</div>)
}

View File

@ -1,10 +1,12 @@
import { Box, CircularProgress, Typography, Paper, Chip, withStyles, colors } from '@material-ui/core'; import { Box, CircularProgress, Typography, Paper, Chip, withStyles, colors, Link } from '@material-ui/core';
import {ChipProps} from '@material-ui/core/Chip'; import {ChipProps} from '@material-ui/core/Chip';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import {QueryListOption,Content} from '../../model/contents'; import {QueryListOption,Content} from '../../model/contents';
import {ClientContentAccessesor} from '../accessor/contents'; import {ClientContentAccessesor} from '../accessor/contents';
import {useTheme, makeStyles, Theme, emphasize, fade} from '@material-ui/core/styles'; import {useTheme, makeStyles, Theme, emphasize, fade} from '@material-ui/core/styles';
import {blue , pink} from '@material-ui/core/colors'; import {blue , pink} from '@material-ui/core/colors';
import {Link as RouterLink} from 'react-router-dom';
import {makeContentInfoUrl} from './contentinfo';
type TagChipStyleProp = { type TagChipStyleProp = {
color: string color: string
@ -67,8 +69,8 @@ const useStyles = makeStyles((theme:Theme)=>({
gridGap: theme.spacing(4), gridGap: theme.spacing(4),
}, },
table_thumbnail:{ table_thumbnail:{
width: 200, width: theme.spacing(25),
height: 200, height: theme.spacing(25),
background: '#272733', background: '#272733',
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
@ -88,15 +90,18 @@ const useStyles = makeStyles((theme:Theme)=>({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
}, },
content_info_title:{
marginLeft:theme.spacing(2),
},
tag_list:{ tag_list:{
display: 'flex', display: 'flex',
justifyContent: 'flex-start', justifyContent: 'flex-start',
flexWrap: 'wrap', flexWrap: 'wrap',
overflowY: 'hidden',
'& > *': { '& > *': {
margin: theme.spacing(0.5), margin: theme.spacing(0.5),
}, },
},
}
})); }));
export type GalleryProp = { export type GalleryProp = {
@ -128,17 +133,19 @@ export const Gallery = (props: GalleryProp)=>{
state.content.map(x=>{ state.content.map(x=>{
const thumbnail_url = `/content/${x.id}/${x.content_type}/thumbnail`; const thumbnail_url = `/content/${x.id}/${x.content_type}/thumbnail`;
return (<Paper key={x.id} elevation={4} className={classes.contentPaper}> return (<Paper key={x.id} elevation={4} className={classes.contentPaper}>
<a className={classes.table_thumbnail}>{ <Link className={classes.table_thumbnail} component={RouterLink} to={makeContentInfoUrl(x.id)}>{
x.content_type === "manga" ? <img className={classes.content_thumnail} src={thumbnail_url}></img> : x.content_type === "manga" ? <img className={classes.content_thumnail} src={thumbnail_url}></img> :
<video className={classes.content_thumnail} src={thumbnail_url}></video> <video className={classes.content_thumnail} src={thumbnail_url}></video>
}</a> }</Link>
<Box className={classes.content_info}> <Box className={classes.content_info}>
<Typography variant="h5" style={{marginLeft:theme.spacing(2)}}>{x.title}</Typography> <Link component={RouterLink} to={makeContentInfoUrl(x.id)} variant="h5" color="inherit"
className={classes.content_info_title}>
{x.title}
</Link>
<Box className={classes.tag_list}> <Box className={classes.tag_list}>
{x.tags.map(x=>{ {x.tags.map(x=>{
const tagcolor = getTagColorName(x); const tagcolor = getTagColorName(x);
console.log(tagcolor); return (<TagChip key={x} label={x} clickable={true} color={tagcolor} size="small"></TagChip>);
return (<TagChip key={x} label={x} clickable={true} color={tagcolor}></TagChip>);
})} })}
</Box> </Box>
</Box> </Box>

View File

@ -106,7 +106,7 @@ const useStyles = makeStyles((theme: Theme) => ({
}, },
})); }));
export const Headline = (prop: { children?: React.ReactNode }) => { export const Headline = (prop: { children?: React.ReactNode, navListItem?: React.ReactNode}) => {
const [v, setv] = useState(false); const [v, setv] = useState(false);
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null); const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const classes = useStyles(); const classes = useStyles();
@ -145,6 +145,7 @@ export const Headline = (prop: { children?: React.ReactNode }) => {
</ListItemIcon> </ListItemIcon>
<ListItemText primary="Back"></ListItemText> <ListItemText primary="Back"></ListItemText>
</ListItem> </ListItem>
{prop.navListItem}
</List> </List>
</>); </>);
return (<div className={classes.root}> return (<div className={classes.root}>