Skip to content

Commit 56b946a

Browse files
committed
create blog dark mode issue fixed
1 parent e48cc41 commit 56b946a

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

src/components/BlogForm.jsx

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,125 @@
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+
1123
import { useState } from "react";
2124
import ReactQuill from 'react-quill';
3125
import 'react-quill/dist/quill.snow.css';
@@ -100,4 +222,4 @@ const BlogForm = ({ onCreateBlog }) => {
100222
);
101223
};
102224

103-
export default BlogForm;
225+
export default BlogForm;

src/index.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,15 @@
2525
/* border-color: rgba(31, 42, 55, 0.5) */
2626
border-color: rgba(255, 255, 255, 0.4);
2727
/* border-color: #151515; */
28-
}
28+
}
29+
30+
.ql-editor {
31+
color: black;
32+
background-color: white;
33+
}
34+
35+
/* Apply dark mode styles */
36+
.dark .ql-editor {
37+
color: white;
38+
background-color: #374151; /* Adjust as needed for dark backgrounds */
39+
}

tailwind.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export default {
55
theme: {
66
extend: {
77
colors: {
8+
text: "#fff", // Light mode text color
89
primary: "#9D5AE3",
910
secondary: "#484848",
1011
darkFooter: "#333333", // Dark mode footer color

0 commit comments

Comments
 (0)