Add save and load function #46

Merged
MrKBear merged 6 commits from dev-mrkbear into master 2022-04-26 16:44:39 +08:00
2 changed files with 84 additions and 29 deletions
Showing only changes of commit 4137362501 - Show all commits

View File

@ -5,34 +5,51 @@ div.load-file-layer-root {
z-index: 1000;
width: 100%;
height: 100%;
display: flex;
align-content: center;
justify-content: center;
align-items: center;
flex-wrap: wrap;
box-sizing: border-box;
padding: 20px;
div {
user-select: none;
text-align: center;
div.load-file-layer {
width: 100%;
}
height: 100%;
display: flex;
align-content: center;
justify-content: center;
align-items: center;
flex-wrap: wrap;
border-radius: 3px;
div.drag-icon {
font-weight: 200;
font-size: 2.8em;
}
div {
pointer-events: none;
user-select: none;
text-align: center;
width: 100%;
}
div.drag-title {
margin-top: 5px;
margin-bottom: 5px;
font-size: 1.5em;
div.drag-icon {
font-weight: 200;
font-size: 2.8em;
}
div.drag-title {
margin-top: 5px;
margin-bottom: 5px;
font-size: 1.5em;
}
}
}
div.load-file-layer-root.light {
background-color: rgba($color: #FFFFFF, $alpha: .75);
background-color: rgba($color: #FFFFFF, $alpha: .6);
div.load-file-layer {
border: 2px dashed $lt-font-color-normal-light;
}
}
div.load-file-layer-root.dark {
background-color: rgba($color: #000000, $alpha: .75);
background-color: rgba($color: #000000, $alpha: .6);
div.load-file-layer {
border: 2px dashed $lt-font-color-normal-dark;
}
}

View File

@ -4,27 +4,65 @@ import { Icon } from "@fluentui/react";
import { Component, ReactNode } from "react";
import "./LoadFile.scss";
class LoadFile extends Component {
interface ILoadFileState {
show: boolean;
}
class LoadFile extends Component<{}, ILoadFileState> {
public state: Readonly<ILoadFileState> = {
show: false
};
private renderMask() {
return <Theme
className="load-file-layer-root"
fontLevel={FontLevel.normal}
onDragEnter={this.handleWindowsDragOnFiles}
onDragLeave={this.handleWindowsDragOffFiles}
>
<div className="drag-icon">
<Icon iconName="KnowledgeArticle"/>
</div>
<div className="drag-title">
<Localization i18nKey="Info.Hint.Load.File.Title"/>
</div>
<div className="drag-intro">
<Localization i18nKey="Info.Hint.Load.File.Intro"/>
<div className="load-file-layer">
<div className="drag-icon">
<Icon iconName="KnowledgeArticle"/>
</div>
<div className="drag-title">
<Localization i18nKey="Info.Hint.Load.File.Title"/>
</div>
<div className="drag-intro">
<Localization i18nKey="Info.Hint.Load.File.Intro"/>
</div>
</div>
</Theme>;
}
private offDragTimer: NodeJS.Timeout | undefined;
private handleWindowsDragOnFiles = () => {
clearTimeout(this.offDragTimer as number | undefined);
this.setState({
show: true
});
}
private handleWindowsDragOffFiles = () => {
clearTimeout(this.offDragTimer as number | undefined);
this.offDragTimer = setTimeout(() => {
this.setState({
show: false
});
});
}
public componentDidMount() {
window.addEventListener("dragenter", this.handleWindowsDragOnFiles);
}
public componentWillUnmount() {
window.removeEventListener("dragenter", this.handleWindowsDragOnFiles);
}
public render(): ReactNode {
return <></>;
return this.state.show ? this.renderMask() : null;
}
}