-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGithubRepositoryLink.stories.tsx
More file actions
68 lines (59 loc) · 1.96 KB
/
GithubRepositoryLink.stories.tsx
File metadata and controls
68 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import type { Meta, StoryObj } from "@storybook/react";
import { GithubRepositoryLink } from "./GithubRepositoryLink";
import { GithubPermalinkProvider } from "../config/GithubPermalinkContext";
import "../GithubPermalink/github-permalink.css";
const meta: Meta<typeof GithubRepositoryLink> = {
component: GithubRepositoryLink,
};
export default meta;
type Story = StoryObj<typeof GithubRepositoryLink>;
export const Primary: Story = {
render: () => (
<GithubRepositoryLink repositoryLink="https://github.com/dwjohnston/react-github-permalink" />
),
};
export const Inline: Story = {
render: () => (
<div>
<p>Check out this repository: <GithubRepositoryLink
repositoryLink="https://github.com/dwjohnston/react-github-permalink"
variant="inline"
/> for more details.</p>
</div>
),
};
export const WithToken: Story = {
render: () => (
<GithubPermalinkProvider githubToken={process.env.STORYBOOK_GITHUB_TOKEN}>
<GithubRepositoryLink repositoryLink="https://github.com/dwjohnston/react-github-permalink" />
</GithubPermalinkProvider>
),
};
export const CustomDataFn: Story = {
render: () => (
<GithubPermalinkProvider
getRepositoryFn={(repositoryLink) => {
return Promise.resolve({
owner: "example",
repo: "test-repo",
name: "test-repo",
fullName: "example/test-repo",
description: "A test repository with custom data",
stargazersCount: 100,
forksCount: 25,
htmlUrl: "https://github.com/example/test-repo",
status: "ok"
});
}}
>
<GithubRepositoryLink repositoryLink="https://github.com/example/test-repo" />
</GithubPermalinkProvider>
),
};
export const ErrorReporting: Story = {
render: () => (
<GithubPermalinkProvider onError={(err) => console.error(err)}>
<GithubRepositoryLink repositoryLink="https://github.com/nonexistent/repo" />
</GithubPermalinkProvider>
),
};