feat: implement extension's popup and options

This commit is contained in:
Steven
2023-08-08 20:16:14 +08:00
parent b638d9cdf4
commit f886bd7eb8
13 changed files with 344 additions and 91 deletions

View File

@ -4,13 +4,13 @@ import axios from "axios";
import { useState } from "react";
import { toast } from "react-hot-toast";
import { Shortcut } from "@/types/proto/api/v2/shortcut_service_pb";
import "../style.css";
import Icon from "./Icon";
import "./style.css";
function PullShortcutsButton() {
const [domain] = useStorage("domain");
const [accessToken] = useStorage("access_token");
const [shortcuts, setShortcuts] = useStorage("shortcuts");
const [, setShortcuts] = useStorage("shortcuts");
const [isPulling, setIsPulling] = useState(false);
const handlePullShortcuts = async () => {
@ -30,13 +30,9 @@ function PullShortcutsButton() {
};
return (
<div className="w-full mt-4">
<Button loading={isPulling} className="w-full" onClick={handlePullShortcuts}>
<Icon.RefreshCcw className="w-5 h-auto mr-1" />
<span>Pull</span>
<span className="opacity-70 ml-1">{Array.isArray(shortcuts) ? `(${shortcuts.length})` : ""}</span>
</Button>
</div>
<Button loading={isPulling} color="neutral" variant="plain" size="sm" onClick={handlePullShortcuts}>
<Icon.RefreshCcw className="w-4 h-auto" />
</Button>
);
}