diff --git a/src/Components/Inputs/TextEditor/TextEditor.tsx b/src/Components/Inputs/TextEditor/TextEditor.tsx index 0f3d604..7462a77 100644 --- a/src/Components/Inputs/TextEditor/TextEditor.tsx +++ b/src/Components/Inputs/TextEditor/TextEditor.tsx @@ -41,7 +41,7 @@ export default function TextEditor({ placeholder, initialContent }: Props) { const linkExtension = useMemo(() => { const extension = new LinkExtension({ autoLink: true }); extension.addHandler('onClick', (_, data) => { - alert(`You clicked link: ${JSON.stringify(data)}`); + window.open(data.href, '_blank')?.focus(); return true; }); return extension; diff --git a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx index 76d72f9..1d646fe 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx @@ -42,7 +42,7 @@ export default function ContentEditor({ placeholder, initialContent, name }: Pro const linkExtension = useMemo(() => { const extension = new LinkExtension({ autoLink: true }); extension.addHandler('onClick', (_, data) => { - alert(`You clicked link: ${JSON.stringify(data)}`); + window.open(data.href, '_blank')?.focus(); return true; }); return extension; diff --git a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/styles.module.scss b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/styles.module.scss index 99a7830..d904235 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/styles.module.scss +++ b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/styles.module.scss @@ -6,6 +6,16 @@ overflow: hidden; border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; + + + a{ + color: rgb(54, 139, 236); + + &:hover{ + text-decoration: underline; + cursor: pointer; + } + } } .ProseMirror, diff --git a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx index efe912a..1c33489 100644 --- a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx +++ b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.tsx @@ -43,15 +43,12 @@ export default function StoryForm() { resolver: yupResolver(schema) as Resolver, defaultValues: { title: '', - tags: [{ - title: 'tag 1' - }], + tags: [], body: '', - cover_image: 'https://i.picsum.photos/id/10/1600/900.jpg?hmac=9R7fIkKwC5JxHx8ayZAKNMt6FvJXqKKyiv8MClikgDo' + cover_image: '' } - }); - const { handleSubmit, control, register, formState: { errors }, watch, } = formMethods; + const { handleSubmit, control, register, formState: { errors }, } = formMethods; const onSubmit: SubmitHandler = data => console.log(data); @@ -63,8 +60,6 @@ export default function StoryForm() {
- - ; + + +const Template: ComponentStory = (args) => + +export const Default = Template.bind({}); +Default.args = { +} + + diff --git a/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx b/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx index ff6fda8..ef1b3ed 100644 --- a/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx +++ b/src/features/Posts/pages/CreatePostPage/CreatePostPage.tsx @@ -1,9 +1,31 @@ +import { useState } from "react"; +import StoryForm from "./Components/StoryForm/StoryForm"; +import PostTypeList from "./PostTypeList"; + interface Props { } export default function CreatePostPage() { + + const [postType, setPostType] = useState<'story' | 'bounty' | 'question'>('story'); + return ( -
CreatePostPage
+
+
+ +
+
+ {postType === 'story' && <> +

+ Create Story +

+ + } +
+
) } diff --git a/src/features/Posts/pages/CreatePostPage/PostTypeList.tsx b/src/features/Posts/pages/CreatePostPage/PostTypeList.tsx new file mode 100644 index 0000000..4836f36 --- /dev/null +++ b/src/features/Posts/pages/CreatePostPage/PostTypeList.tsx @@ -0,0 +1,47 @@ +import React, { useState } from 'react' + +const types = [ + { + text: "📜 Story", + value: 'story' + }, { + text: "💰 Bounty", + value: 'bounty' + }, { + text: "❓ Question", + value: 'question' + }, +] as const; + +type Value = typeof types[number]['value']; + +interface Props { + selectionChanged?: (newFilter: Value) => void +} + +export default function PostTypeList({ selectionChanged }: Props) { + + const [selected, setSelected] = useState(types[0].value); + + const handleClick = (newValue: Value) => { + if (selected === newValue) + return + setSelected(newValue); + selectionChanged?.(newValue); + } + + return ( +
+

Type of post

+
    + {types.map((f, idx) =>
  • handleClick(f.value)} + > + {f.text} +
  • )} +
+
+ ) +}