Commit bdf75829 by Madhankumar

code changes

parent 6914ff67
"use client"; "use client";
import { createContext, useContext, useState, useEffect } from "react"; import { createContext, useContext, useState, useEffect } from "react";
import { useRouter, useSearchParams, usePathname } from "next/navigation"; import { useRouter, useSearchParams, usePathname } from "next/navigation";
export const ThemeContext = createContext(); export const ThemeContext = createContext();
export const useAppContext = () => useContext(ThemeContext); export const useAppContext = () => useContext(ThemeContext);
...@@ -16,19 +17,12 @@ export const ThemeProvider = ({ children }) => { ...@@ -16,19 +17,12 @@ export const ThemeProvider = ({ children }) => {
useEffect(() => { useEffect(() => {
const storedTheme = localStorage.getItem("theme"); const storedTheme = localStorage.getItem("theme");
setTheme(storedTheme); setTheme(storedTheme || "light");
}, [theme]); }, []);
useEffect(() => { useEffect(() => {
if (!search) { setText(search || "");
setText(""); setIsDisabled(pathName.includes("singleblog"));
} else {
setText(search);
}
if (pathName.includes("singleblog")) {
setIsDisabled(true);
} else {
setIsDisabled(false);
}
}, [pathName, search]); }, [pathName, search]);
const toggleTheme = () => { const toggleTheme = () => {
...@@ -36,15 +30,15 @@ export const ThemeProvider = ({ children }) => { ...@@ -36,15 +30,15 @@ export const ThemeProvider = ({ children }) => {
localStorage.setItem("theme", newTheme); localStorage.setItem("theme", newTheme);
setTheme(newTheme); setTheme(newTheme);
}; };
const handleSearchInput = (value, currentPage) => { const handleSearchInput = (value, currentPage) => {
setText(value); setText(value);
const query = value const query = value
? `?page=${currentPage}&search=${value}` ? `?page=${currentPage}&search=${value}`
: `?page=${currentPage}`; : `?page=${currentPage}`;
router.push(query, undefined, { shallow: true }); router.push(query, undefined, { shallow: true });
}; };
const contextValue = { const contextValue = {
theme, theme,
toggleTheme, toggleTheme,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
.blog-list ul { .blog-list ul {
padding: 0rem 2.3rem; padding: 0rem 2.3rem;
} }
.blogContent { .blogContent {
padding: 1rem; padding: 1rem;
border-radius: 15px; border-radius: 15px;
...@@ -107,6 +108,12 @@ ...@@ -107,6 +108,12 @@
.tag { .tag {
gap: 1rem; gap: 1rem;
} }
.title {
padding-inline-start: 0.5em;
}
.blogList ul li {
padding-inline-start: 1.5em;
}
} }
@media screen and (min-width: 1440px) { @media screen and (min-width: 1440px) {
.container { .container {
...@@ -120,4 +127,8 @@ ...@@ -120,4 +127,8 @@
.blogList ul { .blogList ul {
margin-top: 1rem; margin-top: 1rem;
} }
.title,
.blogList ul li {
padding-inline-start: 0em;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment