forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
90 lines (85 loc) · 2.33 KB
/
index.tsx
File metadata and controls
90 lines (85 loc) · 2.33 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import React from 'react';
import { ModuleViewIcon } from '../../icons/ModuleView';
import { ProjectViewIcon } from '../../icons/ProjectView';
import { NewWindowIcon } from '../../icons/NewWindow';
import { BackIcon } from '../../icons/Back';
import { ForwardIcon } from '../../icons/Forward';
import { ReloadIcon } from '../../icons/Reload';
import Tooltip from '../../Tooltip';
import AddressBar from '../AddressBar';
import {
Container,
Icons,
Icon,
AddressBarContainer,
IconWithBackground,
} from './elements';
export interface NavigatorProps {
url: string;
onChange: (val: string) => void;
onConfirm: () => void;
onRefresh: () => void;
toggleProjectView?: () => void;
onBack?: () => void;
onForward?: () => void;
openNewWindow?: () => void;
zenMode?: boolean;
isProjectView: boolean;
}
function Navigator({
url,
onChange,
onConfirm,
onBack,
onForward,
onRefresh,
isProjectView,
toggleProjectView,
openNewWindow,
zenMode,
}: NavigatorProps) {
return (
<Container className="flying-container-handler" style={{ cursor: 'move' }}>
<Icons>
<Icon aria-label="Go Back" disabled={!onBack} onClick={onBack}>
<BackIcon />
</Icon>
<Icon aria-label="Go Forward" disabled={!onForward} onClick={onForward}>
<ForwardIcon />
</Icon>
<Icon aria-label="Refresh" onClick={onRefresh}>
<ReloadIcon />
</Icon>
</Icons>
<AddressBarContainer
onMouseDown={e => {
e.stopPropagation();
}}
>
<AddressBar url={url} onChange={onChange} onConfirm={onConfirm} />
</AddressBarContainer>
{!zenMode && toggleProjectView && (
<IconWithBackground
onClick={toggleProjectView}
moduleView={!isProjectView}
>
<Tooltip
delay={0}
content={isProjectView ? 'Project View' : 'Current Module View'}
placement="left"
>
{isProjectView ? <ProjectViewIcon /> : <ModuleViewIcon />}
</Tooltip>
</IconWithBackground>
)}
{openNewWindow && (
<IconWithBackground onClick={openNewWindow}>
<Tooltip delay={0} content="Open In New Window">
<NewWindowIcon />
</Tooltip>
</IconWithBackground>
)}
</Container>
);
}
export default Navigator;