mirror of https://github.com/usememos/memos
chore: add github badge
parent
1b50ab5dca
commit
8a91b0ad9d
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,31 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import * as api from "../helpers/api";
|
||||
import "../less/github-badge.less";
|
||||
|
||||
interface Props {}
|
||||
|
||||
const GitHubBadge: React.FC<Props> = () => {
|
||||
const [starCount, setStarCount] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
api.getRepoStarCount().then((data) => {
|
||||
setStarCount(data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleClick = () => {
|
||||
window.location.href = "https://github.com/usememos/memos";
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="github-badge-container" onClick={handleClick}>
|
||||
<div className="github-icon">
|
||||
<img className="icon-img" src="/github.webp" alt="" />
|
||||
Star
|
||||
</div>
|
||||
<span className={`count-text ${starCount || "pulse"}`}>{starCount || "🌟"}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default GitHubBadge;
|
@ -0,0 +1,38 @@
|
||||
.github-badge-container {
|
||||
@apply h-7 flex flex-row justify-start items-center border rounded cursor-pointer hover:opacity-80;
|
||||
|
||||
> .github-icon {
|
||||
@apply w-auto h-full px-2 border-r rounded-l flex flex-row justify-center items-center text-xs font-bold text-gray-800 bg-gray-100;
|
||||
|
||||
> .icon-img {
|
||||
@apply w-4 h-auto mr-1;
|
||||
}
|
||||
}
|
||||
|
||||
> .count-text {
|
||||
@apply px-3 text-xs font-bold text-gray-800;
|
||||
|
||||
&.pulse {
|
||||
@apply text-sm;
|
||||
animation: 1s linear 0s infinite pulse;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
30% {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
60% {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
70% {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
100% {
|
||||
margin-bottom: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue