-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHeader.svelte
More file actions
175 lines (154 loc) · 4.46 KB
/
Copy pathHeader.svelte
File metadata and controls
175 lines (154 loc) · 4.46 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<script lang="ts">
import { _ } from 'svelte-i18n'
import logo from '$lib/assets/images/logo.svg'
import logoDark from '$lib/assets/images/logo-dark.svg'
import LocaleSwitcher from './LocaleSwitcher.svelte'
import '$lib/global.scss'
import Hamburger from '$lib/components/header/Hamburger.svelte'
import { page } from '$app/state'
import { resolve } from '$app/paths'
import ThemeSwitcher from './ThemeSwitcher.svelte'
import { FF_BUSINESS, BUSINESS_URL } from '$lib/env'
const allItems = [
{ name: 'fs', route: '/fileshare' },
{ name: 'about', route: '/about/' },
{ name: 'blog', route: '/blog/' },
{ name: 'pol', route: '/privacy/' },
{ name: 'business', route: BUSINESS_URL },
{ name: 'docs', route: 'https://docs.postguard.eu' },
]
let items = FF_BUSINESS
? allItems
: allItems.filter((i) => i.name !== 'business')
function isSelected(route: string) {
return page.url.pathname === route
}
</script>
<div class="pg-topbar">
<a href={resolve('/')}>
<img
src={logo}
alt="postguard logo"
width="128"
height="70"
class="logo-light"
/>
<img
src={logoDark}
alt="postguard logo"
width="128"
height="70"
class="logo-dark"
/>
</a>
<div class="pg-desktop-menu">
<ul>
{#each items as item (item.name)}
<li class:selected={isSelected(item.route)}>
<!-- eslint-disable-next-line svelte/no-navigation-without-resolve -->
<a href={item.route}>
{$_(`header.${item.name}`)}
</a>
</li>
{/each}
</ul>
<LocaleSwitcher />
<ThemeSwitcher />
<a
href={resolve('/decrypt')}
class="inbox-btn"
class:selected={isSelected('/decrypt')}
>
{$_('header.inbox')}
</a>
</div>
<Hamburger items={[...items, { name: 'inbox', route: '/decrypt' }]} />
</div>
<style lang="scss">
.logo-light {
display: block;
}
.logo-dark {
display: none;
}
:global(.dark) .logo-light {
display: none;
}
:global(.dark) .logo-dark {
display: block;
}
.pg-topbar {
width: auto;
margin: 0.5rem 1rem 1rem 1rem;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.pg-desktop-menu {
display: none;
margin-left: auto;
flex-direction: row;
align-items: center;
gap: 1rem;
}
@media only screen and (min-width: 768px) {
.pg-desktop-menu {
display: flex;
}
}
.inbox-btn {
padding: 0.25rem 1rem;
background: var(--pg-primary);
color: white;
border-radius: var(--pg-border-radius-sm);
text-decoration: none;
font-weight: var(--pg-font-weight-medium);
font-size: var(--pg-font-size-sm);
transition: opacity 0.2s ease;
white-space: nowrap;
&:hover {
opacity: 0.9;
}
&.selected {
opacity: 0.85;
box-shadow: 0 0 0 2px var(--pg-primary);
background: transparent;
color: var(--pg-primary);
}
}
.pg-desktop-menu ul li {
display: inline-block;
position: relative;
list-style-type: none;
margin-left: 15px;
padding-right: 15px;
&:not(:last-child) {
border-right: 1px solid var(--pg-text);
}
&.selected a {
text-decoration: 2px underline;
text-decoration-color: var(--pg-text);
text-underline-offset: 4px;
}
&:not(.selected) a {
text-decoration: none;
&:after {
content: '';
position: absolute;
width: calc(100% - 15px);
transform: scaleX(0);
height: 2px;
bottom: 0;
left: 0;
background-color: var(--pg-text);
transform-origin: bottom right;
transition: transform 0.25s ease-out;
}
&:hover:after {
transform: scaleX(1);
transform-origin: bottom left;
}
}
}
</style>