Skip to content

Commit 78135ac

Browse files
committed
feat: updated colours and icons
1 parent 91c96e4 commit 78135ac

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

components/Navbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SiSqlite, SiGithub } from "react-icons/si";
2-
import { FaFileCsv, FaHome } from "react-icons/fa";
2+
import { FaHome, FaFileExport } from "react-icons/fa";
33
import { useState, useEffect } from "react";
44

55
const Navbar: React.FC = () => {
@@ -45,7 +45,7 @@ const Navbar: React.FC = () => {
4545
}}
4646
title="Convert"
4747
>
48-
<FaFileCsv />
48+
<FaFileExport />
4949
Convert
5050
</a>
5151
<a

pages/convert.tsx

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import React, { useState, useEffect } from "react";
44
import { FaCloudUploadAlt, FaDatabase } from "react-icons/fa";
5+
import { VscJson } from "react-icons/vsc";
6+
import { LuFileSpreadsheet } from "react-icons/lu";
57
import initSqlJs from "sql.js";
68
import JSZip from "jszip";
79

@@ -101,7 +103,17 @@ export default function Home() {
101103
},
102104
);
103105

104-
blobs.push({ name: "database.json", blob: jsonBlob });
106+
blobs.push({ name: `${file.name}.json`, blob: jsonBlob });
107+
}
108+
109+
if (blobs.length === 0) {
110+
alert(
111+
'No data to export. Make sure you have selected "CSV" or "JSON" format.',
112+
);
113+
114+
return console.error(
115+
"No blobs to export. How does this happen?",
116+
);
105117
}
106118

107119
if (blobs.length === 1) {
@@ -116,15 +128,15 @@ export default function Home() {
116128
a.click();
117129
document.body.removeChild(a);
118130
URL.revokeObjectURL(url);
119-
} else if (blobs.length > 1) {
131+
} else {
120132
// Create ZIP archive for multiple files
121133
blobs.forEach(({ name, blob }) => zip.file(name, blob));
122134
zip.generateAsync({ type: "blob" }).then((zipBlob) => {
123135
const zipUrl = URL.createObjectURL(zipBlob);
124136
const a = document.createElement("a");
125137

126138
a.href = zipUrl;
127-
a.download = "database_export.zip";
139+
a.download = `${file.name}_export.zip`;
128140
document.body.appendChild(a);
129141
a.click();
130142
document.body.removeChild(a);
@@ -159,7 +171,7 @@ export default function Home() {
159171
onChange={handleFileChange}
160172
/>
161173
<label
162-
className="px-6 py-2 rounded hover:bg-blue-600 transition inline-flex items-center gap-2"
174+
className="px-6 py-2 rounded transition inline-flex items-center gap-2"
163175
htmlFor="file-upload"
164176
style={{
165177
backgroundColor: "var(--button-bg)",
@@ -190,7 +202,10 @@ export default function Home() {
190202
2. Select your chosen output format
191203
</h2>
192204
<div className="flex justify-center gap-4">
193-
{["CSV", "JSON"].map((option) => {
205+
{[
206+
{ key: "CSV", icon: <LuFileSpreadsheet /> },
207+
{ key: "JSON", icon: <VscJson /> },
208+
].map(({ key, icon }) => {
194209
const descriptions: { [key: string]: string } =
195210
{
196211
CSV: "Comma-Separated Values",
@@ -199,41 +214,40 @@ export default function Home() {
199214

200215
return (
201216
<label
202-
key={option}
217+
key={key}
203218
className={`flex items-center gap-2 px-4 py-2 rounded cursor-pointer transition ${
204-
selectedKeys.has(option)
205-
? "bg-green-500 text-white hover:bg-green-600"
206-
: "bg-blue-500 text-white hover:bg-blue-600"
219+
selectedKeys.has(key)
220+
? "bg-green-700 text-white hover:bg-green-800"
221+
: "bg-[var(--button-bg)] text-white hover:bg-blue-800"
207222
}`}
208-
title={descriptions[option]}
223+
title={descriptions[key]}
209224
>
210225
<input
211-
checked={selectedKeys.has(option)}
226+
checked={selectedKeys.has(key)}
212227
className="form-checkbox hidden"
213228
name="custom-checkbox"
214229
type="checkbox"
215-
value={option}
230+
value={key}
216231
onChange={() => {
217232
const newSelectedKeys = new Set(
218233
selectedKeys,
219234
);
220235

221-
newSelectedKeys.has(option)
236+
newSelectedKeys.has(key)
222237
? newSelectedKeys.delete(
223-
option,
238+
key,
224239
)
225-
: newSelectedKeys.add(
226-
option,
227-
);
240+
: newSelectedKeys.add(key);
228241
setSelectedKeys(
229242
new Set(newSelectedKeys),
230243
);
231244
}}
232245
/>
233-
{selectedKeys.has(option) && (
246+
{selectedKeys.has(key) && (
234247
<span>&#10003;</span>
235248
)}
236-
{option}
249+
{icon}
250+
{key}
237251
</label>
238252
);
239253
})}
@@ -255,6 +269,7 @@ export default function Home() {
255269
backgroundColor: "var(--button-bg)",
256270
color: "var(--button-text-color)",
257271
}}
272+
type="button"
258273
onClick={handleUpload}
259274
>
260275
<FaCloudUploadAlt />

0 commit comments

Comments
 (0)