Skip to content

Commit c95a1b2

Browse files
committed
Add a banner if theres a new version since last visit
1 parent 82ad09f commit c95a1b2

5 files changed

Lines changed: 50 additions & 2 deletions

File tree

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.3.14/schema.json",
33
"vcs": {
44
"enabled": false,
55
"clientKind": "git",

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ <h1 class="hero-fluff">
123123
<div class="download-notes">
124124
<a href="#release-notes" class="download-version">View release notes</a>
125125
</div>
126+
<a class="update-banner" id="js-update-banner" href="#release-notes" hidden>
127+
New version released since your last visit — view release notes
128+
</a>
126129
</div>
127130
</div>
128131
<div class="hero-right">

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"fix": "biome check --write"
66
},
77
"devDependencies": {
8-
"@biomejs/biome": "2.2.4"
8+
"@biomejs/biome": "2.3.14"
99
}
1010
}

static/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ fetch('https://api.github.com/repositories/42366054/releases?per_page=5', {
4040

4141
const latestRelease = releases[0];
4242

43+
try {
44+
const currentVersion = latestRelease.tag_name;
45+
const storedVersion = localStorage.getItem('s2v-last-version');
46+
47+
if (storedVersion && storedVersion !== currentVersion) {
48+
const banner = document.getElementById('js-update-banner');
49+
banner.hidden = false;
50+
51+
banner.addEventListener('click', () => {
52+
banner.hidden = true;
53+
localStorage.setItem('s2v-last-version', currentVersion);
54+
});
55+
} else {
56+
localStorage.setItem('s2v-last-version', currentVersion);
57+
}
58+
} catch (e) {
59+
console.error(e);
60+
}
61+
4362
for (const asset of latestRelease.assets) {
4463
if (asset.name === 'Source2Viewer.exe') {
4564
document.getElementById('js-download').href =

static/style.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ a:active {
6262
z-index: -1;
6363
}
6464

65+
.update-banner {
66+
display: inline-block;
67+
margin-top: 0.75rem;
68+
padding: 0.5rem 0.75rem;
69+
background: hsl(140 50% 20%);
70+
border: 1px solid hsl(140 60% 50%);
71+
border-radius: 0.5rem;
72+
font-size: 0.9rem;
73+
color: #fff;
74+
text-decoration: none;
75+
cursor: pointer;
76+
opacity: 1;
77+
transition: opacity 200ms;
78+
79+
&:hover {
80+
background: hsl(140 50% 25%);
81+
color: #fff;
82+
}
83+
84+
&[hidden] {
85+
display: inline-block;
86+
pointer-events: none;
87+
opacity: 0;
88+
}
89+
}
90+
6591
.hero {
6692
min-height: max(1000px, 90vh);
6793
display: flex;

0 commit comments

Comments
 (0)