Skip to content

Commit c1d521c

Browse files
committed
fix: improve style formatting for star us button
1 parent ee0d867 commit c1d521c

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

website/src/pages/index.astro

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import HomeLayout from "@layouts/HomeLayout.astro";
33
import { keystatic } from "@lib/keystatic/client";
44
import invariant from "tiny-invariant";
5-
import { Icon } from "astro-icon/components"; // Assuming astro-icon is installed and Icon can be imported like this
5+
import { Icon } from "astro-icon/components";
66
77
const i18n = await keystatic.singletons.homepage.read({
88
resolveLinkedFiles: true,
@@ -52,8 +52,10 @@ invariant(i18n, "No homepage content found");
5252
id="star-repo-button"
5353
class="mt-4 flex items-center justify-center bg-white text-btcgray-800 border border-btcgray-800 p-3 rounded hover:bg-btcgray-100 hover:cursor-pointer w-full"
5454
>
55-
<Icon name="simple-icons:github" class="w-5 h-5 mr-2" />
56-
<span id="star-repo-text">Star Us | 4</span>
55+
<Icon name="simple-icons:github" class="w-4 h-4 mr-2" />
56+
<span>star us</span>
57+
<span class="mx-1">|</span>
58+
<span id="github-star-count">4</span>
5759
</a>
5860
</form>
5961
</section>
@@ -89,7 +91,7 @@ invariant(i18n, "No homepage content found");
8991
const form = document.querySelector("form");
9092
const emailInput = document.querySelector('input[type="email"]');
9193
const submitButton = document.querySelector('button[type="submit"]');
92-
const starRepoButtonText = document.getElementById("star-repo-text");
94+
const githubStarCountElement = document.getElementById("github-star-count");
9395
const subscriberCountValue = document.getElementById(
9496
"subscriber-count-value"
9597
);
@@ -148,7 +150,6 @@ invariant(i18n, "No homepage content found");
148150
);
149151
htmlSubmitButton.classList.add("bg-green-500");
150152

151-
// incrase the subscriber count by 1
152153
const currentCount = parseInt(
153154
subscriberCountValue?.textContent || "0",
154155
10
@@ -159,7 +160,6 @@ invariant(i18n, "No homepage content found");
159160
).toLocaleString();
160161
}
161162
} else if (response.status === 409) {
162-
// If the email already exists, we can handle it gracefully
163163
htmlSubmitButton.textContent = "Already Subscribed";
164164
htmlSubmitButton.disabled = false;
165165
htmlSubmitButton.classList.remove(
@@ -282,18 +282,18 @@ invariant(i18n, "No homepage content found");
282282
}
283283

284284
async function fetchGitHubStars() {
285-
if (!starRepoButtonText) {
286-
console.error("Star repo button text element not found.");
285+
if (!githubStarCountElement) {
286+
console.error("GitHub star count element not found.");
287287
return;
288288
}
289289
try {
290290
const response = await fetch(
291-
"https://api.github.com/repos/devflowinc/threshold"
291+
"https.api.github.com/repos/devflowinc/threshold"
292292
);
293293
if (response.ok) {
294294
const data = await response.json();
295295
const starCount = data.stargazers_count;
296-
starRepoButtonText.textContent = `Star Us | ${starCount}`;
296+
githubStarCountElement.textContent = starCount.toLocaleString();
297297
} else {
298298
console.error("Failed to fetch GitHub stars:", response.status);
299299
}

0 commit comments

Comments
 (0)