Skip to content

Commit 1083276

Browse files
committed
Format
1 parent 1009609 commit 1083276

File tree

5 files changed

+115
-235
lines changed

5 files changed

+115
-235
lines changed

src/components/Browser.tsx

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
import { ChevronLeft, ChevronRight, Home, Lock, Menu, MoreVertical, Plus, RotateCw, Star, X, Maximize2 } from "lucide-react";
2-
import { useMemo, useState, useRef, useEffect } from "react";
3-
import {
4-
type Tab,
5-
formatUrl,
6-
classNames,
7-
iconButtonClass,
8-
tabButtonClass,
9-
closeButtonClass,
10-
addressInputClass,
11-
actionBarClass,
12-
getDefaultUrl,
13-
encodeProxyUrl,
14-
getActualUrl,
15-
} from "@/lib/browser";
1+
import { ChevronLeft, ChevronRight, Home, Lock, Maximize2, Menu, MoreVertical, Plus, RotateCw, Star, X } from "lucide-react";
2+
import { useEffect, useMemo, useRef, useState } from "react";
3+
import { actionBarClass, addressInputClass, classNames, closeButtonClass, encodeProxyUrl, formatUrl, getActualUrl, getDefaultUrl, iconButtonClass, type Tab, tabButtonClass } from "@/lib/tabs";
164

175
export default function Browser() {
18-
const [tabs, setTabs] = useState<Tab[]>([
19-
{ id: 1, title: "New Tab", url: "about:blank", active: true, reloadKey: 0 },
20-
]);
6+
const [tabs, setTabs] = useState<Tab[]>([{ id: 1, title: "New Tab", url: "about:blank", active: true, reloadKey: 0 }]);
217
const [url, setUrl] = useState("about:blank");
228
const activeTab = useMemo(() => tabs.find((tab) => tab.active), [tabs]);
239
const iframeRefs = useRef<{ [key: number]: HTMLIFrameElement | null }>({});
2410

2511
useEffect(() => {
2612
const defaultUrl = getDefaultUrl();
27-
setTabs(prev => prev.map(tab => ({ ...tab, url: defaultUrl })));
13+
setTabs((prev) => prev.map((tab) => ({ ...tab, url: defaultUrl })));
2814
setUrl(defaultUrl);
2915
}, []);
3016

@@ -44,24 +30,18 @@ export default function Browser() {
4430
const actualUrl = getActualUrl(iframe);
4531
if (actualUrl && actualUrl !== url) {
4632
setUrl(actualUrl);
47-
33+
4834
try {
4935
const hostname = new URL(actualUrl).hostname;
50-
setTabs((prev) =>
51-
prev.map((tab) =>
52-
tab.id === activeTab.id
53-
? { ...tab, title: hostname || "New Tab" }
54-
: tab
55-
)
56-
);
36+
setTabs((prev) => prev.map((tab) => (tab.id === activeTab.id ? { ...tab, title: hostname || "New Tab" } : tab)));
5737
} catch (e) {
5838
// Invalid URL
5939
}
6040
}
6141
};
6242

6343
iframe.addEventListener("load", updateUrlBar);
64-
44+
6545
const interval = setInterval(updateUrlBar, 1000);
6646

6747
return () => {
@@ -117,7 +97,7 @@ export default function Browser() {
11797
const handleNavigate = (value: string) => {
11898
if (!activeTab) return;
11999
const formattedUrl = formatUrl(value);
120-
100+
121101
setTabs((prev) =>
122102
prev.map((tab) =>
123103
tab.id === activeTab.id
@@ -169,10 +149,10 @@ export default function Browser() {
169149
if (!activeTab) return;
170150
const iframe = iframeRefs.current[activeTab.id];
171151
const actualUrl = getActualUrl(iframe) || activeTab.url;
172-
152+
173153
const title = prompt("Enter a Title for this bookmark:", activeTab.title || "New Bookmark");
174-
175-
if (title && typeof localStorage !== 'undefined') {
154+
155+
if (title && typeof localStorage !== "undefined") {
176156
try {
177157
const bookmarks = JSON.parse(localStorage.getItem("bookmarks") || "[]");
178158
bookmarks.push({ Title: title, url: actualUrl });
@@ -201,12 +181,7 @@ export default function Browser() {
201181
setActiveTab(tab.id);
202182
}
203183
}}
204-
className={classNames(
205-
tabButtonClass,
206-
tab.active
207-
? "bg-background-secondary text-text shadow-sm"
208-
: "bg-background text-text-secondary hover:bg-interactive"
209-
)}
184+
className={classNames(tabButtonClass, tab.active ? "bg-background-secondary text-text shadow-sm" : "bg-background text-text-secondary hover:bg-interactive")}
210185
>
211186
<div className="flex min-w-0 flex-1 items-center gap-2">
212187
<div className="h-4 w-4 shrink-0 rounded bg-accent/30" />
@@ -295,4 +270,4 @@ export default function Browser() {
295270
</div>
296271
</div>
297272
);
298-
}
273+
}

src/lib/browser.ts

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)