-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathHeader.vue
120 lines (106 loc) · 2.97 KB
/
Header.vue
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
<script setup lang="ts">
import { computed, useCssModule } from "vue";
export interface HeaderProps {
css?: string;
isSkinned?: boolean;
isSticky?: boolean;
isHeaderContentStart?: boolean;
isHeaderContentEnd?: boolean;
}
const styles = useCssModule();
const props = withDefaults(defineProps<HeaderProps>(), {
css: "",
isSkinned: true,
});
const classes = computed(() => ({
// If skinned we use .card which includes .card-base and .card-skin
[styles.header]: props.isSkinned,
// Otherwise only the .card-base
[styles["header-base"]]: !props.isSkinned,
[styles["header-sticky"]]: props.isSticky,
[`${props.css}`]: !!props.css,
}));
const headerContentClasses = computed(() => ({
[styles["header-content"]]: true,
[styles["header-content-start"]]: props.isHeaderContentStart,
[styles["header-content-end"]]: props.isHeaderContentEnd,
}));
</script>
<template>
<nav :class="classes">
<div :class="headerContentClasses">
<slot name="logoleft" />
<slot name="headernav" />
<slot name="logoright" />
</div>
</nav>
</template>
<style module>
.header,
.header-base {
display: block;
}
.header-base img,
.header 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>