popup ui
This commit is contained in:
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
|||||||
import { limitNumber } from "../../libs/utils";
|
import { limitNumber } from "../../libs/utils";
|
||||||
import { isMobile } from "../../libs/mobile";
|
import { isMobile } from "../../libs/mobile";
|
||||||
import { setFab } from "../../libs/storage";
|
import { setFab } from "../../libs/storage";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
|
|
||||||
const getEdgePosition = (
|
const getEdgePosition = (
|
||||||
{ x: left, y: top, edge },
|
{ x: left, y: top, edge },
|
||||||
@@ -58,6 +59,17 @@ const getHidePosition = (
|
|||||||
return { x: left, y: top, edge, hide: true };
|
return { x: left, y: top, edge, hide: true };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function DraggableWrapper({ children, usePaper, ...props }) {
|
||||||
|
if (usePaper) {
|
||||||
|
return (
|
||||||
|
<Paper {...props} elevation={4}>
|
||||||
|
{children}
|
||||||
|
</Paper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return <div {...props}>{children}</div>;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Draggable({
|
export default function Draggable({
|
||||||
windowSize,
|
windowSize,
|
||||||
width,
|
width,
|
||||||
@@ -70,6 +82,7 @@ export default function Draggable({
|
|||||||
onMove,
|
onMove,
|
||||||
handler,
|
handler,
|
||||||
children,
|
children,
|
||||||
|
usePaper,
|
||||||
}) {
|
}) {
|
||||||
const [origin, setOrigin] = useState({
|
const [origin, setOrigin] = useState({
|
||||||
x: left,
|
x: left,
|
||||||
@@ -181,7 +194,8 @@ export default function Draggable({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<DraggableWrapper
|
||||||
|
usePaper={usePaper}
|
||||||
style={{
|
style={{
|
||||||
opacity,
|
opacity,
|
||||||
position: "fixed",
|
position: "fixed",
|
||||||
@@ -202,6 +216,6 @@ export default function Draggable({
|
|||||||
{handler}
|
{handler}
|
||||||
</div>
|
</div>
|
||||||
<div>{children}</div>
|
<div>{children}</div>
|
||||||
</div>
|
</DraggableWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
import TranslateIcon from "@mui/icons-material/Translate";
|
import TranslateIcon from "@mui/icons-material/Translate";
|
||||||
import ThemeProvider from "../../hooks/Theme";
|
import ThemeProvider from "../../hooks/Theme";
|
||||||
@@ -9,6 +8,8 @@ import Popup from "../Popup";
|
|||||||
import { debounce } from "../../libs/utils";
|
import { debounce } from "../../libs/utils";
|
||||||
import { isGm } from "../../libs/client";
|
import { isGm } from "../../libs/client";
|
||||||
import Header from "../Popup/Header";
|
import Header from "../Popup/Header";
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
import {
|
import {
|
||||||
DEFAULT_SHORTCUTS,
|
DEFAULT_SHORTCUTS,
|
||||||
OPT_SHORTCUT_TRANSLATE,
|
OPT_SHORTCUT_TRANSLATE,
|
||||||
@@ -178,17 +179,17 @@ export default function Action({ translator, fab }) {
|
|||||||
show={showPopup}
|
show={showPopup}
|
||||||
onStart={handleStart}
|
onStart={handleStart}
|
||||||
onMove={handleMove}
|
onMove={handleMove}
|
||||||
|
usePaper
|
||||||
handler={
|
handler={
|
||||||
<Paper style={{ cursor: "move" }} elevation={3}>
|
<Box style={{ cursor: "move" }}>
|
||||||
<Header setShowPopup={setShowPopup} />
|
<Header setShowPopup={setShowPopup} />
|
||||||
</Paper>
|
<Divider />
|
||||||
|
</Box>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Paper>
|
{showPopup && (
|
||||||
{showPopup && (
|
<Popup setShowPopup={setShowPopup} translator={translator} />
|
||||||
<Popup setShowPopup={setShowPopup} translator={translator} />
|
)}
|
||||||
)}
|
|
||||||
</Paper>
|
|
||||||
</Draggable>
|
</Draggable>
|
||||||
<Draggable
|
<Draggable
|
||||||
key="fab"
|
key="fab"
|
||||||
|
|||||||
Reference in New Issue
Block a user