@pareto-engineering/design-system 5.0.2 → 5.0.4

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 (50) hide show
  1. package/dist/cjs/a/Charts/AreaChart/AreaChart.js +13 -3
  2. package/dist/cjs/a/Charts/BarChart/BarChart.js +4 -6
  3. package/dist/cjs/a/Charts/Common/CustomLegend/CustomLegend.js +7 -26
  4. package/dist/cjs/a/Charts/Common/CustomLegend/styles.scss +14 -41
  5. package/dist/cjs/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +7 -18
  6. package/dist/cjs/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +4 -3
  7. package/dist/cjs/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
  8. package/dist/cjs/a/Charts/index.js +1 -8
  9. package/dist/cjs/a/index.js +0 -6
  10. package/dist/cjs/f/fields/FileUpload/common/Preview/Preview.js +9 -2
  11. package/dist/cjs/utils/formatting.js +2 -10
  12. package/dist/cjs/utils/index.js +0 -6
  13. package/dist/es/a/Charts/AreaChart/AreaChart.js +13 -3
  14. package/dist/es/a/Charts/BarChart/BarChart.js +4 -6
  15. package/dist/es/a/Charts/Common/CustomLegend/CustomLegend.js +21 -38
  16. package/dist/es/a/Charts/Common/CustomLegend/styles.scss +14 -41
  17. package/dist/es/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.js +8 -19
  18. package/dist/es/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.js +5 -3
  19. package/dist/es/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
  20. package/dist/es/a/Charts/index.js +1 -2
  21. package/dist/es/a/index.js +1 -1
  22. package/dist/es/f/fields/FileUpload/common/Preview/Preview.js +9 -2
  23. package/dist/es/utils/formatting.js +0 -7
  24. package/dist/es/utils/index.js +1 -1
  25. package/package.json +2 -2
  26. package/src/stories/a/AreaChart.stories.jsx +1 -1
  27. package/src/stories/a/BarChart.stories.jsx +1 -1
  28. package/src/ui/a/Charts/AreaChart/AreaChart.jsx +14 -8
  29. package/src/ui/a/Charts/BarChart/BarChart.jsx +2 -4
  30. package/src/ui/a/Charts/Common/CustomLegend/CustomLegend.jsx +29 -54
  31. package/src/ui/a/Charts/Common/CustomLegend/styles.scss +14 -41
  32. package/src/ui/a/Charts/Common/CustomTooltipContent/CustomTooltipContent.jsx +13 -25
  33. package/src/ui/a/Charts/Common/YLabelsDropDown/YlabelsDropDown.jsx +4 -4
  34. package/src/ui/a/Charts/Common/YLabelsDropDown/styles.scss +6 -7
  35. package/src/ui/a/Charts/index.js +0 -1
  36. package/src/ui/a/index.js +1 -1
  37. package/src/ui/f/fields/FileUpload/common/Preview/Preview.jsx +26 -12
  38. package/src/ui/utils/formatting.js +0 -8
  39. package/src/ui/utils/index.js +1 -3
  40. package/tests/__snapshots__/Storyshots.test.js.snap +428 -1164
  41. package/dist/cjs/a/Charts/PieChart/PieChart.js +0 -99
  42. package/dist/cjs/a/Charts/PieChart/index.js +0 -13
  43. package/dist/cjs/a/Charts/PieChart/styles.scss +0 -48
  44. package/dist/es/a/Charts/PieChart/PieChart.js +0 -89
  45. package/dist/es/a/Charts/PieChart/index.js +0 -1
  46. package/dist/es/a/Charts/PieChart/styles.scss +0 -48
  47. package/src/stories/a/PieChart.stories.jsx +0 -53
  48. package/src/ui/a/Charts/PieChart/PieChart.jsx +0 -125
  49. package/src/ui/a/Charts/PieChart/index.js +0 -1
  50. package/src/ui/a/Charts/PieChart/styles.scss +0 -48
@@ -1,7 +1,6 @@
1
1
  @use "@pareto-engineering/bem";
2
2
 
3
3
  $default-padding: 1rem;
4
- $default-margin: 1rem;
5
4
  $default-text-font-size: calc(var(--s-1) * 1rem);
6
5
  $default-border-radius: .25rem;
7
6
  $default-legend-gap: .625rem;
@@ -9,59 +8,33 @@ $default-legend-padding: calc($default-padding * .125) calc($default-padding * .
9
8
  $default-legend-dot-width: .5rem;
10
9
  $default-legend-dot-height: .5rem;
11
10
  $default-legend-dot-margin-right: .3125rem;
12
- $default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
13
11
 
14
12
  .#{bem.$base} {
15
13
  &.custom-legend {
14
+ display: flex;
16
15
  gap: $default-legend-gap;
17
16
  justify-content: flex-end;
18
17
  padding-bottom: $default-padding;
19
18
  padding-right: calc($default-padding * .25);
20
19
 
21
- &.vertical {
22
- display: block;
23
- margin-right: calc($default-margin * 2);
24
- min-width: fit-content;
25
-
26
- .item {
27
- box-shadow: $default-box-shadow;
28
- padding-top: $default-padding;
29
- }
30
- }
31
-
32
- &.horizontal {
33
- display: flex;
34
- }
35
-
36
20
  .item {
21
+ align-items: center;
37
22
  border-radius: $default-border-radius;
23
+ display: flex;
38
24
  padding: $default-legend-padding;
25
+ }
39
26
 
40
- .title {
41
- align-items: center;
42
- display: flex;
43
-
44
- .dot {
45
- border-radius: 50%;
46
- display: inline-block;
47
- height: $default-legend-dot-height;
48
- margin-right: $default-legend-dot-margin-right;
49
- width: $default-legend-dot-width;
50
- }
51
-
52
- .text {
53
- color: var(--paragraph);
54
- font-size: calc($default-text-font-size * .75);
55
- }
56
- }
27
+ .dot {
28
+ border-radius: 50%;
29
+ display: inline-block;
30
+ height: $default-legend-dot-height;
31
+ margin-right: $default-legend-dot-margin-right;
32
+ width: $default-legend-dot-width;
33
+ }
57
34
 
58
- .sub-title {
59
- color: var(--heading);
60
- display: flex;
61
- font-size: calc($default-text-font-size * 1.2);
62
- font-weight: 500;
63
- justify-content: flex-end;
64
- }
35
+ .text {
36
+ color: var(--paragraph);
37
+ font-size: calc($default-text-font-size * .75);
65
38
  }
66
39
  }
67
40
  }
@@ -1,30 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styleNames from '@pareto-engineering/bem/exports';
4
- import { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "../../../../utils";
4
+ import { formatTime, formatDate, DATE_FORMATS } from "../../../../utils";
5
5
  import "./styles.scss";
6
6
  const baseClassName = styleNames.base;
7
7
  const componentClassName = 'custom-tooltip-content';
8
8
  const CustomTooltipContent = ({
9
9
  id,
10
10
  className: userClassName,
11
+ xLabel,
11
12
  dateFormat,
12
13
  isTimeFormat,
13
- isDateValue,
14
14
  active,
15
15
  payload,
16
16
  label
17
17
  }) => {
18
- const formatLabelValue = value => {
19
- if (isTimeFormat) {
20
- return formatTime(value);
21
- }
22
- if (typeof value === 'number') {
23
- if (Number.isInteger(value)) return value;
24
- return value.toFixed(2);
25
- }
26
- return value;
27
- };
28
18
  if (active && payload && payload.length) {
29
19
  const newPayload = payload.filter(item => item.name !== 'bounds');
30
20
  return /*#__PURE__*/React.createElement("div", {
@@ -32,14 +22,14 @@ const CustomTooltipContent = ({
32
22
  className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' ')
33
23
  }, /*#__PURE__*/React.createElement("p", {
34
24
  className: "label"
35
- }, isDateValue ? formatDate(label, dateFormat) : label), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
25
+ }, `${xLabel}: ${formatDate(label, dateFormat)}`), newPayload.map(entry => /*#__PURE__*/React.createElement("p", {
36
26
  className: "label",
37
27
  key: `${entry.name}`,
38
28
  style: {
39
29
  color: entry.color,
40
30
  textTransform: 'capitalize'
41
31
  }
42
- }, `${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`)));
32
+ }, `${entry.name}: ${isTimeFormat ? formatTime(entry.value) : entry.value}`)));
43
33
  }
44
34
  return null;
45
35
  };
@@ -52,6 +42,10 @@ CustomTooltipContent.propTypes = {
52
42
  * Additional class names for the dropdown component.
53
43
  */
54
44
  className: PropTypes.string,
45
+ /**
46
+ * The label for the x-axis.
47
+ */
48
+ xLabel: PropTypes.string,
55
49
  /**
56
50
  * Flag on whether it is a timeformat or not
57
51
  */
@@ -60,10 +54,6 @@ CustomTooltipContent.propTypes = {
60
54
  * The type of format for the datetime value
61
55
  */
62
56
  dateFormat: PropTypes.oneOf(Object.values(DATE_FORMATS)),
63
- /**
64
- * Flag on whether the label is a date value or not
65
- */
66
- isDateValue: PropTypes.bool,
67
57
  /**
68
58
  * If set true, the tooltip is displayed.
69
59
  * If set false, the tooltip is hidden, usually calculated internally.
@@ -81,7 +71,6 @@ CustomTooltipContent.propTypes = {
81
71
  };
82
72
  CustomTooltipContent.defaultProps = {
83
73
  isTimeFormat: false,
84
- isDateValue: true,
85
74
  dateFormat: DATE_FORMATS.HUMAN_READABLE
86
75
  };
87
76
  export default CustomTooltipContent;
@@ -2,8 +2,10 @@
2
2
  import * as React from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import styleNames from '@pareto-engineering/bem/exports';
5
- import { snakeCaseToTitleCase } from "../../../../utils";
6
5
  import "./styles.scss";
6
+
7
+ // Local Definitions
8
+
7
9
  const baseClassName = styleNames.base;
8
10
  const componentClassName = 'y-labels-dropdown';
9
11
  const YLabelsDropDown = ({
@@ -44,7 +46,7 @@ const YLabelsDropDown = ({
44
46
  style: {
45
47
  backgroundColor: item.color
46
48
  }
47
- }), snakeCaseToTitleCase(item.label), selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
49
+ }), item.label, selectedYLabels.some(label => label.label === item.label) && /*#__PURE__*/React.createElement("span", {
48
50
  className: "icon checkmark"
49
51
  }, "I")))));
50
52
  };
@@ -81,6 +83,6 @@ YLabelsDropDown.propTypes = {
81
83
  }))
82
84
  };
83
85
  YLabelsDropDown.defaultProps = {
84
- placeholder: 'Select Item'
86
+ placeholder: 'Submission status'
85
87
  };
86
88
  export default YLabelsDropDown;
@@ -1,8 +1,7 @@
1
1
  @use "@pareto-engineering/bem";
2
2
 
3
3
  $default-margin: 1rem;
4
- $default-border: var(--theme-default-input-border);
5
- $default-border-radius: var(--theme-default-input-border-radius);
4
+ $default-border-radius: .25rem;
6
5
  $default-padding: 1rem;
7
6
  $default-width: 15rem;
8
7
  $default-box-shadow: 0 .25rem .75rem var(--ui-lines);
@@ -17,9 +16,9 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
17
16
 
18
17
  .dropdown-button {
19
18
  align-items: center;
20
- background-color: var(--background-far);
21
- border: $default-border;
22
- border-radius: calc($default-border-radius / 2);
19
+ background-color: var(--soft-background-inputs);
20
+ border: none;
21
+ border-radius: $default-border-radius;
23
22
  color: var(--hard-paragraph);
24
23
  cursor: pointer;
25
24
  display: flex;
@@ -54,8 +53,8 @@ $default-checkmark-font-size: calc(var(--s-1) * .75rem);
54
53
 
55
54
  .dropdown-item {
56
55
  align-items: center;
57
- border-radius: calc($default-border-radius / 2);
58
- color: var(--paragraph);
56
+ border-radius: $default-border-radius;
57
+ color: var(--hard-paragraph);
59
58
  cursor: pointer;
60
59
  display: flex;
61
60
  margin: calc($default-margin * .125);
@@ -1,3 +1,2 @@
1
1
  export { AreaChart } from "./AreaChart";
2
- export { BarChart } from "./BarChart";
3
- export { PieChart } from "./PieChart";
2
+ export { BarChart } from "./BarChart";
@@ -28,4 +28,4 @@ export { ToggleSwitch } from "./ToggleSwitch";
28
28
  export { XMLEditor } from "./XMLEditor";
29
29
  export { DatePicker } from "./DatePicker";
30
30
  export { Tooltip } from "./Tooltip";
31
- export { AreaChart, BarChart, PieChart } from "./Charts";
31
+ export { AreaChart, BarChart } from "./Charts";
@@ -57,12 +57,19 @@ const Preview = ({
57
57
  }, type), /*#__PURE__*/React.createElement("span", {
58
58
  title: file.name,
59
59
  className: "name"
60
- }, file.name), isFileBroken ? /*#__PURE__*/React.createElement(Tooltip, {
60
+ }, file.name), isFileBroken ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Tooltip, {
61
61
  description: "bulk-updates-text",
62
62
  content: /*#__PURE__*/React.createElement("p", null, "This file doesn't have a link or the link is invalid.")
63
63
  }, /*#__PURE__*/React.createElement("span", {
64
64
  className: "icon x-ui-icons c-x"
65
- }, "h")) : /*#__PURE__*/React.createElement(Button, {
65
+ }, "h")), writeOnly && /*#__PURE__*/React.createElement(Button, {
66
+ color: "ui-icons",
67
+ isCompact: true,
68
+ isSimple: true,
69
+ onClick: () => handleDelete()
70
+ }, /*#__PURE__*/React.createElement("span", {
71
+ className: "icon"
72
+ }, canDelete ? 'Y' : '9'))) : /*#__PURE__*/React.createElement(Button, {
66
73
  color: "ui-icons",
67
74
  isCompact: true,
68
75
  isSimple: true,
@@ -37,9 +37,6 @@ export const formatTime = seconds => {
37
37
  if (hours > 0) parts.push(`${hours}h`);
38
38
  if (minutes > 0 || hours > 0 && remainingSeconds > 0) parts.push(`${minutes}m`);
39
39
  if (remainingSeconds > 0) parts.push(`${remainingSeconds}s`);
40
-
41
- // Cater for decimal seconds
42
- if (parts.length === 0) return '0s';
43
40
  return parts.join(' ');
44
41
  };
45
42
  const parseDate = input => {
@@ -102,8 +99,4 @@ export const formatDate = (input, format = DATE_FORMATS.HUMAN_READABLE) => {
102
99
  } catch (error) {
103
100
  return 'Invalid Date';
104
101
  }
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
102
  };
@@ -1,2 +1,2 @@
1
1
  export { useWindowSize, useDynamicPosition, useOutsideClick } from "./hooks";
2
- export { formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase } from "./formatting";
2
+ export { formatTime, formatDate, DATE_FORMATS } from "./formatting";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -87,5 +87,5 @@
87
87
  "remark-math": "^6.0.0"
88
88
  },
89
89
  "browserslist": "> 2%",
90
- "gitHead": "af1d9f8a840222f80506834a9ed5402c4465b69a"
90
+ "gitHead": "a9fbff3dbe659640a9ce467be3ef88f3b4f0e4b0"
91
91
  }
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import { AreaChart } from 'ui'
5
5
 
6
6
  export default {
7
- title :'a/Charts/AreaChart',
7
+ title :'a/AreaChart',
8
8
  component:AreaChart,
9
9
  }
10
10
 
@@ -4,7 +4,7 @@ import React from 'react'
4
4
  import { BarChart } from 'ui'
5
5
 
6
6
  export default {
7
- title :'a/Charts/BarChart',
7
+ title :'a/BarChart',
8
8
  component:BarChart,
9
9
  }
10
10
 
@@ -50,6 +50,18 @@ const AreaChart = ({
50
50
 
51
51
  const [selectedYLabels, setSelectedYLabels] = useState(allYLabels)
52
52
 
53
+ const processedData = data.map((item) => {
54
+ const yValues = yKeys.map((key) => item[key])
55
+ const lowerBound = Math.min(...yValues)
56
+ const upperBound = Math.max(...yValues)
57
+ const margin = (upperBound - lowerBound) * 0.1
58
+ return {
59
+ ...item,
60
+ bounds:[lowerBound - margin, upperBound + margin],
61
+ isTimeFormat,
62
+ }
63
+ })
64
+
53
65
  const yAxisBounds = () => {
54
66
  const yValues = data.map((item) => yKeys.map((key) => item[key]))
55
67
  const min = Math.min(...yValues.flat())
@@ -83,7 +95,7 @@ const AreaChart = ({
83
95
  capitalizedLegend={capitalizedLegend}
84
96
  />
85
97
  <ResponsiveContainer width={width} height={height}>
86
- <RechartsAreaChart data={data}>
98
+ <RechartsAreaChart data={processedData}>
87
99
  <CartesianGrid strokeDasharray="3 3" />
88
100
  <XAxis
89
101
  dataKey={xKey}
@@ -114,13 +126,7 @@ const AreaChart = ({
114
126
  return value.toFixed(2)
115
127
  }}
116
128
  />
117
- <Tooltip content={(
118
- <CustomTooltipContent
119
- dateFormat={dateFormat}
120
- isTimeFormat={isTimeFormat}
121
- />
122
- )}
123
- />
129
+ <Tooltip content={<CustomTooltipContent xLabel={xLabel} />} />
124
130
  {filled && (
125
131
  <Area
126
132
  id="bounds"
@@ -38,8 +38,7 @@ const BarChart = ({
38
38
  colors,
39
39
  height,
40
40
  width,
41
- isTimeFormat,
42
- capitalizedLegend,
41
+ // ...otherProps
43
42
  }) => {
44
43
  const allYLabels = yKeys.map((key) => ({
45
44
  label:key,
@@ -70,7 +69,6 @@ const BarChart = ({
70
69
  <CustomLegend
71
70
  colorsArray={selectedYLabels.map((item) => item.color)}
72
71
  yKeysArray={selectedYLabels.map((item) => item.label)}
73
- capitalizedLegend={capitalizedLegend}
74
72
  />
75
73
  <ResponsiveContainer width={width} height={height}>
76
74
  <RechartsBarChart data={data}>
@@ -89,7 +87,7 @@ const BarChart = ({
89
87
  axisLine={false}
90
88
  tickLine={false}
91
89
  />
92
- <Tooltip content={<CustomTooltipContent isTimeFormat={isTimeFormat} />} />
90
+ <Tooltip content={<CustomTooltipContent xLabel={xLabel} />} />
93
91
  {selectedYLabels.map((key) => (
94
92
  <Bar
95
93
  stackId="a"
@@ -4,8 +4,6 @@ import PropTypes from 'prop-types'
4
4
 
5
5
  import styleNames from '@pareto-engineering/bem/exports'
6
6
 
7
- import { snakeCaseToTitleCase } from 'ui/utils'
8
-
9
7
  import './styles.scss'
10
8
 
11
9
  const baseClassName = styleNames.base
@@ -17,44 +15,40 @@ const CustomLegend = ({
17
15
  className: userClassName,
18
16
  colorsArray,
19
17
  yKeysArray,
20
- orientation,
21
- getLegendItemTitle,
22
- getLegendItemSubtitle,
23
18
  capitalizedLegend,
24
- }) => (
25
- <div
26
- id={id}
27
- className={[
28
- baseClassName,
29
- componentClassName,
30
- userClassName,
31
- orientation,
32
- ]
33
- .filter((e) => e)
34
- .join(' ')}
35
- >
36
- {yKeysArray.map((key, index) => (
37
- <div key={key} className="item">
38
- <div className="title">
19
+ }) => {
20
+ const capitalizeWord = (word) => {
21
+ if (!capitalizedLegend) return word
22
+ const wordsToCapitalize = ['average', 'best', 'worst']
23
+ return word.split(' ').map((part) => (wordsToCapitalize.includes(part.toLowerCase())
24
+ ? part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()
25
+ : part),
26
+ ).join(' ')
27
+ }
28
+
29
+ return (
30
+ <div
31
+ id={id}
32
+ className={[
33
+ baseClassName,
34
+ componentClassName,
35
+ userClassName,
36
+ ]
37
+ .filter((e) => e)
38
+ .join(' ')}
39
+ >
40
+ {yKeysArray.map((key, index) => (
41
+ <div key={key} className="item">
39
42
  <span
40
43
  className="dot"
41
44
  style={{ backgroundColor: colorsArray[index] }}
42
45
  />
43
- <span className="text">
44
- {
45
- capitalizedLegend
46
- ? snakeCaseToTitleCase(getLegendItemTitle(key))
47
- : getLegendItemTitle(key)
48
- }
49
- </span>
46
+ <span className="text">{capitalizeWord(key)}</span>
50
47
  </div>
51
- <span className="sub-title">
52
- {getLegendItemSubtitle(key)}
53
- </span>
54
- </div>
55
- ))}
56
- </div>
57
- )
48
+ ))}
49
+ </div>
50
+ )
51
+ }
58
52
 
59
53
  CustomLegend.propTypes = {
60
54
  /**
@@ -77,21 +71,6 @@ CustomLegend.propTypes = {
77
71
  */
78
72
  yKeysArray:PropTypes.arrayOf(PropTypes.string).isRequired,
79
73
 
80
- /**
81
- * The orientation of the Legend
82
- */
83
- orientation:PropTypes.oneOf(['vertical', 'horizontal']),
84
-
85
- /**
86
- * The function to get the legendItemKey
87
- */
88
- getLegendItemTitle:PropTypes.func,
89
-
90
- /**
91
- * The function to get legend children
92
- */
93
- getLegendItemSubtitle:PropTypes.func,
94
-
95
74
  /**
96
75
  * Flag on whether to capitalize legend keys
97
76
  */
@@ -99,11 +78,7 @@ CustomLegend.propTypes = {
99
78
  }
100
79
 
101
80
  CustomLegend.defaultProps = {
102
- orientation :'horizontal',
103
- getLegendItemTitle :(key) => key,
104
- /* eslint-disable no-unused-vars */
105
- getLegendItemSubtitle:() => {},
106
- capitalizedLegend :false,
81
+ capitalizedLegend:false,
107
82
  }
108
83
 
109
84
  export default CustomLegend
@@ -1,7 +1,6 @@
1
1
  @use "@pareto-engineering/bem";
2
2
 
3
3
  $default-padding: 1rem;
4
- $default-margin: 1rem;
5
4
  $default-text-font-size: calc(var(--s-1) * 1rem);
6
5
  $default-border-radius: .25rem;
7
6
  $default-legend-gap: .625rem;
@@ -9,59 +8,33 @@ $default-legend-padding: calc($default-padding * .125) calc($default-padding * .
9
8
  $default-legend-dot-width: .5rem;
10
9
  $default-legend-dot-height: .5rem;
11
10
  $default-legend-dot-margin-right: .3125rem;
12
- $default-box-shadow: 0 4px 16px 0 var(--soft-shadow);
13
11
 
14
12
  .#{bem.$base} {
15
13
  &.custom-legend {
14
+ display: flex;
16
15
  gap: $default-legend-gap;
17
16
  justify-content: flex-end;
18
17
  padding-bottom: $default-padding;
19
18
  padding-right: calc($default-padding * .25);
20
19
 
21
- &.vertical {
22
- display: block;
23
- margin-right: calc($default-margin * 2);
24
- min-width: fit-content;
25
-
26
- .item {
27
- box-shadow: $default-box-shadow;
28
- padding-top: $default-padding;
29
- }
30
- }
31
-
32
- &.horizontal {
33
- display: flex;
34
- }
35
-
36
20
  .item {
21
+ align-items: center;
37
22
  border-radius: $default-border-radius;
23
+ display: flex;
38
24
  padding: $default-legend-padding;
25
+ }
39
26
 
40
- .title {
41
- align-items: center;
42
- display: flex;
43
-
44
- .dot {
45
- border-radius: 50%;
46
- display: inline-block;
47
- height: $default-legend-dot-height;
48
- margin-right: $default-legend-dot-margin-right;
49
- width: $default-legend-dot-width;
50
- }
51
-
52
- .text {
53
- color: var(--paragraph);
54
- font-size: calc($default-text-font-size * .75);
55
- }
56
- }
27
+ .dot {
28
+ border-radius: 50%;
29
+ display: inline-block;
30
+ height: $default-legend-dot-height;
31
+ margin-right: $default-legend-dot-margin-right;
32
+ width: $default-legend-dot-width;
33
+ }
57
34
 
58
- .sub-title {
59
- color: var(--heading);
60
- display: flex;
61
- font-size: calc($default-text-font-size * 1.2);
62
- font-weight: 500;
63
- justify-content: flex-end;
64
- }
35
+ .text {
36
+ color: var(--paragraph);
37
+ font-size: calc($default-text-font-size * .75);
65
38
  }
66
39
  }
67
40
  }
@@ -4,9 +4,7 @@ import PropTypes from 'prop-types'
4
4
 
5
5
  import styleNames from '@pareto-engineering/bem/exports'
6
6
 
7
- import {
8
- formatTime, formatDate, DATE_FORMATS, snakeCaseToTitleCase,
9
- } from 'ui/utils'
7
+ import { formatTime, formatDate, DATE_FORMATS } from 'ui/utils'
10
8
 
11
9
  import './styles.scss'
12
10
 
@@ -17,26 +15,13 @@ const componentClassName = 'custom-tooltip-content'
17
15
  const CustomTooltipContent = ({
18
16
  id,
19
17
  className: userClassName,
18
+ xLabel,
20
19
  dateFormat,
21
20
  isTimeFormat,
22
- isDateValue,
23
21
  active,
24
22
  payload,
25
23
  label,
26
24
  }) => {
27
- const formatLabelValue = (value) => {
28
- if (isTimeFormat) {
29
- return formatTime(value)
30
- }
31
-
32
- if (typeof value === 'number') {
33
- if (Number.isInteger(value)) return value
34
- return value.toFixed(2)
35
- }
36
-
37
- return value
38
- }
39
-
40
25
  if (active && payload && payload.length) {
41
26
  const newPayload = payload.filter((item) => item.name !== 'bounds')
42
27
  return (
@@ -51,11 +36,15 @@ const CustomTooltipContent = ({
51
36
  .join(' ')}
52
37
  >
53
38
  <p className="label">
54
- {isDateValue ? formatDate(label, dateFormat) : label}
39
+ {`${xLabel}: ${formatDate(label, dateFormat)}`}
55
40
  </p>
56
41
  {newPayload.map((entry) => (
57
42
  <p className="label" key={`${entry.name}`} style={{ color: entry.color, textTransform: 'capitalize' }}>
58
- {`${snakeCaseToTitleCase(entry.name)}: ${formatLabelValue(entry.value)}`}
43
+ {`${entry.name}: ${
44
+ isTimeFormat
45
+ ? formatTime(entry.value)
46
+ : entry.value
47
+ }`}
59
48
  </p>
60
49
  ))}
61
50
  </div>
@@ -75,6 +64,11 @@ CustomTooltipContent.propTypes = {
75
64
  */
76
65
  className:PropTypes.string,
77
66
 
67
+ /**
68
+ * The label for the x-axis.
69
+ */
70
+ xLabel:PropTypes.string,
71
+
78
72
  /**
79
73
  * Flag on whether it is a timeformat or not
80
74
  */
@@ -85,11 +79,6 @@ CustomTooltipContent.propTypes = {
85
79
  */
86
80
  dateFormat:PropTypes.oneOf(Object.values(DATE_FORMATS)),
87
81
 
88
- /**
89
- * Flag on whether the label is a date value or not
90
- */
91
- isDateValue:PropTypes.bool,
92
-
93
82
  /**
94
83
  * If set true, the tooltip is displayed.
95
84
  * If set false, the tooltip is hidden, usually calculated internally.
@@ -110,7 +99,6 @@ CustomTooltipContent.propTypes = {
110
99
 
111
100
  CustomTooltipContent.defaultProps = {
112
101
  isTimeFormat:false,
113
- isDateValue :true,
114
102
  dateFormat :DATE_FORMATS.HUMAN_READABLE,
115
103
  }
116
104