groovinads-ui 1.2.52 → 1.2.54
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/README.md +26 -20
- package/dist/index.es.js +3 -3
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/components/Navigation/Sidebar.jsx +26 -15
- package/src/components/Toasts/Toast/ToastCardComponent.jsx +47 -0
- package/src/components/Toasts/ToastComponent.jsx +21 -58
- package/src/stories/ToastComponent.stories.jsx +55 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groovinads-ui",
|
|
3
3
|
"description": "Groovinads UI is a React component library designed exclusively for Groovinads applications. It provides ready-to-use UI elements styled according to Groovinads design guidelines to facilitate rapid development.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.54",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
7
7
|
"sass",
|
|
@@ -21,11 +21,13 @@ const Sidebar = ({
|
|
|
21
21
|
onNavigate,
|
|
22
22
|
selectedClient,
|
|
23
23
|
showClients = false,
|
|
24
|
-
setGroovinProfile
|
|
24
|
+
setGroovinProfile,
|
|
25
|
+
inModal = false,
|
|
26
|
+
customUrl,
|
|
25
27
|
}) => {
|
|
26
|
-
const isMobile = useMediaQuery({ query: '(max-width: 992px)' });
|
|
28
|
+
const isMobile = inModal ? true : useMediaQuery({ query: '(max-width: 992px)' });
|
|
27
29
|
|
|
28
|
-
const url = window.location.pathname; // to get current url
|
|
30
|
+
const url = customUrl !== undefined ? customLinks : window.location.pathname; // to get current url
|
|
29
31
|
|
|
30
32
|
const [sidebarLinks, setSidebarLinks] = useState([]);
|
|
31
33
|
const [openIndex, setOpenIndex] = useState(null);
|
|
@@ -52,23 +54,27 @@ const Sidebar = ({
|
|
|
52
54
|
}, [show]);
|
|
53
55
|
|
|
54
56
|
useEffect(() => {
|
|
55
|
-
if (isMobile && setShow) setShow(innerShow);
|
|
56
|
-
setInnerShow(isMobile ? false : firstOpen.current ? defaultOpened : show);
|
|
57
|
+
if (isMobile && setShow && !inModal) setShow(innerShow);
|
|
58
|
+
if (!inModal) setInnerShow(isMobile ? false : firstOpen.current ? defaultOpened : show);
|
|
57
59
|
firstOpen.current = false;
|
|
58
60
|
}, []);
|
|
59
61
|
|
|
60
62
|
return (
|
|
61
63
|
<Collapse in={innerShow} dimension={'width'}>
|
|
62
64
|
<nav id='sidebarMenu' className='sidebar' ref={sidebarRef}>
|
|
63
|
-
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
{!inModal ? (
|
|
66
|
+
<div className='position-relative d-none d-lg-block'>
|
|
67
|
+
<button
|
|
68
|
+
className='collapse-button'
|
|
69
|
+
// Toggle the sidebar
|
|
70
|
+
onClick={() => setInnerShow((prev) => !prev)}
|
|
71
|
+
>
|
|
72
|
+
<Icon className='collapse-icon' iconName='chevron-left' />
|
|
73
|
+
</button>
|
|
74
|
+
</div>
|
|
75
|
+
) : (
|
|
76
|
+
<></>
|
|
77
|
+
)}
|
|
72
78
|
|
|
73
79
|
{/* SECTIONS */}
|
|
74
80
|
<div className='scroll'>
|
|
@@ -155,7 +161,12 @@ Sidebar.propTypes = {
|
|
|
155
161
|
onNavigate: PropTypes.func.isRequired, // Nueva prop para manejar la navegación
|
|
156
162
|
selectedClient: PropTypes.object,
|
|
157
163
|
showClients:PropTypes.oneOf([true, false, 'single']),
|
|
158
|
-
setGroovinProfile: PropTypes.func
|
|
164
|
+
setGroovinProfile: PropTypes.func,
|
|
165
|
+
inModal: PropTypes.bool,
|
|
166
|
+
customUrl: PropTypes.oneOfType([
|
|
167
|
+
PropTypes.string,
|
|
168
|
+
PropTypes.oneOf([undefined])
|
|
169
|
+
]),
|
|
159
170
|
};
|
|
160
171
|
|
|
161
172
|
export default Sidebar;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { children, useState } from 'react';
|
|
2
|
+
import Toast from 'react-bootstrap/Toast';
|
|
3
|
+
import { Icon } from '../../Labels';
|
|
4
|
+
|
|
5
|
+
function ToastCardComponent({ variant, autoClose, children, className, position }) {
|
|
6
|
+
const [show, setShow] = useState(true);
|
|
7
|
+
|
|
8
|
+
const toggleShow = () => setShow(!show);
|
|
9
|
+
|
|
10
|
+
const variantIcons = {
|
|
11
|
+
info: 'circle-info',
|
|
12
|
+
success: 'circle-check',
|
|
13
|
+
warning: 'triangle-exclamation',
|
|
14
|
+
error: 'circle-xmark',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Toast
|
|
19
|
+
onClose={toggleShow}
|
|
20
|
+
show={show}
|
|
21
|
+
delay={autoClose ? 3500 : null}
|
|
22
|
+
autohide={autoClose}
|
|
23
|
+
className={`${position} ${variant} ${className ? className : ''}`}
|
|
24
|
+
>
|
|
25
|
+
<Toast.Body>
|
|
26
|
+
<div className='toast-wrapper'>
|
|
27
|
+
<div className='toast-type'>
|
|
28
|
+
<Icon
|
|
29
|
+
style={'solid'}
|
|
30
|
+
iconName={variantIcons[variant]}
|
|
31
|
+
scale={1}
|
|
32
|
+
className={'icon'}
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
<span>{children}</span>
|
|
36
|
+
</div>
|
|
37
|
+
{!autoClose && (
|
|
38
|
+
<button className='btn-close' onClick={toggleShow}>
|
|
39
|
+
<Icon style={'solid'} iconName={'xmark'} scale={1} />
|
|
40
|
+
</button>
|
|
41
|
+
)}
|
|
42
|
+
</Toast.Body>
|
|
43
|
+
</Toast>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default ToastCardComponent;
|
|
@@ -1,82 +1,45 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
4
|
// BOOTSTRAP
|
|
5
|
-
import Toast from 'react-bootstrap/Toast';
|
|
6
5
|
import { ToastContainer } from 'react-bootstrap';
|
|
7
6
|
|
|
8
7
|
// COMPONENTS
|
|
9
|
-
import
|
|
8
|
+
import ToastCardComponent from './Toast/ToastCardComponent';
|
|
10
9
|
|
|
11
|
-
const ToastComponent = ({
|
|
12
|
-
|
|
13
|
-
autoClose = true,
|
|
14
|
-
position = 'bottom-start',
|
|
15
|
-
children,
|
|
16
|
-
className,
|
|
17
|
-
}) => {
|
|
18
|
-
const [show, setShow] = useState(true);
|
|
10
|
+
const ToastComponent = ({ toast, position = 'bottom-end' }) => {
|
|
11
|
+
const [toastsHistory, setToastsHistory] = useState([]);
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const autohide = autoClose ? true : false;
|
|
24
|
-
|
|
25
|
-
const variantIcons = {
|
|
26
|
-
info: 'circle-info',
|
|
27
|
-
success: 'circle-check',
|
|
28
|
-
warning: 'triangle-exclamation',
|
|
29
|
-
error: 'circle-xmark',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const iconClass = variantIcons[variant];
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (toast) setToastsHistory([...toastsHistory, toast]);
|
|
15
|
+
}, [toast]);
|
|
33
16
|
|
|
34
17
|
return (
|
|
35
18
|
<ToastContainer position={position}>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
iconName={iconClass}
|
|
49
|
-
scale={1}
|
|
50
|
-
className={'icon'}
|
|
51
|
-
/>
|
|
52
|
-
</div>
|
|
53
|
-
<span>{children}</span>
|
|
54
|
-
</div>
|
|
55
|
-
{!autoClose && (
|
|
56
|
-
<button className='btn-close' onClick={toggleShow}>
|
|
57
|
-
<Icon
|
|
58
|
-
style={'solid'}
|
|
59
|
-
iconName={'xmark'}
|
|
60
|
-
scale={1}
|
|
61
|
-
/>
|
|
62
|
-
</button>
|
|
63
|
-
)}
|
|
64
|
-
</Toast.Body>
|
|
65
|
-
</Toast>
|
|
19
|
+
{toastsHistory.map(
|
|
20
|
+
({ variant = 'info', autoClose = true, children, className }, i) => (
|
|
21
|
+
<ToastCardComponent
|
|
22
|
+
variant={variant}
|
|
23
|
+
autoClose={autoClose}
|
|
24
|
+
children={children}
|
|
25
|
+
className={className}
|
|
26
|
+
position={position}
|
|
27
|
+
key={children + variant + i}
|
|
28
|
+
/>
|
|
29
|
+
),
|
|
30
|
+
)}
|
|
66
31
|
</ToastContainer>
|
|
67
32
|
);
|
|
68
33
|
};
|
|
69
34
|
|
|
70
35
|
ToastComponent.propTypes = {
|
|
71
|
-
|
|
72
|
-
autoClose: PropTypes.bool,
|
|
36
|
+
toast: PropTypes.object,
|
|
73
37
|
position: PropTypes.oneOf([
|
|
74
38
|
'top-start',
|
|
75
39
|
'top-end',
|
|
76
40
|
'bottom-start',
|
|
77
41
|
'bottom-end',
|
|
78
42
|
]),
|
|
79
|
-
className: PropTypes.string,
|
|
80
43
|
};
|
|
81
44
|
|
|
82
|
-
export default ToastComponent;
|
|
45
|
+
export default ToastComponent;
|
|
@@ -1,11 +1,62 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import ToastComponent from '../components/Toasts/ToastComponent';
|
|
3
3
|
|
|
4
|
+
import Button from '../components/Button/Button';
|
|
5
|
+
|
|
4
6
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
title: 'Toasts/ToastComponent',
|
|
8
|
+
component: ToastComponent,
|
|
7
9
|
};
|
|
8
10
|
|
|
9
|
-
const Template = (args) =>
|
|
11
|
+
const Template = (args) => {
|
|
12
|
+
|
|
13
|
+
const [selected, setSelected] = useState(null);
|
|
14
|
+
|
|
15
|
+
const toasts = [
|
|
16
|
+
{
|
|
17
|
+
variant: 'info',
|
|
18
|
+
autoClose: true,
|
|
19
|
+
children: 'Se eliminó',
|
|
20
|
+
// className,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
variant: 'success',
|
|
24
|
+
autoClose: true,
|
|
25
|
+
children: 'Se guardó',
|
|
26
|
+
// className,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
variant: 'warning',
|
|
30
|
+
autoClose: true,
|
|
31
|
+
children: 'Se modificó',
|
|
32
|
+
// className,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
variant: 'error',
|
|
36
|
+
autoClose: true,
|
|
37
|
+
children: 'Error',
|
|
38
|
+
// className,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
variant: 'info',
|
|
42
|
+
autoClose: false,
|
|
43
|
+
children: 'No se puede eliminar',
|
|
44
|
+
// className,
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
const pushToast = () => {
|
|
49
|
+
setSelected(toasts[Math.floor(Math.random() * toasts.length)]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<Button onClick={pushToast}>Nuevo toast</Button>
|
|
55
|
+
<ToastComponent toast={selected} {...args}>
|
|
56
|
+
ToastComponent
|
|
57
|
+
</ToastComponent>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
10
61
|
|
|
11
|
-
export const Default = Template.bind({});
|
|
62
|
+
export const Default = Template.bind({});
|