Skip to content

Commit eff0dd2

Browse files
authored
Merge pull request #13978 from Baystef/feat/contributorscomponent-story
Create Story for Contributors Component
2 parents 170ed2c + 1054562 commit eff0dd2

File tree

3 files changed

+116
-4
lines changed

3 files changed

+116
-4
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import { Meta, StoryObj } from "@storybook/react"
2+
3+
import ContributorsComponent, { type Contributor } from "."
4+
5+
const meta = {
6+
title: "Molecules / Display Content / Contributors",
7+
component: ContributorsComponent,
8+
parameters: {
9+
layout: "fullscreen",
10+
},
11+
decorators: [
12+
(Story) => (
13+
<article className="max-w-3xl scroll-mt-24">
14+
<Story />
15+
</article>
16+
),
17+
],
18+
} satisfies Meta<typeof ContributorsComponent>
19+
20+
export default meta
21+
22+
type Story = StoryObj<typeof meta>
23+
24+
const mockContributors: Contributor[] = [
25+
{
26+
login: "carlfairclough",
27+
name: "Carl Fairclough",
28+
avatar_url: "https://avatars1.githubusercontent.com/u/4670881?v=4",
29+
profile: "http://carlfairclough.me",
30+
contributions: ["design", "code", "bug"],
31+
},
32+
{
33+
login: "RichardMcSorley",
34+
name: "Richard McSorley",
35+
avatar_url: "https://avatars2.githubusercontent.com/u/6407008?v=4",
36+
profile: "https://github.com/RichardMcSorley",
37+
contributions: ["code"],
38+
},
39+
{
40+
login: "ajsantander",
41+
name: "Alejandro Santander",
42+
avatar_url: "https://avatars2.githubusercontent.com/u/550409?v=4",
43+
profile: "http://ajsantander.github.io/",
44+
contributions: ["content"],
45+
},
46+
{
47+
login: "Lililashka",
48+
name: "Lililashka",
49+
avatar_url: "https://avatars1.githubusercontent.com/u/28689401?v=4",
50+
profile: "http://impermanence.co",
51+
contributions: ["design", "bug"],
52+
},
53+
{
54+
login: "chriseth",
55+
name: "chriseth",
56+
avatar_url: "https://avatars2.githubusercontent.com/u/9073706?v=4",
57+
profile: "https://github.com/chriseth",
58+
contributions: ["content", "review"],
59+
},
60+
{
61+
login: "fzeoli",
62+
name: "Franco Zeoli",
63+
avatar_url: "https://avatars2.githubusercontent.com/u/232174?v=4",
64+
profile: "https://nomiclabs.io",
65+
contributions: ["content", "review"],
66+
},
67+
{
68+
login: "P1X3L0V4",
69+
name: "Anna Karpińska",
70+
avatar_url: "https://avatars2.githubusercontent.com/u/3372341?v=4",
71+
profile: "https://github.com/P1X3L0V4",
72+
contributions: ["translation"],
73+
},
74+
{
75+
login: "vrde",
76+
name: "vrde",
77+
avatar_url: "https://avatars1.githubusercontent.com/u/134680?v=4",
78+
profile: "https://github.com/vrde",
79+
contributions: ["content"],
80+
},
81+
{
82+
login: "AlexandrouR",
83+
name: "Rousos Alexandros",
84+
avatar_url: "https://avatars1.githubusercontent.com/u/21177075?v=4",
85+
profile: "https://github.com/AlexandrouR",
86+
contributions: ["content"],
87+
},
88+
{
89+
login: "eswarasai",
90+
name: "Eswara Sai",
91+
avatar_url: "https://avatars2.githubusercontent.com/u/5172086?v=4",
92+
profile: "https://eswarasai.com",
93+
contributions: ["code"],
94+
},
95+
]
96+
97+
export const Contributors: Story = {
98+
args: {
99+
contributors: mockContributors,
100+
},
101+
}

src/components/Contributors.tsx renamed to src/components/Contributors/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@ export interface Contributor {
2020

2121
const allContributors = JSON.parse(data)
2222

23-
const Contributors = () => {
23+
interface ContributorsProps {
24+
contributors?: Contributor[]
25+
}
26+
27+
const Contributors = ({ contributors }: ContributorsProps) => {
2428
const [contributorsList, setContributorsList] = useState<Contributor[]>([])
2529

2630
useEffect(() => {
27-
setContributorsList(shuffle(allContributors.contributors))
28-
}, [])
31+
if (contributors) {
32+
setContributorsList(contributors)
33+
} else {
34+
setContributorsList(shuffle(allContributors.contributors))
35+
}
36+
}, [contributors])
2937

3038
return (
3139
<>
@@ -44,6 +52,9 @@ const Contributors = () => {
4452
className="h-[132px] w-[132px]"
4553
src={contributor.avatar_url}
4654
alt={contributor.name}
55+
width={132}
56+
height={132}
57+
sizes="132px"
4758
/>
4859
<div className="p-4">
4960
<h3 className="mb-4 mt-2 text-md">

src/components/DataTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ const DataTable = <TData, TValue>({
137137
</div>
138138
<Table {...props}>
139139
<TableBody
140-
className={`duration-75 transition-opacity ${
140+
className={`transition-opacity duration-75 ${
141141
isVisible ? "opacity-100" : "opacity-0"
142142
}`}
143143
>

0 commit comments

Comments
 (0)