@sohanemon/utils 4.0.6 → 4.0.7

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
- export { Icon as Iconify } from '@iconify/react';
2
- export declare function TailwindIndicator(): any;
1
+ import * as React from 'react';
2
+ export declare const ResponsiveIndicator: React.FC;
@@ -1,10 +1,67 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- export { Icon as Iconify } from '@iconify/react';
4
- // @ts-ignore
5
- import styles from './responsiveness-indicator.module.css';
6
- export function TailwindIndicator() {
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import * as React from 'react';
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
+ };
7
64
  if (process.env.NODE_ENV === 'production')
8
65
  return null;
9
- return (_jsxs("div", { className: styles.fixedBottomLeft, children: [_jsx("div", { className: styles.xs, children: "xs" }), _jsx("div", { className: styles.sm, children: "sm" }), _jsx("div", { className: styles.md, children: "md" }), _jsx("div", { className: styles.lg, children: "lg" }), _jsx("div", { className: styles.xl, children: "xl" }), _jsx("div", { className: styles['two-xl'], children: "2xl" })] }));
10
- }
66
+ return (_jsx("button", { style: buttonStyle, onClick: handleClick, children: text }));
67
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sohanemon/utils",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./dist/index.js",