Skip to content

Commit d288d06

Browse files
authored
🐛 fix: ボタンをコンポーネント化し、URLリンクを追加
* 🐛 fix: buttonをリンク付きコンポーネントに修正 #203 * 🔧 chore: URLのメタデータを追加 * ♻️ refactor: 使用していないコードを削除
1 parent c838787 commit d288d06

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

lib/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ export const SITE_NAME = "First Contributions JA";
22
export const SITE_URL = "https://first-contributions-ja.github.io/";
33
export const SITE_DESC =
44
"Git/Githubの実践的な使い方やオープンソースでコラボレーションする作法を学ぶための日本語のチュートリアルです!";
5+
export const GITHUB_URL =
6+
"https://github.com/first-contributions-ja/first-contributions-ja.github.io";
7+
export const TWITTER_SHARE =
8+
"https://twitter.com/intent/tweet?text=完全日本語のチュートリアルで、OSS活動を始める🚀&url=https://github.com/first-contributions-ja/first-contributions-ja.github.io&hashtags=プログラミング";

src/app/page.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import Image from "next/image";
21
import { basePath } from "../../next.config";
32
export const BASE_PATH = basePath ? basePath : "";
43
import GitHubIcon from "@mui/icons-material/GitHub";
54
import ShareIcon from "@mui/icons-material/Share";
6-
import { SITE_NAME } from "../../lib/constants";
5+
import { TWITTER_SHARE } from "../../lib/constants";
76
import KeyboardDoubleArrowDownSharpIcon from "@mui/icons-material/KeyboardDoubleArrowDownSharp";
87
import GradientBackground from "@/components/gradient-background";
98
import ScreenEmojis from "@/components/screen-emojis";
@@ -14,9 +13,9 @@ import {
1413
groupContributorsBySection,
1514
latestContributorsColor,
1615
} from "@/utils/contributors-grouping";
16+
import Button from "@/components/ui/button";
1717

1818
export default function Home() {
19-
const contributorsNumber = contributors.length;
2019
const contributorsGroups = groupContributorsBySection(contributors, 3);
2120

2221
return (
@@ -40,14 +39,14 @@ export default function Home() {
4039
</p>
4140

4241
<div className="mt-8 flex flex-col items-start gap-4 lg:mt-12 lg:flex-row">
43-
<button className="flex h-12 w-40 items-center justify-center gap-2 rounded-full bg-red-600 px-4 text-center text-white duration-300 hover:opacity-60">
42+
<Button>
4443
<GitHubIcon className="text-2xl" />
4544
GitHub
46-
</button>
47-
<button className="flex h-12 w-40 items-center justify-center gap-2 rounded-full border border-stone-800 bg-white px-4 text-red-600 duration-300 hover:opacity-60">
45+
</Button>
46+
<Button type="outline" href={TWITTER_SHARE}>
4847
<ShareIcon className="text-2xl" />
4948
Share
50-
</button>
49+
</Button>
5150
</div>
5251
</div>
5352
</div>

src/components/ui/button.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { GITHUB_URL } from "../../../lib/constants";
2+
3+
interface ButtonProps {
4+
type?: "primary" | "outline";
5+
href?: string;
6+
children: React.ReactNode;
7+
}
8+
9+
const PRIMARY_BUTTON_CLASS =
10+
"flex h-12 w-40 items-center justify-center gap-2 rounded-full bg-red-600 px-4 text-center text-white duration-300 hover:opacity-60";
11+
const OUTLINE_BUTTON_CLASS =
12+
"flex h-12 w-40 items-center justify-center gap-2 rounded-full border border-stone-800 bg-white px-4 text-red-600 duration-300 hover:opacity-60";
13+
14+
const Button: React.FC<ButtonProps> = ({
15+
type = "primary",
16+
href = GITHUB_URL,
17+
children,
18+
}) => {
19+
const buttonClass =
20+
type === "primary" ? PRIMARY_BUTTON_CLASS : OUTLINE_BUTTON_CLASS;
21+
22+
return (
23+
<a href={href} target="_blank" rel="noopener" className={buttonClass}>
24+
{children}
25+
</a>
26+
);
27+
};
28+
29+
export default Button;

0 commit comments

Comments
 (0)