Skip to content

Commit 32546ac

Browse files
committed
fix responsive issues and add loading state
1 parent 580f74f commit 32546ac

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

.firebase/hosting.ZGlzdA.cache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
index.html,1688103362469,8b75454b05189ea5d540463bfc001d76a29c3b53839709ced384824c1427df4b
21
vite.svg,1674978059710,59ec4b6085a0cb1bf712a5e48dd5f35b08e34830d49c2026c18241be04e05d5a
3-
assets/download-74b78f19.png,1688103362469,ec437581e513f5015311a5c0e1480a3322ed9bd846ff4edb7fe0b50e3f4dca3d
4-
assets/preview-35b286f0.png,1688103362469,63f0a4f8898a72f68b5e6ff6436a8098e23485f9374b92ac99b41e82b5ba5903
5-
assets/index-eb9637c9.css,1688103362470,134fc779b3164cb837355b1eac94b9934b049e831cf6ecf2e717352174940f0f
6-
assets/Shouldirenovate Logo - Blue-19a85a31.png,1688103362470,92191206e7ac4341ef00fcb897148434c8d9e89a845eccbe6cb12b99431c8aa6
7-
assets/index-afb894c4.js,1688103362470,9c5a5fcd9585d3877436a1792f11fa532a87175bfd179463d900993e91c582c2
2+
index.html,1688378971753,9e310cea400ad03f188bf0b17855e36716c7bb7019dd6f06527703ad1c31d52e
3+
assets/download-74b78f19.png,1688378971753,ec437581e513f5015311a5c0e1480a3322ed9bd846ff4edb7fe0b50e3f4dca3d
4+
assets/index-eb9637c9.css,1688378971754,134fc779b3164cb837355b1eac94b9934b049e831cf6ecf2e717352174940f0f
5+
assets/preview-35b286f0.png,1688378971753,63f0a4f8898a72f68b5e6ff6436a8098e23485f9374b92ac99b41e82b5ba5903
6+
assets/Shouldirenovate Logo - Blue-19a85a31.png,1688378971753,92191206e7ac4341ef00fcb897148434c8d9e89a845eccbe6cb12b99431c8aa6
7+
assets/index-ff9a305f.js,1688378971754,7326dabd255e16d42b60cd9842339af447f36bdf07502d72c8f15330ca30da6c

src/page/ImageCrop.jsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function App() {
1414
const [completedCrop, setCompletedCrop] = useState();
1515
const [scale, setScale] = useState(1);
1616
const [rotate, setRotate] = useState(0);
17+
const [isLoading, setIsLoading] = useState(false);
1718

1819
function onSelectFile(e) {
1920
if (e.target.files && e.target.files.length > 0) {
@@ -42,6 +43,7 @@ export default function App() {
4243
}
4344

4445
function onDownloadCropClick() {
46+
setIsLoading(true);
4547
if (!previewCanvasRef.current) {
4648
throw new Error("Crop canvas does not exist");
4749
}
@@ -58,6 +60,8 @@ export default function App() {
5860
hiddenAnchorRef.current.href = blobUrl;
5961
hiddenAnchorRef.current.download = "croped-image.png";
6062
hiddenAnchorRef.current.click();
63+
64+
setIsLoading(false);
6165
},
6266
});
6367
}, "image/png");
@@ -81,15 +85,15 @@ export default function App() {
8185
}, [completedCrop, scale, rotate]);
8286

8387
return (
84-
<section className="max-w-7xl mx-auto bg-gray-200 p-14 rounded-xl min-h-screen">
88+
<section className="max-w-7xl mx-auto bg-gray-200 p-6 sm:p-14 rounded-xl min-h-screen">
8589
<div className="mb-6">
8690
<h1 className="font-extrabold text-[#222328] text-[32px]">
8791
Image Crop Tool
8892
</h1>
89-
<p className="mt-2 text-[#666e75] text-[16px] max-w[500px]">
93+
<p className="mt-2 text-[#666e75] text-[16px] max-w-[500px]">
9094
Select an image and crop it, then download the cropped version.
9195
</p>
92-
<p className="mt-2 text-[#666e75] text-[16px] max-w[500px]">
96+
<p className="mt-2 text-[#666e75] text-[16px] max-w-[500px]">
9397
Copyright © 2023 <span className="font-bold">ShouldiRenovate</span>.
9498
All rights reserved.
9599
</p>
@@ -101,7 +105,7 @@ export default function App() {
101105
type="file"
102106
accept="image/*"
103107
onChange={onSelectFile}
104-
className="py-2 px-4 bg-blue-500 text-white rounded-md cursor-pointer"
108+
className="py-2 px-4 bg-blue-500 text-white rounded-md cursor-pointer w-[101%] max-w-full lg:w-auto"
105109
/>
106110
</div>
107111
{!!imgSrc && (
@@ -136,12 +140,18 @@ export default function App() {
136140
}}
137141
/>
138142
<div className="mt-4">
139-
<button
140-
onClick={onDownloadCropClick}
141-
className="py-2 px-4 bg-green-500 text-white rounded-md cursor-pointer"
142-
>
143-
Download Crop
144-
</button>
143+
{isLoading ? (
144+
<button className="py-2 px-4 bg-green-500 text-white rounded-md cursor-pointer">
145+
Downloading...
146+
</button>
147+
) : (
148+
<button
149+
onClick={onDownloadCropClick}
150+
className="py-2 px-4 bg-green-500 text-white rounded-md cursor-pointer"
151+
>
152+
Download Image
153+
</button>
154+
)}
145155
<a
146156
ref={hiddenAnchorRef}
147157
download

0 commit comments

Comments
 (0)