code7-leia 0.1.44 → 0.1.45

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.
Files changed (30) hide show
  1. package/dist/code7-leia.cjs.development.js +196 -47
  2. package/dist/code7-leia.cjs.development.js.map +1 -1
  3. package/dist/code7-leia.cjs.production.min.js +1 -1
  4. package/dist/code7-leia.cjs.production.min.js.map +1 -1
  5. package/dist/code7-leia.esm.js +197 -48
  6. package/dist/code7-leia.esm.js.map +1 -1
  7. package/dist/components/FileArea/components/Modal/ModalButtonClose.d.ts +6 -0
  8. package/dist/components/FileArea/components/Modal/ModalContent.d.ts +8 -0
  9. package/dist/components/FileArea/components/Modal/ModalFooter.d.ts +6 -0
  10. package/dist/components/FileArea/components/Modal/ModalHeader.d.ts +6 -0
  11. package/dist/components/FileArea/components/Modal/ModalTitle.d.ts +6 -0
  12. package/dist/components/FileArea/components/Modal/index.d.ts +22 -0
  13. package/dist/components/FileArea/components/Modal/styles.d.ts +26 -0
  14. package/dist/interface/Language.d.ts +1 -0
  15. package/package.json +1 -1
  16. package/src/components/FileArea/components/Modal/ModalButtonClose.tsx +23 -0
  17. package/src/components/FileArea/components/Modal/ModalContent.tsx +26 -0
  18. package/src/components/FileArea/components/Modal/ModalFooter.tsx +18 -0
  19. package/src/components/FileArea/components/Modal/ModalHeader.tsx +18 -0
  20. package/src/components/FileArea/components/Modal/ModalTitle.tsx +18 -0
  21. package/src/components/FileArea/components/Modal/index.tsx +131 -0
  22. package/src/components/FileArea/components/Modal/styles.tsx +121 -0
  23. package/src/components/FileArea/index.tsx +37 -3
  24. package/src/components/TestArea/index.tsx +1 -1
  25. package/src/interface/Language.ts +1 -0
  26. package/src/utils/getLanguage.tsx +2 -0
  27. /package/dist/components/{TestArea/components/Select → Select}/index.d.ts +0 -0
  28. /package/dist/components/{TestArea/components/Select → Select}/styles.d.ts +0 -0
  29. /package/src/components/{TestArea/components/Select → Select}/index.tsx +0 -0
  30. /package/src/components/{TestArea/components/Select → Select}/styles.tsx +0 -0
@@ -0,0 +1,131 @@
1
+ import React, { useEffect, useCallback, useRef } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { MdClose } from 'react-icons/md';
4
+
5
+ import * as S from './styles';
6
+ import ModalFooter from './ModalFooter';
7
+ import ModalContent from './ModalContent';
8
+ import ModalHeader from './ModalHeader';
9
+ import ModalTitle from './ModalTitle';
10
+ import ModalButtonClose from './ModalButtonClose';
11
+
12
+ interface ModalProps {
13
+ isOpen: boolean;
14
+ style?: React.CSSProperties;
15
+ maxWidth?: string;
16
+ maxHeight?: string;
17
+ className?: string;
18
+ title?: string | React.ReactElement | React.ComponentType;
19
+ children: React.ReactNode;
20
+ onClose?: () => void;
21
+ contentStyle?: React.CSSProperties;
22
+ isFixed?: boolean;
23
+ zIndex?: number;
24
+ }
25
+
26
+ const Modal: React.FC<ModalProps> = ({
27
+ isOpen,
28
+ style,
29
+ maxWidth,
30
+ maxHeight,
31
+ className,
32
+ title,
33
+ children,
34
+ onClose,
35
+ contentStyle,
36
+ isFixed,
37
+ zIndex,
38
+ }) => {
39
+ const modalRef = useRef<HTMLDivElement>(null);
40
+
41
+ const handleKeyUp = useCallback(
42
+ (e: KeyboardEvent) => {
43
+ const keys: { [key: number]: () => void } = {
44
+ // ESC Key
45
+ 27: () => {
46
+ e.preventDefault();
47
+ if (!isFixed && onClose) {
48
+ onClose();
49
+ }
50
+ window.removeEventListener('keyup', handleKeyUp, false);
51
+ },
52
+ };
53
+
54
+ if (keys[e.keyCode] && isOpen) {
55
+ keys[e.keyCode]();
56
+ }
57
+ },
58
+ [onClose, isOpen, isFixed]
59
+ );
60
+
61
+ const handleOutsideClick = useCallback(
62
+ (e: MouseEvent) => {
63
+ if (modalRef.current && modalRef.current.parentNode === e.target) {
64
+ if (!isFixed && onClose) {
65
+ onClose();
66
+ }
67
+ document.removeEventListener('click', handleOutsideClick, false);
68
+ }
69
+ },
70
+ [onClose, isFixed]
71
+ );
72
+
73
+ useEffect(() => {
74
+ window.addEventListener('keyup', handleKeyUp, false);
75
+ document.addEventListener('click', handleOutsideClick, false);
76
+
77
+ return () => {
78
+ window.removeEventListener('keyup', handleKeyUp, false);
79
+ document.removeEventListener('click', handleOutsideClick, false);
80
+ };
81
+ }, [handleKeyUp, handleOutsideClick]);
82
+
83
+ return (
84
+ <S.FullScreen isFixed={isFixed ? 1 : 0} isOpen={isOpen ? 1 : 0} zIndex={zIndex ?? 0}>
85
+ <S.Modal ref={modalRef} style={style} maxWidth={maxWidth} className={className}>
86
+ <S.ModalContainer className="styleOverlay" maxHeight={maxHeight} style={contentStyle}>
87
+ <S.ModalHeader>
88
+ <S.ModalTitle>{String(title)}</S.ModalTitle>
89
+ <S.ModalButtonClose type="button" onClick={onClose}>
90
+ <MdClose color="#5A5D68" size={16} />
91
+ </S.ModalButtonClose>
92
+ </S.ModalHeader>
93
+ {children}
94
+ </S.ModalContainer>
95
+ </S.Modal>
96
+ </S.FullScreen>
97
+ );
98
+ };
99
+
100
+ Modal.propTypes = {
101
+ isOpen: PropTypes.bool.isRequired,
102
+ title: PropTypes.oneOfType([
103
+ PropTypes.element,
104
+ PropTypes.string,
105
+ PropTypes.func,
106
+ ]),
107
+ children: PropTypes.node.isRequired,
108
+ onClose: PropTypes.func,
109
+ style: PropTypes.objectOf(PropTypes.any),
110
+ contentStyle: PropTypes.objectOf(PropTypes.any),
111
+ className: PropTypes.string,
112
+ maxWidth: PropTypes.string,
113
+ maxHeight: PropTypes.string,
114
+ isFixed: PropTypes.bool,
115
+ zIndex: PropTypes.number,
116
+ };
117
+
118
+ Modal.defaultProps = {
119
+ title: '',
120
+ style: {},
121
+ contentStyle: {},
122
+ className: '',
123
+ maxWidth: '360px',
124
+ maxHeight: 'max-content',
125
+ isFixed: false,
126
+ onClose: () => {},
127
+ zIndex: 9999,
128
+ };
129
+
130
+ export { ModalHeader, ModalTitle, ModalButtonClose, ModalContent, ModalFooter };
131
+ export default Modal;
@@ -0,0 +1,121 @@
1
+ import styled from 'styled-components';
2
+
3
+ interface FullScreenProps {
4
+ isOpen: number;
5
+ isFixed: number;
6
+ zIndex: number;
7
+ }
8
+
9
+ export const FullScreen = styled.div<FullScreenProps>`
10
+ display: ${({ isOpen }) => (isOpen === 1 ? 'flex' : 'none')};
11
+ cursor: ${({ isFixed }) => (isFixed === 0 ? 'pointer' : 'default')};
12
+
13
+ position: fixed;
14
+ top: 0;
15
+ left: 0;
16
+ right: 0;
17
+ bottom: 0;
18
+ justify-content: center;
19
+ align-items: center;
20
+ z-index: ${({ zIndex }) => zIndex};
21
+ animation: fadeIn 380ms ease-in-out 1;
22
+ background-color: #2f3845b8;
23
+ backdrop-filter: blur(2px);
24
+
25
+ @keyframes fadeIn {
26
+ from {
27
+ background-color: #2f384521;
28
+ }
29
+ to {
30
+ background-color: #2f3845b8;
31
+ }
32
+ }
33
+ `;
34
+
35
+ interface ModalProps {
36
+ maxWidth?: string;
37
+ maxHeight?: string;
38
+ }
39
+
40
+ export const Modal = styled.div<ModalProps>`
41
+ background-color: #fff;
42
+ border-radius: 3px;
43
+ position: relative;
44
+ cursor: default;
45
+ width: 100%;
46
+ max-width: ${({ maxWidth }) => maxWidth};
47
+ animation: slideIn 350ms cubic-bezier(0.42, 0, 0.21, 1) 1;
48
+
49
+ @keyframes slideIn {
50
+ from {
51
+ transform: translateY(-120px);
52
+ opacity: 0;
53
+ }
54
+
55
+ 20% {
56
+ opacity: 0;
57
+ }
58
+
59
+ to {
60
+ transform: translateY(0);
61
+ opacity: 1;
62
+ }
63
+ }
64
+ `;
65
+
66
+ interface ModalContainerProps {
67
+ maxHeight?: string;
68
+ }
69
+
70
+ export const ModalContainer = styled.div<ModalContainerProps>`
71
+ width: 100%;
72
+ overflow-y: auto;
73
+ max-height: ${({ maxHeight }) => maxHeight};
74
+ `;
75
+
76
+ export const ModalHeader = styled.header`
77
+ display: flex;
78
+ justify-content: space-between;
79
+ align-items: center;
80
+ border-bottom: 1px solid #dadce3;
81
+ padding: var(--spacement-medium);
82
+ `;
83
+
84
+ export const ModalTitle = styled.div`
85
+ font-style: normal;
86
+ font-weight: normal;
87
+ font-size: 20px;
88
+ line-height: 150%;
89
+ letter-spacing: 0.0075em;
90
+ color: var(--neutral-4);
91
+ `;
92
+
93
+ export const ModalButtonClose = styled.button`
94
+ outline: none;
95
+ cursor: pointer;
96
+
97
+ :hover {
98
+ opacity: 0.7;
99
+ }
100
+ `;
101
+
102
+ interface ModalContentWrapperProps {
103
+ overflowY?: string;
104
+ maxHeight?: string;
105
+ }
106
+
107
+ export const ModalContentWrapper = styled.div<ModalContentWrapperProps>`
108
+ width: 100%;
109
+ overflow-y: ${({ overflowY }) => overflowY};
110
+ max-height: ${({ maxHeight }) => maxHeight};
111
+ padding: var(--spacement-medium);
112
+ `;
113
+
114
+ export const ModalFooterWrapper = styled.div`
115
+ padding: var(--spacement-medium);
116
+ background: var(--neutral-0);
117
+ display: flex;
118
+ align-items: center;
119
+ justify-content: flex-end;
120
+ gap: var(--spacement-medium);
121
+ `;
@@ -13,14 +13,24 @@ import { getLanguage } from '../../utils/getLanguage'
13
13
  import * as S from './styles';
14
14
  import Table from './components/Table';
15
15
  import Search from './components/Search';
16
+ import Modal from './components/Modal'
16
17
  import EmptyState from '../EmptyState';
18
+ import Select from '../Select'
17
19
 
18
20
  export const FileArea = () => {
19
21
  const [files, setFiles] = useState<FileData[]>([]);
20
22
  const [initialFiles, setInitialFiles] = useState<FileData[]>([]);
21
23
  const { pathname } = useLocation();
24
+ const [modal, setModal] = useState(false)
22
25
  const id = pathname.split('/')[4]
23
26
  const t = getLanguage('pt-br')
27
+ const tags = [
28
+ "pae",
29
+ "boteria",
30
+ "vr",
31
+ "code7",
32
+ "vidalink"
33
+ ]
24
34
 
25
35
  useEffect(() => {
26
36
  setFiles([
@@ -66,6 +76,10 @@ export const FileArea = () => {
66
76
  console.log('files, id, t: ', files, id, t)
67
77
  }, [files])
68
78
 
79
+ const optionsPresset = tags.map(tag => {
80
+ return { label: tag, value: tag }
81
+ })
82
+
69
83
  const presset = (tags: string) => {
70
84
  const tagsSplit = tags.split(',');
71
85
  let html = '';
@@ -75,7 +89,15 @@ export const FileArea = () => {
75
89
  }).join('');
76
90
 
77
91
  return html;
78
- }
92
+ }
93
+
94
+ const handleOpenModal = () => {
95
+ setModal(!modal)
96
+ }
97
+
98
+ const handleSelect = (value: string | number) => {
99
+ console.log(value);
100
+ };
79
101
 
80
102
  const renderFiles = () => {
81
103
  return (
@@ -87,7 +109,7 @@ export const FileArea = () => {
87
109
  </div>
88
110
  <div className='actions'>
89
111
  <Search placeholder={t.fileArea.search} setFiles={setFiles} initialFiles={initialFiles}></Search>
90
- <button><FaUpload /> {t.fileArea.fileUpload}</button>
112
+ <button onClick={handleOpenModal}><FaUpload /> {t.fileArea.fileUpload}</button>
91
113
  </div>
92
114
  </S.Header>
93
115
  {
@@ -131,7 +153,19 @@ export const FileArea = () => {
131
153
  </tbody>
132
154
  </Table>
133
155
  }
134
-
156
+ <Modal
157
+ isOpen={modal}
158
+ maxWidth="1100px"
159
+ maxHeight="max-content"
160
+ onClose={handleOpenModal}
161
+ title={t.fileArea.modal.uploadFile}
162
+ >
163
+ <div>
164
+ <input type="file" id="file" name="file" />
165
+ <label htmlFor="file">{t.fileArea.modal.chooseFile}</label>
166
+ <Select placeholder={t.testArea.selectPresset} options={optionsPresset} onSelect={handleSelect} />
167
+ </div>
168
+ </Modal>
135
169
  </S.Container>
136
170
  );
137
171
  }
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { getLanguage } from '../../utils/getLanguage'
3
3
  import * as S from './styles';
4
- import Select from './components/Select'
4
+ import Select from '../Select'
5
5
  import InputTest from './components/InputTest'
6
6
  import { PiWaveformBold } from 'react-icons/pi';
7
7
  import { FaList } from 'react-icons/fa';
@@ -12,6 +12,7 @@ type FileArea = {
12
12
  modal: {
13
13
  descriptionUpload: string;
14
14
  chooseFile: string;
15
+ uploadFile: string;
15
16
  };
16
17
  };
17
18
 
@@ -18,6 +18,7 @@ const defaultLanguage: Language = {
18
18
  modal: {
19
19
  descriptionUpload: 'Drag and drop files here or',
20
20
  chooseFile: 'Choose a file',
21
+ uploadFile: 'Upload a file',
21
22
  },
22
23
  },
23
24
  buttons: {
@@ -59,6 +60,7 @@ export const getLanguage = (language: keyof Record<'en' | 'pt-br' | 'es', Langua
59
60
  ...defaultLanguage.fileArea.modal,
60
61
  descriptionUpload: 'Arraste e solte os arquivos aqui ou',
61
62
  chooseFile: 'Escolha um arquivo',
63
+ uploadFile: 'Enviar um arquivo',
62
64
  },
63
65
  },
64
66
  buttons: {