@canmingir/link 1.1.1 → 1.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canmingir/link",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -10,7 +10,8 @@
10
10
  "./platform/components": "./components/index.js",
11
11
  "./platform/hooks": "./src/hooks/index.js",
12
12
  "./platform/cypress": "./cypress/cypress.js",
13
- "./platform/commands": "./commands/index.js"
13
+ "./platform/commands": "./commands/index.js",
14
+ "./platform/http": "./src/http/index.js"
14
15
  },
15
16
  "scripts": {
16
17
  "dev": "cd project && concurrently \"npm run dev\" \"npm run server\"",
@@ -1,18 +1,51 @@
1
+ import React, { useEffect, useState } from "react";
2
+
1
3
  import Box from "@mui/material/Box";
2
4
  import Link from "@mui/material/Link";
3
- import React from "react";
4
5
  import { RouterLink } from "../../routes/components";
5
6
  import config from "../../config/config";
6
- // ----------------------------------------------------------------------
7
7
 
8
- const Logo = ({ disabledLink = false, sx }) => {
8
+ // ----------------------------------------------------------------------
9
+ const Logo = ({ disabledLink = false, sx, maxSize= 99 }) => {
9
10
  const { icon } = config().template.login;
11
+ const [dimensions, setDimensions] = useState({
12
+ width: maxSize,
13
+ height: maxSize
14
+ });
15
+
16
+ useEffect(() => {
17
+ if (icon) {
18
+ const img = new Image();
19
+ img.onload = () => {
20
+ const { naturalWidth, naturalHeight } = img;
21
+
22
+ if (naturalWidth > maxSize || naturalHeight > maxSize) {
23
+ setDimensions({
24
+ width: 40,
25
+ height: 40
26
+ });
27
+ } else {
28
+ setDimensions({
29
+ width: naturalWidth,
30
+ height: naturalHeight
31
+ });
32
+ }
33
+ };
34
+ img.src = icon;
35
+ }
36
+ }, [icon, maxSize]);
37
+
10
38
 
11
39
  const logo = (
12
40
  <Box
13
41
  component="img"
14
42
  src={icon}
15
- sx={{ width: 40, height: 40, cursor: "pointer", ...sx }}
43
+ sx={{
44
+ width: dimensions.width,
45
+ height: dimensions.height,
46
+ cursor: "pointer",
47
+ ...sx
48
+ }}
16
49
  />
17
50
  );
18
51
 
@@ -27,4 +60,4 @@ const Logo = ({ disabledLink = false, sx }) => {
27
60
  );
28
61
  };
29
62
 
30
- export default Logo;
63
+ export default Logo;
@@ -24,6 +24,7 @@ export default function AuthModernLayout({ image }) {
24
24
  }}
25
25
  >
26
26
  <Logo
27
+ maxSize={200}
27
28
  sx={{
28
29
  mt: { xs: 2, md: 8 },
29
30
  mb: { xs: 10, md: 8 },