Add drag layer
This commit is contained in:
parent
4c014a7200
commit
4137362501
@ -3,6 +3,12 @@
|
|||||||
div.load-file-layer-root {
|
div.load-file-layer-root {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 20px;
|
||||||
|
|
||||||
|
div.load-file-layer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -10,8 +16,10 @@ div.load-file-layer-root {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
border-radius: 3px;
|
||||||
|
|
||||||
div {
|
div {
|
||||||
|
pointer-events: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -27,12 +35,21 @@ div.load-file-layer-root {
|
|||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
font-size: 1.5em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.load-file-layer-root.light {
|
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 {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,13 +4,24 @@ import { Icon } from "@fluentui/react";
|
|||||||
import { Component, ReactNode } from "react";
|
import { Component, ReactNode } from "react";
|
||||||
import "./LoadFile.scss";
|
import "./LoadFile.scss";
|
||||||
|
|
||||||
class LoadFile extends Component {
|
interface ILoadFileState {
|
||||||
|
show: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoadFile extends Component<{}, ILoadFileState> {
|
||||||
|
|
||||||
|
public state: Readonly<ILoadFileState> = {
|
||||||
|
show: false
|
||||||
|
};
|
||||||
|
|
||||||
private renderMask() {
|
private renderMask() {
|
||||||
return <Theme
|
return <Theme
|
||||||
className="load-file-layer-root"
|
className="load-file-layer-root"
|
||||||
fontLevel={FontLevel.normal}
|
fontLevel={FontLevel.normal}
|
||||||
|
onDragEnter={this.handleWindowsDragOnFiles}
|
||||||
|
onDragLeave={this.handleWindowsDragOffFiles}
|
||||||
>
|
>
|
||||||
|
<div className="load-file-layer">
|
||||||
<div className="drag-icon">
|
<div className="drag-icon">
|
||||||
<Icon iconName="KnowledgeArticle"/>
|
<Icon iconName="KnowledgeArticle"/>
|
||||||
</div>
|
</div>
|
||||||
@ -20,11 +31,38 @@ class LoadFile extends Component {
|
|||||||
<div className="drag-intro">
|
<div className="drag-intro">
|
||||||
<Localization i18nKey="Info.Hint.Load.File.Intro"/>
|
<Localization i18nKey="Info.Hint.Load.File.Intro"/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</Theme>;
|
</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 {
|
public render(): ReactNode {
|
||||||
return <></>;
|
return this.state.show ? this.renderMask() : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user