Skip to content

Commit 2b432f1

Browse files
authored
Merge pull request #113 from zoosky/fix/site-mobile-layout
Fit the site to a phone, and show the build in the footer
2 parents bbe2a94 + 4d35ab1 commit 2b432f1

4 files changed

Lines changed: 168 additions & 7 deletions

File tree

docs/themes/sass/assets/css/main.scss

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,48 @@ code, kbd, samp, pre { font-family: var(--mono); }
248248
}
249249
}
250250

251+
.site-tools {
252+
display: flex;
253+
align-items: center;
254+
gap: 0.35rem;
255+
}
256+
257+
// A phone cannot hold the wordmark, six links and two buttons on one 60px row:
258+
// at 390px the row ran to 521px and every page scrolled sideways. So the
259+
// header wraps into two rows. The buttons stay beside the wordmark, and the
260+
// links take a full-width row of their own that scrolls sideways when it does
261+
// not fit, rather than hiding links to make the rest fit.
251262
@media (max-width: 640px) {
252-
.site-nav .hide-sm { display: none; }
263+
// The sticky header is taller here, so in-page links need a larger offset.
264+
html { scroll-padding-top: 7.5rem; }
265+
266+
.site-header > .container {
267+
flex-wrap: wrap;
268+
height: auto;
269+
column-gap: 0.75rem;
270+
row-gap: 0.15rem;
271+
padding-top: 0.6rem;
272+
}
273+
274+
.site-tools { margin-left: auto; }
275+
276+
.site-nav {
277+
order: 3;
278+
flex: 1 0 100%;
279+
// Full-bleed, so the row scrolls to the screen edges; the inner padding
280+
// lines the first link's text up with the wordmark above it.
281+
margin: 0 -1.5rem;
282+
padding: 0 1.5rem 0.55rem 0.9rem;
283+
overflow-x: auto;
284+
scrollbar-width: none;
285+
286+
&::-webkit-scrollbar { display: none; }
287+
288+
a {
289+
flex: none;
290+
white-space: nowrap;
291+
}
292+
}
253293
}
254294

255295
// ---------------------------------------------------------------------------
@@ -841,8 +881,72 @@ code, kbd, samp, pre { font-family: var(--mono); }
841881

842882
@media (max-width: 940px) {
843883
position: static;
844-
padding-bottom: 1.25rem;
845-
border-bottom: 1px solid var(--border);
884+
}
885+
886+
// Beside the page the menu is always open and needs no control, so its
887+
// summary is hidden. Above the page it is a one-line disclosure naming the
888+
// page you are on; see the note in docs.html.jinja.
889+
.docs-nav-menu > summary { display: none; }
890+
891+
@media (max-width: 940px) {
892+
.docs-nav-menu {
893+
border: 1px solid var(--border);
894+
border-radius: var(--radius-sm);
895+
background: var(--surface);
896+
}
897+
898+
.docs-nav-menu > summary {
899+
display: flex;
900+
align-items: center;
901+
gap: 0.75rem;
902+
padding: 0.7rem 0.9rem;
903+
cursor: pointer;
904+
list-style: none;
905+
font-family: var(--mono);
906+
font-size: 0.72rem;
907+
letter-spacing: 0.14em;
908+
text-transform: uppercase;
909+
color: var(--text-faint);
910+
911+
&::-webkit-details-marker { display: none; }
912+
913+
// A chevron drawn with two borders, pointing down while closed and up
914+
// while open.
915+
&::after {
916+
content: "";
917+
flex: none;
918+
width: 0.45rem;
919+
height: 0.45rem;
920+
margin: 0 0.2rem 0.2rem 0;
921+
border-right: 1.5px solid currentColor;
922+
border-bottom: 1.5px solid currentColor;
923+
transform: rotate(45deg);
924+
}
925+
}
926+
927+
.docs-nav-menu[open] > summary::after {
928+
margin: 0.2rem 0.2rem 0 0;
929+
transform: rotate(-135deg);
930+
}
931+
932+
.docs-nav-current {
933+
flex: 1;
934+
min-width: 0;
935+
overflow: hidden;
936+
text-overflow: ellipsis;
937+
white-space: nowrap;
938+
text-align: right;
939+
font-family: var(--font);
940+
font-size: 0.9rem;
941+
letter-spacing: 0;
942+
text-transform: none;
943+
color: var(--text);
944+
}
945+
946+
.docs-nav-lists {
947+
padding: 0.9rem 0.6rem 0.2rem;
948+
border-top: 1px solid var(--border);
949+
}
846950
}
847951

848952
.nav-title {
@@ -980,6 +1084,13 @@ code, kbd, samp, pre { font-family: var(--mono); }
9801084
font-size: 0.83rem;
9811085
color: var(--text-faint);
9821086
}
1087+
1088+
.build-info {
1089+
margin: 0.5rem 0 0;
1090+
font-family: var(--mono);
1091+
font-size: 0.72rem;
1092+
color: var(--text-faint);
1093+
}
9831094
}
9841095

9851096
// ---------------------------------------------------------------------------

docs/themes/sass/templates/base.html.jinja

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@
5454
<div class="container">
5555
<a class="wordmark" href="{{ url('/') }}">accent<span class="mark">-</span>sass</a>
5656

57+
{# The links and the two buttons are separate groups so a narrow screen
58+
can lay them out differently: the buttons stay beside the wordmark,
59+
and the links take a row of their own that scrolls sideways. Every
60+
link stays reachable on a phone that way, where hiding some did not
61+
make the rest fit. #}
5762
<nav class="site-nav" aria-label="Main">
5863
<a href="{{ url('/guide') }}" {% if page.url and '/guide' in page.url %}class="active"{% endif %}>Guide</a>
5964
<a href="{{ url('/reference') }}" {% if page.url and '/reference' in page.url %}class="active"{% endif %}>Reference</a>
6065
<a href="{{ url('/demo/') }}" {% if page.url and '/demo' in page.url %}class="active"{% endif %}>Demo</a>
61-
<a class="hide-sm{% if page.url and '/changelog' in page.url %} active{% endif %}" href="{{ url('/changelog') }}">Changelog</a>
62-
<a class="ext hide-sm" href="https://docs.rs/accent-sass">API</a>
66+
<a href="{{ url('/changelog') }}" {% if page.url and '/changelog' in page.url %}class="active"{% endif %}>Changelog</a>
67+
<a class="ext" href="https://docs.rs/accent-sass">API</a>
6368
<a class="ext" href="https://github.com/zoosky/accent-sass">GitHub</a>
69+
</nav>
6470

71+
<div class="site-tools">
6572
<button type="button" class="icon-btn search-trigger" id="search-trigger"
6673
aria-label="Search" aria-expanded="false" aria-controls="search-overlay">
6774
<svg viewBox="0 0 16 16" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="M10.5 10.5 14 14"/></svg>
@@ -76,7 +83,7 @@
7683
<svg class="icon-sun" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3.2"/><path d="M8 .8v1.8M8 13.4v1.8M15.2 8h-1.8M2.6 8H.8M13.09 2.91l-1.27 1.27M4.18 11.82l-1.27 1.27M13.09 13.09l-1.27-1.27M4.18 4.18 2.91 2.91"/></svg>
7784
<svg class="icon-moon" viewBox="0 0 16 16" aria-hidden="true"><path d="M13.5 9.6A5.8 5.8 0 0 1 6.4 2.5a5.8 5.8 0 1 0 7.1 7.1Z"/></svg>
7885
</button>
79-
</nav>
86+
</div>
8087
</div>
8188
</header>
8289

@@ -159,6 +166,26 @@
159166
accent-sass. The <a href="{{ url('/demo/') }}">demo</a> runs the same
160167
compiler in your browser.
161168
</p>
169+
170+
{# Which build a reader is looking at. `accent.version_string` names the
171+
Accent binary that rendered the page and its git hash, for example
172+
`0.25.1 (abc1234)`. The date is when the site was built, which here is
173+
when a change was last deployed: the Pages workflow rebuilds on every
174+
change to the docs, the theme, the compiler or CHANGELOG.md. File
175+
modification dates are not used, because a CI checkout gives every
176+
file the time of the checkout.
177+
178+
`site.built_at` is an ISO 8601 timestamp such as `2026-09-13T16:00:14Z`.
179+
The `date` filter passes it through unformatted, so the date is its
180+
first ten characters, which reads the same under every Accent release.
181+
v0.25.1, the release the workflow pins, renders `site.built_at` though
182+
its documentation only lists it from v0.26; `site.last_modified` is the
183+
fallback if a release ever omits it. #}
184+
{% set updated = site.built_at or site.last_modified %}
185+
<p class="build-info">
186+
Built with Accent CMS {{ accent.version_string }}{% if updated %} · Last updated
187+
<time datetime="{{ updated }}">{{ updated[:10] }}</time>{% endif %}
188+
</p>
162189
</div>
163190
</footer>
164191
<script src="{{ url('/_search/search.js') }}" defer></script>

docs/themes/sass/templates/docs.html.jinja

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@
3232
{% block body %}
3333
<div class="container docs-layout">
3434
<nav class="docs-nav" aria-label="Documentation">
35+
{# A disclosure, so a narrow screen -- where this sits above the page
36+
rather than beside it -- can collapse the twenty links to one line and
37+
show the content first. It ships open, which is what a reader without
38+
JavaScript gets on any screen; the script below closes it on a narrow
39+
screen before the page below it renders. #}
40+
<details class="docs-nav-menu" open>
41+
<summary>Pages<span class="docs-nav-current">{{ page.title }}</span></summary>
42+
<div class="docs-nav-lists">
3543
<p class="nav-title">Usage guide</p>
3644
<ul>
3745
<li>
@@ -69,6 +77,21 @@
6977
<li><a href="https://sass-lang.com/documentation/">Sass language</a></li>
7078
<li><a href="https://github.com/zoosky/accent-sass">Source</a></li>
7179
</ul>
80+
</div>
81+
</details>
82+
{# Inline and synchronous rather than in the deferred chrome.js: a deferred
83+
script closes the menu after first paint, so a phone would show the
84+
whole list and then jump. The width matches the stacking breakpoint in
85+
main.scss, and crossing it -- a rotated tablet -- resets the state. #}
86+
<script>
87+
(function () {
88+
var menu = document.currentScript.previousElementSibling;
89+
var narrow = window.matchMedia("(max-width: 940px)");
90+
function sync() { menu.open = !narrow.matches; }
91+
sync();
92+
narrow.addEventListener("change", sync);
93+
})();
94+
</script>
7295
</nav>
7396

7497
<article class="docs-main">

docs/themes/sass/templates/home.html.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<span class="tok-cm">// No Node, no libsass, no subprocess. The same</span>
5656
<span class="tok-cm">// compiler runs in a browser:</span>
57-
<span class="tok-cm">// import { compileString } from "accent-sass";</span></code></pre>
57+
<span class="tok-cm">// import { compileString } from "@zoosky/accent-sass";</span></code></pre>
5858
</div>
5959
</div>
6060
</div>

0 commit comments

Comments
 (0)