-
Notifications
You must be signed in to change notification settings - Fork 14
/
_tab-title.scss
154 lines (134 loc) · 3.75 KB
/
_tab-title.scss
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
@forward './../../variables/options';
@use './../../mixins/color' as color-mx;
@use './../../mixins/utilities' as utilities-mx;
@use './../../variables/color';
@use './../../variables/spacing';
@use './../../variables/components/nav';
.tab-title[role='tab'] {
display: inline-block;
cursor: pointer;
position: relative;
box-sizing: border-box;
padding: nav.$nav-link-padding;
transition: background-color 100ms;
border-right: 1px solid transparent;
border-left: 1px solid transparent;
outline-color: currentColor;
opacity: 0.7;
color: var(--post-contrast-color);
text-decoration: none;
background-color: transparent;
&:focus {
background-color: unset;
color: var(--post-contrast-color);
}
&:hover {
opacity: 1;
background-color: rgba(var(--post-contrast-color-rgb), 0.6);
color: var(--post-contrast-color-inverted);
}
// same styles as focus, can't use placeholder here because focus-visible can't be described outside of the support condition
&:focus-visible {
outline: transparent;
opacity: 1;
background-color: rgba(var(--post-contrast-color-rgb), 0.6);
color: var(--post-contrast-color-inverted);
box-shadow: none;
&::after {
content: '';
display: block;
position: absolute;
top: nav.$nav-tabs-focus-box-shadow-width;
right: nav.$nav-tabs-focus-box-shadow-width - 1px;
bottom: 0;
left: nav.$nav-tabs-focus-box-shadow-width - 1px;
box-shadow: nav.$nav-tabs-focus-box-shadow;
}
}
&.active {
z-index: 1; // Lift above the line and make focus visible all around
border-right-color: nav.$nav-tabs-border-color;
border-left-color: nav.$nav-tabs-border-color;
opacity: 1;
background-color: var(--post-contrast-color-inverted);
color: var(--post-contrast-color);
font-weight: 700;
// Create a line that does not suffer from border corner mitering
&::before {
content: '';
display: block;
position: absolute;
top: 0;
right: -1px;
left: -1px;
height: spacing.$size-micro;
background-color: nav.$nav-tabs-link-active-border-color;
}
}
// Tabs with dark backgrounds
@include color-mx.on-dark-background() {
&:hover {
background-color: rgba(nav.$nav-tabs-link-active-bg, 0.2);
}
&:focus-visible {
background-color: rgba(nav.$nav-tabs-link-active-bg, 0.2);
}
}
@include utilities-mx.high-contrast-mode() {
opacity: 1;
border-left-color: Canvas;
border-right-color: Canvas;
color: LinkText;
&:hover,
&:focus,
&:focus-within,
&:focus-visible {
outline: spacing.$size-line solid Highlight;
outline-offset: -(spacing.$size-micro);
}
&.active {
border-left-color: ButtonText;
border-right-color: ButtonText;
color: Highlight;
&::before {
background-color: Highlight;
}
}
}
}
// Careful, this generates a lot of code
@each $key, $color in color.$background-colors {
.bg-#{$key} {
.tab-title {
background-color: $color;
&.active {
background-color: $color;
}
}
.nav-item {
background-color: $color;
}
}
}
[class*='bg-'] .tab-title.active {
&:focus {
&::after {
background-color: rgba(255, 255, 255, 0.2);
}
}
// write supports for selectors this way: https://stackoverflow.com/a/62666132
// need to include * otherwise it throws build error
@supports #{'\selector(*:focus-visible)'} {
&:focus {
&::after {
background-color: unset;
}
}
// same styles as focus, can't use placeholder here because focus-visible can't be described outside of the support condition
&:focus-visible {
&::after {
background-color: rgba(255, 255, 255, 0.2);
}
}
}
}