Skip to content

Commit 906ce79

Browse files
committed
refactor: Improve app responsiveness and layout across different screen sizes
1 parent 6283804 commit 906ce79

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

src/components/SortingVisualizer/index.jsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -258,11 +258,11 @@ const SortingVisualizer = ({ onDarkModeChange }) => {
258258
};
259259

260260
return (
261-
<div className={`p-4 w-full min-h-screen mx-auto ${isDarkMode ? 'bg-gray-900 text-white' : 'bg-white text-black'}`}>
262-
<div className="max-w-4xl mx-auto">
261+
<div className={`p-2 sm:p-4 w-full min-h-screen mx-auto ${isDarkMode ? 'bg-gray-900 text-white' : 'bg-white text-black'}`}>
262+
<div className="max-w-4xl mx-auto px-2 sm:px-0">
263263
{/* Controls section */}
264-
<div className="mb-2 flex gap-4 justify-between items-start">
265-
<div className="flex gap-4">
264+
<div className="mb-2 flex flex-col sm:flex-row gap-4 justify-between items-start">
265+
<div className="flex flex-wrap gap-2 sm:gap-4">
266266
<select
267267
value={selectedAlgorithm}
268268
onChange={(e) => {
@@ -358,7 +358,7 @@ const SortingVisualizer = ({ onDarkModeChange }) => {
358358
</div>
359359

360360
{/* Action buttons section */}
361-
<div className="mb-4 flex gap-4">
361+
<div className="mb-4 flex flex-wrap gap-2 sm:gap-4">
362362
<Button
363363
onClick={shuffleArray}
364364
disabled={isSorting}
@@ -393,7 +393,7 @@ const SortingVisualizer = ({ onDarkModeChange }) => {
393393
)}
394394

395395
{/* Stats Panel */}
396-
<div className="mb-4 grid grid-cols-4 gap-4 text-sm">
396+
<div className="mb-4 grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-4 text-sm">
397397
<div className={`p-2 rounded ${isDarkMode ? 'bg-gray-800' : 'bg-gray-100'}`}>
398398
<div className="font-semibold">Sorted</div>
399399
<div>{stats.sortedPercentage}%</div>
@@ -413,7 +413,7 @@ const SortingVisualizer = ({ onDarkModeChange }) => {
413413
</div>
414414

415415
{/* Visualization section */}
416-
<div className={`h-96 ${isDarkMode ? 'bg-black' : 'bg-gray-100'} relative overflow-hidden`}>
416+
<div className={`h-48 sm:h-72 md:h-96 ${isDarkMode ? 'bg-black' : 'bg-gray-100'} relative overflow-hidden rounded-lg`}>
417417
{visualizationMode === VISUALIZATION_MODES.CIRCLE ? (
418418
// Radial visualization with thin bars
419419
<div className="w-full h-full relative transform-gpu">

src/index.css

+25-1
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,29 @@
7272
}
7373
body {
7474
@apply bg-background text-foreground;
75+
-webkit-text-size-adjust: 100%;
76+
text-size-adjust: 100%;
7577
}
76-
}
78+
79+
/* Responsive text sizes */
80+
html {
81+
font-size: 14px;
82+
}
83+
@screen sm {
84+
html {
85+
font-size: 16px;
86+
}
87+
}
88+
@screen lg {
89+
html {
90+
font-size: 16px;
91+
}
92+
}
93+
}
94+
95+
/* Prevent content from becoming too small on tiny screens */
96+
@layer utilities {
97+
.min-safe {
98+
min-width: min(65ch, 100%);
99+
}
100+
}

tailwind.config.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ export default {
99
theme: {
1010
container: {
1111
center: true,
12-
padding: "2rem",
12+
padding: {
13+
DEFAULT: '1rem',
14+
sm: '2rem',
15+
lg: '4rem',
16+
xl: '5rem',
17+
'2xl': '6rem',
18+
},
1319
screens: {
14-
"2xl": "1400px",
20+
sm: '640px',
21+
md: '768px',
22+
lg: '1024px',
23+
xl: '1280px',
24+
'2xl': '1400px',
1525
},
1626
},
1727
extend: {
@@ -58,4 +68,4 @@ export default {
5868
},
5969
},
6070
plugins: ["tailwindcss-animate"],
61-
}
71+
}

0 commit comments

Comments
 (0)