FIX: UploadFileDialog is now a proper dialog for easy focusing
This commit is contained in:
committed by
Nicolás Hatcher Andrés
parent
185a70224c
commit
b95c0642da
@@ -1,4 +1,4 @@
|
|||||||
import styled from "@emotion/styled";
|
import { Dialog, styled } from "@mui/material";
|
||||||
import { BookOpen, FileUp, X } from "lucide-react";
|
import { BookOpen, FileUp, X } from "lucide-react";
|
||||||
import { type DragEvent, useEffect, useRef, useState } from "react";
|
import { type DragEvent, useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ function UploadFileDialog(properties: {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const root = document.getElementById("root");
|
const root = document.getElementById("root");
|
||||||
if (root) {
|
if (root) {
|
||||||
root.style.filter = "blur(2px)";
|
root.style.filter = "none";
|
||||||
}
|
}
|
||||||
if (crossRef.current) {
|
if (crossRef.current) {
|
||||||
crossRef.current.focus();
|
crossRef.current.focus();
|
||||||
@@ -97,9 +97,11 @@ function UploadFileDialog(properties: {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UploadDialog
|
<DialogWrapper
|
||||||
tabIndex={-1}
|
open={true}
|
||||||
|
tabIndex={0}
|
||||||
role="dialog"
|
role="dialog"
|
||||||
|
onClose={handleClose}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.code === "Escape") {
|
if (event.code === "Escape") {
|
||||||
handleClose();
|
handleClose();
|
||||||
@@ -116,6 +118,7 @@ function UploadFileDialog(properties: {
|
|||||||
title="Close Dialog"
|
title="Close Dialog"
|
||||||
ref={crossRef}
|
ref={crossRef}
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
onKeyDown={(event) => event.key === "Enter" && properties.onClose()}
|
||||||
>
|
>
|
||||||
<X />
|
<X />
|
||||||
</Cross>
|
</Cross>
|
||||||
@@ -167,6 +170,14 @@ function UploadFileDialog(properties: {
|
|||||||
fileInputRef.current.click();
|
fileInputRef.current.click();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
tabIndex={0}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
if (fileInputRef.current) {
|
||||||
|
fileInputRef.current.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
click to browse
|
click to browse
|
||||||
</DocLink>
|
</DocLink>
|
||||||
@@ -192,9 +203,7 @@ function UploadFileDialog(properties: {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<UploadFooter>
|
<UploadFooter>
|
||||||
<BookOpen
|
<BookOpen />
|
||||||
style={{ width: 16, height: 16, marginLeft: 12, marginRight: 8 }}
|
|
||||||
/>
|
|
||||||
<UploadFooterLink
|
<UploadFooterLink
|
||||||
href="https://docs.ironcalc.com/web-application/importing-files.html"
|
href="https://docs.ironcalc.com/web-application/importing-files.html"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -203,10 +212,19 @@ function UploadFileDialog(properties: {
|
|||||||
Learn more about importing files into IronCalc
|
Learn more about importing files into IronCalc
|
||||||
</UploadFooterLink>
|
</UploadFooterLink>
|
||||||
</UploadFooter>
|
</UploadFooter>
|
||||||
</UploadDialog>
|
</DialogWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DialogWrapper = styled(Dialog)`
|
||||||
|
.MuiDialog-paper {
|
||||||
|
width: 460px;
|
||||||
|
}
|
||||||
|
.MuiBackdrop-root {
|
||||||
|
background-color: rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const Cross = styled("div")`
|
const Cross = styled("div")`
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
@@ -233,12 +251,27 @@ const DocLink = styled("span")`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const UploadTitle = styled("div")`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
height: 44px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
font-family: Inter;
|
||||||
|
`;
|
||||||
|
|
||||||
const UploadFooter = styled("div")`
|
const UploadFooter = styled("div")`
|
||||||
height: 44px;
|
height: 44px;
|
||||||
border-top: 1px solid #e0e0e0;
|
border-top: 1px solid #e0e0e0;
|
||||||
color: #757575;
|
color: #757575;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
font-family: Inter;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 0px 12px;
|
||||||
|
svg {
|
||||||
|
max-width: 16px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const UploadFooterLink = styled("a")`
|
const UploadFooterLink = styled("a")`
|
||||||
@@ -251,49 +284,14 @@ const UploadFooterLink = styled("a")`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const UploadTitle = styled("div")`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
border-bottom: 1px solid #e0e0e0;
|
|
||||||
height: 44px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const UploadDialog = styled("div")`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
width: 460px;
|
|
||||||
max-width: 90%;
|
|
||||||
height: 285px;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #e0e0e0;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0px 1px 3px 0px #0000001a;
|
|
||||||
font-family: Inter;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const DropZone = styled("div")`
|
const DropZone = styled("div")`
|
||||||
&:hover {
|
|
||||||
border: 1px dashed #f2994a;
|
|
||||||
transition: 0.2s ease-in-out;
|
|
||||||
gap: 8px;
|
|
||||||
background: linear-gradient(
|
|
||||||
180deg,
|
|
||||||
rgba(242, 153, 74, 0.12) 0%,
|
|
||||||
rgba(242, 153, 74, 0) 100%
|
|
||||||
);
|
|
||||||
}
|
|
||||||
flex-grow: 2;
|
flex-grow: 2;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
height: 160px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 12px;
|
margin: 12px;
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
font-family: Arial, sans-serif;
|
font-family: Inter;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #faebd7;
|
background-color: #faebd7;
|
||||||
border: 1px dashed #efaa6d;
|
border: 1px dashed #efaa6d;
|
||||||
@@ -307,6 +305,16 @@ const DropZone = styled("div")`
|
|||||||
vertical-align: center;
|
vertical-align: center;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
transition: 0.2s ease-in-out;
|
transition: 0.2s ease-in-out;
|
||||||
|
&:hover {
|
||||||
|
border: 1px dashed #f2994a;
|
||||||
|
transition: 0.2s ease-in-out;
|
||||||
|
gap: 8px;
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
rgba(242, 153, 74, 0.12) 0%,
|
||||||
|
rgba(242, 153, 74, 0) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default UploadFileDialog;
|
export default UploadFileDialog;
|
||||||
|
|||||||
Reference in New Issue
Block a user