-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
122 additions
and
30 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { ReactElement, useState, useEffect, useCallback } from 'react'; | ||
|
||
const NOTARY_API_LS_KEY = 'notary-api'; | ||
const PROXY_API_LS_KEY = 'proxy-api'; | ||
|
||
export default function Options(): ReactElement { | ||
const [notary, setNotary] = useState('http://localhost:7047'); | ||
const [proxy, setProxy] = useState('ws://127.0.0.1:55688'); | ||
const [dirty, setDirty] = useState(false); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
setNotary(await get(NOTARY_API_LS_KEY)); | ||
setProxy(await get(PROXY_API_LS_KEY)); | ||
})(); | ||
}, []); | ||
|
||
const onSave = useCallback(async () => { | ||
await set(NOTARY_API_LS_KEY, notary); | ||
await set(PROXY_API_LS_KEY, proxy); | ||
setDirty(false); | ||
}, [notary, proxy]); | ||
|
||
return ( | ||
<div className="flex flex-col flex-nowrap flex-grow"> | ||
<div className="flex flex-row flex-nowrap py-1 px-2 gap-2 font-bold text-base"> | ||
API Settings | ||
</div> | ||
<div className="flex flex-col flex-nowrap py-1 px-2 gap-2"> | ||
<div className="font-semibold">Notary API</div> | ||
<input | ||
type="text" | ||
className="input border" | ||
placeholder="http://localhost:7047" | ||
onChange={e => { | ||
setNotary(e.target.value); | ||
setDirty(true); | ||
}} | ||
value={notary} | ||
/> | ||
</div> | ||
<div className="flex flex-col flex-nowrap py-1 px-2 gap-2"> | ||
<div className="font-semibold">Proxy API</div> | ||
<input | ||
type="text" | ||
className="input border" | ||
placeholder="ws://127.0.0.1:55688" | ||
onChange={e => { | ||
setProxy(e.target.value); | ||
setDirty(true); | ||
}} | ||
value={proxy} | ||
/> | ||
</div> | ||
<div className="flex flex-row flex-nowrap justify-end gap-2 p-2"> | ||
<button | ||
className="button !bg-primary/[0.9] hover:bg-primary/[0.8] active:bg-primary !text-white" | ||
disabled={!dirty} | ||
onClick={onSave} | ||
> | ||
Save | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
Check failure on line 66 in src/components/Options/index.tsx GitHub Actions / build
|
||
|
||
async function set(key: string, value: string) { | ||
return chrome.storage.sync | ||
.set({ [key]: value }); | ||
} | ||
|
||
async function get(key: string) { | ||
return chrome.storage.sync | ||
.get(key) | ||
.then((json: any) => json[key]) | ||
.catch(() => ''); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ | |
"offscreen", | ||
"http://*/", | ||
"https://*/", | ||
"storage", | ||
"webRequest", | ||
"activeTab", | ||
"<all_urls>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
$fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; | ||
|
||
@import "@fortawesome/fontawesome-free/scss/fontawesome"; | ||
@import "@fortawesome/fontawesome-free/scss/brands"; | ||
@import "@fortawesome/fontawesome-free/scss/solid"; | ||
@import "@fortawesome/fontawesome-free/scss/regular"; | ||
|
||
|
||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", | ||
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
position: relative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
|
||
import Options from './Options'; | ||
import Options from '../../components/Options'; | ||
import './index.css'; | ||
|
||
const container = document.getElementById('app-container'); | ||
const root = createRoot(container!); // createRoot(container!) if you use TypeScript | ||
root.render(<Options title={'Settings'} />); | ||
root.render(<Options />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters