From 1a8b3d5d15d6c16d1a432a21124fc46043391bfd Mon Sep 17 00:00:00 2001 From: monoid Date: Tue, 5 Jan 2021 17:42:41 +0900 Subject: [PATCH] add contentinfo page --- src/client/js/app.tsx | 21 ++++++++++++++------- src/client/js/contentinfo.tsx | 9 +++++++++ src/client/js/gallery.tsx | 27 +++++++++++++++++---------- src/client/js/headline.tsx | 3 ++- 4 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 src/client/js/contentinfo.tsx diff --git a/src/client/js/app.tsx b/src/client/js/app.tsx index c2334ab..6c866a4 100644 --- a/src/client/js/app.tsx +++ b/src/client/js/app.tsx @@ -1,19 +1,26 @@ import React from 'react'; 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 {Gallery} from './gallery'; +import {ContentInfo} from './contentinfo'; -import style from '../css/style.css'; - +import '../css/style.css'; +const FooProfile = ()=>
test profile
; const App = ()=> ( - - - -
test profile
+ + + + + + + +
404 Not Found
+
+
); diff --git a/src/client/js/contentinfo.tsx b/src/client/js/contentinfo.tsx new file mode 100644 index 0000000..b2677eb --- /dev/null +++ b/src/client/js/contentinfo.tsx @@ -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(
{match?.url}
) +} \ No newline at end of file diff --git a/src/client/js/gallery.tsx b/src/client/js/gallery.tsx index 2267d39..e9efea9 100644 --- a/src/client/js/gallery.tsx +++ b/src/client/js/gallery.tsx @@ -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 React, { useEffect, useState } from 'react'; import {QueryListOption,Content} from '../../model/contents'; import {ClientContentAccessesor} from '../accessor/contents'; import {useTheme, makeStyles, Theme, emphasize, fade} from '@material-ui/core/styles'; import {blue , pink} from '@material-ui/core/colors'; +import {Link as RouterLink} from 'react-router-dom'; +import {makeContentInfoUrl} from './contentinfo'; type TagChipStyleProp = { color: string @@ -67,8 +69,8 @@ const useStyles = makeStyles((theme:Theme)=>({ gridGap: theme.spacing(4), }, table_thumbnail:{ - width: 200, - height: 200, + width: theme.spacing(25), + height: theme.spacing(25), background: '#272733', display: 'flex', alignItems: 'center', @@ -88,15 +90,18 @@ const useStyles = makeStyles((theme:Theme)=>({ display: 'flex', flexDirection: 'column', }, + content_info_title:{ + marginLeft:theme.spacing(2), + }, tag_list:{ display: 'flex', justifyContent: 'flex-start', flexWrap: 'wrap', + overflowY: 'hidden', '& > *': { margin: theme.spacing(0.5), }, - - } + }, })); export type GalleryProp = { @@ -128,17 +133,19 @@ export const Gallery = (props: GalleryProp)=>{ state.content.map(x=>{ const thumbnail_url = `/content/${x.id}/${x.content_type}/thumbnail`; return ( - { + { x.content_type === "manga" ? : - } + } - {x.title} + + {x.title} + {x.tags.map(x=>{ const tagcolor = getTagColorName(x); - console.log(tagcolor); - return (); + return (); })} diff --git a/src/client/js/headline.tsx b/src/client/js/headline.tsx index e912d70..77c7e23 100644 --- a/src/client/js/headline.tsx +++ b/src/client/js/headline.tsx @@ -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 [anchorEl, setAnchorEl] = React.useState(null); const classes = useStyles(); @@ -145,6 +145,7 @@ export const Headline = (prop: { children?: React.ReactNode }) => { + {prop.navListItem} ); return (