@pareto-engineering/design-system 5.0.0 → 5.0.2

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 (123) hide show
  1. package/dist/cjs/a/{AreaChart → Charts/AreaChart}/AreaChart.js +89 -73
  2. package/dist/cjs/a/Charts/AreaChart/styles.scss +48 -0
  3. package/dist/cjs/a/Charts/BarChart/BarChart.js +137 -0
  4. package/dist/cjs/a/Charts/BarChart/index.js +13 -0
  5. package/dist/cjs/a/Charts/BarChart/styles.scss +48 -0
  6. package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +88 -0
  7. package/dist/cjs/a/Charts/Common/CustomLegend/index.js +13 -0
  8. package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +67 -0
  9. package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +97 -0
  10. package/dist/cjs/a/Charts/Common/CustomTooltipContent/index.js +13 -0
  11. package/dist/cjs/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  12. package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +97 -0
  13. package/dist/cjs/a/Charts/Common/YLabelsDropDown/index.js +13 -0
  14. package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  15. package/dist/cjs/a/Charts/Common/index.js +26 -0
  16. package/dist/cjs/a/Charts/PieChart/PieChart.js +99 -0
  17. package/dist/cjs/a/Charts/PieChart/index.js +13 -0
  18. package/dist/cjs/a/Charts/PieChart/styles.scss +48 -0
  19. package/dist/cjs/a/Charts/index.js +26 -0
  20. package/dist/cjs/a/Tooltip/styles.scss +1 -1
  21. package/dist/cjs/a/index.js +14 -2
  22. package/dist/cjs/f/FormInput/FormInput.js +6 -0
  23. package/dist/cjs/f/fields/FileUpload/FileUpload.js +18 -4
  24. package/dist/cjs/f/fields/LatexPreviewInput/LatexPreviewInput.js +78 -0
  25. package/dist/cjs/f/fields/LatexPreviewInput/convertLatexToHtml.js +46 -0
  26. package/dist/cjs/f/fields/LatexPreviewInput/index.js +20 -0
  27. package/dist/cjs/f/fields/LatexPreviewInput/styles.scss +24 -0
  28. package/dist/cjs/f/fields/index.js +13 -0
  29. package/dist/cjs/g/FormBuilder/FormBuilder.js +3 -6
  30. package/dist/cjs/g/FormBuilder/common/Builder/Builder.js +1 -3
  31. package/dist/cjs/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
  32. package/dist/cjs/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
  33. package/dist/cjs/g/FormBuilder/common/Renderer/Renderer.js +2 -4
  34. package/dist/cjs/g/FormBuilder/common/Renderer/common/Section/Section.js +2 -10
  35. package/dist/cjs/utils/formatting.js +119 -0
  36. package/dist/cjs/utils/index.js +26 -1
  37. package/dist/es/a/{AreaChart → Charts/AreaChart}/AreaChart.js +88 -69
  38. package/dist/es/a/Charts/AreaChart/styles.scss +48 -0
  39. package/dist/es/a/Charts/BarChart/BarChart.js +128 -0
  40. package/dist/es/a/Charts/BarChart/index.js +1 -0
  41. package/dist/es/a/Charts/BarChart/styles.scss +48 -0
  42. package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +76 -0
  43. package/dist/es/a/Charts/Common/CustomLegend/index.js +1 -0
  44. package/dist/es/a/Charts/Common/CustomLegend/styles.scss +67 -0
  45. package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +87 -0
  46. package/dist/es/a/Charts/Common/CustomTooltipContent/index.js +1 -0
  47. package/dist/es/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  48. package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +86 -0
  49. package/dist/es/a/Charts/Common/YLabelsDropDown/index.js +1 -0
  50. package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  51. package/dist/es/a/Charts/Common/index.js +3 -0
  52. package/dist/es/a/Charts/PieChart/PieChart.js +89 -0
  53. package/dist/es/a/Charts/PieChart/index.js +1 -0
  54. package/dist/es/a/Charts/PieChart/styles.scss +48 -0
  55. package/dist/es/a/Charts/index.js +3 -0
  56. package/dist/es/a/Tooltip/styles.scss +1 -1
  57. package/dist/es/a/index.js +1 -1
  58. package/dist/es/f/FormInput/FormInput.js +7 -1
  59. package/dist/es/f/fields/FileUpload/FileUpload.js +18 -4
  60. package/dist/es/f/fields/LatexPreviewInput/LatexPreviewInput.js +70 -0
  61. package/dist/es/f/fields/LatexPreviewInput/convertLatexToHtml.js +31 -0
  62. package/dist/es/f/fields/LatexPreviewInput/index.js +3 -0
  63. package/dist/es/f/fields/LatexPreviewInput/styles.scss +24 -0
  64. package/dist/es/f/fields/index.js +1 -0
  65. package/dist/es/g/FormBuilder/FormBuilder.js +3 -6
  66. package/dist/es/g/FormBuilder/common/Builder/Builder.js +1 -3
  67. package/dist/es/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.js +5 -7
  68. package/dist/es/g/FormBuilder/common/Builder/common/Section/Section.js +2 -4
  69. package/dist/es/g/FormBuilder/common/Renderer/Renderer.js +2 -4
  70. package/dist/es/g/FormBuilder/common/Renderer/common/Section/Section.js +32 -42
  71. package/dist/es/utils/formatting.js +109 -0
  72. package/dist/es/utils/index.js +2 -1
  73. package/jest.config.js +3 -0
  74. package/package.json +7 -3
  75. package/src/stories/a/AreaChart.stories.jsx +1 -1
  76. package/src/stories/a/BarChart.stories.jsx +89 -0
  77. package/src/stories/a/PieChart.stories.jsx +53 -0
  78. package/src/ui/a/{AreaChart → Charts/AreaChart}/AreaChart.jsx +114 -65
  79. package/src/ui/a/Charts/AreaChart/styles.scss +48 -0
  80. package/src/ui/a/Charts/BarChart/BarChart.jsx +167 -0
  81. package/src/ui/a/Charts/BarChart/index.js +1 -0
  82. package/src/ui/a/Charts/BarChart/styles.scss +48 -0
  83. package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +109 -0
  84. package/src/ui/a/Charts/Common/CustomLegend/index.js +1 -0
  85. package/src/ui/a/Charts/Common/CustomLegend/styles.scss +67 -0
  86. package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +117 -0
  87. package/src/ui/a/Charts/Common/CustomTooltipContent/index.js +1 -0
  88. package/src/ui/a/Charts/Common/CustomTooltipContent/styles.scss +22 -0
  89. package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +121 -0
  90. package/src/ui/a/Charts/Common/YLabelsDropDown/index.js +1 -0
  91. package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +89 -0
  92. package/src/ui/a/Charts/Common/index.js +3 -0
  93. package/src/ui/a/Charts/PieChart/PieChart.jsx +125 -0
  94. package/src/ui/a/Charts/PieChart/index.js +1 -0
  95. package/src/ui/a/Charts/PieChart/styles.scss +48 -0
  96. package/src/ui/a/Charts/index.js +3 -0
  97. package/src/ui/a/Tooltip/styles.scss +1 -1
  98. package/src/ui/a/index.js +1 -1
  99. package/src/ui/f/FormInput/FormInput.jsx +11 -0
  100. package/src/ui/f/fields/FileUpload/FileUpload.jsx +24 -4
  101. package/src/ui/f/fields/LatexPreviewInput/LatexPreviewInput.jsx +91 -0
  102. package/src/ui/f/fields/LatexPreviewInput/convertLatexToHtml.jsx +38 -0
  103. package/src/ui/f/fields/LatexPreviewInput/index.js +3 -0
  104. package/src/ui/f/fields/LatexPreviewInput/styles.scss +24 -0
  105. package/src/ui/f/fields/index.js +4 -0
  106. package/src/ui/g/FormBuilder/FormBuilder.jsx +0 -3
  107. package/src/ui/g/FormBuilder/common/Builder/Builder.jsx +0 -2
  108. package/src/ui/g/FormBuilder/common/Builder/common/InputBuilder/InputBuilder.jsx +4 -7
  109. package/src/ui/g/FormBuilder/common/Builder/common/Section/Section.jsx +0 -2
  110. package/src/ui/g/FormBuilder/common/Renderer/Renderer.jsx +0 -2
  111. package/src/ui/g/FormBuilder/common/Renderer/common/Section/Section.jsx +49 -64
  112. package/src/ui/utils/formatting.js +133 -0
  113. package/src/ui/utils/index.js +3 -0
  114. package/tests/__snapshots__/Storyshots.test.js.snap +2227 -296
  115. package/tests/emptyMock.js +3 -0
  116. package/tests/mockTextEncoder.js +7 -0
  117. package/tests/test-setup.js +7 -0
  118. package/dist/cjs/a/AreaChart/styles.scss +0 -89
  119. package/dist/es/a/AreaChart/styles.scss +0 -89
  120. package/src/ui/a/AreaChart/styles.scss +0 -89
  121. /package/dist/cjs/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
  122. /package/dist/es/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
  123. /package/src/ui/a/{AreaChart → Charts/AreaChart}/index.js +0 -0
@@ -23,8 +23,7 @@ const Section = ({
23
23
  className: userClassName,
24
24
  style,
25
25
  index,
26
- handleDeleteSection,
27
- customInputMap
26
+ handleDeleteSection
28
27
  // ...otherProps
29
28
  }) => {
30
29
  const {
@@ -56,8 +55,7 @@ const Section = ({
56
55
  sectionIndex: index,
57
56
  inputIndex: indx,
58
57
  onDelete: handleDeleteInput,
59
- onCopy: handleCopyInput,
60
- customInputMap: customInputMap
58
+ onCopy: handleCopyInput
61
59
  }),
62
60
  identifier: input.name
63
61
  }));
@@ -65,8 +65,7 @@ const Renderer = ({
65
65
  fileUploadStatus,
66
66
  handleFileDelete,
67
67
  onFileUpload,
68
- shouldUpdateInputStateInRealTime = true,
69
- customInputMap
68
+ shouldUpdateInputStateInRealTime = true
70
69
  // ...otherProps
71
70
  }) => {
72
71
  const [currentSectionIndex, setCurrentSectionIndex] = useState(0);
@@ -143,8 +142,7 @@ const Renderer = ({
143
142
  fileUploadStatus: fileUploadStatus,
144
143
  handleFileDelete: handleFileDelete,
145
144
  onFileUpload: onFileUpload,
146
- sectionIndex: sectionIndex,
147
- customInputMap: customInputMap
145
+ sectionIndex: sectionIndex
148
146
  }))), /*#__PURE__*/React.createElement("div", {
149
147
  className: "navigator-container"
150
148
  }, updatedFormData.sections.length > 1 && /*#__PURE__*/React.createElement(Button, {
@@ -34,50 +34,40 @@ const Section = ({
34
34
  fileUploadStatus,
35
35
  handleFileDelete,
36
36
  onFileUpload,
37
- sectionIndex,
38
- customInputMap
37
+ sectionIndex
39
38
  // ...otherProps
40
- }) => {
41
- const customInputTypes = customInputMap ? Object.keys(customInputMap) : [];
42
- return /*#__PURE__*/React.createElement("div", {
43
- id: id,
44
- className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
45
- style: style
46
- }, /*#__PURE__*/React.createElement("p", {
47
- className: "h3"
48
- }, title), /*#__PURE__*/React.createElement(ExpandableLexicalPreview, {
49
- nodes: description,
50
- name: "instructions"
51
- }), inputs?.map((input, inputIndex) => {
52
- const isFileInput = input.type === 'file';
53
- const isCustomInput = customInputTypes.includes(input.type);
54
- const CustomInputComponent = isCustomInput ? customInputMap[input.type].component : null;
55
- return !isCustomInput ? /*#__PURE__*/React.createElement(FormInput, _extends({
56
- key: input.name
57
- }, input, {
58
- disabled: readOnly
59
- }, isFileInput && {
60
- uploadStatus: fileUploadStatus,
61
- handleFileDelete,
62
- onChange: files => {
63
- const filesToUpload = files?.filter(file => file instanceof File).map(file => ({
64
- file,
65
- name: file.name,
66
- mimeType: file.type,
67
- type: fileTypeMapper[getFileType(file)] || 'Generic',
68
- title: file.name,
69
- sectionIndex,
70
- inputIndex
71
- }));
72
- onFileUpload(filesToUpload);
73
- }
74
- })) : /*#__PURE__*/React.createElement(CustomInputComponent, _extends({
75
- key: input.name
76
- }, input, {
77
- disabled: readOnly
78
- }));
39
+ }) => /*#__PURE__*/React.createElement("div", {
40
+ id: id,
41
+ className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
42
+ style: style
43
+ }, /*#__PURE__*/React.createElement("p", {
44
+ className: "h3"
45
+ }, title), /*#__PURE__*/React.createElement(ExpandableLexicalPreview, {
46
+ nodes: description,
47
+ name: "instructions"
48
+ }), inputs?.map((input, inputIndex) => {
49
+ const isFileInput = input.type === 'file';
50
+ return /*#__PURE__*/React.createElement(FormInput, _extends({
51
+ key: input.name
52
+ }, input, {
53
+ disabled: readOnly
54
+ }, isFileInput && {
55
+ uploadStatus: fileUploadStatus,
56
+ handleFileDelete,
57
+ onChange: files => {
58
+ const filesToUpload = files?.filter(file => file instanceof File).map(file => ({
59
+ file,
60
+ name: file.name,
61
+ mimeType: file.type,
62
+ type: fileTypeMapper[getFileType(file)] || 'Generic',
63
+ title: file.name,
64
+ sectionIndex,
65
+ inputIndex
66
+ }));
67
+ onFileUpload(filesToUpload);
68
+ }
79
69
  }));
80
- };
70
+ }));
81
71
  Section.propTypes = {
82
72
  /**
83
73
  * The HTML id for this element
@@ -0,0 +1,109 @@
1
+ export const DATE_FORMATS = {
2
+ HUMAN_READABLE: 'human_readable',
3
+ TIME: 'time',
4
+ DATETIME: 'datetime',
5
+ CHART_DATE: 'chart_date',
6
+ CHART_TIME: 'chart_time',
7
+ WEEKDAY_DATE: 'weekday_date',
8
+ DAY_VIEW: 'day_view'
9
+ };
10
+ const isValidDate = date => date instanceof Date && !Number.isNaN(date);
11
+ const isTimeSliceFormat = input => {
12
+ const timeSliceRegex = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
13
+ return timeSliceRegex.test(input);
14
+ };
15
+ const createTimeFromSlice = timeSlice => {
16
+ const [hours, minutes] = timeSlice.split(':').map(Number);
17
+ const date = new Date();
18
+ date.setHours(hours, minutes, 0, 0);
19
+ return date;
20
+ };
21
+ const format12Hour = date => {
22
+ const hour = date.getHours();
23
+ const ampm = hour >= 12 ? 'PM' : 'AM';
24
+ const hour12 = hour % 12 || 12;
25
+ return `${hour12} ${ampm}`;
26
+ };
27
+ const shouldShowYear = date => {
28
+ const currentYear = new Date().getFullYear();
29
+ return date.getFullYear() !== currentYear;
30
+ };
31
+ export const formatTime = seconds => {
32
+ if (!seconds) return '0s';
33
+ const hours = Math.floor(seconds / 3600);
34
+ const minutes = Math.floor(seconds % 3600 / 60);
35
+ const remainingSeconds = Math.floor(seconds % 60);
36
+ const parts = [];
37
+ if (hours > 0) parts.push(`${hours}h`);
38
+ if (minutes > 0 || hours > 0 && remainingSeconds > 0) parts.push(`${minutes}m`);
39
+ if (remainingSeconds > 0) parts.push(`${remainingSeconds}s`);
40
+
41
+ // Cater for decimal seconds
42
+ if (parts.length === 0) return '0s';
43
+ return parts.join(' ');
44
+ };
45
+ const parseDate = input => {
46
+ if (input instanceof Date) return input;
47
+ if (typeof input === 'number') return new Date(input);
48
+ if (typeof input === 'string') {
49
+ if (isTimeSliceFormat(input)) {
50
+ return createTimeFromSlice(input);
51
+ }
52
+ const parsed = new Date(input);
53
+ if (isValidDate(parsed)) return parsed;
54
+ const timestamp = parseInt(input, 10);
55
+ if (!Number.isNaN(timestamp)) {
56
+ const date = new Date(timestamp * 1000);
57
+ if (isValidDate(date)) return date;
58
+ }
59
+ }
60
+ return null;
61
+ };
62
+ const formatStrategies = {
63
+ [DATE_FORMATS.CHART_DATE]: date => {
64
+ const monthDay = date.toLocaleDateString('en-US', {
65
+ month: 'short',
66
+ day: 'numeric',
67
+ timeZone: 'UTC'
68
+ });
69
+ return shouldShowYear(date) ? `${monthDay} ${date.getFullYear()}` : monthDay;
70
+ },
71
+ [DATE_FORMATS.CHART_TIME]: date => format12Hour(date),
72
+ [DATE_FORMATS.HUMAN_READABLE]: date => date.toLocaleDateString('en-US', {
73
+ year: 'numeric',
74
+ month: 'short',
75
+ day: 'numeric',
76
+ timeZone: 'UTC'
77
+ }),
78
+ default: date => date.toISOString()
79
+ };
80
+ export const formatDate = (input, format = DATE_FORMATS.HUMAN_READABLE) => {
81
+ try {
82
+ if (typeof input === 'string' && isTimeSliceFormat(input)) {
83
+ if (format === DATE_FORMATS.CHART_TIME || format === DATE_FORMATS.TIME) {
84
+ const date = createTimeFromSlice(input);
85
+ if (format === DATE_FORMATS.CHART_TIME) {
86
+ return format12Hour(date);
87
+ }
88
+ return date.toLocaleTimeString('en-US', {
89
+ hour: '2-digit',
90
+ minute: '2-digit',
91
+ timeZone: 'UTC'
92
+ });
93
+ }
94
+ return input;
95
+ }
96
+ const date = parseDate(input);
97
+ if (!date && (typeof input === 'string' || typeof input === 'number')) {
98
+ return input.toString();
99
+ }
100
+ const formatStrategy = formatStrategies[format] || formatStrategies.default;
101
+ return formatStrategy(date);
102
+ } catch (error) {
103
+ return 'Invalid Date';
104
+ }
105
+ };
106
+ export const snakeCaseToTitleCase = word => {
107
+ const result = word.replace(/([A-Z])/g, ' $1');
108
+ return result.charAt(0).toUpperCase() + result.slice(1);
109
+ };
@@ -1 +1,2 @@
1
- export { useWindowSize, useDynamicPosition, useOutsideClick } from "./hooks";
1
+ export { useWindowSize, useDynamicPosition, useOutsideClick } from "./hooks";
2
+ export { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "./formatting";
package/jest.config.js CHANGED
@@ -10,6 +10,9 @@ module.exports = {
10
10
  moduleNameMapper:{
11
11
  '^.+\\.(css|scss)$' :'<rootDir>/tests/staticStub.js',
12
12
  '^.+\\.(mdx)$' :'<rootDir>/tests/staticStub.js',
13
+ 'react-markdown' :'<rootDir>/tests/emptyMock.js',
14
+ 'remark-math' :'<rootDir>/tests/emptyMock.js',
15
+ 'rehype-mathjax' :'<rootDir>/tests/emptyMock.js',
13
16
  // https://jestjs.io/docs/webpack#mocking-css-modules
14
17
  '^@pareto-engineering/bem$' :'identity-obj-proxy',
15
18
  '^@pareto-engineering/bem/exports$':'identity-obj-proxy',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -63,6 +63,7 @@
63
63
  "@pareto-engineering/bem": "^5.0.0",
64
64
  "@pareto-engineering/styles": "^5.0.0",
65
65
  "@pareto-engineering/utils": "^5.0.0",
66
+ "better-react-mathjax": "^2.0.3",
66
67
  "codemirror": "^6.0.1",
67
68
  "date-fns": "^2.29.3",
68
69
  "downshift": "^6.1.12",
@@ -77,11 +78,14 @@
77
78
  "react-day-picker": "^8.10.0",
78
79
  "react-dom": "^18.2.0",
79
80
  "react-helmet-async": "^1.3.0",
81
+ "react-markdown": "^9.0.1",
80
82
  "react-relay": "^15.0.0",
81
83
  "react-router-dom": "^5.3.4",
82
84
  "recharts": "^2.13.3",
83
- "relay-test-utils": "^15.0.0"
85
+ "rehype-mathjax": "^6.0.0",
86
+ "relay-test-utils": "^15.0.0",
87
+ "remark-math": "^6.0.0"
84
88
  },
85
89
  "browserslist": "> 2%",
86
- "gitHead": "6892e855aadac7d1c0e4a8f00570e644ba9cfb55"
90
+ "gitHead": "af1d9f8a840222f80506834a9ed5402c4465b69a"
87
91
  }
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import { AreaChart } from 'ui'
5
5
 
6
6
  export default {
7
- title :'a/AreaChart',
7
+ title :'a/Charts/AreaChart',
8
8
  component:AreaChart,
9
9
  }
10
10
 
@@ -0,0 +1,89 @@
1
+ // front/packages/design-system/src/ui/a/BarChart/BarChart.stories.jsx
2
+
3
+ import React from 'react'
4
+ import { BarChart } from 'ui'
5
+
6
+ export default {
7
+ title :'a/Charts/BarChart',
8
+ component:BarChart,
9
+ }
10
+
11
+ const data = [
12
+ {
13
+ date:'Jan', pendingReview:200, accepted:150, rejected:100, toRevise:250, revised:50,
14
+ },
15
+ {
16
+ date:'Feb', pendingReview:180, accepted:160, rejected:120, toRevise:240, revised:60,
17
+ },
18
+ {
19
+ date:'Mar', pendingReview:220, accepted:140, rejected:110, toRevise:230, revised:70,
20
+ },
21
+ {
22
+ date:'Apr', pendingReview:210, accepted:130, rejected:130, toRevise:220, revised:80,
23
+ },
24
+ {
25
+ date:'May', pendingReview:230, accepted:120, rejected:140, toRevise:210, revised:90,
26
+ },
27
+ {
28
+ date:'Jun', pendingReview:240, accepted:110, rejected:150, toRevise:200, revised:100,
29
+ },
30
+ {
31
+ date:'Jul', pendingReview:250, accepted:100, rejected:160, toRevise:190, revised:110,
32
+ },
33
+ {
34
+ date:'Aug', pendingReview:260, accepted:90, rejected:170, toRevise:180, revised:120,
35
+ },
36
+ {
37
+ date:'Sep', pendingReview:270, accepted:80, rejected:180, toRevise:170, revised:130,
38
+ },
39
+ {
40
+ date:'Oct', pendingReview:280, accepted:70, rejected:190, toRevise:160, revised:140,
41
+ },
42
+ {
43
+ date:'Nov', pendingReview:290, accepted:60, rejected:200, toRevise:150, revised:150,
44
+ },
45
+ {
46
+ date:'Dec', pendingReview:300, accepted:50, rejected:210, toRevise:140, revised:160,
47
+ },
48
+ ]
49
+
50
+ const Template = (args) => (
51
+ <div style={{ height: '100%', width: '100%' }}>
52
+ <BarChart {...args} />
53
+ </div>
54
+ )
55
+
56
+ export const Default = Template.bind({})
57
+ Default.args = {
58
+ data,
59
+ title :'Throughput',
60
+ xKey :'date',
61
+ yKeys :['pendingReview', 'accepted', 'rejected', 'toRevise', 'revised'],
62
+ xLabel:'Date',
63
+ yLabel:'Submissions',
64
+ colors:['purple', 'green', 'orange', 'blue', 'red'],
65
+ height:400,
66
+ }
67
+
68
+ const TemplateSideBySide = (args) => (
69
+ <div style={{ display: 'flex', gap: '20px' }}>
70
+ <div style={{ flex: 1 }}>
71
+ {/* eslint-disable-next-line react/destructuring-assignment */}
72
+ <BarChart {...args[0]} />
73
+ </div>
74
+ <div style={{ flex: 1 }}>
75
+ {/* eslint-disable-next-line react/destructuring-assignment */}
76
+ <BarChart {...args[1]} />
77
+ </div>
78
+ </div>
79
+ )
80
+
81
+ export const SideBySide = TemplateSideBySide.bind({})
82
+ SideBySide.args = [
83
+ {
84
+ ...Default.args,
85
+ },
86
+ {
87
+ ...Default.args,
88
+ },
89
+ ]
@@ -0,0 +1,53 @@
1
+ import React from 'react'
2
+ import { PieChart } from 'ui'
3
+
4
+ export default {
5
+ title :'a/Charts/PieChart',
6
+ component:PieChart,
7
+ }
8
+
9
+ const data = [
10
+ { status: 'pendingReview', value: 230 },
11
+ { status: 'accepted', value: 350 },
12
+ { status: 'rejected', value: 80 },
13
+ { status: 'toRevise', value: 10 },
14
+ { status: 'revised', value: 60 },
15
+ ]
16
+
17
+ const Template = (args) => (
18
+ <div style={{ height: '100%', width: '100%' }}>
19
+ <PieChart {...args} />
20
+ </div>
21
+ )
22
+
23
+ export const Default = Template.bind({})
24
+ Default.args = {
25
+ data,
26
+ valueKey:'value',
27
+ labelKey:'status',
28
+ colors :['#8CB0F8', '#7F7CF6', '#FFD66E', '#E8E9ED', '#F6BC7E'],
29
+ height :400,
30
+ }
31
+
32
+ const TemplateSideBySide = (args) => (
33
+ <div style={{ display: 'flex', gap: '20px' }}>
34
+ <div style={{ flex: 1 }}>
35
+ {/* eslint-disable-next-line react/destructuring-assignment */}
36
+ <PieChart {...args[0]} />
37
+ </div>
38
+ <div style={{ flex: 1 }}>
39
+ {/* eslint-disable-next-line react/destructuring-assignment */}
40
+ <PieChart {...args[1]} />
41
+ </div>
42
+ </div>
43
+ )
44
+
45
+ export const SideBySide = TemplateSideBySide.bind({})
46
+ SideBySide.args = [
47
+ {
48
+ ...Default.args,
49
+ },
50
+ {
51
+ ...Default.args,
52
+ },
53
+ ]