1
+ // import ReactQuill from 'react-quill';
2
+ // import 'react-quill/dist/quill.snow.css';
3
+ // import { useForm, Controller } from "react-hook-form";
4
+ // import { yupResolver } from "@hookform/resolvers/yup";
5
+ // import * as Yup from "yup";
6
+ // import { useEffect } from 'react';
7
+
8
+ // const BlogForm = ({ onCreateBlog }) => {
9
+ // const schema = Yup.object().shape({
10
+ // title: Yup.string().required("Title is required"),
11
+ // author: Yup.string().required("Author is required"),
12
+ // description: Yup.string().required("Description is required"),
13
+ // imgUrl: Yup.string().url("Must be a valid URL").required("Image URL is required"),
14
+ // });
15
+
16
+ // const { register, handleSubmit, control, formState: { errors } } = useForm({
17
+ // resolver: yupResolver(schema),
18
+ // });
19
+
20
+ // // Add an effect to dynamically apply dark mode styles to ReactQuill's editor content
21
+ // useEffect(() => {
22
+ // const quillEditor = document.querySelector('.ql-editor');
23
+ // if (quillEditor) {
24
+ // if (document.documentElement.classList.contains('dark')) {
25
+ // quillEditor.style.color = 'white';
26
+ // } else {
27
+ // quillEditor.style.color = 'black';
28
+ // }
29
+ // }
30
+ // }, []);
31
+
32
+ // const onSubmit = (data) => {
33
+ // const newBlog = {
34
+ // ...data,
35
+ // date: new Date().toLocaleDateString(),
36
+ // };
37
+ // onCreateBlog(newBlog);
38
+ // };
39
+
40
+ // return (
41
+ // <div className="border-gray-600 mt-20 max-w-lg mx-auto p-6 rounded-lg shadow-2xl bg-white dark:bg-gray-800">
42
+ // <h2 className="text-2xl font-bold mb-6 text-center text-primary dark:text-primary">
43
+ // Create New Blog
44
+ // </h2>
45
+
46
+ // <form onSubmit={handleSubmit(onSubmit)}>
47
+ // <div className="mb-4">
48
+ // <label htmlFor="title" className="block text-gray-700 dark:text-gray-300">
49
+ // Blog Title
50
+ // </label>
51
+ // <input
52
+ // id="title"
53
+ // type="text"
54
+ // className="w-full px-4 py-2 mt-1 border border-primary rounded-lg dark:bg-gray-700 dark:text-white"
55
+ // {...register("title")}
56
+ // placeholder="Enter blog title"
57
+ // />
58
+ // {errors.title && <span className="text-red-500">{errors.title.message}</span> }
59
+ // </div>
60
+
61
+ // <div className="mb-4">
62
+ // <label htmlFor="author" className="block text-gray-700 dark:text-gray-300">
63
+ // Author
64
+ // </label>
65
+ // <input
66
+ // id="author"
67
+ // type="text"
68
+ // className="w-full px-4 py-2 mt-1 border border-primary rounded-lg dark:bg-gray-700 dark:text-white"
69
+ // {...register("author")}
70
+ // placeholder="Enter author name"
71
+ // />
72
+ // {errors.author && <span className="text-red-500">{errors.author.message}</span> }
73
+ // </div>
74
+
75
+ // <div className="mb-4">
76
+ // <label htmlFor="description" className="block text-gray-700 dark:text-gray-300">
77
+ // Description
78
+ // </label>
79
+ // <Controller
80
+ // name="description"
81
+ // control={control}
82
+ // render={({ field }) => (
83
+ // <ReactQuill
84
+ // theme="snow"
85
+ // className="dark:bg-gray-700 dark:text-white"
86
+ // value={field.value}
87
+ // onChange={field.onChange}
88
+ // placeholder="Enter your description..."
89
+ // />
90
+ // )}
91
+ // />
92
+ // {errors.description && <span className="text-red-500">{errors.description.message}</span> }
93
+ // </div>
94
+
95
+ // <div className="mb-4">
96
+ // <label htmlFor="imgUrl" className="block text-gray-700 dark:text-gray-300">
97
+ // Image URL
98
+ // </label>
99
+ // <input
100
+ // id="imgUrl"
101
+ // type="url"
102
+ // className="w-full px-4 py-2 mt-1 border border-primary rounded-lg dark:bg-gray-700 dark:text-white"
103
+ // {...register("imgUrl")}
104
+ // placeholder="Enter image URL"
105
+ // />
106
+ // {errors.imgUrl && <span className="text-red-500">{errors.imgUrl.message}</span> }
107
+ // </div>
108
+
109
+ // <button
110
+ // type="submit"
111
+ // className="w-full bg-primary text-white py-2 rounded-lg hover:scale-105 transition duration-300"
112
+ // >
113
+ // Create Blog
114
+ // </button>
115
+ // </form>
116
+ // </div>
117
+ // );
118
+ // };
119
+
120
+ // export default BlogForm;
121
+
122
+
1
123
import { useState } from "react" ;
2
124
import ReactQuill from 'react-quill' ;
3
125
import 'react-quill/dist/quill.snow.css' ;
@@ -100,4 +222,4 @@ const BlogForm = ({ onCreateBlog }) => {
100
222
) ;
101
223
} ;
102
224
103
- export default BlogForm ;
225
+ export default BlogForm ;
0 commit comments