Skip to content

Commit 0514a4a

Browse files
authored
feat: replace FeedbackButton with GitHubButton (#54)
- Removed FeedbackButton component and integrated GitHubButton for improved functionality. - Added GitHubButton component to fetch and display star count from GitHub API. - Introduced new styles for GitHubButton and updated the GitHubIcon for better visual representation.
1 parent 44fb731 commit 0514a4a

File tree

5 files changed

+77
-38
lines changed

5 files changed

+77
-38
lines changed

src/frontend/src/ExcalidrawWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Children, cloneElement, useState, useEffect } from 'react';
22
import DiscordButton from './ui/DiscordButton';
3-
import FeedbackButton from './ui/FeedbackButton';
3+
import GitHubButton from './ui/GitHubButton';
44
import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types';
55
import type { NonDeletedExcalidrawElement } from '@atyrode/excalidraw/element/types';
66
import type { AppState } from '@atyrode/excalidraw/types';
@@ -99,7 +99,7 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
9999
renderEmbeddable: (element, appState) => renderCustomEmbeddable(element, appState, excalidrawAPI),
100100
renderTopRightUI: renderTopRightUI ?? (() => (
101101
<div style={{ display: "flex", gap: "0.5rem", alignItems: "center" }}>
102-
<FeedbackButton />
102+
<GitHubButton />
103103
<DiscordButton />
104104
</div>
105105
)),

src/frontend/src/icons/GithubIcon.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,29 @@ interface GithubIconProps {
44
className?: string;
55
width?: number;
66
height?: number;
7-
stroke?: string;
8-
strokeWidth?: number;
7+
fill?: string;
98
}
109

1110
export const GithubIcon: React.FC<GithubIconProps> = ({
1211
className = "",
1312
width = 20,
1413
height = 20,
15-
stroke = "currentColor",
16-
strokeWidth = 2,
14+
fill = "currentColor",
1715
}) => {
1816
return (
1917
<svg
2018
xmlns="http://www.w3.org/2000/svg"
2119
width={width}
2220
height={height}
23-
viewBox="0 0 24 24"
24-
fill="none"
25-
stroke={stroke}
26-
strokeWidth={strokeWidth}
27-
strokeLinecap="round"
28-
strokeLinejoin="round"
21+
viewBox="0 0 98 96"
2922
className={className}
3023
>
31-
<path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4" />
32-
<path d="M9 18c-4.51 2-5-2-7-2" />
24+
<path
25+
fillRule="evenodd"
26+
clipRule="evenodd"
27+
d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"
28+
fill={fill}
29+
/>
3330
</svg>
3431
);
3532
};

src/frontend/src/ui/FeedbackButton.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,36 @@
1-
.feedback-button {
1+
.github-button {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
25
height: 2.75rem;
36
padding: 0 1rem;
47
border-radius: 0.5rem;
58
margin-left: 0.275rem;
6-
79
background: #232329;
810
color: #fff;
911
border: none;
1012
cursor: pointer;
1113
font-weight: 500;
1214
transition: background 0.15s ease-in-out, border 0.15s ease-in-out;
15+
gap: 0.5rem;
16+
font-size: 1.05rem;
17+
font-weight: 500;
18+
color: #c9c9c9;
19+
font-family: "Roboto", sans-serif;
1320

1421
&:hover,
1522
&:focus {
1623
background: #cc6d24;
1724
outline: none;
1825
}
26+
27+
.github-icon {
28+
margin-right: 0.15rem;
29+
}
1930
}
2031

2132
@media (max-width: 730px) {
22-
.feedback-button {
33+
.github-button {
2334
display: none !important;
2435
}
2536
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useEffect, useState } from "react";
2+
import { GithubIcon } from "../icons";
3+
import "./GitHubButton.scss";
4+
5+
const GitHubButton: React.FC = () => {
6+
const [starCount, setStarCount] = useState<string | null>(null);
7+
8+
useEffect(() => {
9+
// Fetch star count from GitHub API
10+
fetch("https://api.github.com/repos/pad-ws/pad.ws")
11+
.then(response => response.json())
12+
.then(data => {
13+
const stars = data.stargazers_count;
14+
15+
// Format the star count with European number formatting (commas as thousand separators)
16+
let formattedStars;
17+
if (stars >= 1000) {
18+
// For numbers >= 1000, format with commas as thousand separators
19+
// e.g., 1000 -> 1,000, 1500 -> 1,500, etc.
20+
formattedStars = stars.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
21+
} else {
22+
// For numbers < 1000, just use the number as is
23+
formattedStars = stars.toString();
24+
}
25+
26+
setStarCount(formattedStars);
27+
})
28+
.catch(error => {
29+
console.error("Error fetching GitHub stars:", error);
30+
setStarCount("--");
31+
});
32+
}, []);
33+
34+
return (
35+
<button
36+
className="github-button"
37+
type="button"
38+
onClick={() => window.open("https://github.com/pad-ws/pad.ws", "_blank")}
39+
aria-label="View on GitHub"
40+
>
41+
<GithubIcon
42+
className="github-icon"
43+
width={24}
44+
height={24}
45+
fill="#fff"
46+
/>
47+
{starCount || "..."}
48+
</button>
49+
);
50+
};
51+
52+
export default GitHubButton;

0 commit comments

Comments
 (0)