Skip to content

Commit f1cec76

Browse files
authored
Merge pull request #361 from VinayLodhi1712/navbarfixeddone
Navbar fixed in both mode : #328 done
2 parents b9a1a6a + f1811f3 commit f1cec76

File tree

3 files changed

+99
-184
lines changed

3 files changed

+99
-184
lines changed

client/src/component/Faq.jsx

+26-143
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
import PropTypes from 'prop-types';
2-
import { useState } from 'react';
3-
import { FaGithub, FaLinkedin, FaXTwitter, FaYoutube } from 'react-icons/fa6';
1+
// component/FAQ.jsx
2+
import React, { useState } from 'react';
3+
import './FAQ.css'; // Import the CSS file for styling
4+
5+
const FAQ = () => {
6+
const [activeIndex, setActiveIndex] = useState(null);
7+
8+
const toggleAnswer = (index) => {
9+
setActiveIndex(activeIndex === index ? null : index);
10+
};
11+
12+
return (
13+
<div className="faq-container">
14+
<h1>Frequently Asked Questions</h1>
15+
{faqData.map((item, index) => (
16+
<div key={index} className="faq-item">
17+
<h2 onClick={() => toggleAnswer(index)} className="faq-question">
18+
{item.question}
19+
</h2>
20+
{activeIndex === index && <p className="faq-answer">{item.answer}</p>}
21+
</div>
22+
))}
23+
</div>
24+
);
25+
};
426

5-
// Sample FAQ data array
627
const faqData = [
728
{
829
question: "What is BitBox?",
@@ -24,145 +45,7 @@ const faqData = [
2445
question: "How can I contact support if I need help?",
2546
answer: "You can reach out to support through the 'Contact Us' page or by emailing [email protected].",
2647
},
27-
{
28-
question: "What programming languages does BitBox support?",
29-
answer: "BitBox supports a wide range of programming languages including Python, Java, JavaScript, and more.",
30-
},
31-
{
32-
question: "Are there any tutorials available for BitBox?",
33-
answer: "Yes, we offer comprehensive tutorials and documentation to help users get the most out of BitBox.",
34-
},
35-
{
36-
question: "Can I use BitBox for open-source projects?",
37-
answer: "Absolutely! BitBox is designed to support both open-source and private projects.",
38-
},
39-
{
40-
question: "What are the system requirements for using BitBox?",
41-
answer: "BitBox is a web-based platform, so you only need a modern web browser and an internet connection.",
42-
},
43-
{
44-
question: "Is there a mobile app for BitBox?",
45-
answer: "Currently, BitBox does not have a dedicated mobile app, but the platform is mobile-friendly and accessible via web browsers.",
46-
},
4748
];
4849

49-
function FAQ(props) {
50-
const [activeIndex, setActiveIndex] = useState(null);
51-
const [visibleCount, setVisibleCount] = useState(5);
52-
53-
const toggleFAQ = (index) => {
54-
setActiveIndex(activeIndex === index ? null : index);
55-
};
56-
57-
const loadMoreFAQs = () => {
58-
setVisibleCount((prevCount) => prevCount + 2);
59-
};
60-
61-
// Dynamic styles based on mode
62-
const bgClass = props.mode === 'dark' ? 'bg-black' : 'bg-gray-100';
63-
const textPrimary = props.mode === 'dark' ? 'text-gray-200' : 'text-gray-800';
64-
const textSecondary = props.mode === 'dark' ? 'text-gray-400' : 'text-gray-600';
65-
const borderClass = props.mode === 'dark' ? 'border-gray-600' : 'border-gray-300';
66-
const buttonBg = props.mode === 'dark' ? 'bg-blue-600' : 'bg-blue-900';
67-
const buttonHover = props.mode === 'dark' ? 'bg-blue-500' : 'bg-blue-800';
68-
69-
return (
70-
<div className={`${bgClass} p-8 mt-28`}>
71-
<div className="max-w-full mx-auto">
72-
{/* Header Section */}
73-
<div className="flex flex-col md:flex-row items-center mb-8">
74-
<div className="text-center md:text-left w-3/5 mb-4 md:mb-0 flex justify-center">
75-
<div className='w-1/2' data-aos="fade-right" data-aos-duration='1300'>
76-
<h2 className={`text-3xl font-bold ${textPrimary}`}>FAQs</h2>
77-
<p className={textSecondary}>
78-
Have questions? Here you’ll find the answers most valued by our partners,
79-
along with access to step-by-step instructions and support.
80-
</p>
81-
</div>
82-
</div>
83-
<div className="md:w-1/3" data-aos="fade-left" data-aos-duration='1300'>
84-
<img
85-
src="https://img.freepik.com/free-vector/tiny-people-sitting-standing-near-giant-faq_74855-7879.jpg?t=st=1730230687~exp=1730234287~hmac=c4b0ded086432ac95ae1b1da544d08d153b0dc1de2436041fec87835dc56a0db&w=1380"
86-
alt="FAQ illustration"
87-
className="w-full max-w-[28rem] mx-auto"
88-
/>
89-
</div>
90-
</div>
91-
92-
{/* FAQ List */}
93-
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 w-4/5 m-auto">
94-
{/* Sidebar Links */}
95-
<div className="col-md-6 col-lg-5 col-12 ft-1 w-4/5" data-aos="fade-up" data-aos-delay="100" data-aos-duration="1800">
96-
<h3 style={{ fontFamily: "medium", fontSize: "2.5rem" }} className={textPrimary}>
97-
BIT<span className='code' style={{ color: "#0D92F4" }}>BOX</span>
98-
</h3>
99-
<p className={textSecondary}>
100-
Empowering Developers,<br />
101-
Where Projects Find Solutions Together
102-
</p>
103-
<div className="footer-icons">
104-
{/* Social media icons with links */}
105-
<a href="https://github.com/bitboxcommunity" target="_blank" rel="noopener noreferrer" aria-label="GitHub">
106-
<FaGithub color={props.mode === 'dark' ? "#f0f0f0" : "#211F1F"} fontSize="2rem" />
107-
</a>
108-
<a href="https://twitter.com/BITBOX688152" target="_blank" rel="noopener noreferrer" aria-label="Twitter">
109-
<FaXTwitter color={props.mode === 'dark' ? "#1da1f2" : "#1da1f2"} fontSize="2rem" />
110-
</a>
111-
<a href="https://www.youtube.com/channel/UCXUTdcw27jaH_go9iyUjJnA" target="_blank" rel="noopener noreferrer" aria-label="YouTube">
112-
<FaYoutube color={props.mode === 'dark' ? "#FF0000" : "red"} fontSize="2rem" />
113-
</a>
114-
<a href="https://www.linkedin.com/in/bit-box-community" target="_blank" rel="noopener noreferrer" aria-label="LinkedIn">
115-
<FaLinkedin color={props.mode === 'dark' ? "#0A66C2" : "#0077b5"} fontSize="2rem" />
116-
</a>
117-
</div>
118-
</div>
119-
120-
{/* FAQ Section */}
121-
<div className="md:col-span-2" data-aos="fade-up" data-aos-delay="200" data-aos-duration="1800">
122-
<h3 className={`text-xl font-semibold ${textPrimary} mb-4`}>About us</h3>
123-
<div className="space-y-4">
124-
{faqData.slice(0, visibleCount).map((faq, index) => (
125-
<div key={index} className={`border-b ${borderClass}`}>
126-
<button
127-
onClick={() => toggleFAQ(index)}
128-
className={`w-full text-left flex justify-between items-center py-4 focus:outline-none ${textSecondary}`}
129-
>
130-
<span className={`font-medium ${textPrimary}`}>{faq.question}</span>
131-
<svg
132-
className={`w-5 h-5 transition-transform duration-200 ${activeIndex === index ? 'rotate-180' : ''}`}
133-
fill="none"
134-
stroke={props.mode === 'dark' ? 'white' : 'currentColor'}
135-
viewBox="0 0 24 24"
136-
xmlns="http://www.w3.org/2000/svg"
137-
>
138-
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7" />
139-
</svg>
140-
</button>
141-
{activeIndex === index && (
142-
<div className={textSecondary}>
143-
{faq.answer}
144-
</div>
145-
)}
146-
</div>
147-
))}
148-
</div>
149-
{visibleCount < faqData.length && (
150-
<button
151-
className={`${buttonBg} cursor-pointer text-white px-7 my-2 py-2 rounded-lg hover:${buttonHover}`}
152-
onClick={loadMoreFAQs}
153-
>
154-
View More
155-
</button>
156-
)}
157-
</div>
158-
</div>
159-
</div>
160-
</div>
161-
);
162-
}
163-
164-
FAQ.propTypes = {
165-
mode: PropTypes.string.isRequired,
166-
};
16750

168-
export default FAQ;
51+
export default FAQ;

client/src/component/Navbar.jsx

+46-40
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,23 @@ function Navbar(props) {
2525

2626
const toggleSidebar = (e) => {
2727
e.preventDefault();
28-
setIsSidebarOpen((prev) => !prev); // Toggle sidebar visibility
28+
setIsSidebarOpen((prev) => !prev);
29+
document.body.classList.toggle("no-scroll", !isSidebarOpen);
2930
};
3031

3132
const style = { color: "white", fontSize: "1.5em" };
3233

34+
useEffect(() => {
35+
const handleResize = () => {
36+
if (window.innerWidth > 768) { // Adjust for your breakpoint
37+
setIsSidebarOpen(false);
38+
document.body.classList.remove("no-scroll");
39+
}
40+
};
41+
42+
window.addEventListener("resize", handleResize);
43+
return () => window.removeEventListener("resize", handleResize);
44+
}, []);
3345
useEffect(() => {
3446
window.onscroll = function () {
3547
myFunction();
@@ -109,20 +121,23 @@ function Navbar(props) {
109121
<div>
110122
{/* Sticky Navbar */}
111123
<nav
112-
className={`navbar navbar-expand-lg ${
113-
isScrolled ? "sticky" : ""
114-
} navbar-${props.mode === "dark" ? "dark" : "light"}`}
115-
style={{
116-
backgroundColor: props.mode === "dark" ? "black" : "white",
117-
borderBottom: "1px solid white",
118-
}}
119-
id="navbar"
120-
>
124+
id="navbar"
125+
className={`navbar navbar-expand-lg ${
126+
isSidebarOpen ? "sticky" : ""
127+
} navbar-${mode === "dark" ? "dark" : "light"}`}
128+
style={{
129+
backgroundColor: mode === "dark" ? "black" : "white",
130+
borderBottom: "1px solid white",
131+
position: "fixed", // Fixed positioning
132+
top: 0,
133+
width: "100%",
134+
zIndex: 1000, // Ensure navbar appears above other content
135+
}}
136+
>
121137
{/* Hamburger icon */}
122138
<div
123-
className={`w-full gap-[1rem] visible navbar-collapse rnav ${
124-
isOpen ? "show" : ""
125-
}`}
139+
className={`w-full gap-[1rem] visible navbar-collapse rnav ${isOpen ? "show" : ""
140+
}`}
126141
style={{ backgroundColor: props.mode === "dark" ? "black" : "white" }}
127142
>
128143
<Link
@@ -135,25 +150,22 @@ function Navbar(props) {
135150
alt="logo"
136151
/>
137152
<div
138-
className={`logoTitle md:block hidden ${
139-
props.mode === "dark" ? "text-white" : "text-black"
140-
}`}
153+
className={`logoTitle md:block hidden ${props.mode === "dark" ? "text-white" : "text-black"
154+
}`}
141155
>
142156
{props.title}
143157
</div>
144158
</Link>
145159
<div
146-
className={`collapse navbar-collapse justify-content-center ${
147-
isOpen ? "show" : ""
148-
}`}
160+
className={`collapse navbar-collapse justify-content-center ${isOpen ? "show" : ""
161+
}`}
149162
id="navbarSupportedContent"
150163
>
151164
<ul className="navbar-nav mb-2 mb-lg-0 gap-3 fw-medium menu2">
152165
<li className="nav-item fs-6 fw-medium">
153166
<Link
154-
className={`nav-link ${
155-
location.pathname === "/" ? "active" : ""
156-
}`}
167+
className={`nav-link ${location.pathname === "/" ? "active" : ""
168+
}`}
157169
aria-current="page"
158170
to="/"
159171
>
@@ -162,9 +174,8 @@ function Navbar(props) {
162174
</li>
163175
<li className="nav-item fs-6">
164176
<Link
165-
className={`nav-link ${
166-
location.pathname === "/about" ? "active" : ""
167-
}`}
177+
className={`nav-link ${location.pathname === "/about" ? "active" : ""
178+
}`}
168179
aria-current="page"
169180
to="/about"
170181
>
@@ -173,9 +184,8 @@ function Navbar(props) {
173184
</li>
174185
<li className="nav-item fs-6">
175186
<Link
176-
className={`nav-link ${
177-
location.pathname === "/community" ? "active" : ""
178-
}`}
187+
className={`nav-link ${location.pathname === "/community" ? "active" : ""
188+
}`}
179189
aria-current="page"
180190
to="/community"
181191
>
@@ -184,9 +194,8 @@ function Navbar(props) {
184194
</li>
185195
<li className="nav-item fs-6">
186196
<Link
187-
className={`nav-link ${
188-
location.pathname === "/discussion" ? "active" : ""
189-
}`}
197+
className={`nav-link ${location.pathname === "/discussion" ? "active" : ""
198+
}`}
190199
aria-current="page"
191200
to="/discussion"
192201
>
@@ -195,9 +204,8 @@ function Navbar(props) {
195204
</li>
196205
<li className="nav-item fs-6">
197206
<Link
198-
className={`nav-link ${
199-
location.pathname === "/blog" ? "active" : ""
200-
}`}
207+
className={`nav-link ${location.pathname === "/blog" ? "active" : ""
208+
}`}
201209
aria-current="page"
202210
to="/blog"
203211
>
@@ -206,9 +214,8 @@ function Navbar(props) {
206214
</li>
207215
<li className="nav-item fs-6">
208216
<Link
209-
className={`nav-link ${
210-
location.pathname === "/contributors" ? "active" : ""
211-
}`}
217+
className={`nav-link ${location.pathname === "/contributors" ? "active" : ""
218+
}`}
212219
aria-current="page"
213220
to="/contributors"
214221
>
@@ -217,9 +224,8 @@ function Navbar(props) {
217224
</li>
218225
<li className="nav-item fs-6">
219226
<Link
220-
className={`nav-link ${
221-
location.pathname === "/myprofile" ? "active" : ""
222-
}`}
227+
className={`nav-link ${location.pathname === "/myprofile" ? "active" : ""
228+
}`}
223229
aria-current="page"
224230
to="/myprofile"
225231
>

client/src/css/Navbar.css

+27-1
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,30 @@
537537

538538
.main-content {
539539
margin-top: 10vh;
540-
}
540+
}
541+
542+
543+
/* Navbar.css */
544+
.sidebar {
545+
position: fixed;
546+
top: 0;
547+
left: 0;
548+
width: 250px; /* Adjust as needed */
549+
height: 100vh;
550+
overflow-y: auto;
551+
transition: transform 0.3s ease-in-out;
552+
transform: translateX(-100%); /* Initially hidden */
553+
z-index: 1000;
554+
background-color: #111; /* Change color based on theme */
555+
}
556+
557+
.sidebar.open {
558+
transform: translateX(0);
559+
left: 0;
560+
display: flex;
561+
}
562+
563+
/* Lock background scroll when sidebar is open */
564+
.no-scroll {
565+
overflow: hidden;
566+
}

0 commit comments

Comments
 (0)