@scality/core-ui 0.166.0 → 0.168.0

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 (119) hide show
  1. package/.storybook/preview.js +6 -4
  2. package/README.md +27 -80
  3. package/dist/components/barchart/BarChart.component.d.ts +5 -0
  4. package/dist/components/barchart/BarChart.component.d.ts.map +1 -1
  5. package/dist/components/barchart/BarChart.component.js +5 -0
  6. package/dist/components/barchartv2/Barchart.component.d.ts +5 -1
  7. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
  8. package/dist/components/barchartv2/Barchart.component.js +6 -2
  9. package/dist/components/barchartv2/utils.js +2 -2
  10. package/dist/components/button/Button.component.d.ts +2 -1
  11. package/dist/components/button/Button.component.d.ts.map +1 -1
  12. package/dist/components/button/Button.component.js +2 -1
  13. package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -1
  14. package/dist/components/chartlegend/ChartLegend.js +7 -13
  15. package/dist/components/chartlegend/ChartLegendWrapper.d.ts +1 -2
  16. package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -1
  17. package/dist/components/chartlegend/ChartLegendWrapper.js +4 -9
  18. package/dist/components/date/FormattedDateTime.d.ts +6 -1
  19. package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
  20. package/dist/components/date/FormattedDateTime.js +11 -0
  21. package/dist/components/icon/Icon.component.d.ts +9 -11
  22. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  23. package/dist/components/icon/Icon.component.js +2 -0
  24. package/dist/components/linetemporalchart/ChartUtil.d.ts +3 -2
  25. package/dist/components/linetemporalchart/ChartUtil.d.ts.map +1 -1
  26. package/dist/components/linetemporalchart/ChartUtil.js +30 -20
  27. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +4 -0
  28. package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +1 -1
  29. package/dist/components/linetemporalchart/LineTemporalChart.component.js +4 -0
  30. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +8 -2
  31. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
  32. package/dist/components/linetimeseriechart/linetimeseriechart.component.js +17 -11
  33. package/dist/index.d.ts +1 -11
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +0 -11
  36. package/dist/next.d.ts +1 -0
  37. package/dist/next.d.ts.map +1 -1
  38. package/jest.config.js +1 -0
  39. package/package.json +16 -37
  40. package/src/lib/components/barchart/BarChart.component.tsx +5 -0
  41. package/src/lib/components/barchartv2/Barchart.component.test.tsx +11 -7
  42. package/src/lib/components/barchartv2/Barchart.component.tsx +15 -3
  43. package/src/lib/components/barchartv2/utils.test.ts +2 -2
  44. package/src/lib/components/barchartv2/utils.ts +2 -2
  45. package/src/lib/components/button/Button.component.tsx +2 -1
  46. package/src/lib/components/chartlegend/ChartLegend.test.tsx +17 -0
  47. package/src/lib/components/chartlegend/ChartLegend.tsx +6 -12
  48. package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +5 -13
  49. package/src/lib/components/date/FormattedDateTime.tsx +14 -1
  50. package/src/lib/components/icon/Icon.component.tsx +12 -1
  51. package/src/lib/components/linetemporalchart/ChartUtil.test.ts +23 -35
  52. package/src/lib/components/linetemporalchart/ChartUtil.ts +38 -26
  53. package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +19 -15
  54. package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +36 -13
  55. package/src/lib/components/linetimeseriechart/linetimeseriechart.test.tsx +68 -0
  56. package/src/lib/components/selectv2/selectv2.test.tsx +1 -1
  57. package/src/lib/components/toast/useMutationsHandler.test.tsx +22 -32
  58. package/src/lib/index.ts +6 -11
  59. package/src/lib/next.ts +1 -0
  60. package/stories/BarChart/barchart.stories.tsx +108 -13
  61. package/stories/barchart.stories.tsx +1 -1
  62. package/stories/card.stories.tsx +7 -5
  63. package/stories/controls.ts +19 -20
  64. package/stories/linecharttemporal.stories.tsx +1 -1
  65. package/stories/linetimeseriechart.stories.tsx +146 -0
  66. package/stories/navbar.stories.tsx +103 -0
  67. package/stories/tabsv2.stories.tsx +51 -56
  68. package/dist/components/areachart/AreaChart.component.d.ts +0 -13
  69. package/dist/components/areachart/AreaChart.component.d.ts.map +0 -1
  70. package/dist/components/areachart/AreaChart.component.js +0 -27
  71. package/dist/components/chips/Chips.component.d.ts +0 -21
  72. package/dist/components/chips/Chips.component.d.ts.map +0 -1
  73. package/dist/components/chips/Chips.component.js +0 -105
  74. package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts +0 -10
  75. package/dist/components/cloudprogressbar/CloudProgressBar.component.d.ts.map +0 -1
  76. package/dist/components/cloudprogressbar/CloudProgressBar.component.js +0 -38
  77. package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts +0 -9
  78. package/dist/components/collapsiblepanel/CollapsiblePanel.component.d.ts.map +0 -1
  79. package/dist/components/collapsiblepanel/CollapsiblePanel.component.js +0 -44
  80. package/dist/components/linechart/LineChart.component.d.ts +0 -21
  81. package/dist/components/linechart/LineChart.component.d.ts.map +0 -1
  82. package/dist/components/linechart/LineChart.component.js +0 -109
  83. package/dist/components/multiselect/MultiSelect.component.d.ts +0 -28
  84. package/dist/components/multiselect/MultiSelect.component.d.ts.map +0 -1
  85. package/dist/components/multiselect/MultiSelect.component.js +0 -73
  86. package/dist/components/select/Select.component.d.ts +0 -14
  87. package/dist/components/select/Select.component.d.ts.map +0 -1
  88. package/dist/components/select/Select.component.js +0 -71
  89. package/dist/components/spacedbox/SpacedBox.d.ts +0 -34
  90. package/dist/components/spacedbox/SpacedBox.d.ts.map +0 -1
  91. package/dist/components/spacedbox/SpacedBox.js +0 -64
  92. package/dist/components/sparkline/SparkLine.component.d.ts +0 -18
  93. package/dist/components/sparkline/SparkLine.component.d.ts.map +0 -1
  94. package/dist/components/sparkline/SparkLine.component.js +0 -148
  95. package/dist/components/vegachart/VegaChart.component.d.ts +0 -13
  96. package/dist/components/vegachart/VegaChart.component.d.ts.map +0 -1
  97. package/dist/components/vegachart/VegaChart.component.js +0 -120
  98. package/plopfile.js +0 -38
  99. package/src/lib/components/areachart/AreaChart.component.tsx +0 -49
  100. package/src/lib/components/chips/Chips.component.tsx +0 -169
  101. package/src/lib/components/cloudprogressbar/CloudProgressBar.component.tsx +0 -105
  102. package/src/lib/components/collapsiblepanel/CollapsiblePanel.component.tsx +0 -77
  103. package/src/lib/components/linechart/LineChart.component.tsx +0 -152
  104. package/src/lib/components/multiselect/MultiSelect.component.tsx +0 -158
  105. package/src/lib/components/select/Select.component.tsx +0 -98
  106. package/src/lib/components/spacedbox/SpacedBox.ts +0 -116
  107. package/src/lib/components/sparkline/SparkLine.component.tsx +0 -176
  108. package/src/lib/components/vegachart/VegaChart.component.tsx +0 -146
  109. package/stories/areachart.stories.tsx +0 -120
  110. package/stories/chips.stories.tsx +0 -107
  111. package/stories/cloudprogressbar.stories.tsx +0 -93
  112. package/stories/collapsiblepanel.stories.tsx +0 -57
  113. package/stories/data/areachart.ts +0 -122
  114. package/stories/data/sparklinechart.ts +0 -164
  115. package/stories/linechart.stories.tsx +0 -319
  116. package/stories/multiselect.stories.tsx +0 -126
  117. package/stories/select.stories.tsx +0 -52
  118. package/stories/sparkline.stories.tsx +0 -85
  119. package/stories/vegachart.stories.tsx +0 -98
@@ -1,120 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // @ts-nocheck
3
- import { useEffect, useContext, useRef } from 'react';
4
- import vegaEmbed from 'vega-embed';
5
- import { ThemeContext, createGlobalStyle } from 'styled-components';
6
- import { getThemePropSelector } from '../../utils';
7
- export const TOP = 'top';
8
- export const BOTTOM = 'bottom';
9
- /* How to theme tooltip:
10
- https://github.com/vega/vega-tooltip/blob/master/docs/customizing_your_tooltip.md
11
- */
12
- const VegaTooltipTheme = createGlobalStyle `
13
- #vg-tooltip-element.vg-tooltip.custom-theme {
14
- padding: 8px;
15
- position: fixed;
16
- z-index: 1000;
17
- font-family: 'Lato';
18
- font-size: 12px;
19
- border-radius: 3px;
20
- box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
21
- color: ${getThemePropSelector('textPrimary')};
22
- background-color: ${getThemePropSelector('backgroundLevel1')};
23
- border: 1px solid ${getThemePropSelector('border')};
24
- // customize the title
25
- h2 {
26
- color: ${getThemePropSelector('textSecondary')};
27
- margin-bottom: 10px;
28
- font-size: 12px;
29
- }
30
- }
31
- `;
32
- function VegaChart({ id, spec, tooltipPosition = BOTTOM, theme = 'custom', }) {
33
- const themeContext = useContext(ThemeContext);
34
- const currentBackgroundColor = themeContext && themeContext.brand
35
- ? themeContext.brand.backgroundLevel4
36
- : themeContext.backgroundLevel4;
37
- // the background color of the view
38
- const currentBackgroundColor2 = themeContext && themeContext.brand
39
- ? themeContext.brand.backgroundLevel1
40
- : themeContext.backgroundLevel1;
41
- const brandText = themeContext && themeContext.brand
42
- ? themeContext.brand.textPrimary
43
- : themeContext.textPrimary;
44
- const themeConfig = {
45
- config: {
46
- background: currentBackgroundColor,
47
- axis: {
48
- labelColor: brandText,
49
- titleColor: brandText,
50
- grid: false,
51
- domainColor: currentBackgroundColor2,
52
- },
53
- title: {
54
- color: brandText,
55
- font: 'Lato',
56
- },
57
- view: {
58
- stroke: 'transparent',
59
- fill: currentBackgroundColor2,
60
- },
61
- // the headers provide a title and labels for faceted plots.
62
- header: {
63
- labelColor: brandText,
64
- },
65
- // the label of max/min
66
- text: {
67
- color: brandText,
68
- font: 'Lato',
69
- },
70
- // the up, bottom trend line and verticle line when hover
71
- rule: {
72
- color: brandText,
73
- },
74
- legend: {
75
- labelColor: brandText,
76
- titleColor: brandText,
77
- },
78
- },
79
- };
80
- const themedSpec = { ...spec, ...themeConfig };
81
- const vegaInstance = useRef();
82
- let tooltipOptions = {
83
- theme: theme,
84
- };
85
- if (tooltipPosition === TOP) {
86
- tooltipOptions = {
87
- theme: theme,
88
- offsetX: -85,
89
- offsetY: -140,
90
- };
91
- }
92
- useEffect(() => {
93
- let isMounted = true;
94
- vegaEmbed(`#${id}`, themedSpec, {
95
- renderer: 'svg',
96
- // Override the DEFAULT_OPTIONS https://github.com/vega/vega-tooltip/blob/master/src/defaults.ts
97
- tooltip: tooltipOptions,
98
- /* Determines if action links
99
- ("Export as PNG/SVG", "View Source", "View Vega" (only for Vega-Lite), "Open in Vega Editor") are included with the embedded view.
100
- If the value is true, all action links will be shown and none if the value is false. */
101
- actions: false,
102
- })
103
- .then((result) => {
104
- vegaInstance.current = result; // result.view contains the Vega view
105
- })
106
- .catch((...args) => {
107
- if (isMounted) {
108
- console.error(...args); // TODO: we should handle this with a retry or an error state of the component
109
- }
110
- });
111
- return () => {
112
- isMounted = false;
113
- if (vegaInstance.current) {
114
- vegaInstance.current.view.finalize();
115
- }
116
- };
117
- }, [id, themedSpec, tooltipOptions, vegaInstance]);
118
- return (_jsx("div", { id: id, className: "sc-vegachart", children: _jsx(VegaTooltipTheme, {}) }));
119
- }
120
- export { VegaChart };
package/plopfile.js DELETED
@@ -1,38 +0,0 @@
1
- module.exports = function (plop) {
2
- plop.addHelper('lowerCase', (text) => text.toLowerCase());
3
- plop.addHelper('properCase', (text) =>
4
- text.replace(/\w\S*/g, function (txt) {
5
- return txt.charAt(0).toUpperCase() + txt.substr(1);
6
- }),
7
- );
8
-
9
- plop.setGenerator('component', {
10
- description: 'Add a react component',
11
- prompts: [
12
- {
13
- type: 'input',
14
- name: 'name',
15
- message: 'Component name please (ex: layout, breadcrumbs, menuItem)!',
16
- },
17
- ],
18
- actions: [
19
- {
20
- type: 'add',
21
- path:
22
- 'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.js',
23
- templateFile: 'plop-templates/component.hbs',
24
- },
25
- {
26
- type: 'add',
27
- path:
28
- 'src/lib/components/{{lowerCase name}}/{{properCase name}}.component.test.js',
29
- templateFile: 'plop-templates/component.test.hbs',
30
- },
31
- {
32
- type: 'add',
33
- path: 'stories/{{lowerCase name}}.stories.js',
34
- templateFile: 'plop-templates/stories.hbs',
35
- },
36
- ],
37
- });
38
- };
@@ -1,49 +0,0 @@
1
- import { VegaChart } from '../vegachart/VegaChart.component';
2
-
3
- type Props = {
4
- id: string;
5
- data: Array<Record<string, any>>;
6
- xAxis: Record<string, any>;
7
- yAxis: Array<Record<string, any>>;
8
- color?: Record<string, any>;
9
- areas: Array<Record<string, any>>;
10
- width?: number;
11
- height?: number;
12
- };
13
-
14
- function AreaChart({
15
- id,
16
- data,
17
- xAxis,
18
- yAxis,
19
- color,
20
- height = 300,
21
- width = 1000,
22
- areas = [],
23
- ...rest
24
- }: Props) {
25
- const lines = yAxis.map((y) => ({
26
- mark: {
27
- type: 'line',
28
- },
29
- encoding: {
30
- y,
31
- },
32
- }));
33
- const spec = {
34
- data: {
35
- values: data,
36
- },
37
- encoding: {
38
- x: xAxis,
39
- color,
40
- },
41
- layer: [...lines, ...areas],
42
- height,
43
- width,
44
- ...rest,
45
- };
46
- return <VegaChart className="sc-areachart" id={id} spec={spec}></VegaChart>;
47
- }
48
-
49
- export { AreaChart };
@@ -1,169 +0,0 @@
1
- import { lighten } from 'polished';
2
- import styled, { css } from 'styled-components';
3
- import { fontSize, grayLight, white } from '../../style/theme';
4
- import { Button } from '../button/Button.component';
5
- import { Size } from '../constants';
6
-
7
- import { Icon } from '../icon/Icon.component';
8
- type Props = {
9
- text: string;
10
- variant?:
11
- | 'statusHealthy'
12
- | 'statusWarning'
13
- | 'statusCritical'
14
- | 'infoPrimary'
15
- | 'infoSecondary';
16
- icon?: JSX.Element;
17
- onClick?: (arg0: any) => void;
18
- onRemove?: (arg0: any) => void;
19
- size?: Size;
20
- };
21
- const ChipsContainer = styled.div<{
22
- size?: string;
23
- variant?: any;
24
- icon?: JSX.Element;
25
- }>`
26
- display: inline-flex;
27
- .sc-chips-remove {
28
- padding-right: 10px;
29
- color: ${white};
30
- &:hover {
31
- color: ${grayLight};
32
- }
33
- }
34
- ${(props) => {
35
- switch (props.size) {
36
- case 'smaller':
37
- return css`
38
- border-radius: 10px;
39
- .sc-chips-icon {
40
- border-radius: 10px;
41
- padding: 5px;
42
- }
43
- `;
44
-
45
- case 'small':
46
- return css`
47
- border-radius: 12px;
48
- .sc-chips-icon {
49
- border-radius: 12px;
50
- padding: 6px;
51
- }
52
- `;
53
-
54
- case 'large':
55
- return css`
56
- border-radius: 14px;
57
- .sc-chips-icon {
58
- border-radius: 14px;
59
- padding: 6px;
60
- }
61
- `;
62
-
63
- case 'larger':
64
- return css`
65
- border-radius: 17px;
66
- .sc-chips-icon {
67
- border-radius: 17px;
68
- padding: 7px;
69
- }
70
- `;
71
-
72
- default:
73
- return css`
74
- border-radius: 12px;
75
- .sc-chips-icon {
76
- border-radius: 12px;
77
- padding: 6px;
78
- }
79
- `;
80
- }
81
- }}
82
- ${(props) => {
83
- const brand = props.theme;
84
- return css`
85
- color: ${brand.textReverse};
86
- `;
87
- }}
88
-
89
- ${(props) => {
90
- const brand = props.theme;
91
- const brandLight = lighten(0.1, brand[props.variant]).toString();
92
- return props.onClick
93
- ? css`
94
- background-color: ${brand[props.variant]};
95
- font-size: ${fontSize[props.size || 'base']};
96
- &:hover {
97
- cursor: pointer;
98
- background-color: ${brandLight};
99
- }
100
- &:active {
101
- background-color: ${brand[props.variant]};
102
- }
103
- `
104
- : css`
105
- background-color: ${brand[props.variant]};
106
- font-size: ${fontSize[props.size || 'base']};
107
- `;
108
- }}
109
- `;
110
- export const ChipsIcon = styled.span<{
111
- variant: any;
112
- text: string;
113
- size: Size;
114
- }>`
115
- display: inline-flex;
116
- justify-content: center;
117
- align-items: center;
118
- background-color: ${(props) =>
119
- lighten(0.15, props.theme[props.variant]).toString()};
120
- `;
121
- export const ChipsText = styled.span<{ icon: any; isRemovable: boolean }>`
122
- display: inline-flex;
123
- justify-content: center;
124
- align-items: center;
125
- padding: ${(props) => (props.icon || props.isRemovable ? '5px' : '5px 10px')};
126
- `;
127
-
128
- const Chips = ({
129
- text = '',
130
- variant = 'infoPrimary',
131
- icon = undefined,
132
- onClick,
133
- onRemove,
134
- size = 'base',
135
- }: Props) => (
136
- <ChipsContainer
137
- className="sc-chips"
138
- onClick={onClick}
139
- variant={variant}
140
- icon={icon}
141
- size={size}
142
- >
143
- {icon && (
144
- <ChipsIcon
145
- className="sc-chips-icon"
146
- text={text}
147
- variant={variant}
148
- size={size}
149
- >
150
- {icon}
151
- </ChipsIcon>
152
- )}
153
- <ChipsText className="sc-chips-text" icon={icon} isRemovable={!!onRemove}>
154
- {text}
155
- </ChipsText>
156
- {onRemove && (
157
- <Button
158
- // @ts-ignore
159
- className="sc-chips-remove"
160
- size={size}
161
- inverted={true}
162
- icon={<Icon name="Close" />}
163
- onClick={onRemove}
164
- />
165
- )}
166
- </ChipsContainer>
167
- );
168
-
169
- export { Chips };
@@ -1,105 +0,0 @@
1
- import styled, { css, keyframes } from 'styled-components';
2
- import { coreUIAvailableThemes } from '../../style/theme';
3
- export type CloudProgressBarProps = {
4
- percentage: number;
5
- borderSize: string;
6
- cloudColor?: string;
7
- progressCloudColor?: string;
8
- children: JSX.Element;
9
- };
10
-
11
- const keyFrameCloud = (props) => {
12
- return keyframes`
13
- from {
14
- height:100%
15
- }
16
- to {
17
- height:${100 - props.percentage}%
18
- }`;
19
- };
20
-
21
- const Container = styled.div`
22
- ${(props) => {
23
- return css`
24
- text-align: center;
25
- position: relative;
26
- `;
27
- }}
28
- `;
29
- const ContainerProgress = styled.div<{ percentage: number }>`
30
- ${(props) => {
31
- return css`
32
- animation-duration: 1s;
33
- animation-fill-mode: both;
34
- animation-name: ${keyFrameCloud};
35
- position: absolute;
36
- top: 0;
37
- left: 0;
38
- width: 100%;
39
- overflow: hidden;
40
- `;
41
- }}
42
- `;
43
-
44
- const Cloud = ({ strokeColor, borderSize }) => (
45
- <svg
46
- xmlns="http://www.w3.org/2000/svg"
47
- viewBox="0 15 72 42"
48
- enableBackground="new 0 0 72 72"
49
- >
50
- <g>
51
- <path
52
- fill="none"
53
- stroke={strokeColor}
54
- strokeWidth={borderSize}
55
- strokeLinecap="round"
56
- strokeLinejoin="round"
57
- strokeMiterlimit="10"
58
- d="M15.9,30.3c0,0.4-0.4,0.8-0.8,0.8C10,31.6,6,36.7,6,42.9c0,6.6,4.5,11.9,10.2,11.9h38.7C61,54.8,66,49.1,66,42.2c0-6.6-4.6-12.1-10.4-12.5c-0.4,0-0.8-0.3-0.9-0.8c-1.3-6.7-7.3-11.7-14.3-11.7c-4.6,0-8.7,2.1-11.3,5.4C28.8,23,28.3,23.1,28,23c-1-0.4-2.1-0.6-3.3-0.6C20.1,22.3,16.3,25.8,15.9,30.3z"
59
- />
60
- </g>
61
- </svg>
62
- );
63
-
64
- const CloudProgress = ({ strokeColor, percentage, borderSize }) => (
65
- <ContainerProgress percentage={percentage}>
66
- <svg
67
- xmlns="http://www.w3.org/2000/svg"
68
- viewBox="0 15 72 42"
69
- enableBackground="new 0 0 72 72"
70
- >
71
- <g>
72
- <path
73
- fill="none"
74
- stroke={strokeColor}
75
- strokeWidth={borderSize}
76
- strokeLinecap="round"
77
- strokeLinejoin="round"
78
- strokeMiterlimit="10"
79
- d="M15.9,30.3c0,0.4-0.4,0.8-0.8,0.8C10,31.6,6,36.7,6,42.9c0,6.6,4.5,11.9,10.2,11.9h38.7C61,54.8,66,49.1,66,42.2c0-6.6-4.6-12.1-10.4-12.5c-0.4,0-0.8-0.3-0.9-0.8c-1.3-6.7-7.3-11.7-14.3-11.7c-4.6,0-8.7,2.1-11.3,5.4C28.8,23,28.3,23.1,28,23c-1-0.4-2.1-0.6-3.3-0.6C20.1,22.3,16.3,25.8,15.9,30.3z"
80
- />
81
- </g>
82
- </svg>
83
- </ContainerProgress>
84
- );
85
-
86
- const CloudProgressBar = ({
87
- percentage = 0,
88
- borderSize = '2px',
89
- cloudColor = coreUIAvailableThemes.darkRebrand.statusHealthy,
90
- progressCloudColor = coreUIAvailableThemes.darkRebrand.backgroundLevel1,
91
- children,
92
- }: CloudProgressBarProps) => (
93
- <Container className="sc-cloudprogressbar">
94
- <Cloud strokeColor={progressCloudColor} borderSize={borderSize} />
95
- <CloudProgress
96
- strokeColor={cloudColor}
97
- percentage={percentage}
98
- borderSize={borderSize}
99
- />
100
-
101
- {children}
102
- </Container>
103
- );
104
-
105
- export { CloudProgressBar };
@@ -1,77 +0,0 @@
1
- import styled from 'styled-components';
2
- import { spacing } from '../../spacing';
3
- import { fontSize } from '../../style/theme';
4
- import { Icon } from '../icon/Icon.component';
5
- type Props = {
6
- expanded: boolean;
7
- onHeaderClick: (arg0: any) => void;
8
- children: React.ReactNode;
9
- headerItems: Array<JSX.Element>;
10
- };
11
- const ARROW = {
12
- colapsed: 'fas fa-angle-down',
13
- expanded: 'fas fa-angle-up',
14
- };
15
- const HeaderText = styled.div`
16
- display: flex;
17
- align-items: center;
18
- flex-grow: 1;
19
- `;
20
- const HeaderItem = styled.div`
21
- margin-right: ${spacing.r16};
22
- display: flex;
23
- flex-grow: 1;
24
- `;
25
- const HeaderIcon = styled.div`
26
- font-size: ${fontSize.larger};
27
- margin: 0 ${spacing.r16};
28
- `;
29
- const CollapsiblePanelContainer = styled.div`
30
- display: flex;
31
- flex-direction: column;
32
- border-radius: 4px;
33
- background-color: ${(props) => props.theme.backgroundLevel1};
34
- color: ${(props) => props.theme.textPrimary};
35
- `;
36
- const HeaderContainer = styled.div`
37
- display: flex;
38
- cursor: pointer;
39
- padding: ${spacing.r16};
40
- `;
41
- const ExpandedContainer = styled.div`
42
- padding: ${spacing.r16};
43
- color: ${(props) => props.theme.textPrimary};
44
- background-color: ${(props) => props.theme.backgroundLevel1};
45
- `;
46
-
47
- function CollapsiblePanel({
48
- expanded = false,
49
- onHeaderClick,
50
- children,
51
- headerItems = [],
52
- }: Props) {
53
- return (
54
- <CollapsiblePanelContainer className="sc-collapsiblepanel">
55
- <HeaderContainer
56
- onClick={onHeaderClick}
57
- className="sc-collapsiblepanel-header"
58
- >
59
- <HeaderText>
60
- {headerItems.map((item, index) => (
61
- <HeaderItem key={index}>{item}</HeaderItem>
62
- ))}
63
- </HeaderText>
64
- <HeaderIcon>
65
- <Icon name={expanded ? 'Dropdown-up' : 'Dropdown-down'} />
66
- </HeaderIcon>
67
- </HeaderContainer>
68
- {expanded && (
69
- <ExpandedContainer className="sc-collapsiblepanel-content">
70
- {children}
71
- </ExpandedContainer>
72
- )}
73
- </CollapsiblePanelContainer>
74
- );
75
- }
76
-
77
- export { CollapsiblePanel };
@@ -1,152 +0,0 @@
1
- // @ts-nocheck
2
- import { $PropertyType } from 'utility-types';
3
- import { VegaChart } from '../vegachart/VegaChart.component';
4
- import type { Encoding, Field } from 'vega-lite';
5
- type Props = {
6
- id: string;
7
- data: Array<Record<string, any>>;
8
- xAxis: Record<string, any>;
9
- yAxis: Array<Record<string, any>>;
10
- color?: Record<string, any>;
11
- tooltip?: boolean;
12
- lineConfig?: Record<string, any>;
13
- width?: number;
14
- height?: number;
15
- displayTrendLine?: boolean;
16
- strokeDashEncodingConfig?: $PropertyType<Encoding<Field>, 'strokeDash'>;
17
- opacityEncodingConfig?: $PropertyType<Encoding<Field>, 'opacity'>;
18
- tooltipConfig?: $PropertyType<Encoding<Field>, 'tooltip'>;
19
- tooltipTheme?: 'light' | 'dark' | 'custom';
20
- };
21
-
22
- function LineChart({
23
- id,
24
- data,
25
- xAxis,
26
- yAxis,
27
- color,
28
- tooltip = false,
29
- lineConfig,
30
- height = 300,
31
- width = 1000,
32
- displayTrendLine = false,
33
- strokeDashEncodingConfig,
34
- opacityEncodingConfig,
35
- tooltipConfig,
36
- tooltipTheme,
37
- ...rest
38
- }: Props) {
39
- // hardcode the trendline configuration for tooltip
40
- const trendline = {
41
- mark: 'rule',
42
- selection: {
43
- index: {
44
- type: 'single',
45
- on: 'mousemove',
46
- encodings: ['x'],
47
- nearest: true,
48
- },
49
- },
50
- encoding: {
51
- color: {
52
- condition: {
53
- selection: {
54
- not: 'index',
55
- },
56
- value: 'transparent',
57
- },
58
- },
59
- },
60
- };
61
-
62
- /*
63
- ** strokeDash encoding allows to define a field in data items that defines the line stroke dash property
64
- ** this would allow to get same color lines but having some dashed and some plains
65
- ** https://vega.github.io/vega-lite/docs/line.html#multi-series-line-chart-with-varying-dashes
66
- */
67
-
68
- /*
69
- ** opacity Encoding allows to define rules for each line's opacity
70
- */
71
- const lines = yAxis.map((y) => ({
72
- mark: {
73
- type: 'line',
74
- ...lineConfig,
75
- },
76
- encoding: {
77
- y,
78
- strokeDash: strokeDashEncodingConfig,
79
- opacity: opacityEncodingConfig,
80
- },
81
- }));
82
- const currentTimeTrendline = {
83
- mark: {
84
- type: 'rule',
85
- style: 'ruleCurrentTime',
86
- color: 'white',
87
- opacity: 0.2,
88
- },
89
- encoding: {
90
- x: {
91
- value: width / 2,
92
- },
93
- y: {
94
- value: height,
95
- },
96
- y2: {
97
- value: 0,
98
- },
99
- },
100
- };
101
- const topTrendline = {
102
- mark: {
103
- type: 'rule',
104
- style: 'ruleTop',
105
- color: 'orange',
106
- opacity: 0.2,
107
- },
108
- encoding: {
109
- y: {
110
- aggregate: 'max',
111
- field: 'capacity',
112
- type: 'quantitative',
113
- },
114
- x: {
115
- value: 0,
116
- },
117
- x2: {
118
- value: width,
119
- },
120
- },
121
- };
122
- const spec = {
123
- data: {
124
- values: data,
125
- },
126
- encoding: {
127
- x: xAxis,
128
- color,
129
- // To disable tooltips for a particular single view specification, you can set the "tooltip" property of a mark definition block to null.
130
- tooltip: tooltip ? [xAxis, ...yAxis] : null,
131
- },
132
- height,
133
- width,
134
- layer: [...lines],
135
- ...rest,
136
- };
137
-
138
- if (tooltip) {
139
- spec.layer.push(tooltipConfig || trendline);
140
- }
141
-
142
- if (displayTrendLine) {
143
- spec.layer.push(currentTimeTrendline);
144
- spec.layer.push(topTrendline);
145
- }
146
-
147
- return (
148
- <VegaChart id={id} spec={spec} theme={tooltipTheme || 'light'}></VegaChart>
149
- );
150
- }
151
-
152
- export { LineChart };