|
@@ -14,9 +14,11 @@ import {
|
|
AiOutlineTwitter,
|
|
AiOutlineTwitter,
|
|
AiOutlineSave,
|
|
AiOutlineSave,
|
|
AiOutlineFileAdd,
|
|
AiOutlineFileAdd,
|
|
|
|
+ AiOutlineLink,
|
|
} from "react-icons/ai";
|
|
} from "react-icons/ai";
|
|
|
|
|
|
import { Tooltip } from "src/components/Tooltip";
|
|
import { Tooltip } from "src/components/Tooltip";
|
|
|
|
+import { Modal } from "src/components/Modal/index";
|
|
import { ConfigActionType } from "src/reducer/reducer";
|
|
import { ConfigActionType } from "src/reducer/reducer";
|
|
import { useConfig } from "src/hocs/config";
|
|
import { useConfig } from "src/hocs/config";
|
|
import { useRouter } from "next/router";
|
|
import { useRouter } from "next/router";
|
|
@@ -109,11 +111,16 @@ export const Sidebar: React.FC = () => {
|
|
const { json, settings, dispatch } = useConfig();
|
|
const { json, settings, dispatch } = useConfig();
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
const [jsonFile, setJsonFile] = React.useState<File | null>(null);
|
|
const [jsonFile, setJsonFile] = React.useState<File | null>(null);
|
|
|
|
+ const [visible, setVisible] = React.useState(false);
|
|
|
|
|
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
if (e.target.files) setJsonFile(e.target.files?.item(0));
|
|
if (e.target.files) setJsonFile(e.target.files?.item(0));
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const handleImportJSONFromURL = () => {
|
|
|
|
+ setVisible(true);
|
|
|
|
+ };
|
|
|
|
+
|
|
const handleClear = () => {
|
|
const handleClear = () => {
|
|
dispatch({ type: ConfigActionType.SET_JSON, payload: "{}" });
|
|
dispatch({ type: ConfigActionType.SET_JSON, payload: "{}" });
|
|
localStorage.removeItem("json");
|
|
localStorage.removeItem("json");
|
|
@@ -147,6 +154,7 @@ export const Sidebar: React.FC = () => {
|
|
return (
|
|
return (
|
|
<StyledSidebar>
|
|
<StyledSidebar>
|
|
<StyledTopWrapper>
|
|
<StyledTopWrapper>
|
|
|
|
+ <Modal visible={visible} setVisible={setVisible} />
|
|
<Link passHref href="/">
|
|
<Link passHref href="/">
|
|
<StyledElement onClick={() => router.push("/")}>
|
|
<StyledElement onClick={() => router.push("/")}>
|
|
<StyledLogo>
|
|
<StyledLogo>
|
|
@@ -168,6 +176,11 @@ export const Sidebar: React.FC = () => {
|
|
</StyledImportFile>
|
|
</StyledImportFile>
|
|
</StyledElement>
|
|
</StyledElement>
|
|
</Tooltip>
|
|
</Tooltip>
|
|
|
|
+ <Tooltip title="Fetch JSON from URL">
|
|
|
|
+ <StyledElement onClick={handleImportJSONFromURL}>
|
|
|
|
+ <AiOutlineLink />
|
|
|
|
+ </StyledElement>
|
|
|
|
+ </Tooltip>
|
|
<Tooltip title="Rotate Layout">
|
|
<Tooltip title="Rotate Layout">
|
|
<StyledElement
|
|
<StyledElement
|
|
onClick={() => dispatch({ type: ConfigActionType.TOGGLE_LAYOUT })}
|
|
onClick={() => dispatch({ type: ConfigActionType.TOGGLE_LAYOUT })}
|