@sohanemon/utils 4.0.7 → 4.0.8
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
export { Icon as Iconify } from '@iconify/react';
|
|
2
|
+
export { ResponsiveIndicator } from './responsive-indicator';
|
package/dist/components/index.js
CHANGED
|
@@ -1,67 +1,3 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export const ResponsiveIndicator = () => {
|
|
5
|
-
const [viewportWidth, setViewportWidth] = React.useState(window.innerWidth);
|
|
6
|
-
const [position, setPosition] = React.useState(0); // State to manage button position
|
|
7
|
-
React.useEffect(() => {
|
|
8
|
-
const handleResize = () => {
|
|
9
|
-
setViewportWidth(window.innerWidth);
|
|
10
|
-
};
|
|
11
|
-
window.addEventListener('resize', handleResize);
|
|
12
|
-
return () => {
|
|
13
|
-
window.removeEventListener('resize', handleResize);
|
|
14
|
-
};
|
|
15
|
-
}, []);
|
|
16
|
-
// Function to handle button click
|
|
17
|
-
const handleClick = () => {
|
|
18
|
-
setPosition((prevPosition) => (prevPosition + 1) % 4); // Cycle through positions
|
|
19
|
-
};
|
|
20
|
-
let text = '';
|
|
21
|
-
if (viewportWidth < 640) {
|
|
22
|
-
text = 'xs';
|
|
23
|
-
}
|
|
24
|
-
else if (viewportWidth >= 640 && viewportWidth < 768) {
|
|
25
|
-
text = 'sm';
|
|
26
|
-
}
|
|
27
|
-
else if (viewportWidth >= 768 && viewportWidth < 1024) {
|
|
28
|
-
text = 'md';
|
|
29
|
-
}
|
|
30
|
-
else if (viewportWidth >= 1024 && viewportWidth < 1280) {
|
|
31
|
-
text = 'lg';
|
|
32
|
-
}
|
|
33
|
-
else if (viewportWidth >= 1280 && viewportWidth < 1536) {
|
|
34
|
-
text = 'xl';
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
text = '2xl';
|
|
38
|
-
}
|
|
39
|
-
// Define positions
|
|
40
|
-
const positions = [
|
|
41
|
-
{ bottom: '2rem', left: '2rem' },
|
|
42
|
-
{ bottom: '2rem', right: '2rem' },
|
|
43
|
-
{ top: '2rem', right: '2rem' },
|
|
44
|
-
{ top: '2rem', left: '2rem' }, // Top left
|
|
45
|
-
];
|
|
46
|
-
const buttonStyle = {
|
|
47
|
-
position: 'fixed',
|
|
48
|
-
zIndex: 50,
|
|
49
|
-
display: 'grid',
|
|
50
|
-
height: '2.5rem',
|
|
51
|
-
width: '2.5rem',
|
|
52
|
-
borderRadius: '50%',
|
|
53
|
-
placeContent: 'center',
|
|
54
|
-
backgroundColor: '#2d3748',
|
|
55
|
-
fontFamily: 'Courier New, Courier, monospace',
|
|
56
|
-
fontSize: '1rem',
|
|
57
|
-
color: '#ffffff',
|
|
58
|
-
border: '2px solid #4a5568',
|
|
59
|
-
boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
60
|
-
padding: '0.5rem',
|
|
61
|
-
transition: 'all 0.2s ease-in-out',
|
|
62
|
-
...positions[position], // Apply the current position
|
|
63
|
-
};
|
|
64
|
-
if (process.env.NODE_ENV === 'production')
|
|
65
|
-
return null;
|
|
66
|
-
return (_jsx("button", { style: buttonStyle, onClick: handleClick, children: text }));
|
|
67
|
-
};
|
|
2
|
+
export { Icon as Iconify } from '@iconify/react';
|
|
3
|
+
export { ResponsiveIndicator } from './responsive-indicator';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
export const ResponsiveIndicator = () => {
|
|
4
|
+
const [viewportWidth, setViewportWidth] = React.useState(window.innerWidth);
|
|
5
|
+
const [position, setPosition] = React.useState(0); // State to manage button position
|
|
6
|
+
React.useEffect(() => {
|
|
7
|
+
const handleResize = () => {
|
|
8
|
+
setViewportWidth(window.innerWidth);
|
|
9
|
+
};
|
|
10
|
+
window.addEventListener('resize', handleResize);
|
|
11
|
+
return () => {
|
|
12
|
+
window.removeEventListener('resize', handleResize);
|
|
13
|
+
};
|
|
14
|
+
}, []);
|
|
15
|
+
// Function to handle button click
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
setPosition((prevPosition) => (prevPosition + 1) % 4); // Cycle through positions
|
|
18
|
+
};
|
|
19
|
+
let text = '';
|
|
20
|
+
if (viewportWidth < 640) {
|
|
21
|
+
text = 'xs';
|
|
22
|
+
}
|
|
23
|
+
else if (viewportWidth >= 640 && viewportWidth < 768) {
|
|
24
|
+
text = 'sm';
|
|
25
|
+
}
|
|
26
|
+
else if (viewportWidth >= 768 && viewportWidth < 1024) {
|
|
27
|
+
text = 'md';
|
|
28
|
+
}
|
|
29
|
+
else if (viewportWidth >= 1024 && viewportWidth < 1280) {
|
|
30
|
+
text = 'lg';
|
|
31
|
+
}
|
|
32
|
+
else if (viewportWidth >= 1280 && viewportWidth < 1536) {
|
|
33
|
+
text = 'xl';
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
text = '2xl';
|
|
37
|
+
}
|
|
38
|
+
// Define positions
|
|
39
|
+
const positions = [
|
|
40
|
+
{ bottom: '2rem', left: '2rem' },
|
|
41
|
+
{ bottom: '2rem', right: '2rem' },
|
|
42
|
+
{ top: '2rem', right: '2rem' },
|
|
43
|
+
{ top: '2rem', left: '2rem' }, // Top left
|
|
44
|
+
];
|
|
45
|
+
const buttonStyle = {
|
|
46
|
+
position: 'fixed',
|
|
47
|
+
zIndex: 50,
|
|
48
|
+
display: 'grid',
|
|
49
|
+
height: '2.5rem',
|
|
50
|
+
width: '2.5rem',
|
|
51
|
+
borderRadius: '50%',
|
|
52
|
+
placeContent: 'center',
|
|
53
|
+
backgroundColor: '#2d3748',
|
|
54
|
+
fontFamily: 'Courier New, Courier, monospace',
|
|
55
|
+
fontSize: '1rem',
|
|
56
|
+
color: '#ffffff',
|
|
57
|
+
border: '2px solid #4a5568',
|
|
58
|
+
boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
59
|
+
padding: '0.5rem',
|
|
60
|
+
transition: 'all 0.2s ease-in-out',
|
|
61
|
+
...positions[position], // Apply the current position
|
|
62
|
+
};
|
|
63
|
+
if (process.env.NODE_ENV === 'production')
|
|
64
|
+
return null;
|
|
65
|
+
return (_jsx("button", { style: buttonStyle, onClick: handleClick, children: text }));
|
|
66
|
+
};
|