11//modules
22import { useEffect } from 'react' ;
3- import { useLanguage } from 'r22n' ;
43//views
54import type {
65 PanelAppProps ,
6+ LayoutHeadProps ,
77 LayoutPanelProps
88} from 'stackpress/view/client' ;
99import {
1010 unload ,
11- useSession ,
1211 useTheme ,
13- useToggle ,
12+ useLanguage ,
1413 NotifyContainer ,
15- LayoutHead ,
16- LayoutRight ,
1714 LayoutMain ,
1815 LayoutProvider
1916} from 'stackpress/view/client' ;
2017
21- export function UserMenu ( ) {
22- const session = useSession ( ) ;
23- const { changeLanguage } = useLanguage ( ) ;
18+ export function Head ( props : LayoutHeadProps ) {
19+ const { theme, toggleTheme } = props ;
20+ const { _ } = useLanguage ( ) ;
21+ const themeColor = theme === 'dark' ? 'bg-gray-600' : 'bg-orange-600' ;
22+ const themeIcon = theme === 'dark' ? 'fa-moon' : 'fa-sun' ;
2423 return (
25- < section className = "flex flex-col px-h-100-0" >
26- < header >
27- { session . data . id ? (
28- < div className = "px-px-10 px-py-14 theme-tx1 flex items-center" >
29- < i className = "px-fs-26 inline-block px-mr-10 fas fa-user-circle" />
30- < span > { session . data . name } </ span >
31- </ div >
32- ) : null }
33- < nav className = "theme-bg-bg3 px-px-10 px-py-12" >
34- < a
35- className = "theme-info theme-bg-bg0 px-fs-10 inline-block px-p-5"
36- onClick = { ( ) => changeLanguage ( 'en_US' ) }
37- > EN</ a >
24+ < header className = "theme-bg-bg1 theme-bc-bd0 duration-200 absolute px-h-60 px-l-0 px-r-0 px-t-0 border-b" >
25+ < div className = "flex items-center px-px-20 px-h-100-0" >
26+ < a className = "theme-tx1 flex items-center no-underline px-mr-10" href = "/" >
27+ < img
28+ src = "/images/stackpress-logo-icon.png"
29+ alt = "stackpress logo"
30+ className = "px-w-30 px-h-30 px-mr-10"
31+ />
32+ < img
33+ src = "/images/stackpress-logo-text.png"
34+ alt = "stackpress logo"
35+ className = "px-h-16 px-mr-10"
36+ />
37+ </ a >
38+ < nav className = "flex-grow" >
39+ < a className = "theme-tx1 flex items-center no-underline uppercase" href = "/docs/introduction" >
40+ { _ ( 'Docs' ) }
41+ </ a >
42+ </ nav >
43+ < nav className = "rmd-hidden flex items-center" >
44+ < a className = "px-mr-10" href = "https://github.com/stackpress" >
45+ < i className = "px-fs-26 fab fa-github" > </ i >
46+ </ a >
3847 < a
39- className = "theme-info theme-bg-bg0 px-fs-10 inline-block px-p-5 px-ml-5"
40- onClick = { ( ) => changeLanguage ( 'th_TH' ) }
41- > TH</ a >
48+ className = "px-mr-10 px-w-26 px-h-26 hex-bg-CB3837 rounded-full flex justify-center items-center"
49+ href = "https://www.npmjs.com/package/stackpress"
50+ >
51+ < i className = "px-fs-16 fab fa-npm text-white" > </ i >
52+ </ a >
53+ { toggleTheme && (
54+ < button
55+ className = { `flex justify-center items-center b-0 px-mr-10 px-h-26 px-w-26 px-fs-18 rounded-full text-white ${ themeColor } ` }
56+ onClick = { ( ) => toggleTheme ( ) }
57+ >
58+ < i className = { `fas ${ themeIcon } ` } > </ i >
59+ </ button >
60+ ) }
4261 </ nav >
43- </ header >
44- < main className = "flex-grow bg-t-0" >
45- { session . data . id ? (
46- < div className = "px-h-100-0" >
47- { session . data . roles && session . data . roles . includes ( 'ADMIN' ) && (
48- < nav className = "theme-bc-bd0 flex items-center px-px-10 px-py-14 border-b" >
49- < i className = "inline-block px-mr-10 fas fa-gauge" />
50- < a className = "theme-info" href = "/admin/profile/search" > Admin</ a >
51- </ nav >
52- ) }
53-
54- < nav className = "theme-bc-bd0 flex items-center px-px-10 px-py-14 border-b" >
55- < i className = "inline-block px-mr-10 fas fa-power-off" />
56- < a className = "theme-info" href = "/auth/signout" > Sign Out</ a >
57- </ nav >
58- </ div >
59- ) : (
60- < div className = "h-full" >
61- < nav className = "theme-bc-bd0 flex items-center px-px-10 px-py-14 border-b" >
62- < i className = "inline-block px-mr-10 fas fa-lock" />
63- < a className = "theme-info" href = "/auth/signin" > Sign In</ a >
64- </ nav >
65- < nav className = "theme-bc-bd0 flex items-center px-px-10 px-py-14 border-b" >
66- < i className = "inline-block px-mr-10 fas fa-trophy" />
67- < a className = "theme-info" href = "/auth/signup" > Sign Up</ a >
68- </ nav >
69- </ div >
70- ) }
71- </ main >
72- </ section >
62+ </ div >
63+ </ header >
7364 ) ;
7465}
7566
76- export function PanelApp ( props : PanelAppProps ) {
67+ export function App ( props : PanelAppProps ) {
7768 const { children } = props ;
78- const [ right , toggleRight ] = useToggle ( ) ;
7969 const { theme, toggle : toggleTheme } = useTheme ( ) ;
8070 return (
8171 < div className = { `${ theme } relative overflow-hidden px-w-100-0 px-h-100-0 theme-bg-bg0 theme-tx1` } >
82- < LayoutHead
83- theme = { theme }
84- toggleRight = { toggleRight }
85- toggleTheme = { toggleTheme }
86- />
87- < LayoutRight head open = { right } > < UserMenu /> </ LayoutRight >
88- < LayoutMain head right open = { { right } } > { children } </ LayoutMain >
72+ < Head theme = { theme } toggleTheme = { toggleTheme } />
73+ < LayoutMain head > { children } </ LayoutMain >
8974 </ div >
9075 ) ;
9176}
9277
93- export default function LayoutPanel ( props : LayoutPanelProps ) {
78+ export default function Layout ( props : LayoutPanelProps ) {
9479 const {
9580 data,
9681 session,
9782 request,
9883 response,
99- menu,
100- left,
101- right,
10284 children
10385 } = props ;
10486 //unload flash message
@@ -110,9 +92,7 @@ export default function LayoutPanel(props: LayoutPanelProps) {
11092 request = { request }
11193 response = { response }
11294 >
113- < PanelApp left = { left } right = { right } menu = { menu } >
114- { children }
115- </ PanelApp >
95+ < App > { children } </ App >
11696 < NotifyContainer />
11797 </ LayoutProvider >
11898 ) ;
0 commit comments