Skip to content

Commit 2005395

Browse files
phiro56madolson
andauthored
feat: Add GitHub button to navigation bar (#291)
feat: Add GitHub button to navigation bar <img width="1728" alt="Screenshot 2025-07-03 at 10 00 44 PM" src="https://github.com/user-attachments/assets/4442cbe5-e93d-46be-b283-d3a2ddd6095c" /> --------- Signed-off-by: Daniel Phillips <phiro56@gmail.com> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
1 parent 16a1e33 commit 2005395

File tree

3 files changed

+98
-8
lines changed

3 files changed

+98
-8
lines changed

sass/_valkey.scss

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ p {
119119
width: 100%;
120120
padding: 10px;
121121

122-
@include respond-min(768px) {
122+
@include respond-min(1024px) {
123123
padding: 0 20px;
124124
}
125125
}
@@ -163,7 +163,7 @@ p {
163163
padding: .5rem 0;
164164
border-bottom: none;
165165

166-
@include respond-min(768px) {
166+
@include respond-min(1024px) {
167167
border-bottom: 3px solid;
168168
padding: 1rem 0;
169169
border-color: transparent;
@@ -176,13 +176,13 @@ p {
176176
border-color: inherit;
177177
text-decoration: underline;
178178

179-
@include respond-min(768px) {
179+
@include respond-min(1024px) {
180180
text-decoration: none;
181181
}
182182
}
183183
}
184184

185-
@media (max-width: 768px) {
185+
@media (max-width: 1024px) {
186186
display: none;
187187
gap: 1rem;
188188

@@ -212,6 +212,50 @@ p {
212212
}
213213
}
214214
}
215+
216+
.github-button {
217+
display: flex;
218+
align-items: center;
219+
padding: 0.5rem 1rem !important;
220+
background-color: #f8f9fa;
221+
border: 1px solid #dfe1e4;
222+
border-radius: 6px;
223+
color: #444;
224+
text-decoration: none;
225+
transition: all 0.2s ease;
226+
227+
img {
228+
filter: brightness(0) saturate(100%) invert(27%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(0%) contrast(100%);
229+
margin-right: 0.5rem;
230+
}
231+
232+
.star-count {
233+
background: #f1f5f9;
234+
color: #64748b;
235+
font-size: 12px;
236+
padding: 2px 6px;
237+
border-radius: 10px;
238+
margin-left: 0;
239+
font-weight: 500;
240+
white-space: nowrap;
241+
border: 1px solid #e2e8f0;
242+
transition: all 0.2s;
243+
}
244+
245+
&:hover {
246+
background-color: #e9ecef;
247+
border-color: #dee2e6;
248+
text-decoration: none;
249+
border-bottom-color: #e9ecef;
250+
}
251+
252+
@media (max-width: 1024px) {
253+
padding: 0.75rem 1rem !important;
254+
margin-top: 0.5rem;
255+
justify-content: center;
256+
text-align: center;
257+
}
258+
}
215259
}
216260
.btn-menu {
217261
display: none;
@@ -240,7 +284,7 @@ p {
240284
transition-duration: .2s;
241285
}
242286

243-
@media (max-width: 768px) {
287+
@media (max-width: 1024px) {
244288
display: flex;
245289
}
246290
}
@@ -251,7 +295,7 @@ p {
251295
display: block;
252296
align-items: center;
253297

254-
@include respond-min(768px) {
298+
@include respond-min(1024px) {
255299
display: flex;
256300
}
257301

@@ -273,7 +317,7 @@ p {
273317
&:hover {
274318
text-decoration: underline;
275319

276-
@include respond-min(768px) {
320+
@include respond-min(1024px) {
277321
text-decoration: none;
278322
}
279323
}
@@ -290,7 +334,7 @@ p {
290334
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
291335
padding: .25rem 0;
292336

293-
@include respond-min(768px) {
337+
@include respond-min(1024px) {
294338
display: none;
295339
}
296340

static/assets/js/nav.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,45 @@ window.toggleHeaderMenu = function() {
66
}
77
};
88

9+
// Fetch and display GitHub stars count
10+
async function fetchGitHubStars() {
11+
try {
12+
const response = await fetch('https://api.github.com/repos/valkey-io/valkey');
13+
if (response.ok) {
14+
const data = await response.json();
15+
const starCount = data.stargazers_count;
16+
17+
// Find the GitHub button and add star count
18+
const githubButton = document.querySelector('.github-button');
19+
if (githubButton) {
20+
// Create star count element if it doesn't exist
21+
let starCountElement = githubButton.querySelector('.star-count');
22+
if (!starCountElement) {
23+
starCountElement = document.createElement('span');
24+
starCountElement.className = 'star-count';
25+
starCountElement.style.cssText = `
26+
background: #f1f5f9;
27+
color: #64748b;
28+
font-size: 12px;
29+
padding: 2px 6px;
30+
border-radius: 10px;
31+
margin-left: 6px;
32+
font-weight: 500;
33+
white-space: nowrap;
34+
`;
35+
githubButton.appendChild(starCountElement);
36+
}
37+
38+
// Format the number with K for thousands
39+
const formattedCount = starCount >=100? (starCount / 1000).toFixed(1) + 'k' : starCount.toString();
40+
starCountElement.textContent = `${formattedCount} ★`;
41+
}
42+
}
43+
} catch (error) {
44+
console.log('Could not fetch GitHub stars:', error);
45+
}
46+
}
47+
948
// Banner close functionality
1049
function initBannerClose() {
1150
const banner = document.querySelector('.banner');
@@ -47,6 +86,7 @@ function setActiveMenuItem() {
4786
// Run when DOM is loaded
4887
document.addEventListener('DOMContentLoaded', function() {
4988
setActiveMenuItem();
89+
fetchGitHubStars();
5090
initBannerClose();
5191
});
5292

templates/default.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@
5757
<a role="menuitem" href="/community/">Community</a>
5858
<a role="menuitem" href="/participants/">Participants</a>
5959
<a role="menuitem" href="/try-valkey/">Try Valkey</a>
60+
<a role="menuitem" href="https://github.com/valkey-io" target="_blank" class="github-button">
61+
<img src="/img/IconGithub.svg" alt="GitHub Icon" width="16" height="16" />
62+
GitHub
63+
<!-- Star count will be injected here by JS -->
64+
</a>
65+
6066
</nav>
6167
</div>
6268
</div>

0 commit comments

Comments
 (0)