forked from swiftlang/swift-docc-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabnav.vue
104 lines (90 loc) · 1.9 KB
/
Tabnav.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
<!--
This source file is part of the Swift.org open source project
Copyright (c) 2021 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See https://swift.org/LICENSE.txt for license information
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
-->
<template>
<nav
class="tabnav"
:class="{ [`tabnav--${position}`]: position, 'tabnav--vertical': vertical }"
>
<ul class="tabnav-items">
<slot />
</ul>
</nav>
</template>
<script>
const ProvideKey = 'tabnavData';
export default {
name: 'Tabnav',
constants: { ProvideKey },
provide() {
const tabnavData = {
selectTab: this.selectTab,
};
// allows passing the `value` prop as a reactive property
Object.defineProperty(tabnavData, 'activeTab', {
enumerable: true,
get: () => this.value,
});
return {
[ProvideKey]: tabnavData,
};
},
props: {
position: {
type: String,
required: false,
validator: v => new Set(['start', 'center', 'end']).has(v),
},
vertical: {
type: Boolean,
default: false,
},
value: {
type: [String, Number],
required: true,
},
},
methods: {
selectTab(value) {
this.$emit('input', value);
},
},
};
</script>
<style lang='scss' scoped>
@import 'docc-render/styles/_core.scss';
$-tabnav-top-margin: rem(15px);
$-tabnav-bottom-margin: rem(25px);
.tabnav {
margin: 0 0 $-tabnav-bottom-margin 0;
display: flex;
&--center {
justify-content: center;
}
&--end {
justify-content: flex-end;
}
&--vertical {
flex-flow: column wrap;
.tabnav-items {
flex-flow: column;
overflow: hidden;
}
:deep(.tabnav-item) {
padding-left: 0;
.tabnav-link {
padding-top: 8px;
}
}
}
}
.tabnav-items {
display: flex;
margin: 0;
text-align: center;
}
</style>