From f887ce6a9b0acf1c8639b56cb1da879e4c3fadf6 Mon Sep 17 00:00:00 2001 From: monoid Date: Mon, 11 Jan 2021 20:47:42 +0900 Subject: [PATCH] add common menu --- src/client/app.tsx | 6 +++--- src/client/component/headline.tsx | 4 +++- src/client/component/navlist.tsx | 22 ++++++++++++++++++++-- src/client/page/404.tsx | 4 ++-- src/client/page/contentinfo.tsx | 8 ++------ src/client/page/difference.tsx | 11 +++++++++++ src/client/page/gallery.tsx | 17 ++++------------- src/client/page/login.tsx | 5 ++--- src/client/page/mod.ts | 2 ++ src/client/page/profile.tsx | 18 ++++++++++++++++++ 10 files changed, 67 insertions(+), 30 deletions(-) create mode 100644 src/client/page/difference.tsx create mode 100644 src/client/page/profile.tsx diff --git a/src/client/app.tsx b/src/client/app.tsx index fc4a6cd..a469b01 100644 --- a/src/client/app.tsx +++ b/src/client/app.tsx @@ -1,12 +1,11 @@ import React, { createContext, useEffect, useRef, useState } from 'react'; import ReactDom from 'react-dom'; import {BrowserRouter, Redirect, Route, Switch as RouterSwitch} from 'react-router-dom'; -import { Gallery, ContentAbout, LoginPage, NotFoundPage} from './page/mod'; +import { Gallery, ContentAbout, LoginPage, NotFoundPage, ProfilePage,DifferencePage} from './page/mod'; import {getInitialValue, UserContext} from './state'; import './css/style.css'; -const FooProfile = ()=>
test profile
; const App = () => { const [user,setUser] = useState(""); const [userPermission,setUserPermission] = useState([]); @@ -30,7 +29,8 @@ const App = () => { }> }> }/> - + + diff --git a/src/client/component/headline.tsx b/src/client/component/headline.tsx index ab16f67..f33c339 100644 --- a/src/client/component/headline.tsx +++ b/src/client/component/headline.tsx @@ -6,7 +6,9 @@ import { Hidden, Tooltip, Link } from '@material-ui/core'; import { makeStyles, Theme, useTheme, fade } from '@material-ui/core/styles'; -import { ChevronLeft, ChevronRight, Menu as MenuIcon, Search as SearchIcon, AccountCircle } from '@material-ui/icons'; +import { ChevronLeft, ChevronRight, Menu as MenuIcon, Search as SearchIcon, AccountCircle +} from '@material-ui/icons'; + import { Link as RouterLink, useRouteMatch } from 'react-router-dom'; import { doLogout, UserContext } from '../state'; diff --git a/src/client/component/navlist.tsx b/src/client/component/navlist.tsx index 9975ae6..5ecff71 100644 --- a/src/client/component/navlist.tsx +++ b/src/client/component/navlist.tsx @@ -1,6 +1,8 @@ import React from 'react'; -import {List, ListItem, ListItemIcon, Tooltip, ListItemText} from '@material-ui/core'; -import {ArrowBack as ArrowBackIcon} from '@material-ui/icons'; +import {List, ListItem, ListItemIcon, Tooltip, ListItemText, Divider} from '@material-ui/core'; +import {ArrowBack as ArrowBackIcon, Settings as SettingIcon, + Collections as CollectionIcon, VideoLibrary as VideoIcon, Home as HomeIcon, + Folder as FolderIcon } from '@material-ui/icons'; import {Link as RouterLink, useHistory} from 'react-router-dom'; export const NavItem = (props:{name:string,to:string, icon:React.ReactElement})=>{ @@ -23,4 +25,20 @@ export const NavList = (props: {children?:React.ReactNode})=>{ export const BackItem = (props:{to?:string})=>{ return }/>; +} + +export function CommonMenuList(props?:{url?:string}) { + //if(props === undefined){ + // props = {}; + //} + //props.url = props.url || ""; + //{props.url !== "" && <> } + return ( + } /> + }> + } /> + + }> + } /> + ); } \ No newline at end of file diff --git a/src/client/page/404.tsx b/src/client/page/404.tsx index a7e9672..f22ec95 100644 --- a/src/client/page/404.tsx +++ b/src/client/page/404.tsx @@ -1,10 +1,10 @@ import React from 'react'; import {Typography} from '@material-ui/core'; import {ArrowBack as ArrowBackIcon} from '@material-ui/icons'; -import { Headline, BackItem, NavList } from '../component/mod'; +import { Headline, BackItem, NavList, CommonMenuList } from '../component/mod'; export const NotFoundPage = ()=>{ - const menu = (); + const menu = CommonMenuList(); return 404 Not Found diff --git a/src/client/page/contentinfo.tsx b/src/client/page/contentinfo.tsx index e57a5b5..7e38221 100644 --- a/src/client/page/contentinfo.tsx +++ b/src/client/page/contentinfo.tsx @@ -5,7 +5,7 @@ import { LoadingCircle } from '../component/loading'; import { Link, Paper, makeStyles, Theme, Box, useTheme, Typography } from '@material-ui/core'; import {ArrowBack as ArrowBackIcon } from '@material-ui/icons'; import { getPresenter } from './reader/reader'; -import { BackItem, ContentInfo, Headline, NavItem, NavList } from '../component/mod'; +import { BackItem, CommonMenuList, ContentInfo, Headline, NavItem, NavList } from '../component/mod'; export const makeContentInfoUrl = (id: number) => `/doc/${id}`; export const makeMangaReaderUrl = (id: number) => `/doc/${id}/reader`; @@ -34,11 +34,7 @@ export const ContentAbout = (prop: { match: MatchType }) => { } const id = Number.parseInt(match.params['id']); const [info, setInfo] = useState({ content: undefined, notfound:false }); - const menu_list = (link?:string)=>( - - - - ); + const menu_list = () => ; useEffect(() => { (async () => { diff --git a/src/client/page/difference.tsx b/src/client/page/difference.tsx new file mode 100644 index 0000000..ca7ffed --- /dev/null +++ b/src/client/page/difference.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { CommonMenuList, Headline } from "../component/mod"; +import { UserContext } from "../state"; +import { Grid, Typography } from "@material-ui/core"; + +export function DifferencePage(){ + const menu = CommonMenuList(); + return ( +
Not implemented
+
) +} \ No newline at end of file diff --git a/src/client/page/gallery.tsx b/src/client/page/gallery.tsx index 05b7a8e..33fd96d 100644 --- a/src/client/page/gallery.tsx +++ b/src/client/page/gallery.tsx @@ -1,24 +1,15 @@ import React, { useContext, useEffect } from 'react'; -import { NavList, NavItem, Headline, BackItem } from '../component/mod'; -import {ArrowBack as ArrowBackIcon, Settings as SettingIcon, - Collections as CollectionIcon, VideoLibrary as VideoIcon, Home as HomeIcon} from '@material-ui/icons'; +import { Headline, CommonMenuList } from '../component/mod'; import {GalleryInfo} from '../component/mod'; import {useLocation} from 'react-router-dom'; import { QueryStringToMap } from '../accessor/util'; -import { Divider } from '@material-ui/core'; + export const Gallery = ()=>{ const location = useLocation(); const query = QueryStringToMap(location.search); - - const menu_list = ( - {location.search !== "" && <> } - }/> - }> - }/> - - }/> - ); + location; + const menu_list = CommonMenuList({url:location.search}); return ( diff --git a/src/client/page/login.tsx b/src/client/page/login.tsx index f3465ce..4202393 100644 --- a/src/client/page/login.tsx +++ b/src/client/page/login.tsx @@ -1,5 +1,5 @@ import React, { useContext, useState } from 'react'; -import {Headline} from '../component/mod'; +import {CommonMenuList, Headline} from '../component/mod'; import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, MenuList, Paper, TextField, Typography, useTheme } from '@material-ui/core'; import { UserContext } from '../state'; @@ -39,8 +39,7 @@ export const LoginPage = ()=>{ } history.push("/"); } - const menu = ( - ); + const menu = CommonMenuList(); return Login diff --git a/src/client/page/mod.ts b/src/client/page/mod.ts index 1ea5f24..c6b9683 100644 --- a/src/client/page/mod.ts +++ b/src/client/page/mod.ts @@ -2,3 +2,5 @@ export * from './contentinfo'; export * from './gallery'; export * from './login'; export * from './404'; +export * from './profile'; +export * from './difference'; \ No newline at end of file diff --git a/src/client/page/profile.tsx b/src/client/page/profile.tsx new file mode 100644 index 0000000..d041527 --- /dev/null +++ b/src/client/page/profile.tsx @@ -0,0 +1,18 @@ +import { CommonMenuList, Headline } from "../component/mod"; +import React, { useContext } from 'react'; +import { UserContext } from "../state"; +import { Grid, Paper, Typography } from "@material-ui/core"; + +export function ProfilePage(){ + const userctx = useContext(UserContext); + const menu = CommonMenuList(); + return ( + + + + {userctx.username} + + + + ) +} \ No newline at end of file