@canmingir/link 1.2.37 → 1.2.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/logo/logo.jsx +45 -27
- package/src/layouts/DashboardLayout/nav-vertical.jsx +5 -4
- package/src/layouts/DrawerLayout/DrawerLayout.jsx +81 -0
- package/src/layouts/DrawerLayout/index.js +1 -0
- package/src/layouts/auth/modern.jsx +1 -2
- package/src/layouts/index.js +1 -0
- package/src/lib/Flow/core/FlowViewport.jsx +1 -1
package/package.json
CHANGED
|
@@ -3,36 +3,56 @@ import Link from "@mui/material/Link";
|
|
|
3
3
|
import { RouterLink } from "../../routes/components";
|
|
4
4
|
import config from "../../config/config";
|
|
5
5
|
|
|
6
|
-
import React, { useEffect, useState } from "react";
|
|
6
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const resolvedDimensions = {};
|
|
9
|
+
|
|
10
|
+
const Logo = ({ disabledLink = false, sx, maxSize = 65, isLogin = false }) => {
|
|
9
11
|
const { icon } = config().template.login;
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const key = `${icon}`;
|
|
13
|
+
|
|
14
|
+
const [dimensions, setDimensions] = useState(
|
|
15
|
+
resolvedDimensions[key] || { width: maxSize, height: maxSize }
|
|
16
|
+
);
|
|
14
17
|
|
|
15
18
|
useEffect(() => {
|
|
16
|
-
if (icon)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
if (!icon || resolvedDimensions[key]) return;
|
|
20
|
+
|
|
21
|
+
const img = new Image();
|
|
22
|
+
img.onload = () => {
|
|
23
|
+
const { naturalWidth, naturalHeight } = img;
|
|
24
|
+
const isSquare = naturalWidth === naturalHeight;
|
|
25
|
+
let newDimensions;
|
|
26
|
+
|
|
27
|
+
if (naturalWidth > maxSize || naturalHeight > maxSize) {
|
|
28
|
+
if (isSquare) {
|
|
29
|
+
newDimensions = {
|
|
30
|
+
width: isLogin ? maxSize : 40,
|
|
31
|
+
height: isLogin ? maxSize : 40,
|
|
32
|
+
};
|
|
26
33
|
} else {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
const aspectRatio = naturalWidth / naturalHeight;
|
|
35
|
+
if (naturalWidth >= naturalHeight) {
|
|
36
|
+
newDimensions = {
|
|
37
|
+
width: maxSize,
|
|
38
|
+
height: Math.round(maxSize / aspectRatio),
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
newDimensions = {
|
|
42
|
+
width: Math.round(maxSize * aspectRatio),
|
|
43
|
+
height: maxSize,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
31
46
|
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
} else {
|
|
48
|
+
newDimensions = { width: naturalWidth, height: naturalHeight };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
resolvedDimensions[key] = newDimensions;
|
|
52
|
+
setDimensions(newDimensions);
|
|
53
|
+
};
|
|
54
|
+
img.src = icon;
|
|
55
|
+
}, [icon, maxSize, key]);
|
|
36
56
|
|
|
37
57
|
const logo = (
|
|
38
58
|
<Box
|
|
@@ -47,9 +67,7 @@ const Logo = ({ disabledLink = false, sx, maxSize = 99 }) => {
|
|
|
47
67
|
/>
|
|
48
68
|
);
|
|
49
69
|
|
|
50
|
-
if (disabledLink)
|
|
51
|
-
return logo;
|
|
52
|
-
}
|
|
70
|
+
if (disabledLink) return logo;
|
|
53
71
|
|
|
54
72
|
return (
|
|
55
73
|
<Link component={RouterLink} href="/" sx={{ display: "contents" }}>
|
|
@@ -104,7 +104,7 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
104
104
|
mt: 3,
|
|
105
105
|
}}
|
|
106
106
|
>
|
|
107
|
-
<Logo sx={{ ml: 4
|
|
107
|
+
<Logo sx={{ ml: 4 }} />
|
|
108
108
|
<Typography
|
|
109
109
|
sx={{
|
|
110
110
|
ml: 1,
|
|
@@ -130,8 +130,9 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
130
130
|
marginBottom: lgUp ? 3 : 0,
|
|
131
131
|
position: lgUp ? "static" : "fixed",
|
|
132
132
|
bottom: lgUp ? "auto" : 66,
|
|
133
|
-
width: "100%"
|
|
134
|
-
}}
|
|
133
|
+
width: "100%",
|
|
134
|
+
}}
|
|
135
|
+
>
|
|
135
136
|
{actionButtons &&
|
|
136
137
|
actionButtons?.map((Action, index) => (
|
|
137
138
|
<Box key={index} component={Action}></Box>
|
|
@@ -190,7 +191,7 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
190
191
|
sx: {
|
|
191
192
|
width: NAV.W_VERTICAL,
|
|
192
193
|
},
|
|
193
|
-
}
|
|
194
|
+
},
|
|
194
195
|
}}
|
|
195
196
|
>
|
|
196
197
|
{renderContent}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Close } from "@mui/icons-material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
DialogActions,
|
|
6
|
+
DialogContent,
|
|
7
|
+
DialogTitle,
|
|
8
|
+
Drawer,
|
|
9
|
+
IconButton,
|
|
10
|
+
} from "@mui/material";
|
|
11
|
+
|
|
12
|
+
const NARROW_WIDTH = 450;
|
|
13
|
+
const modeWidth = {
|
|
14
|
+
narrow: NARROW_WIDTH,
|
|
15
|
+
wide: undefined,
|
|
16
|
+
fullscreen: "100vw",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const DrawerLayout = ({
|
|
20
|
+
open,
|
|
21
|
+
onClose,
|
|
22
|
+
children,
|
|
23
|
+
title,
|
|
24
|
+
extraActions,
|
|
25
|
+
sx,
|
|
26
|
+
contentSx,
|
|
27
|
+
paperSx,
|
|
28
|
+
titleSx,
|
|
29
|
+
mode = "fullscreen",
|
|
30
|
+
}) => {
|
|
31
|
+
const width = modeWidth[mode];
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Drawer
|
|
35
|
+
anchor="right"
|
|
36
|
+
open={open}
|
|
37
|
+
onClose={onClose}
|
|
38
|
+
sx={sx}
|
|
39
|
+
slotProps={{
|
|
40
|
+
paper: {
|
|
41
|
+
sx: {
|
|
42
|
+
backgroundColor: (theme) =>
|
|
43
|
+
`${theme.palette.background.default} !important`,
|
|
44
|
+
display: "flex",
|
|
45
|
+
flexDirection: "column",
|
|
46
|
+
maxWidth: "100vw",
|
|
47
|
+
width: width ?? { xs: "100vw", sm: "90vw", md: "85vw" },
|
|
48
|
+
transition: "width 0.4s cubic-bezier(0.22, 1, 0.36, 1)",
|
|
49
|
+
"@keyframes slideInFromRight": {
|
|
50
|
+
from: { transform: "translateX(100%)" },
|
|
51
|
+
to: { transform: "translateX(0)" },
|
|
52
|
+
},
|
|
53
|
+
animation: open
|
|
54
|
+
? "slideInFromRight 400ms cubic-bezier(0.22, 1, 0.36, 1) forwards"
|
|
55
|
+
: "none",
|
|
56
|
+
...(paperSx ?? {}),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
{title && (
|
|
62
|
+
<DialogTitle sx={{ flexShrink: 0, ...(titleSx ?? {}) }}>
|
|
63
|
+
{title}
|
|
64
|
+
</DialogTitle>
|
|
65
|
+
)}
|
|
66
|
+
|
|
67
|
+
<DialogContent sx={{ flex: 1, overflow: "auto", ...(contentSx ?? {}) }}>
|
|
68
|
+
{children}
|
|
69
|
+
</DialogContent>
|
|
70
|
+
|
|
71
|
+
<DialogActions sx={{ position: "absolute", top: -10, right: 0 }}>
|
|
72
|
+
{extraActions}
|
|
73
|
+
<IconButton onClick={onClose} size="small">
|
|
74
|
+
<Close />
|
|
75
|
+
</IconButton>
|
|
76
|
+
</DialogActions>
|
|
77
|
+
</Drawer>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default DrawerLayout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./DrawerLayout";
|
package/src/layouts/index.js
CHANGED
|
@@ -5,3 +5,4 @@ export { default as MainLayout } from "./MainLayout";
|
|
|
5
5
|
export { default as SimpleLayout } from "./SimpleLayout";
|
|
6
6
|
export { default as TwoSideLayout } from "./TwoSideLayout";
|
|
7
7
|
export { default as FullScreenLayout } from "./FullScreenLayout";
|
|
8
|
+
export { default as DrawerLayout } from "./DrawerLayout";
|