tangled
alpha
login
or
join now
rocksky.app
/
rocksky
96
fork
atom
A decentralized music tracking and discovery platform built on AT Protocol 🎵
rocksky.app
spotify
atproto
lastfm
musicbrainz
scrobbling
listenbrainz
96
fork
atom
overview
issues
7
pulls
pipelines
[web] update ContextMenu
tsiry-sandratraina.com
7 months ago
41d467f2
b234ba7f
+160
-6
3 changed files
expand all
collapse all
unified
split
apps
web
src
components
ContextMenu
ContextMenu.tsx
pages
dropbox
Dropbox.tsx
googledrive
GoogleDrive.tsx
+142
-4
apps/web/src/components/ContextMenu/ContextMenu.tsx
···
1
1
+
import { Folder2, MusicNoteBeamed } from "@styled-icons/bootstrap";
1
2
import { EllipsisHorizontal } from "@styled-icons/ionicons-sharp";
3
3
+
import { NestedMenus, StatefulMenu } from "baseui/menu";
4
4
+
import { StatefulPopover } from "baseui/popover";
2
5
3
3
-
function ContextMenu() {
6
6
+
export type ContextMenuProps = {
7
7
+
file: {
8
8
+
id: string;
9
9
+
name: string;
10
10
+
type: string;
11
11
+
};
12
12
+
};
13
13
+
14
14
+
function ContextMenu(props: ContextMenuProps) {
15
15
+
const { file } = props;
4
16
return (
5
17
<>
6
6
-
<div className="text-[var(--color-text)] cursor-pointer">
7
7
-
<EllipsisHorizontal size={24} />
8
8
-
</div>
18
18
+
<StatefulPopover
19
19
+
autoFocus={false}
20
20
+
content={({ close }) => (
21
21
+
<div className="border-[var(--color-border)] w-[240px] border-[1px] bg-[var(--color-background)] rounded-[6px]">
22
22
+
<div
23
23
+
className="h-[54px] flex flex-row items-center pl-[5px] pr-[5px]"
24
24
+
style={{
25
25
+
borderBottom: "1px solid var(--color-border)",
26
26
+
}}
27
27
+
>
28
28
+
<div className="h-[43px] flex items-center justify-center ml-[10px] mr-[10px] text-[var(--color-text)]">
29
29
+
{file.type == "folder" && (
30
30
+
<div>
31
31
+
<Folder2 size={20} />
32
32
+
</div>
33
33
+
)}
34
34
+
{file.type !== "folder" && (
35
35
+
<div>
36
36
+
<MusicNoteBeamed size={20} />
37
37
+
</div>
38
38
+
)}
39
39
+
</div>
40
40
+
<div className="text-[var(--color-text)] whitespace-nowrap text-ellipsis overflow-hidden">
41
41
+
{file.name}
42
42
+
</div>
43
43
+
</div>
44
44
+
<NestedMenus>
45
45
+
<StatefulMenu
46
46
+
items={[
47
47
+
{
48
48
+
id: "0",
49
49
+
label: "Play",
50
50
+
},
51
51
+
{
52
52
+
id: "1",
53
53
+
label: "Play Next",
54
54
+
},
55
55
+
{
56
56
+
id: "2",
57
57
+
label: "Add to Playlist",
58
58
+
},
59
59
+
{
60
60
+
id: "3",
61
61
+
label: "Play Last",
62
62
+
},
63
63
+
{
64
64
+
id: "4",
65
65
+
label: "Add Shuffled",
66
66
+
},
67
67
+
]}
68
68
+
onItemSelect={({ item }) => {
69
69
+
console.log(`Selected item: ${item.label}`);
70
70
+
close();
71
71
+
}}
72
72
+
overrides={{
73
73
+
List: {
74
74
+
style: {
75
75
+
boxShadow: "none",
76
76
+
backgroundColor: "var(--color-background)",
77
77
+
},
78
78
+
},
79
79
+
ListItem: {
80
80
+
style: {
81
81
+
backgroundColor: "var(--color-background)",
82
82
+
color: "var(--color-text)",
83
83
+
":hover": {
84
84
+
backgroundColor: "var(--color-menu-hover)",
85
85
+
},
86
86
+
},
87
87
+
},
88
88
+
Option: {
89
89
+
props: {
90
90
+
getChildMenu: (item: { label: string }) => {
91
91
+
if (item.label === "Add to Playlist") {
92
92
+
return (
93
93
+
<div className="border-[var(--color-border)] w-[205px] border-[1px] bg-[var(--color-background)] rounded-[6px]">
94
94
+
<StatefulMenu
95
95
+
items={{
96
96
+
__ungrouped: [
97
97
+
{
98
98
+
label: "Create new playlist",
99
99
+
},
100
100
+
],
101
101
+
}}
102
102
+
overrides={{
103
103
+
List: {
104
104
+
style: {
105
105
+
boxShadow: "none",
106
106
+
backgroundColor:
107
107
+
"var(--color-background)",
108
108
+
},
109
109
+
},
110
110
+
ListItem: {
111
111
+
style: {
112
112
+
backgroundColor:
113
113
+
"var(--color-background)",
114
114
+
color: "var(--color-text)",
115
115
+
":hover": {
116
116
+
backgroundColor:
117
117
+
"var(--color-menu-hover)",
118
118
+
},
119
119
+
},
120
120
+
},
121
121
+
}}
122
122
+
/>
123
123
+
</div>
124
124
+
);
125
125
+
}
126
126
+
return null;
127
127
+
},
128
128
+
},
129
129
+
},
130
130
+
}}
131
131
+
/>
132
132
+
</NestedMenus>
133
133
+
</div>
134
134
+
)}
135
135
+
overrides={{
136
136
+
Inner: {
137
137
+
style: {
138
138
+
backgroundColor: "var(--color-background)",
139
139
+
},
140
140
+
},
141
141
+
}}
142
142
+
>
143
143
+
<div className="text-[var(--color-text)] cursor-pointer">
144
144
+
<EllipsisHorizontal size={24} />
145
145
+
</div>
146
146
+
</StatefulPopover>
9
147
</>
10
148
);
11
149
}
+9
-1
apps/web/src/pages/dropbox/Dropbox.tsx
···
70
70
}),
71
71
columnHelper.accessor("name", {
72
72
header: "",
73
73
-
cell: () => <ContextMenu />,
73
73
+
cell: (info) => (
74
74
+
<ContextMenu
75
75
+
file={{
76
76
+
id: info.row.original.id,
77
77
+
name: info.row.original.name,
78
78
+
type: info.row.original.tag,
79
79
+
}}
80
80
+
/>
81
81
+
),
74
82
}),
75
83
];
76
84
+9
-1
apps/web/src/pages/googledrive/GoogleDrive.tsx
···
57
57
}),
58
58
columnHelper.accessor("name", {
59
59
header: "",
60
60
-
cell: () => <ContextMenu />,
60
60
+
cell: (info) => (
61
61
+
<ContextMenu
62
62
+
file={{
63
63
+
id: info.row.original.id,
64
64
+
name: info.row.original.name,
65
65
+
type: info.row.original.tag,
66
66
+
}}
67
67
+
/>
68
68
+
),
61
69
}),
62
70
];
63
71