pixel-react 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/lib/StyleGuide/ColorPalette/types.d.ts +2 -0
  3. package/lib/components/DragAndDrop/DragAndDrop.d.ts +9 -0
  4. package/lib/components/DragAndDrop/DragAndDrop.stories.d.ts +6 -0
  5. package/lib/components/DragAndDrop/DragAndDropList.d.ts +20 -0
  6. package/lib/components/DragAndDrop/index.d.ts +1 -0
  7. package/lib/components/Drawer/Drawer.d.ts +2 -1
  8. package/lib/components/Modal/Modal.d.ts +5 -0
  9. package/lib/components/Modal/Modal.stories.d.ts +7 -0
  10. package/lib/components/Modal/index.d.ts +1 -0
  11. package/lib/components/Modal/types.d.ts +26 -0
  12. package/lib/components/TableTree/TableTree.d.ts +1 -1
  13. package/lib/components/ThemeProvider/CustomThemeProvider.d.ts +8 -0
  14. package/lib/hooks/useCustomThemeProvider.d.ts +11 -0
  15. package/lib/index.d.ts +12 -3
  16. package/lib/index.esm.js +4714 -72
  17. package/lib/index.esm.js.map +1 -1
  18. package/lib/index.js +4712 -69
  19. package/lib/index.js.map +1 -1
  20. package/lib/tsconfig.tsbuildinfo +1 -1
  21. package/package.json +26 -23
  22. package/src/StyleGuide/ColorPalette/ColorPalette.scss +5 -0
  23. package/src/StyleGuide/ColorPalette/ColorPalette.tsx +10 -1
  24. package/src/StyleGuide/ColorPalette/colorPaletteList.ts +2 -2
  25. package/src/StyleGuide/ColorPalette/types.ts +2 -0
  26. package/src/assets/Themes/BaseTheme.scss +9 -8
  27. package/src/assets/Themes/DarkTheme.scss +1 -0
  28. package/src/assets/icons/collapse-icon.svg +6 -0
  29. package/src/assets/icons/copy-icon.svg +3 -0
  30. package/src/assets/icons/download-icon.svg +3 -0
  31. package/src/assets/icons/expand-icon.svg +6 -0
  32. package/src/assets/icons/license_info.svg +28 -0
  33. package/src/assets/icons/license_warning.svg +10 -0
  34. package/src/assets/icons/refresh-icon.svg +4 -0
  35. package/src/components/DatePicker/DatePicker.scss +3 -3
  36. package/src/components/DragAndDrop/DragAndDrop.d.ts +5 -0
  37. package/src/components/DragAndDrop/DragAndDrop.stories.tsx +25 -0
  38. package/src/components/DragAndDrop/DragAndDrop.ts +7 -0
  39. package/src/components/DragAndDrop/DragAndDropList.scss +69 -0
  40. package/src/components/DragAndDrop/DragAndDropList.tsx +150 -0
  41. package/src/components/DragAndDrop/index.ts +1 -0
  42. package/src/components/Drawer/Drawer.tsx +3 -7
  43. package/src/components/Icon/iconList.ts +14 -0
  44. package/src/components/Modal/Modal.stories.tsx +63 -0
  45. package/src/components/Modal/Modal.tsx +71 -0
  46. package/src/components/Modal/index.tsx +1 -0
  47. package/src/components/Modal/modal.scss +37 -0
  48. package/src/components/Modal/types.ts +37 -0
  49. package/src/components/TableTree/TableTree.tsx +1 -1
  50. package/src/components/ThemeProvider/ThemeProvider.tsx +11 -8
  51. package/src/index.ts +2 -5
  52. package/lib/components/AddButton/AddButton.d.ts +0 -5
  53. package/lib/components/AddButton/AddButton.stories.d.ts +0 -6
  54. package/lib/components/AddButton/index.d.ts +0 -1
  55. package/lib/components/AddButton/types.d.ts +0 -4
@@ -0,0 +1,150 @@
1
+ import { useState } from 'react';
2
+ import DragAndDrop from './DragAndDrop';
3
+ const {
4
+ DNDCore: {
5
+ DndContext,
6
+ KeyboardSensor,
7
+ PointerSensor,
8
+ useSensor,
9
+ useSensors,
10
+ closestCorners,
11
+ },
12
+ DNDSortable: {
13
+ useSortable,
14
+ arrayMove,
15
+ sortableKeyboardCoordinates,
16
+ SortableContext,
17
+ verticalListSortingStrategy,
18
+ },
19
+ DNDUtilities: { CSS },
20
+ } = DragAndDrop;
21
+ import Typography from '../Typography';
22
+
23
+ import './DragAndDropList.scss';
24
+
25
+ interface TaskProps {
26
+ id: number;
27
+ title: string;
28
+ }
29
+
30
+ export const Task = ({ id, title }: TaskProps) => {
31
+ const { attributes, listeners, setNodeRef, transform, transition } =
32
+ useSortable({ id });
33
+
34
+ const style = {
35
+ transition,
36
+ transform: CSS.Transform.toString(transform),
37
+ };
38
+
39
+ return (
40
+ <div
41
+ ref={setNodeRef}
42
+ style={style}
43
+ {...attributes}
44
+ {...listeners}
45
+ className="task"
46
+ >
47
+ <Typography as='h1' fontSize={16} className='task-title'>{title}</Typography>
48
+ </div>
49
+ );
50
+ };
51
+
52
+ interface ColumnProps {
53
+ id: string;
54
+ tasks: { id: number; title: string }[];
55
+ }
56
+
57
+ export const Column: React.FC<ColumnProps> = ({ tasks }) => {
58
+ return (
59
+ <div className="column">
60
+ <SortableContext items={tasks} strategy={verticalListSortingStrategy}>
61
+ {tasks.map((task) => (
62
+ <Task key={task.id} id={task.id} title={task.title} />
63
+ ))}
64
+ </SortableContext>
65
+ </div>
66
+ );
67
+ };
68
+
69
+ interface InputProps {
70
+ onSubmit: (input: string) => void;
71
+ }
72
+
73
+ export const Input: React.FC<InputProps> = ({ onSubmit }) => {
74
+ const [input, setInput] = useState('');
75
+
76
+ const handleSubmit = () => {
77
+ if (!input) return;
78
+
79
+ onSubmit(input);
80
+
81
+ setInput('');
82
+ };
83
+
84
+ return (
85
+ <div className="container">
86
+ <input
87
+ className="input"
88
+ type="text"
89
+ value={input}
90
+ onChange={(e) => setInput(e.target.value)}
91
+ />
92
+ <button onClick={handleSubmit} className="button">
93
+ <Typography fontSize={14}>Add</Typography>
94
+ </button>
95
+ </div>
96
+ );
97
+ };
98
+
99
+ const DragAndDropList = () => {
100
+ const [tasks, setTasks] = useState([
101
+ { id: 1, title: 'Add tests to homepage' },
102
+ { id: 2, title: 'Fix styling in about section' },
103
+ { id: 3, title: 'Learn how to center a div' },
104
+ ]);
105
+
106
+ const addTask = (title: any) => {
107
+ setTasks((tasks) => [...tasks, { id: tasks.length + 1, title }]);
108
+ };
109
+
110
+ const sensors = useSensors(
111
+ useSensor(PointerSensor),
112
+ useSensor(KeyboardSensor, {
113
+ coordinateGetter: sortableKeyboardCoordinates,
114
+ })
115
+ );
116
+
117
+ const getTaskPos = (id: number): number =>
118
+ tasks.findIndex((task) => task.id === id);
119
+
120
+ const handleDragEnd = (event: any) => {
121
+ const { active, over } = event;
122
+
123
+ if (active.id === over.id) return;
124
+
125
+ setTasks((tasks) => {
126
+ const originalPos = getTaskPos(active.id);
127
+ const newPos = getTaskPos(over.id);
128
+
129
+ return arrayMove(tasks, originalPos, newPos);
130
+ });
131
+ };
132
+
133
+ return (
134
+ <div className="drag-and-drop-list">
135
+ <Typography fontSize={32} fontWeight="semi-bold">
136
+ Drag and Drop test ✅
137
+ </Typography>
138
+ <Input onSubmit={addTask} />
139
+ <DndContext
140
+ sensors={sensors}
141
+ collisionDetection={closestCorners}
142
+ onDragEnd={handleDragEnd}
143
+ >
144
+ <Column id="toDo" tasks={tasks} />
145
+ </DndContext>
146
+ </div>
147
+ );
148
+ };
149
+
150
+ export default DragAndDropList;
@@ -0,0 +1 @@
1
+ export * from './DragAndDrop';
@@ -3,11 +3,11 @@ import { DrawerProps } from './Types.js';
3
3
  import Button from '../Button/Button.js';
4
4
  import classNames from 'classnames';
5
5
  import './Drawer.scss';
6
- import { useContext, useEffect, useState } from 'react';
6
+ import { FC, useContext, useEffect, useState } from 'react';
7
7
  import Icon from '../Icon';
8
8
  import useEscapeKey from '../../hooks/keyboardevents/useEscKeyEvent.js';
9
9
  import { ThemeContext } from '../ThemeProvider/ThemeProvider.js';
10
- const Drawer = ({
10
+ const Drawer: FC<DrawerProps> = ({
11
11
  isOpen = true,
12
12
  children = 'Drawer content area',
13
13
  onClose = () => {},
@@ -103,11 +103,7 @@ const Drawer = ({
103
103
  <div className="ff-drawer-title">{title}</div>
104
104
  </div>
105
105
  {_isCloseModalButtonVisible && (
106
- <Icon
107
- name="close"
108
- hoverEffect={false}
109
- onClick={onClose}
110
- />
106
+ <Icon name="close" hoverEffect={false} onClick={onClose} />
111
107
  )}
112
108
  </div>
113
109
  </div>
@@ -45,6 +45,13 @@ import ImpactListIcon from '../../assets/icons/impactList.svg?react';
45
45
  import InfoIcon from '../../assets/icons/info_icon.svg?react';
46
46
  import CalendarIcon from '../../assets/icons/calendar_icon.svg?react';
47
47
  import HideIcon from '../../assets/icons/hide_icon.svg?react';
48
+ import CollapseIcon from '../../assets/icons/collapse-icon.svg?react';
49
+ import ExpandIcon from '../../assets/icons/expand-icon.svg?react';
50
+ import CopyIcon from '../../assets/icons/copy-icon.svg?react';
51
+ import DownloadFile from '../../assets/icons/download-icon.svg?react';
52
+ import RefreshIcon from '../../assets/icons/refresh-icon.svg?react';
53
+ import LicenseInfo from '../../assets/icons/license_info.svg?react';
54
+ import LicenseWarning from '../../assets/icons/license_warning.svg?react';
48
55
  //icons
49
56
  Components['delete_info'] = DeleteInfoIcon;
50
57
  Components['success'] = ToastSuccessIcon;
@@ -90,5 +97,12 @@ Components['add_variable'] = AddVariable;
90
97
  Components['info'] = InfoIcon;
91
98
  Components['calendar_icon'] = CalendarIcon;
92
99
  Components['hide_icon'] = HideIcon;
100
+ Components['collapse_icon'] = CollapseIcon;
101
+ Components['refresh_icon'] = RefreshIcon;
102
+ Components['download_file'] = DownloadFile;
103
+ Components['copy_icon'] = CopyIcon;
104
+ Components['expand_icon'] = ExpandIcon;
105
+ Components['license_info'] = LicenseInfo;
106
+ Components['license_warning'] = LicenseWarning;
93
107
 
94
108
  export default Components;
@@ -0,0 +1,63 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import Modal from './Modal';
3
+ import { useState } from 'react';
4
+ import Button from '../Button';
5
+
6
+ const meta: Meta<typeof Modal> = {
7
+ title: 'Components/Modal',
8
+ component: Modal,
9
+ parameters: {
10
+ layout: 'centered',
11
+ },
12
+ tags: ['autodocs'],
13
+ };
14
+
15
+ type Story = StoryObj<typeof Modal>;
16
+
17
+ export const DefaultModalStory: Story = {
18
+ args: {
19
+ isOpen: true,
20
+ contentLabel: 'modal',
21
+ ariaHideApp: true,
22
+ isHeaderDisplayed: true,
23
+ headerContent: <h2>title</h2>,
24
+ children: <h2>Hello</h2>,
25
+ isFooterDisplayed:true,
26
+ footerContent: <Button variant="primary" label="continue" />,
27
+ },
28
+ };
29
+
30
+ export const Controlled: Story = {
31
+ render: () => {
32
+ const [openModal, setModal] = useState(false);
33
+ return (
34
+ <>
35
+ <Button
36
+ variant="primary"
37
+ onClick={() => {
38
+ setModal(true);
39
+ }}
40
+ >
41
+ Show Modal
42
+ </Button>
43
+ {openModal && (
44
+ <Modal
45
+ overlayClassName="custom-overlay"
46
+ isOpen={openModal}
47
+ onClose={() => {
48
+ setModal(false);
49
+ }}
50
+ headerContent={<div>title</div>}
51
+ isHeaderDisplayed={true}
52
+ children={<div>Hello</div>}
53
+ ariaHideApp={true}
54
+ isFooterDisplayed={true}
55
+ footerContent={<Button variant="primary" label='continue'/>}
56
+ />
57
+ )}
58
+ </>
59
+ );
60
+ },
61
+ };
62
+
63
+ export default meta;
@@ -0,0 +1,71 @@
1
+ import React, { useContext, useEffect } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import './modal.scss';
4
+ import { ModalProps } from './types';
5
+ import { ThemeContext } from '../ThemeProvider/ThemeProvider';
6
+
7
+
8
+ const Modal: React.FC<ModalProps> = ({
9
+ isOpen,
10
+ onClose,
11
+ contentLabel,
12
+ isHeaderDisplayed,
13
+ headerContent,
14
+ footerContent,
15
+ contentClassName,
16
+ isFooterDisplayed,
17
+ overlayClassName,
18
+ shouldCloseOnEsc = true,
19
+ ariaHideApp = true,
20
+ shouldCloseOnOverlayClick = true,
21
+ children,
22
+ }) => {
23
+ useEffect(() => {
24
+ const handleKeyDown = (e: KeyboardEvent) => {
25
+ if (e.key === 'Escape' && shouldCloseOnEsc) {
26
+ onClose();
27
+ }
28
+ };
29
+
30
+ if (isOpen) {
31
+ document.addEventListener('keydown', handleKeyDown);
32
+ if (ariaHideApp) {
33
+ document.body.style.overflow = 'hidden';
34
+ }
35
+ }
36
+ return () => {
37
+ document.removeEventListener('keydown', handleKeyDown);
38
+ if (ariaHideApp) {
39
+ document.body.style.overflow = '';
40
+ }
41
+ };
42
+ }, [isOpen, onClose, ariaHideApp, shouldCloseOnEsc]);
43
+
44
+ if (!isOpen) return null;
45
+ const themeContext = useContext(ThemeContext);
46
+ const currentTheme = themeContext?.currentTheme;
47
+
48
+ return createPortal(
49
+ <div
50
+ className={`ff-modal-overlay ${overlayClassName || ''}`}
51
+ onClick={shouldCloseOnOverlayClick ? onClose : undefined}
52
+ >
53
+ <div
54
+ className={`ff-modal-content ${currentTheme} ${contentClassName || ''}`}
55
+ onClick={(e) => e.stopPropagation()}
56
+ aria-label={contentLabel}
57
+ >
58
+ {isHeaderDisplayed && (
59
+ <div className="ff-modal-header">{headerContent}</div>
60
+ )}
61
+ {children}
62
+ </div>
63
+ {isFooterDisplayed && (
64
+ <div className="ff-modal-footer">{footerContent}</div>
65
+ )}
66
+ </div>,
67
+ document.body
68
+ );
69
+ };
70
+
71
+ export default Modal;
@@ -0,0 +1 @@
1
+ export { default } from './Modal';
@@ -0,0 +1,37 @@
1
+ @use '../../assets/styles/mixins' as *;
2
+ .ff-modal-overlay {
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ width: 100%;
7
+ height: 100%;
8
+ background: var(--background-modal-color);
9
+ @include center-content;
10
+ flex-direction: column;
11
+ }
12
+
13
+ .ff-modal-content {
14
+ background: var(--ff-mini-modal-border);
15
+ position: relative;
16
+ max-width: 549px;
17
+ width: 100%;
18
+ border-radius: 12px 12px 0 0;
19
+ padding: 16px;
20
+ .ff-modal-header {
21
+ height: 32px;
22
+ width: 448px;
23
+ }
24
+ }
25
+ .ff-modal-footer {
26
+ background-color: var(--expandable-menu-option-bg);
27
+ max-width: 549px;
28
+ width: 100%;
29
+ height: 32px;
30
+ border-radius: 0 0 12px 12px;
31
+ display: flex;
32
+ flex-direction: row;
33
+ justify-content: end;
34
+ align-items: center;
35
+ gap: 8px;
36
+ padding: 4px 16px;
37
+ }
@@ -0,0 +1,37 @@
1
+ import { ReactNode } from "react";
2
+
3
+ export interface ModalProps {
4
+ isOpen: boolean;
5
+ onClose: () => void;
6
+
7
+ /*** label value for aria-label */
8
+ contentLabel?: string;
9
+
10
+ /*** default header will be provided with title and close icon. */
11
+ isHeaderDisplayed: boolean;
12
+
13
+ /*** Title to be displayed in the header when defaultHeader is true*/
14
+ headerTitle?: string;
15
+
16
+ /*** Custom class names for the modal content */
17
+ contentClassName?: string;
18
+
19
+ /*** Custom class name for the overlay */
20
+ overlayClassName?: string;
21
+
22
+ /*** Whether the modal should close when the 'Escape' key is pressed */
23
+ shouldCloseOnEsc?: boolean;
24
+
25
+ /*** Whether to hide the app from screen readers when the modal is open */
26
+ ariaHideApp?: boolean; //for screen readers
27
+
28
+ /*** Whether the modal should close when clicking outside of it (on the overlay) */
29
+ shouldCloseOnOverlayClick?: boolean;
30
+ // shouldFocusAfterRender?: boolean;
31
+ // shouldReturnFocusAfterClose?: boolean;
32
+ headerContent?: string | ReactNode;
33
+ footerContent?: ReactNode;
34
+ /***Content to be displayed inside the modal */
35
+ children: ReactNode;
36
+ isFooterDisplayed: boolean;
37
+ }
@@ -1,12 +1,12 @@
1
1
  /* eslint-disable */
2
2
  // @ts-nocheck
3
- import './TableTree.scss';
4
3
  import React, { ReactNode, useLayoutEffect, useRef, useState } from 'react';
5
4
  import { prepareData } from '../../utils/TableCell/TableCell';
6
5
  import Icon from '../Icon';
7
6
  import { checkEmpty } from '../../utils/checkEmpty/checkEmpty';
8
7
 
9
8
  import Checkbox from '../Checkbox';
9
+ import './TableTree.scss';
10
10
 
11
11
  interface ColumnDataProps {
12
12
  name: string;
@@ -1,21 +1,24 @@
1
- import React, { createContext, useState } from 'react';
1
+ import React, { createContext, useState, useEffect } from 'react';
2
2
  import { ThemeContextType, ThemeProviderProps, Theme } from './types';
3
3
  import '../../assets/Themes/Theme.scss';
4
4
 
5
5
  const ThemeContext = createContext<ThemeContextType | undefined>(undefined);
6
6
 
7
7
  const ThemeProvider: React.FC<ThemeProviderProps> = ({ children, theme }) => {
8
- const [currentTheme, setCurrentTheme] = useState<Theme>(
9
- theme || 'ff-light-theme'
10
- );
8
+ const [currentTheme, setCurrentTheme] = useState<Theme>(theme || 'ff-light-theme');
11
9
 
12
10
  const applyTheme = (newTheme: Theme) => setCurrentTheme(newTheme);
13
11
 
12
+ useEffect(() => {
13
+ document.body.className = currentTheme;
14
+ return () => {
15
+ document.body.className = '';
16
+ };
17
+ }, [currentTheme]);
18
+
14
19
  return (
15
- <ThemeContext.Provider
16
- value={{ currentTheme, setCurrentTheme, applyTheme }}
17
- >
18
- <div className={currentTheme}>{children}</div>
20
+ <ThemeContext.Provider value={{ currentTheme, setCurrentTheme, applyTheme }}>
21
+ {children}
19
22
  </ThemeContext.Provider>
20
23
  );
21
24
  };
package/src/index.ts CHANGED
@@ -14,10 +14,8 @@ import ExpandableMenu from './components/ExpandableMenu';
14
14
  import Select from './components/Select/Select';
15
15
  import TextArea from './components/TextArea';
16
16
  import StatusButton from './components/StatusButton';
17
-
18
17
  import MenuOption from './components/MenuOption';
19
18
  import Table from './components/Table/Table';
20
-
21
19
  import AddResourceButton from './components/AddResourceButton';
22
20
  import DonutChart from './components/Charts/DonutChart';
23
21
  import FileDropzone from './components/FileDropzone';
@@ -26,7 +24,6 @@ import ThemeProvider from './components/ThemeProvider';
26
24
  import Typography from './components/Typography';
27
25
  import useTheme from './hooks/useTheme';
28
26
  import Form from './components/Form';
29
-
30
27
  import InputWithDropdown from './components/InputWithDropdown';
31
28
  import RadioButton from './components/RadioButton';
32
29
  import RadioGroup from './components/RadioGroup';
@@ -39,6 +36,7 @@ import Search from './components/Search/Search';
39
36
  import DatePicker from './components/DatePicker';
40
37
  import StateDropdown from './components/StateDropdown';
41
38
  import IconButton from './components/IconButton';
39
+ import DragAndDrop from './components/DragAndDrop/DragAndDrop';
42
40
 
43
41
  // Utils imports
44
42
  import { checkEmpty } from './utils/checkEmpty/checkEmpty';
@@ -47,7 +45,6 @@ import {
47
45
  getExtensionWithPeriod,
48
46
  } from './utils/getExtension/getExtension';
49
47
 
50
-
51
48
  export {
52
49
  Button,
53
50
  Tooltip,
@@ -89,7 +86,7 @@ export {
89
86
  StateDropdown,
90
87
  StatusButton,
91
88
  IconButton,
92
-
89
+ DragAndDrop,
93
90
 
94
91
  // utils exports
95
92
  checkEmpty,
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import './AddButton.scss';
3
- import { AddButtonProps } from './types';
4
- declare const AddButton: React.FC<AddButtonProps>;
5
- export default AddButton;
@@ -1,6 +0,0 @@
1
- import type { Meta, StoryObj } from '@storybook/react';
2
- import AddButton from './AddButton';
3
- declare const meta: Meta<typeof AddButton>;
4
- type Story = StoryObj<typeof AddButton>;
5
- export declare const PrimaryAddButton: Story;
6
- export default meta;
@@ -1 +0,0 @@
1
- export { default } from './AddButton';
@@ -1,4 +0,0 @@
1
- export interface AddButtonProps {
2
- name: string;
3
- onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
4
- }