forked from swiftlang/swift-docc-render
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTabnavItem.vue
115 lines (98 loc) · 2.26 KB
/
TabnavItem.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
<!--
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>
<li class="tabnav-item">
<a
href="#"
class="tabnav-link"
:class="{ 'active': isActive }"
:aria-current="isActive ? 'true' : 'false'"
@click.prevent="tabnavData.selectTab(value)"
>
<slot />
</a>
</li>
</template>
<script>
export default {
name: 'TabnavItem',
inject: {
tabnavData: {
default: { activeTab: null, selectTab: () => {} },
},
},
props: {
value: {
type: [String, Number],
default: null,
},
},
computed: {
isActive({ tabnavData, value }) {
return tabnavData.activeTab === value;
},
},
};
</script>
<style lang='scss' scoped>
@import 'docc-render/styles/_core.scss';
$tabnav-padding: 6px !default;
$tabnav-margin: 4px !default;
$tabnav-item-gutter: rem(30px);
.tabnav-item {
border-bottom: 1px solid;
border-color: var(--colors-tabnav-item-border-color, var(--color-tabnav-item-border-color));
display: flex;
list-style: none;
padding-left: $tabnav-item-gutter;
margin: 0;
outline: none;
&:first-child {
padding-left: 0;
}
// hack to make sure item margin is not overwritten by external css
&:nth-child(n+1) {
margin: 0;
}
}
.tabnav-link {
color: var(--colors-secondary-label, var(--color-secondary-label));
@include font-styles(tabnav-link);
padding: $tabnav-padding 0;
margin-top: $tabnav-margin;
margin-bottom: $tabnav-margin;
text-align: left;
text-decoration: none;
display: block;
position: relative;
z-index: 0;
width: 100%;
&:hover {
text-decoration: none;
}
&:focus {
outline-offset: -1px;
}
&:after {
content: '';
position: absolute;
bottom: -1 * ($tabnav-margin + 1);
left: 0;
width: 100%;
border: 1px solid transparent;
}
&.active {
color: var(--colors-text, var(--color-text));
cursor: default;
z-index: 10;
&:after {
border-bottom-color: var(--colors-text, var(--color-text));
}
}
}
</style>