Skip to content

Commit 141596e

Browse files
committed
feat(ui): make NavBar responsive for smaller screens
1 parent 93c7ea9 commit 141596e

27 files changed

Lines changed: 1392 additions & 1258 deletions

src/Home.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ const HeroSection = () => {
111111
<div className="flex flex-col sm:flex-row gap-4 justify-center items-center !mb-8">
112112
<a
113113
href="/#tools"
114-
className="bg-[#4446a6] text-2xl text-white/95 inline-flex-center whitespace-nowrap text-sm font-medium transition-all h-10 rounded-md !px-6 gap-2"
114+
className="max-w-[163px] bg-[#4446a6] text-2xl text-white/95 inline-flex-center whitespace-nowrap text-sm font-medium transition-all h-10 rounded-md !px-6 gap-2"
115115
>
116116
<Zap className="w-5 h-5" />
117117
Explore Tools
118118
</a>
119119
<ExternalLinkA
120120
href="https://github.com/sabeerbikba/dev.tools"
121-
className="text-white hover:bg-[#4446a6]/25 border border-[#4446a6]/60 inline-flex-center whitespace-nowrap text-sm font-medium transition-all h-10 rounded-md !px-2 gap-2"
121+
className="max-w-[163px] !px-[21px] text-white hover:bg-[#4446a6]/25 border border-[#4446a6]/60 inline-flex-center whitespace-nowrap text-sm font-medium transition-all h-10 rounded-md !px-2 gap-2"
122122
style={{
123123
backgroundImage:
124124
"url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 fill-opacity=%220.35%22 viewBox=%220 0 100 100%22><text x=%220%22 y=%2216%22 font-size=%2216%22>⭐</text></svg>')",
125125
backgroundRepeat: "no-repeat",
126126
backgroundSize: "220px",
127127
}}
128128
>
129-
Star us on GitHub ({stars})
129+
Star on GitHub ({stars})
130130
</ExternalLinkA>
131131
</div>
132132
</div>

src/Layout.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
import { Outlet, useLocation } from "react-router-dom";
22

33
import cn from "@/utils/cn";
4+
import { mobileResponsivePaths } from "@/routes";
45
import NavBar from "@/components/Nav";
56
import Footer from "@/components/Footer";
67
import MobileInfoModal from "@/components/MobileInfoModel";
8+
// import useMediaQuery from "@/hooks/useMediaQuery";
79

810
const Layout = () => {
911
const location = useLocation();
1012
const isHomePage = location.pathname === "/";
13+
// const isMobile = useMediaQuery("max-width: 640px");
1114

1215
return (
1316
<>
1417
<MobileInfoModal />
1518
{!isHomePage && <NavBar />}
1619
<main
1720
className={cn(
18-
!isHomePage
19-
? "!ml-[210px] text-sm !text-white h-screen"
20-
: "!p-0 overflow-hidden"
21+
!isHomePage &&
22+
mobileResponsivePaths.includes(location.pathname) &&
23+
"sm:ml-[210px]",
24+
!mobileResponsivePaths.includes(location.pathname) && "ml-[210px]",
25+
!isHomePage ? "text-sm !text-white h-screen" : "!p-0 overflow-hidden"
2126
)}
2227
>
2328
<Outlet />

src/common/Input.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import PropTypes from 'prop-types';
22

3+
// convert entire component styles in tailwindcss
4+
35
export default function Input({
46
name,
57
label = '',
@@ -93,7 +95,3 @@ Input.propTypes = {
9395
onFocus: PropTypes.func,
9496
inputDisalbed: PropTypes.bool,
9597
};
96-
97-
// function UPDATE_INPUT(field, value) {
98-
// dispatch({ type: actionTypes.UPDATE_INPUT, field: field, value: value })
99-
// }

src/common/TextArea.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function TextArea({
2121
};
2222

2323
return (
24-
<div className="w-full h-full">
24+
<div className="size-full">
2525
<div className="flex items-center mb-4 gap-4">
2626
<p className="font-bold text-xl text-white"> {title} </p>
2727
<button

src/common/ToolBox.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import cn from "@/utils/cn";
44
const ToolBox = ({
55
title,
66
children,
7+
mainClass = "",
78
tailwindStyles = "",
89
boxWidth = "50%",
910
controls,
1011
controlsPositionEnd = false,
1112
border, // for development purpose
1213
}) => {
1314
const tailwind = {
14-
main: cn("w-1/2 h-full ", border && "border-2 border-red-500"),
15+
main: cn("w-1/2 h-full ", border && "border-2 border-red-500", mainClass),
1516
controlsDiv: "flex mb-4 gap-4 justify-between block",
1617
title: "font-bold text-xl",
1718
controls: cn(
1819
"flex gap-4 items-center w-full",
1920
controlsPositionEnd && "justify-end"
2021
),
21-
content: cn("w-full h-full p-2 overflow-y-auto ", tailwindStyles),
22+
content: cn("size-full p-2 overflow-y-auto ", tailwindStyles),
2223
};
2324

2425
return (
@@ -35,6 +36,7 @@ const ToolBox = ({
3536
ToolBox.propTypes = {
3637
title: PropTypes.string.isRequired,
3738
children: PropTypes.node.isRequired,
39+
mainClass: PropTypes.string,
3840
tailwind: PropTypes.string,
3941
controls: PropTypes.node,
4042
boxWidth: PropTypes.string,

src/common/ToolBoxLayout.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import PropTypes from "prop-types";
2+
import cn from "@/utils/cn"
23

34
const ToolBoxLayout = ({
45
children,
56
height = '100vh',
7+
classNames
68
}) => {
79
return (
810
<div
9-
className="flex gap-4 p-4 w-full h-full text-white"
10-
style={{ minWidth: '1620px', height: height, overflow: 'hidden' }}
11+
className={cn("flex gap-4 p-4 size-full text-white", classNames)}
12+
style={{ minWidth: '1620px', height, overflow: 'hidden' }}
1113
>
1214
{children}
1315
</div>
@@ -17,6 +19,7 @@ const ToolBoxLayout = ({
1719
ToolBoxLayout.propTypes = {
1820
children: PropTypes.node.isRequired,
1921
height: PropTypes.string,
22+
classNames: PropTypes.string,
2023
}
2124

2225
export default ToolBoxLayout;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { useState } from "react";
2+
import PropTypes from "prop-types";
3+
4+
import cn from "@/utils/cn";
5+
import useMediaQuery from "@/hooks/useMediaQuery";
6+
7+
// TODO: mobile not friendly error need to show for non responsive value
8+
9+
const EditorSplitViewLayout = ({ editorBtns, editor, preview }) => {
10+
const [enabledEditor, setEnabledEditor] = useState(true);
11+
const isMobile = useMediaQuery("max-width: 640px");
12+
13+
const btnsBaseClass =
14+
"flex justify-around h-[5%] [&>button]:w-[30%] [&>button]:h-[92%] [&>button]:rounded-sm [&>button]:cursor-pointer";
15+
16+
return (
17+
<div className="sm:flex size-full">
18+
<div
19+
className={cn(
20+
"sm:w-1/2 max-sm:w-full sm:h-full max-sm:h-[88%] flex flex-col bg-[#808080cc]",
21+
enabledEditor || isMobile && "hidden h-0"
22+
)}
23+
>
24+
<div className={cn(btnsBaseClass, "max-sm:hidden")}>{editorBtns}</div>
25+
<div className="max-sm:h-full sm:h-[95%] max-sm:border-b max-sm:border-white">
26+
{editor}
27+
</div>
28+
</div>
29+
<div
30+
className={cn(
31+
"sm:w-1/2 max-sm:w-full sm:h-full max-sm:h-[88%] text-white max-sm:border-b max-sm:border-white",
32+
!enabledEditor || isMobile && "hidden"
33+
)}
34+
>
35+
{preview}
36+
</div>
37+
<div className={cn(btnsBaseClass, "sm:hidden mt-1")}>{editorBtns}</div>
38+
<div className="flex justify-end items-center h-10 pt-2 mr-8 sm:hidden">
39+
<span>Editor</span>
40+
<div
41+
onClick={() => setEnabledEditor((prev) => !prev)}
42+
className={`mx-2 w-14 h-8 flex items-center bg-gray-300 rounded-full p-1 cursor-pointer transition-colors duration-300 ${
43+
enabledEditor ? "bg-indigo-500" : "bg-gray-400"
44+
}`}
45+
>
46+
<div
47+
className={`bg-white w-6 h-6 rounded-full shadow-md transform transition-transform duration-300 ${
48+
enabledEditor ? "translate-x-6" : "translate-x-0"
49+
}`}
50+
/>
51+
</div>
52+
<span>Preview</span>
53+
</div>
54+
</div>
55+
);
56+
};
57+
EditorSplitViewLayout.PropTypes = {
58+
editorBtns: PropTypes.element.isRequired,
59+
editor: PropTypes.element.isRequired,
60+
preview: PropTypes.element.isRequired,
61+
};
62+
63+
export default EditorSplitViewLayout;

src/components/MobileInfoModel.jsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@ import { useState, useEffect } from "react";
22
import { Monitor, Smartphone } from "lucide-react";
33
import { useLocation } from "react-router-dom";
44

5-
import { paths } from "@/routes";
5+
import { mobileResponsivePaths } from "@/routes";
6+
import useMediaQuery from "@/hooks/useMediaQuery";
7+
68

79
const MobileInfoModal = () => {
810
const location = useLocation();
911
const [isOpen, setIsOpen] = useState(false);
1012
const [dismissed, setDismissed] = useState(false);
13+
const isMobile = useMediaQuery("max-width: 970px");
1114

1215
const handleContinue = () => {
1316
setIsOpen(false);
1417
setDismissed(true);
1518
};
1619

1720
const checkScreenSize = () => {
18-
const isMobile = window.innerWidth < 970;
19-
if (paths.includes(location.pathname) && isMobile && !dismissed) {
21+
if (
22+
!mobileResponsivePaths.includes(location.pathname) &&
23+
isMobile &&
24+
!dismissed
25+
) {
2026
setIsOpen(true);
2127
} else {
2228
setIsOpen(false);
@@ -48,22 +54,24 @@ const MobileInfoModal = () => {
4854

4955
return isOpen ? (
5056
<div className="fixed inset-0 z-50 bg-black/60 flex items-center justify-center">
51-
<div className="bg-[#374151] text-white p-6 rounded-2xl shadow-2xl w-full max-w-md mx-4 relative text-center">
57+
<div className="bg-[#374151] p-6 rounded-2xl shadow-2xl w-full max-w-md mx-4 relative text-center">
5258
<div className="flex flex-col items-center gap-4">
5359
<div className="bg-[#6366f1]/10 rounded-full p-4">
5460
<Monitor className="w-8 h-8 text-[#6366f1]" />
5561
</div>
56-
<h2 className="text-xl font-semibold">Best Viewed on Desktop</h2>
62+
<h2 className="text-xl font-semibold text-white">
63+
Best Viewed on Desktop
64+
</h2>
5765
<p className="text-sm text-gray-300">
5866
Dev.tools is best experienced on wider screens
5967
</p>
6068

6169
<div className="flex items-center justify-center gap-4 py-2">
62-
<div className="flex flex-col items-center gap-1 opacity-50">
70+
<div className="flex flex-col items-center gap-1 opacity-50 text-white">
6371
<Smartphone className="w-6 h-6" />
6472
<span className="text-xs">Mobile</span>
6573
</div>
66-
<div className="text-2xl"></div>
74+
<div className="text-2xl text-white"></div>
6775
<div className="flex flex-col items-center gap-1 text-[#6366f1]">
6876
<Monitor className="w-6 h-6" />
6977
<span className="text-xs">Desktop</span>

0 commit comments

Comments
 (0)