Skip to content

Commit 3bdc76f

Browse files
committed
Rework the download all button and related js
- Make it look the same as the other buttons - Refactor so it is unhidden by the platform/os detection js instead of created from scratch.
1 parent d36021f commit 3bdc76f

3 files changed

Lines changed: 25 additions & 24 deletions

File tree

website/assets/css/custom.css

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@ h3.button {
189189
stroke: white;
190190
}
191191

192-
a.all-downloads {
193-
display: block;
194-
position: absolute;
195-
color: var(--color-gray-30);
196-
padding-left: 1rem;
197-
}
198-
199192
p.big {
200193
font-size: 115%;
201194
}
@@ -517,29 +510,33 @@ p.big {
517510
line-height: var(--doc-line-height);
518511
}
519512

520-
a.all-downloads{
521-
position:relative!important;
522-
padding:0;
523-
margin: 0;
513+
.#all-downloads {
514+
/* This is hidden to begin with, see 07-download.js */
515+
display: none!important;
524516
}
525517

526-
.hero-links{
527-
display: grid;
528-
grid-template-columns: auto;
529-
grid-template-columns: auto;
518+
.hero-links {
519+
display: flex;
520+
flex-direction: row;
530521
justify-content: center;
522+
align-items: center;
523+
gap: 1rem;
531524
text-align: center;
525+
padding-bottom: 2.5em;
532526
}
533527

534528
.hero-links h3.button {
535529
padding-top: 10px;
536-
margin: 0 auto;
537-
margin-top: 1em;
538-
margin-bottom: 2em;
530+
margin: 1em 0.5em;
539531
}
540532

541-
.hero-links h3.button#download{
542-
margin-bottom: 5px;
533+
.hero-links h3.button a {
534+
white-space: nowrap;
535+
}
536+
537+
.hero-links h3.button:hover {
538+
transform: translateY(-1px);
539+
background-color: var(--ec-icon-purple);
543540
}
544541

545542
.hero h2 {

website/assets/js/07-download.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
document.addEventListener('DOMContentLoaded', async () => {
22
const download = document.querySelector('#download a');
3+
const downloadAll = document.querySelector('#all-downloads a');
34
if (!download) {
45
return
56
}
67
try {
7-
const response = await fetch('https://api.github.com/repos/conforma/cli/releases/tags/snapshot');
8+
const response = await fetch('https://api.github.com/repos/conforma/cli/releases/latest');
89
const snapshot = await response.json();
910
const uap = new UAParser();
1011
const os = uap.getOS().name.replace('macOS', 'darwin').toLowerCase();
1112
const arch = uap.getCPU().architecture;
1213
const file = `ec_${os}_${arch}`;
1314
const asset = snapshot.assets.find(a => a.name === file);
1415
if (asset) {
15-
download.parentNode.insertAdjacentHTML('afterend', `<a class="all-downloads" href=${download.href}>(All downloads)</a>`)
16+
// Update the download button href to the user's specific platform/arch
1617
download.href = asset.browser_download_url;
1718
download.title = `${uap.getOS().name} / ${uap.getCPU().architecture}`;
19+
// Unhide the download all button
20+
downloadAll.style.display = 'inline-flex';
1821
}
19-
} catch(e) {
22+
} catch (e) {
2023
// Unable to fetch the releases leave the download link as is
2124
return;
2225
}

website/content/_index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
kind: home
33
---
4+
### [{{< icon "arrow-down-circle" >}} Download](https://github.com/conforma/cli/releases/latest){#download .button}
45

5-
### [{{< icon "arrow-down-circle" >}} Download](https://github.com/conforma/cli/releases/tag/snapshot){#download .button}
6+
### [{{< icon "arrow-down-circle" >}} All downloads](https://github.com/conforma/cli/releases/latest){#all-downloads .button}
67

78
### [{{< icon "book-open" >}} Getting Started](docs/user-guide/hitchhikers-guide.html){.button}

0 commit comments

Comments
 (0)