Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
NextJs-Blog
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Madhankumar
NextJs-Blog
Commits
bdf75829
Commit
bdf75829
authored
Jan 05, 2024
by
Madhankumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code changes
parent
6914ff67
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
+19
-14
theme-context.js
app/theme-context.js
+8
-14
styles.module.css
components/top-level/single-blog/styles.module.css
+11
-0
No files found.
app/theme-context.js
View file @
bdf75829
"use client"
;
import
{
createContext
,
useContext
,
useState
,
useEffect
}
from
"react"
;
import
{
useRouter
,
useSearchParams
,
usePathname
}
from
"next/navigation"
;
export
const
ThemeContext
=
createContext
();
export
const
useAppContext
=
()
=>
useContext
(
ThemeContext
);
...
...
@@ -16,19 +17,12 @@ export const ThemeProvider = ({ children }) => {
useEffect
(()
=>
{
const
storedTheme
=
localStorage
.
getItem
(
"theme"
);
setTheme
(
storedTheme
);
},
[
theme
]);
setTheme
(
storedTheme
||
"light"
);
},
[]);
useEffect
(()
=>
{
if
(
!
search
)
{
setText
(
""
);
}
else
{
setText
(
search
);
}
if
(
pathName
.
includes
(
"singleblog"
))
{
setIsDisabled
(
true
);
}
else
{
setIsDisabled
(
false
);
}
setText
(
search
||
""
);
setIsDisabled
(
pathName
.
includes
(
"singleblog"
));
},
[
pathName
,
search
]);
const
toggleTheme
=
()
=>
{
...
...
@@ -36,15 +30,15 @@ export const ThemeProvider = ({ children }) => {
localStorage
.
setItem
(
"theme"
,
newTheme
);
setTheme
(
newTheme
);
};
const
handleSearchInput
=
(
value
,
currentPage
)
=>
{
setText
(
value
);
const
query
=
value
?
`?page=
${
currentPage
}
&search=
${
value
}
`
:
`?page=
${
currentPage
}
`
;
router
.
push
(
query
,
undefined
,
{
shallow
:
true
});
};
const
contextValue
=
{
theme
,
toggleTheme
,
...
...
components/top-level/single-blog/styles.module.css
View file @
bdf75829
...
...
@@ -6,6 +6,7 @@
.blog-list
ul
{
padding
:
0rem
2.3rem
;
}
.blogContent
{
padding
:
1rem
;
border-radius
:
15px
;
...
...
@@ -107,6 +108,12 @@
.tag
{
gap
:
1rem
;
}
.title
{
padding-inline-start
:
0.5em
;
}
.blogList
ul
li
{
padding-inline-start
:
1.5em
;
}
}
@media
screen
and
(
min-width
:
1440px
)
{
.container
{
...
...
@@ -120,4 +127,8 @@
.blogList
ul
{
margin-top
:
1rem
;
}
.title
,
.blogList
ul
li
{
padding-inline-start
:
0em
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment