Debian Codegraph @

src/pydata_sphinx_theme/assets/styles/sections/_header.scss

raw
1 /**
2 * Header at the top of the page
3 * It includes the announcement bar and the navigation bar.
4 */
5
6 // Styling for the Icon links can be found in components/_icon-links.scss
7
8 // If we want the shadow to only point downward in the future, set
9 // box-shadow to: 0 0.125rem 0.25rem -0.125rem rgba(0, 0, 0, 0.11);
10 .bd-header {
11 position: sticky;
12 top: 0;
13 z-index: $zindex-fixed;
14
15 // Overrides bootstrap
16 background-color: var(--pst-color-on-background) !important;
17 box-shadow: 0 0.125rem 0.25rem 0 var(--pst-color-shadow);
18 width: 100%;
19 padding: 0;
20 max-width: 100vw;
21 justify-content: center;
22
23 .bd-header__inner {
24 display: flex;
25 align-items: center;
26 height: fit-content;
27 padding-left: 1rem;
28 padding-right: 1rem;
29 }
30
31 :focus-visible {
32 border-radius: $focus-ring-radius;
33 }
34
35 // These items will define the height of the header
36 .navbar-item {
37 height: var(--pst-header-height);
38 max-height: var(--pst-header-height);
39 display: flex;
40 align-items: center;
41 }
42
43 // Hide the navbar header items on mobile because they're in the sidebar
44 .navbar-header-items {
45 display: none;
46 flex-shrink: 1;
47
48 @include media-breakpoint-up($breakpoint-sidebar-primary) {
49 display: inherit;
50 flex-grow: 1;
51 padding: 0 0 0 0.5rem;
52 }
53 }
54
55 .navbar-header-items__end,
56 .navbar-header-items__center,
57 .navbar-header-items__start {
58 display: flex;
59 align-items: center;
60 flex-flow: wrap;
61
62 // In case we wrap our items to multiple rows on small screens
63 row-gap: 0;
64 }
65
66 .navbar-header-items__end,
67 .navbar-header-items__center {
68 column-gap: $nav-icon-column-gap;
69 }
70
71 // A little smaller because this is displayed by default on mobile
72 .navbar-header-items__start {
73 flex-shrink: 0;
74 margin-right: auto;
75 gap: 0.5rem;
76 }
77
78 .navbar-header-items__end {
79 // End navbar items should snap to the right
80 justify-content: end;
81 }
82
83 // Contains the navigation links within the navbar
84 ul.navbar-nav {
85 display: flex;
86
87 @include media-breakpoint-up($breakpoint-sidebar-primary) {
88 // Align on wide screens so the dropdown button is centered properly
89 align-items: baseline;
90 }
91
92 > li.nav-item {
93 margin-inline: 2px; // breathing room so hover and focus styles do not overlap
94
95 > .nav-link {
96 @include link-style-block;
97
98 padding-inline: 6px;
99 }
100
101 &.current {
102 > .nav-link {
103 color: var(--pst-color-primary);
104
105 // Underline the current navbar item
106 &::before {
107 border-bottom: 3px solid var(--pst-color-primary);
108 }
109 }
110 }
111
112 &.dropdown {
113 margin-inline: 4px;
114
115 button {
116 padding-inline: 8px;
117 }
118
119 > .dropdown-toggle {
120 border-radius: $focus-ring-radius; // make border radius the same for both hover ring and focus ring
121 color: var(--pst-color-text-muted);
122
123 &:focus-visible {
124 box-shadow: $focus-ring-box-shadow;
125 }
126
127 &:hover {
128 text-decoration: none;
129 box-shadow: 0 0 0 $focus-ring-width var(--pst-color-link-hover); // purple focus ring
130 // Brighten the text on hover (muted -> base)
131 color: var(--pst-color-text-base);
132 }
133 }
134 }
135 }
136
137 li a.nav-link.dropdown-item {
138 @include link-style-text;
139 }
140
141 // Dropdowns for the extra links
142 .dropdown {
143 button {
144 display: unset;
145 border: none;
146
147 &:hover {
148 @include link-style-hover;
149 }
150 }
151
152 .dropdown-menu {
153 z-index: $zindex-popover;
154 border: 1px solid var(--pst-color-border);
155 box-shadow: 0 0 0.3rem 0.1rem var(--pst-color-shadow);
156 background-color: var(--pst-color-on-background);
157 padding: 0.5rem 0;
158 margin: 0.5rem 0;
159 min-width: 20rem;
160
161 .dropdown-item {
162 // Give the items in the dropdown some breathing room but let the hit
163 // and hover area of the items extend to the edges of the menu
164 padding: 0.25rem 1.5rem;
165
166 // Override Bootstrap
167 &:focus:not(:hover, :active) {
168 background-color: inherit;
169 }
170
171 &:focus-visible {
172 z-index: 10; // keep focus ring on top (prevent the hover background of the next dropdown item from covering the ring)
173 }
174 }
175
176 // Hide the menu unless show has been clicked
177 &:not(.show) {
178 display: none;
179 }
180 }
181 }
182 }
183
184 // **************************************************************
185 // Showing and hiding the sidebar toggle buttons and header items
186 // **************************************************************
187
188 // Toggle buttons
189 button.sidebar-toggle {
190 font-size: var(--pst-font-size-icon);
191 color: var(--pst-color-muted);
192 margin-bottom: 0;
193 background-color: inherit;
194 padding: 0.5rem;
195 }
196
197 button.primary-toggle {
198 margin-right: 1rem;
199
200 @include media-breakpoint-up($breakpoint-sidebar-primary) {
201 display: none;
202 }
203 }
204
205 button.secondary-toggle {
206 margin-left: 1rem;
207
208 @include media-breakpoint-up($breakpoint-sidebar-secondary) {
209 display: none;
210 }
211 }
212 }
213
214 // inline the element in the navbar as long as they fit and use display block when collapsing
215 @include media-breakpoint-up($breakpoint-sidebar-primary) {
216 .navbar-center-items .navbar-item {
217 display: inline-block;
218 }
219 }
220
221 .nav-link {
222 &:hover {
223 @include link-style-hover;
224 }
225
226 // Override Bootstrap
227 transition: none;
228
229 &.nav-external::after {
230 font: var(--fa-font-solid);
231 content: var(--pst-icon-external-link);
232 font-size: 0.75em;
233 margin-left: 0.3em;
234 }
235 }
236
237 .bd-navbar-elements li.nav-item i {
238 font-size: 0.7rem;
239 padding-left: 2px;
240 vertical-align: middle;
241 }
242
243 // THe elements next to the hamburger menu only show on narrow screens
244 .navbar-persistent--mobile {
245 margin-left: auto;
246
247 @include media-breakpoint-up($breakpoint-sidebar-primary) {
248 display: none;
249 }
250 }
251
252 // The navbar-persistent content should only show on wide screens
253 .navbar-persistent--container {
254 display: none;
255
256 @include media-breakpoint-up($breakpoint-sidebar-primary) {
257 display: flex;
258 }
259 }