react-icons/hi#HiDocumentAdd TypeScript Examples
The following examples show how to use
react-icons/hi#HiDocumentAdd.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Header.tsx From freedeck-configurator with GNU General Public License v3.0 | 4 votes |
Header: React.FC<{
loadConfigFile: (filesOrBuffer: Buffer | FileList) => void;
saveConfigFile: () => void;
setShowSettings: React.Dispatch<React.SetStateAction<boolean>>;
createConfigBuffer: () => Buffer;
addPage: (
previousPageIndex?: number | undefined,
previousDisplayIndex?: number | undefined,
primary?: boolean | undefined
) => Promise<number>;
serialApi?: FDSerialAPI;
}> = ({
loadConfigFile,
saveConfigFile,
serialApi,
setShowSettings,
createConfigBuffer,
addPage,
}) => {
const [connected, setConnected] = useState<boolean>(!!serialApi?.connected);
const [progress, setProgress] = useState<number>(0);
useEffect(() => {
if (!serialApi) return;
const id = serialApi.registerOnConStatusChange((type) => {
setConnected(type === connectionStatus.connect);
});
return () => serialApi.clearOnConStatusChange(id);
}, [serialApi]);
return (
<Wrapper id="header">
<HeadLine>
<HeadLineThin>Free</HeadLineThin>
<HeadLineThick>Deck</HeadLineThick>
<HeadLineThick>{connected}</HeadLineThick>
</HeadLine>
<Buttons>
<form
onSubmit={(event) => {
event.preventDefault();
}}
>
{connected ? (
<Horiz>
<FDIconButton
icon="fa/FaDownload"
ml={4}
size={3}
onClick={() =>
serialApi!
.readConfigFromSerial((rec, size) =>
setProgress(rec / size)
)
.then(loadConfigFile)
}
>
Download Config (Serial)
</FDIconButton>
<FDIconButton
icon="fa/FaUpload"
ml={4}
size={3}
onClick={() =>
serialApi!.writeConfigOverSerial(
createConfigBuffer(),
(rec, size) => setProgress(rec / size)
)
}
>
Upload Config (Serial)
</FDIconButton>
<Value ml={16}>
{progress ? `${(progress * 100).toFixed(0)}%` : ""}
</Value>
</Horiz>
) : (
<Horiz>
<FDIconButton
size={3}
icon={"fa/FaFileUpload"}
htmlFor="loadConfig"
>
Load Config
</FDIconButton>
<InvisibleFile
id="loadConfig"
onChange={(event) =>
event.currentTarget.files &&
loadConfigFile(event.currentTarget.files)
}
></InvisibleFile>
<FDIconButton
icon="fa/FaSave"
ml={4}
size={3}
onClick={() => saveConfigFile()}
>
Save Config
</FDIconButton>
</Horiz>
)}
</form>
<Horiz>
<FDIconButton
ml={5}
icon="ai/AiFillSetting"
onClick={() => setShowSettings(true)}
>
Settings
</FDIconButton>
<FDIconButton ml={5} onClick={() => addPage()}>
<HiDocumentAdd size={22} />
Add Page
</FDIconButton>
</Horiz>
</Buttons>
</Wrapper>
);
}