-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathNav.svelte
82 lines (74 loc) · 1.43 KB
/
Nav.svelte
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
<script>
import { _, locale, locales } from 'svelte-i18n';
export let segment;
</script>
<style>
nav {
border-bottom: 1px solid rgba(255, 62, 0, 0.1);
font-weight: 300;
padding: 0 1em;
display: flex;
justify-content: space-between;
}
ul {
margin: 0;
padding: 0;
}
/* clearfix */
ul::after {
content: '';
display: block;
clear: both;
}
li {
display: block;
float: left;
}
.selected {
position: relative;
display: inline-block;
}
.selected::after {
position: absolute;
content: '';
width: calc(100% - 1em);
height: 2px;
background-color: rgb(255, 62, 0);
display: block;
bottom: -1px;
}
a,
.a {
cursor: pointer;
text-decoration: none;
padding: 1em 0.5em;
display: block;
}
.rtl {
direction: rtl;
display: flex;
}
</style>
<nav class={$_('direction')}>
<ul class={$_('direction')}>
<li>
<a class:selected={segment === undefined} href=".">{$_('nav.home')}</a>
</li>
<li>
<a class:selected={segment === 'about'} href="about">{$_('nav.about')}</a>
</li>
</ul>
<ul class="lang">
{#each $locales as item}
<li>
<span
class="a"
class:selected={$locale.includes(item)}
href={`#!${item}`}
on:click={() => ($locale = item)}>
{$_('languages.' + item.replace('-', '_'))}
</span>
</li>
{/each}
</ul>
</nav>