Skip to content

Commit 7c9353c

Browse files
committed
[frontend] add icons to context menus
1 parent 50fea47 commit 7c9353c

File tree

6 files changed

+35
-2
lines changed

6 files changed

+35
-2
lines changed

frontend/src/Tab.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ import { HistoryPage } from "./pages/HistoryPage";
1515
import { SettingsPage } from "./pages/SettingsPage";
1616
import { scramjet } from "./main";
1717
import { DownloadsPage } from "./pages/DownloadsPage";
18+
import iconBack from "@ktibow/iconset-ion/arrow-back";
19+
import iconForwards from "@ktibow/iconset-ion/arrow-forward";
20+
import iconRefresh from "@ktibow/iconset-ion/refresh";
21+
import iconBookmark from "@ktibow/iconset-ion/bookmark-outline";
22+
import iconCode from "@ktibow/iconset-ion/code-outline";
1823

1924
const requestInspectElement = createDelegate<[HTMLElement, Tab]>();
2025

@@ -657,32 +662,37 @@ function pageContextItems(client: ScramjetClient, tab: Tab, e: MouseEvent) {
657662
action: () => {
658663
tab.back();
659664
},
665+
icon: iconBack,
660666
},
661667
{
662668
label: "Forward",
663669
action: () => {
664670
tab.forward();
665671
},
672+
icon: iconForwards,
666673
},
667674
{
668675
label: "Reload",
669676
action: () => {
670677
tab.reload();
671678
},
679+
icon: iconRefresh,
672680
},
673681
{
674682
label: "Bookmark",
675683
action: () => {
676684
// TODO:
677685
console.log("Bookmarking", tab.title, tab.url);
678686
},
687+
icon: iconBookmark,
679688
},
680689
{
681690
label: "Inspect",
682691
action: () => {
683692
tab.devtoolsOpen = true;
684693
if (e.target) requestInspectElement([e.target as HTMLElement, tab]);
685694
},
695+
icon: iconCode,
686696
},
687697
];
688698
}

frontend/src/components/BookmarksStrip.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const BookmarksStrip: Component = function (cx) {
99
setContextMenu(cx.root, [
1010
{
1111
label: "Add Bookmark",
12+
icon: iconAdd,
1213
action: () => {},
1314
},
1415
{

frontend/src/components/Menu.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { css, Pointer, type Component, type DLElement } from "dreamland/core";
22
import { browser } from "../Browser";
33
import { Checkbox } from "./Checkbox";
4+
import { Icon } from "./Icon";
5+
import type { IconifyIcon } from "@iconify/types";
46

57
export const Menu: Component<{
68
x: number;
@@ -69,7 +71,7 @@ export const Menu: Component<{
6971
e.stopPropagation();
7072
}}
7173
>
72-
<div class="pad" />
74+
{item.icon ? <Icon icon={item.icon}></Icon> : <div class="pad" />}
7375
<span>{item.label}</span>
7476
</button>
7577
)
@@ -128,6 +130,7 @@ type MenuItem = {
128130
label: string;
129131
action?: () => void;
130132
checkbox?: Pointer<boolean>;
133+
icon?: IconifyIcon;
131134
};
132135

133136
export function setContextMenu(elm: HTMLElement, items: MenuItem[]) {

frontend/src/components/Omnibox.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { UrlInput } from "./UrlInput";
1313
import { browser } from "../Browser";
1414
import { Icon } from "./Icon";
1515

16+
import iconNew from "@ktibow/iconset-ion/duplicate-outline";
17+
import iconTime from "@ktibow/iconset-ion/time-outline";
18+
import iconInfo from "@ktibow/iconset-ion/information-circle-outline";
19+
import iconSettings from "@ktibow/iconset-ion/settings-outline";
20+
1621
export const animateDownloadFly = createDelegate<void>();
1722

1823
export const Spacer: Component = function (cx) {
@@ -205,30 +210,35 @@ export const Omnibox: Component<{
205210
action: () => {
206211
browser.newTab(new URL("puter://newtab"), true);
207212
},
213+
icon: iconNew,
208214
},
209215
{
210216
label: "History",
211217
action: () => {
212218
browser.newTab(new URL("puter://history"));
213219
},
220+
icon: iconTime,
214221
},
215222
{
216223
label: "Downloads",
217224
action: () => {
218225
browser.newTab(new URL("puter://downloads"));
219226
},
227+
icon: iconDownload,
220228
},
221229
{
222230
label: "Settings",
223231
action: () => {
224232
browser.newTab(new URL("puter://settings"));
225233
},
234+
icon: iconSettings,
226235
},
227236
{
228237
label: "About",
229238
action: () => {
230239
browser.newTab(new URL("puter://version"));
231240
},
241+
icon: iconInfo,
232242
},
233243
]);
234244
e.stopPropagation();

frontend/src/components/TabStrip.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import iconClose from "@ktibow/iconset-ion/close";
22
import iconAdd from "@ktibow/iconset-ion/add";
3+
import iconNew from "@ktibow/iconset-ion/duplicate-outline";
4+
import iconDuplicate from "@ktibow/iconset-ion/copy-outline";
5+
import iconRefresh from "@ktibow/iconset-ion/refresh-outline";
36
import { css, type Component } from "dreamland/core";
47
import { Icon } from "./Icon";
58
import { memoize } from "../memoize";
@@ -31,24 +34,28 @@ export const DragTab: Component<
3134
setContextMenu(cx.root, [
3235
{
3336
label: "New tab to the right",
37+
icon: iconNew,
3438
action: () => {
3539
browser.newTabRight(this.tab);
3640
},
3741
},
3842
{
3943
label: "Reload",
44+
icon: iconRefresh,
4045
action: () => {
4146
this.tab.frame.reload();
4247
},
4348
},
4449
{
4550
label: "Duplicate",
51+
icon: iconDuplicate,
4652
action: () => {
4753
browser.newTabRight(this.tab, this.tab.url);
4854
},
4955
},
5056
{
5157
label: "Close Tab",
58+
icon: iconClose,
5259
action: () => {
5360
this.destroy();
5461
},
@@ -391,6 +398,7 @@ export const Tabs: Component<
391398
setContextMenu(cx.root, [
392399
{
393400
label: "New Tab",
401+
icon: iconNew,
394402
action: () => {
395403
this.addTab();
396404
},

frontend/src/components/UrlInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import iconStar from "@ktibow/iconset-ion/star-outline";
99
import iconStarFilled from "@ktibow/iconset-ion/star";
1010
import iconSearch from "@ktibow/iconset-ion/search";
1111
import iconForwards from "@ktibow/iconset-ion/arrow-forward";
12+
import iconTrash from "@ktibow/iconset-ion/trash-outline";
1213
import { Icon } from "./Icon";
1314
import { scramjet } from "../main";
1415
import { IconButton } from "./IconButton";
@@ -284,7 +285,7 @@ export const UrlInput: Component<
284285
class="optionsbutton"
285286
on:click={(e: MouseEvent) => {
286287
createMenu(e.clientX, e.clientY, [
287-
{ label: "Clear Site Data" },
288+
{ label: "Clear Site Data", icon: iconTrash },
288289
]);
289290
e.preventDefault();
290291
e.stopPropagation();

0 commit comments

Comments
 (0)