From 274652299dc793f12cb3420dc2eb00893c8840da Mon Sep 17 00:00:00 2001 From: Jamal Carvalho Date: Wed, 19 Apr 2023 20:11:37 +0000 Subject: [PATCH] _content: add toggle to display other ports on download page Fixes golang/go#59317. Change-Id: I1fd8020838f519b3a481745a979a0253458e4257 Reviewed-on: https://go-review.googlesource.com/c/website/+/486555 TryBot-Result: Gopher Robot Reviewed-by: Hyang-Ah Hana Kim Auto-Submit: Jamal Carvalho Run-TryBot: Jamal Carvalho --- _content/css/styles.css | 22 +++++++++++++++++++++- _content/dl.tmpl | 8 ++++---- _content/js/site.js | 9 +++++++++ 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/_content/css/styles.css b/_content/css/styles.css index 7e824f23..5d4f1ac7 100644 --- a/_content/css/styles.css +++ b/_content/css/styles.css @@ -5071,7 +5071,27 @@ table.downloadtable tr { background-color: var(--color-background); border: 2px solid var(--color-background-accented); } - +table.downloadtable tr.first[aria-expanded] { + cursor: pointer; +} +table.downloadtable tr.first[aria-expanded] th::after { + content: "⌵"; + display: inline-block; + padding: 0 0.5rem; + transform: rotate(180deg); + vertical-align: sub; +} +table.downloadtable tr.first[aria-expanded="true"] th::after { + bottom: 0.3125rem; + position: relative; + transform: rotate(0); +} +table.downloadtable tr.first[aria-expanded="false"] ~ tr.secondary { + display: none; +} +table.downloadtable tr.first[aria-expanded="true"] ~ tr.secondary { + display: table-row; +} table.downloadtable tr.first th { text-align: left; font-style: normal; diff --git a/_content/dl.tmpl b/_content/dl.tmpl index 37776a7e..088a0cd1 100644 --- a/_content/dl.tmpl +++ b/_content/dl.tmpl @@ -73,16 +73,16 @@ information about Go releases.

+ {{.Version}} - {{.Version}}

{{if .Stable}}{{else}}

This is an unstable version of Go. Use with caution.

@@ -115,7 +115,7 @@ go install golang.org/dl/{{.Version}}@latest {{range .Files}}{{if .PrimaryPort}}{{template "download-file" .}}{{end}}{{end}} {{/* TODO(cbro): add a link to an explanatory doc page */}} - Other Ports + Other Ports {{range .Files}}{{if not .PrimaryPort}}{{template "download-file" .}}{{end}}{{end}} {{else}} {{range .Files}}{{template "download-file" .}}{{end}} @@ -124,7 +124,7 @@ go install golang.org/dl/{{.Version}}@latest {{end}} {{define "download-file"}} - + {{.Filename}} {{.PrettyKind}} {{.PrettyOS}} diff --git a/_content/js/site.js b/_content/js/site.js index 71cae73e..7177eef9 100644 --- a/_content/js/site.js +++ b/_content/js/site.js @@ -235,6 +235,14 @@ window.initFuncs = []; } } + function registerPortToggles() { + for (const el of document.querySelectorAll('.js-togglePorts')) { + el.addEventListener('click', () => { + el.setAttribute('aria-expanded', el.getAttribute('aria-expanded') === 'true' ? 'false' : 'true') + }) + } + } + /** * Retrieves list of Go versions & returns the latest */ @@ -319,5 +327,6 @@ window.initFuncs = []; setDownloadLinks(); setThemeButtons(); setVersionSpans(); + registerPortToggles(); }); })();