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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
import React, { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router';
import styled from 'styled-components';
import { colors } from '../../config.json';
import { messages } from '../../shared/gettext';
import { IReduxState } from '../redux/store';
import ImageView from './ImageView';
export enum HeaderBarStyle {
default = 'default',
defaultDark = 'defaultDark',
error = 'error',
success = 'success',
}
const headerBarStyleColorMap = {
[HeaderBarStyle.default]: colors.blue,
[HeaderBarStyle.defaultDark]: colors.darkBlue,
[HeaderBarStyle.error]: colors.red,
[HeaderBarStyle.success]: colors.green,
};
interface IHeaderBarContainerProps {
barStyle?: HeaderBarStyle;
unpinnedWindow: boolean;
}
const HeaderBarContainer = styled.header({}, (props: IHeaderBarContainerProps) => ({
padding: '12px 16px',
paddingTop: window.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px',
backgroundColor: headerBarStyleColorMap[props.barStyle ?? HeaderBarStyle.default],
}));
const HeaderBarContent = styled.div({
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end',
// In views without the brand components we still want the Header to have the same height.
minHeight: '51px',
});
interface IHeaderBarProps {
barStyle?: HeaderBarStyle;
className?: string;
children?: React.ReactNode;
}
export default function HeaderBar(props: IHeaderBarProps) {
const unpinnedWindow = useSelector(
(state: IReduxState) => state.settings.guiSettings.unpinnedWindow,
);
return (
<HeaderBarContainer
barStyle={props.barStyle}
className={props.className}
unpinnedWindow={unpinnedWindow}>
<HeaderBarContent>{props.children}</HeaderBarContent>
</HeaderBarContainer>
);
}
const BrandContainer = styled.div({
display: 'flex',
flex: 1,
alignItems: 'center',
});
const Title = styled.span({
fontFamily: 'DINPro',
fontSize: '24px',
fontWeight: 900,
lineHeight: '30px',
color: colors.white80,
marginLeft: '9px',
});
const Logo = styled(ImageView)({
margin: '4px 0 3px',
});
export function Brand(props: React.HTMLAttributes<HTMLDivElement>) {
return (
<BrandContainer {...props}>
<Logo width={44} height={44} source="logo-icon" />
<Title>{messages.pgettext('generic', 'MULLVAD VPN')}</Title>
</BrandContainer>
);
}
const HeaderBarSettingsButtonContainer = styled.button({
cursor: 'default',
padding: 0,
marginLeft: 8,
backgroundColor: 'transparent',
border: 'none',
});
export function HeaderBarSettingsButton() {
const history = useHistory();
const openSettings = useCallback(() => {
history.push('/settings');
}, [history]);
return (
<HeaderBarSettingsButtonContainer
onClick={openSettings}
aria-label={messages.gettext('Settings')}>
<ImageView
height={24}
width={24}
source="icon-settings"
tintColor={colors.white80}
tintHoverColor={colors.white}
/>
</HeaderBarSettingsButtonContainer>
);
}
|