Skip to content

Commit 0895dec

Browse files
committed
feat: add responsive styling and dark mode support for Blogs section
1 parent 3deaa25 commit 0895dec

File tree

2 files changed

+97
-11
lines changed

2 files changed

+97
-11
lines changed

src/pages/blogs/Blogs.css

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.blogs-section {
2+
background-color: var(--bg-color);
3+
color: var(--text-color);
4+
padding: 2rem 1rem;
5+
min-height: 100vh;
6+
transition: background-color 0.3s ease, color 0.3s ease;
7+
}
8+
9+
:root {
10+
--bg-color: #ffffff;
11+
--text-color: #111827;
12+
}
13+
14+
html[data-theme='dark'] {
15+
--bg-color: #1a1a1a;
16+
--text-color: #d1d5db;
17+
}
18+
19+
body {
20+
background-color: var(--bg-color);
21+
color: var(--text-color);
22+
}
23+
24+
.blogs-description {
25+
font-size: 1.125rem;
26+
color: var(--muted-text);
27+
line-height: 1.6;
28+
max-width: 700px;
29+
margin: 0 auto;
30+
}
31+
32+
:root {
33+
--muted-text: #374151;
34+
}
35+
36+
html[data-theme='dark'] {
37+
--muted-text: #d1d5db;
38+
}
39+
40+
41+
.blog-card {
42+
background-color: var(--blog-card-bg);
43+
color: var(--blog-text-primary);
44+
transition: background-color 0.3s, color 0.3s;
45+
}
46+
47+
.blog-title {
48+
font-size: 1.25rem;
49+
font-weight: 600;
50+
color: var(--blog-text-primary);
51+
margin-bottom: 0.5rem;
52+
}
53+
54+
.blog-desc {
55+
font-size: 0.95rem;
56+
color: var(--blog-text-muted);
57+
margin-bottom: 1rem;
58+
}
59+
60+
.read-more {
61+
font-weight: 600;
62+
text-decoration: none;
63+
transition: color 0.3s;
64+
}
65+
66+
.light-link {
67+
color: #3b82f6;
68+
}
69+
70+
.dark-link {
71+
color: #93c5fd;
72+
}
73+
74+
:root {
75+
--blog-card-bg: #ffffff;
76+
--blog-text-primary: #111827;
77+
--blog-text-muted: #6b7280;
78+
}
79+
80+
html[data-theme="dark"] {
81+
--blog-card-bg: #1a1a1a;
82+
--blog-text-primary: #f3f4f6;
83+
--blog-text-muted: #9ca3af;
84+
}

src/pages/blogs/index.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import Layout from "@theme/Layout";
44
import Link from "@docusaurus/Link";
55
import blogs from "../../database/blogs";
66
import Head from "@docusaurus/Head";
7+
import { useColorMode } from "@docusaurus/theme-common";
8+
import "./Blogs.css"; // Make sure this path is correct
79

810
export default function Blogs(): React.JSX.Element {
911
const { siteConfig } = useDocusaurusContext();
@@ -20,15 +22,16 @@ export default function Blogs(): React.JSX.Element {
2022
src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"
2123
/>
2224
</Head>
23-
<section className="m-4 my-10">
25+
<section className="blogs-section">
2426
<div className="text-center mb-8">
2527
<h1 className="text-4xl font-bold gradient-text">
2628
Welcome to RecodeHive Blogs
2729
</h1>
28-
<p className="text-lg text-gray-700 dark:text-gray-300">
30+
<p className="blogs-description">
2931
Discover web development articles ranging from HTML and CSS to
3032
JavaScript, React, Node.js, DSA, and much more.
3133
</p>
34+
3235
</div>
3336
<div className="grid gap-6 grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
3437
{blogs.map((blog) => (
@@ -40,10 +43,11 @@ export default function Blogs(): React.JSX.Element {
4043
);
4144
}
4245

43-
4446
const BlogCard = ({ blog }) => {
47+
const { colorMode } = useColorMode();
48+
4549
return (
46-
<div className="bg-white dark:bg-gray-800 shadow-lg rounded-lg overflow-hidden">
50+
<div className="blog-card shadow-lg rounded-lg overflow-hidden">
4751
<Link to={`/blog/${blog.slug}`}>
4852
<img
4953
src={blog.image}
@@ -52,17 +56,15 @@ const BlogCard = ({ blog }) => {
5256
/>
5357
</Link>
5458
<div className="p-4">
55-
<h2 className="text-xl font-semibold text-white">{blog.title}</h2>
56-
<p className="text-gray-600 dark:text-gray-400 mb-4">
57-
{blog.description}
58-
</p>
59+
<h2 className="blog-title">{blog.title}</h2>
60+
<p className="blog-desc">{blog.description}</p>
5961
<Link
6062
to={`/blog/${blog.slug}`}
61-
className="text-blue-600 dark:text-blue-400 hover:underline"
63+
className={`read-more ${colorMode === "dark" ? "dark-link" : "light-link"}`}
6264
>
63-
Read More
65+
Read More
6466
</Link>
6567
</div>
6668
</div>
6769
);
68-
};
70+
};

0 commit comments

Comments
 (0)