Skip to content

Commit 2537e68

Browse files
committed
Extend AddSocialPlatform with more extensive props
1 parent cb19fa6 commit 2537e68

File tree

4 files changed

+77
-76
lines changed

4 files changed

+77
-76
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@programmer_network/yail",
3-
"version": "1.0.188",
3+
"version": "1.0.189",
44
"description": "Programmer Network's official UI library for React",
55
"author": "Aleksandar Grbic - (https://programmer.network)",
66
"publishConfig": {

src/Components/AddSocialPlatform/AddSocialPlatform.stories.tsx

Lines changed: 64 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,76 @@ export default {
88
component: AddSocialPlatform
99
};
1010

11-
export const Default = () => {
12-
const SOCIAL_PLATFORMS = [
13-
{
14-
name: "Github",
15-
url: "github.com/"
16-
},
17-
{
18-
name: "Gitlab",
19-
url: "gitlab.com/"
20-
},
21-
{
22-
name: "Stackoverflow",
23-
url: "stackoverflow.com/users/"
24-
},
25-
{
26-
name: "Linkedin",
27-
url: "linkedin.com/in/"
28-
},
29-
{
30-
name: "YouTube",
31-
url: "youtube.com/"
32-
},
33-
{
34-
name: "Twitter",
35-
url: "twitter.com/"
36-
},
37-
{
38-
name: "Mastodon",
39-
url: "mastodon.social/"
40-
},
41-
{
42-
name: "Codewars",
43-
url: "codewars.com/users/"
44-
},
45-
{
46-
name: "Patreon",
47-
url: "patreon.com/user?u="
48-
},
49-
{
50-
name: "Hackernews",
51-
url: "news.ycombinator.com/user?id="
52-
},
53-
{
54-
name: "Reddit",
55-
url: "reddit.com/user/"
56-
},
57-
{
58-
name: "Hackerrank",
59-
url: "hackerrank.com/"
60-
},
61-
{
62-
name: "Leetcode",
63-
url: "leetcode.com/"
64-
},
65-
{
66-
name: "Exercism",
67-
url: "exercism.org/profiles/"
68-
}
69-
];
11+
const SOCIAL_PLATFORMS = [
12+
{
13+
name: "Github",
14+
url: "github.com/"
15+
},
16+
{
17+
name: "Gitlab",
18+
url: "gitlab.com/"
19+
},
20+
{
21+
name: "Stackoverflow",
22+
url: "stackoverflow.com/users/"
23+
},
24+
{
25+
name: "Linkedin",
26+
url: "linkedin.com/in/"
27+
},
28+
{
29+
name: "YouTube",
30+
url: "youtube.com/"
31+
},
32+
{
33+
name: "Twitter",
34+
url: "twitter.com/"
35+
},
36+
{
37+
name: "Mastodon",
38+
url: "mastodon.social/"
39+
},
40+
{
41+
name: "Codewars",
42+
url: "codewars.com/users/"
43+
},
44+
{
45+
name: "Patreon",
46+
url: "patreon.com/user?u="
47+
},
48+
{
49+
name: "Hackernews",
50+
url: "news.ycombinator.com/user?id="
51+
},
52+
{
53+
name: "Reddit",
54+
url: "reddit.com/user/"
55+
},
56+
{
57+
name: "Hackerrank",
58+
url: "hackerrank.com/"
59+
},
60+
{
61+
name: "Leetcode",
62+
url: "leetcode.com/"
63+
},
64+
{
65+
name: "Exercism",
66+
url: "exercism.org/profiles/"
67+
}
68+
];
7069

70+
export const Default = () => {
7171
return (
7272
<div>
7373
<AddSocialPlatform
7474
platforms={SOCIAL_PLATFORMS}
7575
onAdd={data => console.log(data)}
76+
valueProps={{
77+
name: "cool",
78+
label: "Story",
79+
hint: "Username, a slug or a handle. Different platforms call it differently. Do not include the base URL."
80+
}}
7681
/>
7782
</div>
7883
);

src/Components/AddSocialPlatform/index.tsx

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ import { FC } from "react";
33

44
import Button from "Components/Button";
55
import { Input, Select } from "Components/Inputs";
6-
import { Paragraph } from "Components/Typography";
76

87
import { IAddSocialPlatformProps } from "./types";
98

109
const AddSocialPlatform: FC<IAddSocialPlatformProps> = ({
1110
onAdd,
12-
platforms
11+
platforms,
12+
valueProps = {
13+
name: "",
14+
label: "",
15+
hint: ""
16+
}
1317
}) => {
1418
const form = useAJVForm(
1519
{
@@ -50,20 +54,7 @@ const AddSocialPlatform: FC<IAddSocialPlatformProps> = ({
5054
/>
5155
<div className='yl-col-span-5'>
5256
<Input
53-
name='url'
54-
label='Username'
55-
hint={
56-
<div>
57-
<Paragraph>
58-
Username, a slug or a handle. Different platforms call it
59-
differently.
60-
</Paragraph>
61-
<Paragraph className='yl-text-red-500'>
62-
<span className='yl-font-bold'>Do not</span> include the base
63-
URL.
64-
</Paragraph>
65-
</div>
66-
}
57+
{...valueProps}
6758
value={form.state.url.value}
6859
error={form.state.url.error}
6960
onChange={form.set}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export interface IAddSocialPlatformProps {
22
platforms: { name: string; url: string }[];
33
onAdd: (data: Record<string, string>) => void;
4+
valueProps?: {
5+
name: string;
6+
label: string;
7+
hint?: string;
8+
};
49
}

0 commit comments

Comments
 (0)