Skip to content

Commit 06ad7b2

Browse files
committed
[frontend] context menu for bookmarks
1 parent 86dd73b commit 06ad7b2

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

frontend/src/components/BookmarksStrip.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { css, type Component } from "dreamland/core";
22
import { Icon } from "./Icon";
33
import iconAdd from "@ktibow/iconset-ion/add";
44
import { browser } from "../main";
5+
import { createMenu } from "./Menu";
56

67
export const BookmarksStrip: Component = function () {
78
return (
@@ -12,9 +13,33 @@ export const BookmarksStrip: Component = function () {
1213
</button>
1314
{use(browser.bookmarks).mapEach((b) => (
1415
<button
15-
on:auxclick={() => {
16+
on:auxclick={(e: MouseEvent) => {
17+
if (e.button != 1) return;
1618
browser.newTab(new URL(b.url));
1719
}}
20+
on:contextmenu={(e: MouseEvent) => {
21+
createMenu(e.clientX, e.clientY, [
22+
{
23+
label: "Open",
24+
action: () => browser.activetab.pushNavigate(new URL(b.url)),
25+
},
26+
{
27+
label: "Open in New Tab",
28+
action: () => browser.newTab(new URL(b.url)),
29+
},
30+
{
31+
label: "Edit Bookmark",
32+
},
33+
{
34+
label: "Delete Bookmark",
35+
action: () => {
36+
browser.bookmarks = browser.bookmarks.filter((br) => br != b);
37+
},
38+
},
39+
]);
40+
e.preventDefault();
41+
e.stopPropagation();
42+
}}
1843
on:click={() => {
1944
browser.activetab.pushNavigate(new URL(b.url));
2045
}}

0 commit comments

Comments
 (0)