Skip to content

Commit 7232ffd

Browse files
committed
Redesign the post footer
1 parent 55f823b commit 7232ffd

2 files changed

Lines changed: 39 additions & 50 deletions

File tree

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
1-
import { capitalize } from "lodash";
2-
import React from "react";
3-
import { FaGithub, FaXTwitter } from "react-icons/fa6";
4-
51
import { ApiArticle } from "@/cms/api/ApiArticle";
62

7-
type ChipProps = { children: React.ReactNode; href: string; type: "twitter" | "github" };
8-
9-
const Chip = ({ children, href, type }: ChipProps) => {
10-
const kype = capitalize(type);
11-
const Icon = type === "twitter" ? FaXTwitter : FaGithub;
12-
13-
const classes = ["Post__Footer__Chip", `Post__Footer__Chip--${kype}`].join(" ");
14-
15-
return (
16-
<a className={classes} href={href} target="blank">
17-
<Icon className="Post__Footer__Chip__Icon" />
18-
{children}
19-
</a>
20-
);
21-
};
22-
233
type FooterProps = { post: ApiArticle };
244

255
export function Footer({ post }: FooterProps) {
26-
const githubEditUrl = `https://github.com/codecoolture/codecoolture.com/edit/trunk/cms/content${post.url}.mdx`;
276
const shareableUrl = `https://codecoolture.com${post.url}`;
287
const tweet = encodeURIComponent(`Check out "${post.title}" by @codecoolture\n\n`);
298

309
return (
3110
<footer className="Post__Footer">
32-
<Chip type="twitter" href={`https://x.com/intent/tweet?url=${encodeURIComponent(shareableUrl)}&text=${tweet}`}>
33-
Share on Twitter
34-
</Chip>
35-
36-
<Chip type="github" href={githubEditUrl}>
37-
Edit on GitHub
38-
</Chip>
11+
<nav>
12+
<ul className="Post__Footer__List">
13+
<li className="Post__Footer__ListItem">
14+
<a
15+
className="Post__Footer__Link"
16+
href={`https://x.com/intent/tweet?url=${encodeURIComponent(shareableUrl)}&text=${tweet}`}
17+
>
18+
Share
19+
</a>
20+
</li>
21+
22+
<li className="Post__Footer__ListItem">
23+
<a
24+
className="Post__Footer__Link"
25+
href={`https://github.com/codecoolture/codecoolture.com/edit/trunk/cms/content${post.url}.mdx`}
26+
>
27+
Edit on GitHub
28+
</a>
29+
</li>
30+
</ul>
31+
</nav>
3932
</footer>
4033
);
4134
}
Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
11
.Post__Footer {
2-
display: flex;
3-
flex-direction: row;
4-
flex-wrap: wrap;
52
font-size: var(--fs-s);
6-
gap: 1rem;
7-
justify-content: center;
8-
margin: 3rem 0 1rem;
3+
margin: 2rem 0 1rem;
94
}
105

11-
.Post__Footer__Chip {
6+
.Post__Footer__List {
127
align-items: center;
13-
display: inline-flex;
14-
justify-content: center;
15-
max-width: 100%;
16-
min-width: calc(200px - 1.5em);
17-
padding: 0.35em 0.75em;
8+
display: flex;
9+
gap: 0.5rem;
10+
margin: 0;
11+
padding: 0;
12+
justify-content: end;
1813

19-
border-radius: 3px;
20-
text-decoration: none;
14+
list-style-type: none;
2115
}
2216

23-
.Post__Footer__Chip--Twitter {
24-
background-color: #24292f;
25-
color: var(--c-white);
17+
.Post__Footer__ListItem {
18+
align-items: center;
19+
display: flex;
2620
}
2721

28-
.Post__Footer__Chip--Github {
29-
background-color: #24292f;
30-
color: var(--c-white);
22+
.Post__Footer__ListItem:not(:first-child)::before {
23+
content: "·";
24+
margin-right: 0.5rem;
25+
26+
color: var(--c-gray-11);
3127
}
3228

33-
.Post__Footer__Chip__Icon {
34-
margin-right: 0.5em;
29+
.Post__Footer__Link {
30+
color: var(--c-gray-11);
3531
}

0 commit comments

Comments
 (0)