-
-
Notifications
You must be signed in to change notification settings - Fork 78.7k
Expand file tree
/
Copy path_navbar.scss
More file actions
313 lines (279 loc) · 9.56 KB
/
Copy path_navbar.scss
File metadata and controls
313 lines (279 loc) · 9.56 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
@use "config" as *;
@use "functions" as *;
@use "layout/breakpoints" as *;
@use "mixins/box-shadow" as *;
@use "mixins/mask-icon" as *;
@use "mixins/tokens" as *;
@use "mixins/transition" as *;
// TODO: fix nav-link-height and navbar-brand-height, which we previously calculated with font-size, line-height, and block padding
// stylelint-disable custom-property-no-missing-var-function
// scss-docs-start navbar-breakpoints
$navbar-breakpoints: $breakpoints !default;
// scss-docs-end navbar-breakpoints
$navbar-tokens: () !default;
$navbar-dark-tokens: () !default;
$navbar-nav-tokens: () !default;
// scss-docs-start navbar-tokens
// stylelint-disable-next-line scss/dollar-variable-default
$navbar-tokens: defaults(
(
--navbar-padding-x: 0,
--navbar-padding-y: .5rem,
--navbar-color: var(--fg-2),
--navbar-hover-color: var(--fg-1),
--navbar-disabled-color: var(--fg-3),
--navbar-active-color: var(--fg-body),
--navbar-brand-padding-y: .75rem,
--navbar-brand-margin-end: 1rem,
--navbar-brand-font-size: var(--font-size-md),
--navbar-brand-font-weight: var(--font-weight-medium),
--navbar-brand-color: var(--fg-body),
--navbar-brand-hover-color: var(--fg-body),
--navbar-nav-link-padding-x: .75rem,
--navbar-toggler-width: 2rem,
--navbar-toggler-padding-y: .25rem,
--navbar-toggler-padding-x: .75rem,
--navbar-toggler-font-size: var(--font-size-lg),
--navbar-toggler-border-color: color-mix(in oklch, var(--fg-body) 15%, transparent),
--navbar-toggler-border-radius: var(--radius-5),
--navbar-toggler-transition: box-shadow .15s ease-in-out,
--navbar-toggler-icon-size: 1.25rem,
--navbar-toggler-icon: #{escape-svg(url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path stroke='black' stroke-linecap='round' stroke-width='1' d='M1 3.5h14M1 8h14M1 12.5h14'/></svg>"))},
),
$navbar-tokens
);
// scss-docs-end navbar-tokens
// scss-docs-start navbar-dark-tokens
// stylelint-disable-next-line scss/dollar-variable-default
$navbar-dark-tokens: defaults(
(
--navbar-color: color-mix(in oklch, var(--white) .55, transparent),
--navbar-hover-color: color-mix(in oklch, var(--white) .75, transparent),
--navbar-disabled-color: color-mix(in oklch, var(--white) .25, transparent),
--navbar-active-color: var(--white),
--navbar-brand-color: var(--white),
--navbar-brand-hover-color: var(--white),
--navbar-toggler-border-color: color-mix(in oklch, var(--white) .1, transparent),
),
$navbar-dark-tokens
);
// scss-docs-end navbar-dark-tokens
// scss-docs-start navbar-nav-tokens
// stylelint-disable-next-line scss/dollar-variable-default
$navbar-nav-tokens: defaults(
(
--nav-gap: .25rem,
--nav-link-gap: .5rem,
--nav-link-padding-x: .5rem,
--nav-link-padding-y: .375rem,
--nav-link-color: var(--navbar-color),
--nav-link-border-width: var(--border-width),
//--nav-link-border-color: var(--border-color),
--nav-link-hover-color: var(--navbar-hover-color),
--nav-link-hover-bg: transparent,
--nav-link-active-color: var(--navbar-active-color),
--nav-link-active-bg: transparent,
--nav-link-disabled-color: var(--navbar-disabled-color),
),
$navbar-nav-tokens
);
// scss-docs-end navbar-nav-tokens
// stylelint-enable custom-property-no-missing-var-function
@layer components {
// Base navbar
.navbar {
@include tokens($navbar-tokens);
position: relative;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
padding: var(--navbar-padding-y) var(--navbar-padding-x);
@include set-container();
color: var(--navbar-color, var(--fg-body));
background-color: var(--navbar-bg, var(--bg-body));
// @include gradient-bg(var(--navbar-bg, var(--bg-body)));
// Container properties for nested containers
%container-flex-properties {
display: flex;
flex-wrap: inherit;
align-items: center;
justify-content: space-between;
}
> .container,
> .container-fluid {
@extend %container-flex-properties;
}
@each $breakpoint, $container-max-width in $container-max-widths {
> .#{breakpoint-prefix($breakpoint, $container-max-widths)}container {
@extend %container-flex-properties;
}
}
}
// Navbar brand
//
// Used for brand, project, or site names.
.navbar-brand {
padding-top: var(--navbar-brand-padding-y);
padding-bottom: var(--navbar-brand-padding-y);
margin-inline-end: var(--navbar-brand-margin-end);
font-size: var(--navbar-brand-font-size);
font-weight: var(--navbar-brand-font-weight);
color: var(--navbar-brand-color);
text-decoration: none;
white-space: nowrap;
&:hover,
&:focus {
color: var(--navbar-brand-hover-color);
}
}
// Navigation within navbars. Sets all nav-link CSS variables needed for
// proper styling.
//
// Relies on `.nav` base class.
.navbar-nav {
@include tokens($navbar-nav-tokens);
display: flex;
flex-direction: column;
gap: var(--nav-gap);
padding-inline-start: 0;
margin-bottom: 0;
list-style-type: "";
.nav-link {
&.active,
&.show {
color: var(--navbar-active-color);
border: var(--nav-link-border-width) solid var(--nav-link-border-color, transparent);
}
}
}
// Navbar text
//
// For adding text or inline elements to the navbar
.navbar-text {
padding-top: var(--navbar-brand-padding-y);
padding-bottom: var(--navbar-brand-padding-y);
color: var(--navbar-color);
a,
a:hover,
a:focus {
color: var(--navbar-active-color);
}
}
// Button for toggling the navbar when in its collapsed state
.navbar-toggler {
--btn-bg: transparent;
--btn-hover-bg: var(--bg-2);
@include transition(var(--navbar-toggler-transition));
}
// Hamburger icon, rendered via CSS mask so it inherits the navbar color
.navbar-toggler-icon {
display: inline-block;
width: var(--navbar-toggler-icon-size);
height: var(--navbar-toggler-icon-size);
background-color: currentcolor;
@include mask-icon(var(--navbar-toggler-icon));
}
// scss-docs-start navbar-expand-loop
// Generate series of responsive `.navbar-expand` classes for configuring
// where your navbar collapses and expands. Uses container queries so the
// navbar responds to its own width, not the viewport width.
// Mixin for expanded state styles (applied to descendants)
@mixin navbar-expanded {
// Style the inner container since we can't style .navbar itself with container queries
> .container,
> .container-fluid,
%navbar-expand-container {
flex-wrap: nowrap;
justify-content: flex-start;
}
.navbar-nav {
--nav-link-padding-x: var(--navbar-nav-link-padding-x);
flex-direction: row;
}
.navbar-toggler {
display: none !important; // stylelint-disable-line declaration-no-important
}
[class*="drawer"] {
// stylelint-disable declaration-no-important
// Reset native <dialog> UA styles and below-breakpoint drawer styles.
// Must use !important to override both UA <dialog> defaults and the
// responsive drawer styles from media-breakpoint-down().
position: static !important;
inset: auto !important;
z-index: auto;
display: flex !important;
flex-grow: 1;
width: auto !important;
max-width: none !important;
height: auto !important;
max-height: none !important;
padding: 0;
margin: 0;
visibility: visible !important;
background-color: transparent !important;
border: 0 !important;
transform: none !important;
@include box-shadow(none);
@include transition(none);
// stylelint-enable declaration-no-important
.drawer-header {
display: none !important; // stylelint-disable-line declaration-no-important
}
.drawer-body {
display: flex;
flex-grow: 1;
flex-direction: row;
align-items: center;
padding: 0;
overflow-y: visible;
}
}
}
// Always expanded (no responsive behavior)
.navbar-expand {
@include navbar-expanded();
// Also set on navbar itself for non-responsive case
flex-wrap: nowrap;
justify-content: flex-start;
}
// Responsive navbar expand classes using container queries
@include loop-breakpoints-down($navbar-breakpoints) using ($breakpoint, $next, $prefix) {
@if $next {
.#{$prefix}navbar-expand {
@include container-breakpoint-up($next) {
@include navbar-expanded();
}
}
}
}
// scss-docs-end navbar-expand-loop
// Prevent drawer flash on breakpoint crossing.
// When the navbar crosses from expanded (inline) to collapsed (drawer),
// the drawer transitions from visibility:visible to visibility:hidden.
// Without this override, the slide transition plays — briefly showing the
// panel sliding away. Disabling transitions when not [open] ensures only
// intentional show/hide actions animate.
// stylelint-disable-next-line no-duplicate-selectors
.navbar {
[class*="drawer"]:not([open], .hiding) {
@include transition(none !important);
}
}
.navbar-translucent {
position: relative;
background-color: transparent;
&::before {
position: absolute;
inset: 0;
z-index: -1;
content: "";
background-color: color-mix(in oklch, var(--navbar-bg, var(--bg-body)) 80%, transparent);
background-image: none;
backdrop-filter: blur(5px) saturate(180%);
}
}
.navbar[data-bs-theme="dark"] {
@include tokens($navbar-dark-tokens);
}
}