-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathHeader.svelte
111 lines (97 loc) · 2.64 KB
/
Header.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
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
<style>
.header,
.header-base {
display: block;
}
.header-base :global(img),
.header :global(img) {
max-width: 100%;
height: auto;
}
.header,
.header-skin {
background-color: var(--agnostic-header-background-color, var(--agnostic-light));
box-shadow:
var(--agnostic-header-box-shadow-hor, 0) var(--agnostic-header-box-shadow-ver, 1px)
var(--agnostic-header-box-shadow-blur, 5px) var(--agnostic-header-box-shadow-spread, 2px)
var(--agnostic-header-box-shadow-color, rgb(0 0 0 / 10%));
font-family: var(--agnostic-header-font-family, var(--agnostic-font-family-body));
border-bottom: 1px solid var(--agnostic-header-border-color, var(--agnostic-gray-light));
padding-block-start: var(--agnostic-vertical-pad, 0.5rem);
padding-block-end: var(--agnostic-vertical-pad, 0.5rem);
padding-inline-start: var(--fluid-24);
padding-inline-end: var(--fluid-24);
}
.header-content {
width: var(--agnostic-header-content-width, 960px);
max-width: 100%;
margin: 0 auto;
display: flex;
justify-content: space-around;
align-items: center;
flex-flow: wrap column;
}
/**
* If you make your header sticky, you should likely consider that jump links
* e.g. <h1 id="Jump-Here">... will tuck underneath the header! Here's a recommendation
* for how to circumnavigate this issue via scroll-margin-top:
h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id] {
scroll-margin-top: 80px;
}
* In this case I have a 64px tall header so I've added 16px for clearance -- you'll need
* to curate your own use case, but scroll-margin-top is super useful for this use case.
*/
.header-sticky {
position: relative;
top: 0;
z-index: 10;
}
@media (min-width: 960px) {
.header-sticky {
position: sticky;
}
.header-content {
flex-direction: row;
justify-content: space-between;
}
.header-content-start {
justify-content: flex-start;
}
.header-content-end {
justify-content: flex-end;
}
}
</style>
<script>
export let isSticky = false;
export let isSkinned = true;
export let isHeaderContentStart = false;
export let isHeaderContentEnd = false;
export let css = "";
const klasses = [
isSkinned ? "header" : "header-base",
isSticky ? "header-sticky" : "",
css ? `${css}` : "",
]
.filter((cl) => cl.length)
.join(" ");
const headerContentClasses = [
"header-content",
isHeaderContentStart ? "header-content-start" : "",
isHeaderContentEnd ? "header-content-end" : "",
]
.filter((cl) => cl.length)
.join(" ");
</script>
<nav class={klasses}>
<div class={headerContentClasses}>
<slot name="logoleft" />
<slot />
<slot name="logoright" />
</div>
</nav>