mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
feat: put the wanted page in the site header
A Wanted files link sits in the bar on every page and every width, beside the search and menu buttons on a phone, current on its own page. Below 27rem the site name is kept for screen readers only. files/ and wanted/ link each other in one line.
This commit is contained in:
1 parent
4a9317cb4c
commit
e6738e591b
5 files changed
+94
-3
No files matched your search
@@ -4887,6 +4887,8 @@ def generate_files_page() -> str:
|
||||
"`scph5501.bin`, the PlayStation BIOS v3.0. "
|
||||
"To look a file up by its name, use the search at the top of the page.",
|
||||
"",
|
||||
"Have a file the collection lacks? [See if it is wanted](../wanted.md).",
|
||||
"",
|
||||
"## Permanent links",
|
||||
"",
|
||||
"A file's card lives on its manufacturer's page, and a file refiled "
|
||||
|
||||
@@ -336,7 +336,9 @@ def page(known: int) -> str:
|
||||
"3. A check reads the file and says if it fits. Then we add it.",
|
||||
"",
|
||||
(f"The page knows {known:,} wanted files by their hash, a fingerprint of the contents. "
|
||||
"The rest are listed on [the gaps page](gaps.md). "
|
||||
"The rest are listed on [the gaps page](gaps.md)."),
|
||||
"",
|
||||
("To look up any file, use [Find or check a file](files/index.md). "
|
||||
"More ways to help are on [Contributing](contributing.md)."),
|
||||
"",
|
||||
])
|
||||
@@ -189,6 +189,38 @@ class SectionTabsInTheHeader(unittest.TestCase):
|
||||
self.assertRegex(nav.group(1), r'aria-current="true"[^>]*>\s*Start here')
|
||||
|
||||
|
||||
class TheWantedPageIsInTheBar(unittest.TestCase):
|
||||
"""The wanted page is the site's call to contribute: in the bar on every
|
||||
page, beside the search and menu buttons on a phone, where the section
|
||||
tabs fold into the menu."""
|
||||
|
||||
LINK = re.compile(r'<a class="rb-wanted-link[^"]*" href="/retrobios/wanted/"([^>]*)>Wanted files</a>')
|
||||
|
||||
def test_the_bar_holds_it_outside_the_tabs(self):
|
||||
header = _read(COMPONENTS / "Header.astro")
|
||||
bar = header[header.index('<div class="rb-header-bar">'):header.index("</div>")]
|
||||
self.assertIn('class="rb-wanted-link print:hidden"', bar)
|
||||
self.assertIn("aria-current={onWanted ? 'page' : undefined}", bar)
|
||||
# Theme colours only, the same in both themes' variables.
|
||||
style = header[header.index(".rb-wanted-link {"):header.index("@media")]
|
||||
self.assertNotRegex(style, r"#[0-9a-fA-F]{3,6}\b")
|
||||
# At 360 px the name was cut to "Retr": the logo stays, the name is
|
||||
# kept for screen readers only.
|
||||
narrow = header[header.index("@media (max-width: 26.99rem)"):]
|
||||
self.assertIn(".site-title span {", narrow[:200])
|
||||
self.assertIn("clip-path: inset(50%);", narrow[:400])
|
||||
|
||||
def test_built_on_every_page_current_on_its_own(self):
|
||||
for page in ("which-pack", "files", "systems"):
|
||||
with self.subTest(page=page):
|
||||
found = self.LINK.search(_built(page))
|
||||
self.assertIsNotNone(found)
|
||||
self.assertNotIn("aria-current", found.group(1))
|
||||
own = self.LINK.search(_built("wanted"))
|
||||
self.assertIsNotNone(own)
|
||||
self.assertIn('aria-current="page"', own.group(1))
|
||||
|
||||
|
||||
def _title_block(html: str) -> str:
|
||||
"""What PageTitle draws: from the main column to the h1."""
|
||||
end = html.index('id="_top"')
|
||||
|
||||
@@ -300,6 +300,15 @@ class ThePageReadsTheListAsTheResolverDoes(_World):
|
||||
self.assertEqual(self._page(WANTED, "b.bin")["issue"], validate_pr.large_file_issue_url(result))
|
||||
|
||||
|
||||
class TheTwoPagesLinkEachOther(unittest.TestCase):
|
||||
"""files/ checks any file, wanted/ the ones the collection lacks: each
|
||||
sends a reader to the other in one line."""
|
||||
|
||||
def test_links(self):
|
||||
self.assertIn("[See if it is wanted](../wanted.md)", generate_site.generate_files_page())
|
||||
self.assertIn("[Find or check a file](files/index.md)", sitewanted.page(1))
|
||||
|
||||
|
||||
class ThePublishedList(unittest.TestCase):
|
||||
"""The list generate_site.py wrote, against the collection: nothing it
|
||||
holds, every folder by validate_pr, and light enough for a phone."""
|
||||
|
||||
@@ -3,12 +3,20 @@
|
||||
// tabs: the funnel (Start here to Contribute) is the site's structure, so it
|
||||
// sits where every docs site puts its sections. On a phone the tabs stay the
|
||||
// first row of the menu, where the sidebar lists them.
|
||||
// The wanted page is the one call to contribute, in the bar on every page
|
||||
// and every width: on a phone it sits beside the search and menu buttons.
|
||||
import Default from '@astrojs/starlight/components/Header.astro';
|
||||
|
||||
const topics = Astro.locals.starlightSidebarTopics?.topics ?? [];
|
||||
const base = import.meta.env.BASE_URL.replace(/\/?$/, '/');
|
||||
const wanted = `${base}wanted/`;
|
||||
const onWanted = Astro.url.pathname.replace(/\/?$/, '/') === wanted;
|
||||
---
|
||||
|
||||
<div class="rb-header-bar"><Default /></div>
|
||||
<div class="rb-header-bar">
|
||||
<Default />
|
||||
<a class="rb-wanted-link print:hidden" href={wanted} aria-current={onWanted ? 'page' : undefined}>Wanted files</a>
|
||||
</div>
|
||||
{
|
||||
topics.length > 0 && (
|
||||
<nav class="rb-tabs print:hidden" aria-label="Sections">
|
||||
@@ -27,7 +35,45 @@ const topics = Astro.locals.starlightSidebarTopics?.topics ?? [];
|
||||
|
||||
<!-- Global: the bar height and the sidebar's topic list belong to other components. -->
|
||||
<style is:global>
|
||||
.rb-header-bar { height: 100%; }
|
||||
.rb-header-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--sl-nav-gap);
|
||||
height: 100%;
|
||||
}
|
||||
.rb-header-bar > .header { flex: 1; min-width: 0; }
|
||||
/* A call to contribute: an outlined pill in the link colour, filled on
|
||||
its own page. The colours are the theme's, in light and dark. */
|
||||
.rb-wanted-link {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
min-height: 2rem;
|
||||
padding: 0 0.75rem;
|
||||
border: 1px solid var(--rb-link);
|
||||
border-radius: 999px;
|
||||
color: var(--rb-link);
|
||||
font-size: var(--sl-text-sm);
|
||||
font-weight: 600;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.rb-wanted-link:hover { background: var(--sl-color-accent-low); }
|
||||
.rb-wanted-link:focus-visible { outline: 2px solid var(--rb-link); outline-offset: 2px; }
|
||||
.rb-wanted-link[aria-current='page'] { background: var(--rb-link); color: var(--sl-color-black); }
|
||||
/* Below 27rem the bar cannot hold the name, the search, the link and the
|
||||
menu: the logo stays as the home link and the name is kept for screen
|
||||
readers, rather than cut to "Retr". */
|
||||
@media (max-width: 26.99rem) {
|
||||
.site-title span {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.rb-tabs { display: none; }
|
||||
|
||||
/* "Look up this hash", the first result of a hash typed in the search (site.ts). */
|
||||
|
||||
Reference in new issue
Block a user