Skip to content

Commit fec4523

Browse files
Fix navbar and footer alignments with the main content (#699)
1 parent 44952f7 commit fec4523

10 files changed

Lines changed: 72 additions & 42 deletions

File tree

‎assets/theme-css/bulma.css‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,9 @@
44
flex-grow: 1;
55
margin: 0 auto;
66
position: relative;
7-
width: auto;
8-
}
9-
@media screen and (min-width: 1024px) {
10-
.container {
11-
max-width: 960px;
12-
}
13-
}
14-
@media screen and (min-width: 1216px) {
15-
.container {
16-
max-width: 1152px;
17-
}
7+
width: 100%;
8+
max-width: var(--spht-page-width);
9+
padding: 0 var(--spht-page-padding);
1810
}
1911
@media screen and (max-width: 768px) {
2012
.is-hidden-mobile {

‎assets/theme-css/content.css‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
.content-padding {
22
display: flex;
33
flex-wrap: nowrap;
4+
width: 100%;
5+
max-width: var(--spht-page-width);
6+
margin: 1em auto;
7+
padding: 0 var(--spht-page-padding);
8+
gap: 1.875rem;
9+
}
10+
11+
/* The home page centres its content, as there is no logo for us to align with. */
12+
.content-padding.is-centered {
413
justify-content: center;
5-
margin: 1em;
614
}
715

816
.content-container {
17+
/* Left-anchored, so content doesn't shift on pages without the sidebar. */
918
flex-basis: 70em;
1019
flex-shrink: 1;
1120
flex-direction: column;
12-
margin: 0 1.875rem;
13-
padding: 1rem;
21+
padding: 1rem 0;
1422

15-
/* Handle code cells overflowing */
16-
overflow: auto;
23+
/* Allow the column to shrink. */
24+
min-width: 0;
1725
}

‎assets/theme-css/footer.css‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Footer */
22
#footer {
3-
padding: 3rem 1.5rem 6rem;
3+
/* Horizontal padding comes from .container. */
4+
padding: 3rem 0 6rem;
45
}
56

67
#footer {
@@ -11,7 +12,7 @@
1112
}
1213

1314
#footer-logo-column {
14-
padding: 1.25rem 5vw;
15+
padding: 1.25rem 0;
1516
font-size: 1rem;
1617
}
1718

@@ -21,6 +22,8 @@
2122

2223
#footer-columns {
2324
display: flex;
25+
flex-wrap: wrap;
26+
column-gap: 3rem;
2427
}
2528

2629
.footer-column {
@@ -52,8 +55,8 @@
5255
}
5356

5457
.footer-actions {
55-
max-width: 25vw;
56-
margin: 1.25rem 1.563rem;
58+
max-width: 24rem;
59+
margin: 1.25rem 0 1.25rem auto;
5760
}
5861

5962
.footer-actions > p {
@@ -73,7 +76,9 @@
7376
}
7477

7578
.footer-actions {
76-
max-width: 50vw;
79+
/* Undo the right-aligning auto margin. */
80+
margin: 1.25rem 0;
81+
max-width: 100%;
7782
}
7883

7984
.community-icons {

‎assets/theme-css/navbar.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
align-items: stretch;
1111
display: flex;
1212
min-height: 4rem;
13+
14+
/* Cancel the first item's padding so the logo sits on the page edge. */
15+
margin-left: -0.75rem;
1316
}
1417
.navbar-logo {
1518
height: 28px;
@@ -168,9 +171,6 @@ a.navbar-item.nav-external::after,
168171
align-items: stretch;
169172
display: flex;
170173
}
171-
.navbar > .container .navbar-brand {
172-
margin-left: -0.75rem;
173-
}
174174
.navbar > .container .navbar-menu {
175175
margin-right: -0.75rem;
176176
}

‎assets/theme-css/sphinx-design/_grids.scss‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ $gutter-widths: $spacings;
1515
.sd-container-xl {
1616
margin-left: auto;
1717
margin-right: auto;
18-
padding-left: var(--sd-gutter-x, 0.75rem);
19-
padding-right: var(--sd-gutter-x, 0.75rem);
18+
// Half the gutter, as in Bootstrap. The original 0.75rem
19+
// overflows with larger gutters.
20+
padding-left: calc(var(--sd-gutter-x, 1.5rem) * 0.5);
21+
padding-right: calc(var(--sd-gutter-x, 1.5rem) * 0.5);
2022
width: 100%;
2123
}
2224

‎assets/theme-css/tables.css‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/* Make wide tables scroll on their own, since the content column does not. */
2+
table {
3+
display: block;
4+
width: max-content;
5+
max-width: 100%;
6+
overflow-x: auto;
7+
}
8+
19
table th {
210
color: var(--pst-color-text-muted);
311
text-align: inherit;

‎assets/theme-css/vars.css‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
--spht-color-link-hover: rgb(77, 171, 207);
66
--spht-footer-height: 6em;
77

8+
/* Page width and edge padding shared by the navbar, content, and footer.
9+
The values are taken from the PST, see:
10+
- https://github.com/pydata/pydata-sphinx-theme/blob/3cffc437857105e0852b1caf0dc09e7f36ff07f6/src/pydata_sphinx_theme/assets/styles/variables/_layout.scss#L23
11+
- https://github.com/pydata/pydata-sphinx-theme/blob/3cffc437857105e0852b1caf0dc09e7f36ff07f6/src/pydata_sphinx_theme/assets/styles/sections/_container.scss#L11-L17
12+
- https://github.com/pydata/pydata-sphinx-theme/blob/3cffc437857105e0852b1caf0dc09e7f36ff07f6/src/pydata_sphinx_theme/assets/styles/sections/_header.scss#L37-L42
13+
- https://github.com/pydata/pydata-sphinx-theme/blob/3cffc437857105e0852b1caf0dc09e7f36ff07f6/src/pydata_sphinx_theme/assets/styles/sections/_footer.scss#L5-L10 */
14+
--spht-page-width: 88rem;
15+
--spht-page-padding: 1rem;
16+
817
/* Font Awesome icon variables. */
918
--fa-copy: "\f0c5"; /* fa-solid fa-copy */
1019
}

‎layouts/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{ end }}
99

1010
{{ if .Content }}
11-
<section class="content-padding">
11+
<section class="content-padding is-centered">
1212
<div class="content-container">
1313
{{ .Content }}
1414
</div>

‎layouts/partials/_elements/grid.html‎

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@
55
{{- if eq $outline "true" -}}
66
{{- $outline = "sd-border-1" -}}
77
{{- end -}}
8-
<div class="sd-container-fluid sd-mb-4 {{ $outline | safeHTMLAttr }}">
8+
{{- $gutterParts := split $gutter " " -}}
9+
{{- $gXs := index $gutterParts 0 -}}
10+
{{- $gSm := $gXs -}}
11+
{{- $gMd := $gXs -}}
12+
{{- $gLg := $gXs -}}
13+
{{- if and (gt (len $gutterParts) 1) (ne (len $gutterParts) 4) -}}
14+
{{- errorf "grid gutter must be either 1 or 4 values (but got %d): %q" (len $gutterParts) $gutter -}}
15+
{{- else if eq (len $gutterParts) 4 -}}
16+
{{- $gSm = index $gutterParts 1 -}}
17+
{{- $gMd = index $gutterParts 2 -}}
18+
{{- $gLg = index $gutterParts 3 -}}
19+
{{- end -}}
20+
{{- /* Both need the classes: the container for its padding, and the row
21+
because its base rule overrides the inherited variable. */ -}}
22+
{{- $gutterClasses := printf "sd-g-%s sd-g-xs-%s sd-g-sm-%s sd-g-md-%s sd-g-lg-%s" $gXs $gXs $gSm $gMd $gLg -}}
23+
{{- if eq $columns "auto" -}}
24+
{{- $gutterClasses = "" -}}
25+
{{- end -}}
26+
<div class="sd-container-fluid sd-mb-4 {{ $outline | safeHTMLAttr }} {{ $gutterClasses }}">
927
{{- if eq $columns "auto"}}
1028
<div class="sd-row sd-row-cols-auto sd-row-cols-xs-auto sd-row-cols-sm-auto sd-row-cols-md-auto sd-row-cols-lg-auto">
1129
{{- else }}
@@ -14,19 +32,7 @@
1432
{{- $sm := index $columns 1 }}
1533
{{- $md := index $columns 2 }}
1634
{{- $lg := index $columns 3 }}
17-
{{- $gutterParts := split $gutter " " -}}
18-
{{- $gXs := index $gutterParts 0 -}}
19-
{{- $gSm := $gXs -}}
20-
{{- $gMd := $gXs -}}
21-
{{- $gLg := $gXs -}}
22-
{{- if and (gt (len $gutterParts) 1) (ne (len $gutterParts) 4) -}}
23-
{{- errorf "grid gutter must be either 1 or 4 values (but got %d): %q" (len $gutterParts) $gutter -}}
24-
{{- else if eq (len $gutterParts) 4 -}}
25-
{{- $gSm = index $gutterParts 1 -}}
26-
{{- $gMd = index $gutterParts 2 -}}
27-
{{- $gLg = index $gutterParts 3 -}}
28-
{{- end -}}
29-
<div class="sd-row sd-row-cols-{{ $xs }} sd-row-cols-xs-{{ $xs }} sd-row-cols-sm-{{ $sm }} sd-row-cols-md-{{ $md }} sd-row-cols-lg-{{ $lg }} sd-g-{{ $gXs }} sd-g-xs-{{ $gXs }} sd-g-sm-{{ $gSm }} sd-g-md-{{ $gMd }} sd-g-lg-{{ $gLg }}">
35+
<div class="sd-row sd-row-cols-{{ $xs }} sd-row-cols-xs-{{ $xs }} sd-row-cols-sm-{{ $sm }} sd-row-cols-md-{{ $md }} sd-row-cols-lg-{{ $lg }} {{ $gutterClasses }}">
3036
{{- end }}
3137
{{- range $key, $item := $items -}}
3238
{{- if eq $item.type "card" }}

‎layouts/shortcodes/blog.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="content-padding flex-row">
1+
<section class="content-padding is-centered flex-row">
22
<div class="content-container">
33
{{ $latest := (first 8 (where $.Site.RegularPages.ByPublishDate.Reverse "Section" "posts")) }}
44

0 commit comments

Comments
 (0)