-
Notifications
You must be signed in to change notification settings - Fork 2
/
popup.tsx
25 lines (21 loc) · 825 Bytes
/
popup.tsx
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
import { Button, Stack } from "@mui/material";
import { sendToContentScript } from "@plasmohq/messaging"
import { useState } from "react";
function IndexPopup() {
const [disemvoweled, setDisemvoweled] = useState(false);
async function handleClick(command) {
const resp = await sendToContentScript({ name: command });
if (resp === 'disemvoweled') {
setDisemvoweled(true);
} else if (resp === 'reset') {
setDisemvoweled(false);
}
}
return (
<Stack direction='row' gap={2}>
<Button disabled={disemvoweled} variant="contained" color="primary" onClick={() => handleClick("disemvowel")}>Disemvowel</Button>
<Button disabled={!disemvoweled} variant="contained" color="secondary" onClick={() => handleClick("reset")}>Reset</Button>
</Stack>
)
}
export default IndexPopup