Skip to content

Commit f4fbe8f

Browse files
committed
chore: Update package.json version to 1.0.190
1 parent 2537e68 commit f4fbe8f

File tree

6 files changed

+43
-34
lines changed

6 files changed

+43
-34
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.189",
3+
"version": "1.0.190",
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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export default {
99
};
1010

1111
const SOCIAL_PLATFORMS = [
12+
{
13+
name: "Website",
14+
url: ""
15+
},
1216
{
1317
name: "Github",
1418
url: "github.com/"
@@ -73,11 +77,6 @@ export const Default = () => {
7377
<AddSocialPlatform
7478
platforms={SOCIAL_PLATFORMS}
7579
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-
}}
8180
/>
8281
</div>
8382
);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const schema = {
2+
type: "object",
3+
properties: {
4+
platform: {
5+
type: "string",
6+
minLength: 1,
7+
errorMessage: "Please select a platform"
8+
},
9+
url: {
10+
type: "string",
11+
minLength: 1,
12+
errorMessage: "Please enter a username"
13+
}
14+
},
15+
required: ["platform", "url"]
16+
};

src/Components/AddSocialPlatform/index.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,20 @@ import { FC } from "react";
44
import Button from "Components/Button";
55
import { Input, Select } from "Components/Inputs";
66

7+
import { schema } from "./constant";
78
import { IAddSocialPlatformProps } from "./types";
9+
import { getValueHint, getValueLabel } from "./utils";
810

911
const AddSocialPlatform: FC<IAddSocialPlatformProps> = ({
1012
onAdd,
11-
platforms,
12-
valueProps = {
13-
name: "",
14-
label: "",
15-
hint: ""
16-
}
13+
platforms
1714
}) => {
1815
const form = useAJVForm(
1916
{
2017
platform: "",
2118
url: ""
2219
},
23-
{
24-
type: "object",
25-
properties: {
26-
platform: {
27-
type: "string",
28-
minLength: 1,
29-
errorMessage: "Please select a platform"
30-
},
31-
url: {
32-
type: "string",
33-
minLength: 1,
34-
errorMessage: "Please enter a username"
35-
}
36-
},
37-
required: ["platform", "url"]
38-
}
20+
schema
3921
);
4022

4123
return (
@@ -54,7 +36,9 @@ const AddSocialPlatform: FC<IAddSocialPlatformProps> = ({
5436
/>
5537
<div className='yl-col-span-5'>
5638
<Input
57-
{...valueProps}
39+
name='url'
40+
label={getValueLabel(form.state.platform.value)}
41+
hint={getValueHint(form.state.platform.value)}
5842
value={form.state.url.value}
5943
error={form.state.url.error}
6044
onChange={form.set}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
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-
};
94
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const getValueHint = (platform: string): string => {
2+
if (platform === "Website") {
3+
return "The URL of your website. Include the protocol (http:// or https://).";
4+
}
5+
6+
return "Username, a slug or a handle. Different platforms call it differently. Do not include the base URL.";
7+
};
8+
9+
export const getValueLabel = (platform: string): string => {
10+
if (platform === "Website") {
11+
return "URL";
12+
}
13+
14+
return "Username";
15+
};

0 commit comments

Comments
 (0)