-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.tsx
More file actions
72 lines (69 loc) · 2.05 KB
/
header.tsx
File metadata and controls
72 lines (69 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { createComponent, RouteLink, Shade } from '@furystack/shades'
import { AppBar, Button } from '@furystack/shades-common-components'
import { environmentOptions } from '../environment-options.js'
import { SessionService } from '../services/session.js'
import { GithubLogo } from './github-logo/index.js'
import { ThemeSwitch } from './theme-switch/index.js'
export interface HeaderProps {
title: string
links: Array<{ name: string; url: string }>
}
export const Header = Shade<HeaderProps>({
shadowDomName: 'shade-app-header',
css: {
'& h3': {
margin: '0 2em 0 0',
cursor: 'pointer',
},
'& route-link': {
color: '#aaa',
textDecoration: 'none',
cursor: 'pointer',
},
'& route-link:hover': {
color: '#fff',
},
'& .nav-link': {
padding: '0 8px',
},
'& .spacer': {
flex: '1',
},
'& .actions': {
display: 'flex',
placeContent: 'center',
marginRight: '24px',
},
},
render: ({ props, injector, useObservable }) => {
const [sessionState] = useObservable('sessionState', injector.getInstance(SessionService).state)
return (
<AppBar id="header">
<h3>
<RouteLink title={props.title} href="/">
{props.title}
</RouteLink>
</h3>
{props.links.map((link) => (
<RouteLink className="nav-link" title={link.name} href={link.url}>
{link.name || ''}
</RouteLink>
))}
<div className="spacer" />
<div className="actions">
<ThemeSwitch variant="outlined" />
<a href={environmentOptions.repository} target="_blank">
<Button variant="outlined" style={{ verticalAlign: 'baseline' }}>
<GithubLogo style={{ height: '25px' }} />
</Button>
</a>
{sessionState === 'authenticated' ? (
<Button variant="outlined" onclick={() => injector.getInstance(SessionService).logout()}>
Log Out
</Button>
) : null}
</div>
</AppBar>
)
},
})