blob: eb8424613c1064cb58c54a9bae0ce903630507bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import React, {useContext, useEffect, useState} from "react";
import CloseIcon from "../assets/close.svg?react"
import {ActiveEdit} from "./Body.tsx";
import {getBrowser} from "../main.tsx";
import RadioButtonGroup from "./RadioButtonGroup.tsx";
import BMIcon from "./BMIcon.tsx";
import IconPicker from "./IconPicker.tsx";
function BMEditor() {
const [activeEdit, setActiveEdit] = useContext(ActiveEdit);
useEffect(() => {
if (!activeEdit) return;
}, [activeEdit]);
let isFolder = activeEdit && activeEdit.children && activeEdit.children.length > 0;
return (
<div id="settings-menu" className={activeEdit ? "open" : "closed"}>
<button id="settings-close" onClick={_ => setActiveEdit(null)}>
<CloseIcon/>
</button>
{activeEdit && (<>
<h1>Edit {isFolder ? "Folder" : "Bookmark"}</h1>
<h3>Name</h3>
<input type={"text"} defaultValue={activeEdit?.title} onChange={e => {
getBrowser().bookmarks.update(activeEdit!.id, {title: e.target.value})
}}/>
{!isFolder && (<>
<h3>URL</h3>
<input type={"url"} defaultValue={activeEdit?.url} onChange={e => {
getBrowser().bookmarks.update(activeEdit!.id, {url: e.target.value})
}}/>
</>)}
<h3>Icon</h3>
<IconPicker bmData={activeEdit}/>
</>)}
</div>
);
}
export default BMEditor;
|