@scality/core-ui 0.171.0 → 0.172.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 (72) hide show
  1. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
  2. package/dist/components/barchartv2/Barchart.component.js +2 -2
  3. package/dist/components/barchartv2/BarchartTooltip.d.ts +11 -0
  4. package/dist/components/barchartv2/BarchartTooltip.d.ts.map +1 -0
  5. package/dist/components/barchartv2/BarchartTooltip.js +27 -0
  6. package/dist/components/charttooltip/ChartTooltip.d.ts +13 -0
  7. package/dist/components/charttooltip/ChartTooltip.d.ts.map +1 -0
  8. package/dist/components/charttooltip/ChartTooltip.js +49 -0
  9. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +4 -0
  10. package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +1 -1
  11. package/dist/components/globalhealthbar/GlobalHealthBar.component.js +4 -0
  12. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts +10 -0
  13. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +1 -0
  14. package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.js +78 -0
  15. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts +18 -0
  16. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +1 -0
  17. package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.js +95 -0
  18. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts +7 -0
  19. package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +1 -0
  20. package/dist/components/globalhealthbar/components/HealthBarXAxis.js +25 -0
  21. package/dist/components/globalhealthbar/healthBarUtils.d.ts +77 -0
  22. package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +1 -0
  23. package/dist/components/globalhealthbar/healthBarUtils.js +196 -0
  24. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +2 -0
  25. package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +1 -0
  26. package/dist/components/globalhealthbar/healthBarUtils.spec.js +391 -0
  27. package/dist/components/globalhealthbar/useHealthBarData.d.ts +18 -0
  28. package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +1 -0
  29. package/dist/components/globalhealthbar/useHealthBarData.js +46 -0
  30. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +2 -0
  31. package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +1 -0
  32. package/dist/components/globalhealthbar/useHealthBarData.spec.js +207 -0
  33. package/dist/components/icon/Icon.component.js +2 -2
  34. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +0 -2
  35. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -1
  36. package/dist/components/linetimeseriechart/linetimeseriechart.component.js +17 -57
  37. package/dist/components/sparkline/sparkline.component.d.ts +16 -0
  38. package/dist/components/sparkline/sparkline.component.d.ts.map +1 -0
  39. package/dist/components/sparkline/sparkline.component.js +20 -0
  40. package/dist/components/text/Text.component.d.ts +1 -1
  41. package/dist/components/text/Text.component.d.ts.map +1 -1
  42. package/dist/components/text/Text.component.js +6 -1
  43. package/dist/next.d.ts +3 -1
  44. package/dist/next.d.ts.map +1 -1
  45. package/dist/next.js +3 -1
  46. package/package.json +2 -2
  47. package/src/lib/components/barchartv2/Barchart.component.tsx +3 -2
  48. package/src/lib/components/barchartv2/{ChartTooltip.test.tsx → BarchartTooltip.test.tsx} +35 -12
  49. package/src/lib/components/barchartv2/BarchartTooltip.tsx +89 -0
  50. package/src/lib/components/charttooltip/ChartTooltip.tsx +83 -0
  51. package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +4 -1
  52. package/src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component.tsx +203 -0
  53. package/src/lib/components/globalhealthbar/components/GlobalHealthBarTooltip.tsx +173 -0
  54. package/src/lib/components/globalhealthbar/components/HealthBarXAxis.tsx +94 -0
  55. package/src/lib/components/globalhealthbar/healthBarUtils.spec.ts +701 -0
  56. package/src/lib/components/globalhealthbar/healthBarUtils.ts +311 -0
  57. package/src/lib/components/globalhealthbar/useHealthBarData.spec.tsx +487 -0
  58. package/src/lib/components/globalhealthbar/useHealthBarData.ts +74 -0
  59. package/src/lib/components/icon/Icon.component.tsx +2 -2
  60. package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +50 -77
  61. package/src/lib/components/sparkline/sparkline.component.tsx +54 -0
  62. package/src/lib/components/text/Text.component.tsx +8 -2
  63. package/src/lib/next.ts +8 -1
  64. package/stories/GlobalHealthBar/globalhealthbarRecharts.stories.tsx +145 -0
  65. package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +5 -0
  66. package/stories/InlineInput/InlineInput.stories.tsx +7 -1
  67. package/stories/globalhealthbar.stories.tsx +25 -5
  68. package/stories/sparkline.stories.tsx +168 -0
  69. package/dist/components/barchartv2/ChartTooltip.d.ts +0 -14
  70. package/dist/components/barchartv2/ChartTooltip.d.ts.map +0 -1
  71. package/dist/components/barchartv2/ChartTooltip.js +0 -41
  72. package/src/lib/components/barchartv2/ChartTooltip.tsx +0 -106
@@ -12,7 +12,7 @@ import {
12
12
  import { useCallback, useMemo, useRef, useState } from 'react';
13
13
  import styled, { useTheme } from 'styled-components';
14
14
  import { spacing } from '../../spacing';
15
- import { fontSize, fontWeight } from '../../style/theme';
15
+ import { fontSize } from '../../style/theme';
16
16
  import { Box } from '../box/Box';
17
17
  import { useChartLegend } from '../chartlegend/ChartLegendWrapper';
18
18
  import { FormattedDateTime } from '../date/FormattedDateTime';
@@ -25,6 +25,13 @@ import { Loader } from '../loader/Loader.component';
25
25
  import { ChartTitleText, SmallerText } from '../text/Text.component';
26
26
  import { Tooltip as TooltipComponent } from '../tooltip/Tooltip.component';
27
27
  import { formatXAxisLabel } from './utils';
28
+ import {
29
+ ChartTooltipContainer,
30
+ ChartTooltipItem,
31
+ ChartTooltipHeader,
32
+ ChartTooltipItemsContainer,
33
+ } from '../charttooltip/ChartTooltip';
34
+ import { LegendShape } from '../chartlegend/ChartLegend';
28
35
 
29
36
  const LineTemporalChartWrapper = styled.div`
30
37
  display: flex;
@@ -38,61 +45,6 @@ const ChartHeader = styled.div`
38
45
  align-items: center;
39
46
  `;
40
47
 
41
- export const TooltipContainer = styled.div`
42
- background-color: ${(props) => props.theme.backgroundLevel1};
43
- padding: ${spacing.r8};
44
- border: 1px solid ${(props) => props.theme.border};
45
- border-radius: 4px;
46
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
47
- max-width: 250px;
48
- `;
49
-
50
- export const TooltipTime = styled.div`
51
- margin-bottom: ${spacing.r8};
52
- color: ${(props) => props.theme.textPrimary};
53
- font-size: ${fontSize.smaller};
54
- font-weight: ${fontWeight.bold};
55
- text-align: center;
56
- `;
57
-
58
- const TooltipValue = styled.div`
59
- font-size: ${fontSize.smaller};
60
- margin-top: 4px;
61
- color: ${(props) => props.theme.textSecondary};
62
- display: flex;
63
- align-items: flex-start;
64
- justify-content: space-between;
65
- width: 100%;
66
- `;
67
-
68
- const TooltipLegend = styled.div<{ color: string }>`
69
- width: 12px;
70
- height: 3px;
71
- background-color: ${(props) => props.color};
72
- margin-right: 8px;
73
- flex-shrink: 0;
74
- margin-top: 8px;
75
- `;
76
-
77
- const TooltipLeftGroup = styled.div`
78
- display: flex;
79
- align-items: flex-start;
80
- min-width: 0;
81
- flex: 1;
82
- `;
83
-
84
- const TooltipName = styled.div`
85
- word-wrap: break-word;
86
- word-break: break-word;
87
- flex: 1;
88
- `;
89
-
90
- const TooltipInstanceValue = styled.div`
91
- margin-left: 16px;
92
- flex-shrink: 0;
93
- text-align: right;
94
- `;
95
-
96
48
  export type Serie = {
97
49
  // the name of the resource
98
50
  resource: string;
@@ -152,12 +104,13 @@ export type LineChartProps = (
152
104
  ) => React.ReactNode;
153
105
  };
154
106
 
155
- const CustomTooltip = ({
107
+ const LineTimeSerieChartTooltip = ({
156
108
  unitLabel,
157
109
  timeFormat,
158
110
  isChartActive,
159
111
  tooltipProps,
160
112
  renderTooltip,
113
+ hoveredValue,
161
114
  }: {
162
115
  tooltipProps: TooltipContentProps<number, string>;
163
116
  unitLabel?: string;
@@ -168,8 +121,9 @@ const CustomTooltip = ({
168
121
  unitLabel?: string,
169
122
  timeFormat?: 'date-time' | 'date',
170
123
  ) => React.ReactNode;
124
+ hoveredValue?: string;
171
125
  }) => {
172
- const { active, payload, label, ...rest } = tooltipProps;
126
+ const { active, payload, label } = tooltipProps;
173
127
 
174
128
  if (!active || !payload || !payload.length || !label || !isChartActive)
175
129
  return null;
@@ -193,8 +147,8 @@ const CustomTooltip = ({
193
147
  });
194
148
 
195
149
  return (
196
- <TooltipContainer>
197
- <TooltipTime>
150
+ <ChartTooltipContainer>
151
+ <ChartTooltipHeader>
198
152
  <FormattedDateTime
199
153
  format={
200
154
  timeFormat === 'date-time'
@@ -203,21 +157,35 @@ const CustomTooltip = ({
203
157
  }
204
158
  value={new Date(label)}
205
159
  />
206
- </TooltipTime>
207
- {sortedPayload.map((entry, index) => (
208
- <TooltipValue key={index}>
209
- <TooltipLeftGroup>
210
- <TooltipLegend color={entry.color} />
211
- <TooltipName>{entry.name}</TooltipName>
212
- </TooltipLeftGroup>
213
- <TooltipInstanceValue>
214
- {!Number.isFinite(entry.value)
215
- ? '-'
216
- : `${entry.value.toFixed(2)} ${unitLabel}`}
217
- </TooltipInstanceValue>
218
- </TooltipValue>
219
- ))}
220
- </TooltipContainer>
160
+ </ChartTooltipHeader>
161
+ <ChartTooltipItemsContainer>
162
+ {sortedPayload.map((entry, index) => {
163
+ const legendIcon = (
164
+ <LegendShape
165
+ color={entry.color}
166
+ shape="line"
167
+ chartColors={{ [entry.color]: entry.color }}
168
+ />
169
+ );
170
+
171
+ const isHovered = entry.name === hoveredValue;
172
+
173
+ const formattedValue = !Number.isFinite(entry.value)
174
+ ? '-'
175
+ : `${entry.value.toFixed(2)} ${unitLabel}`;
176
+
177
+ return (
178
+ <ChartTooltipItem
179
+ key={index}
180
+ label={entry.name}
181
+ value={formattedValue}
182
+ legendIcon={legendIcon}
183
+ isHovered={isHovered}
184
+ />
185
+ );
186
+ })}
187
+ </ChartTooltipItemsContainer>
188
+ </ChartTooltipContainer>
221
189
  );
222
190
  };
223
191
 
@@ -249,7 +217,9 @@ export function LineTimeSerieChart({
249
217
  const chartRef = useRef(null);
250
218
 
251
219
  const [isChartActive, setIsChartActive] = useState(false);
252
-
220
+ const [hoveredValue, setHoveredValue] = useState<string | undefined>(
221
+ undefined,
222
+ );
253
223
  const chartData = useMemo(() => {
254
224
  // Guard against empty/undefined series data
255
225
  if (!series || (Array.isArray(series) && series.length === 0)) {
@@ -560,12 +530,13 @@ export function LineTimeSerieChart({
560
530
  />
561
531
  <Tooltip
562
532
  content={(props: TooltipContentProps<number, string>) => (
563
- <CustomTooltip
533
+ <LineTimeSerieChartTooltip
564
534
  unitLabel={unitLabel}
565
535
  timeFormat={timeFormat}
566
536
  renderTooltip={renderTooltip}
567
537
  tooltipProps={props}
568
538
  isChartActive={isChartActive}
539
+ hoveredValue={hoveredValue}
569
540
  />
570
541
  )}
571
542
  />
@@ -589,6 +560,8 @@ export function LineTimeSerieChart({
589
560
  stroke={colorMapping[resource]}
590
561
  dot={false}
591
562
  isAnimationActive={false}
563
+ onMouseEnter={() => setHoveredValue(label)}
564
+ onMouseLeave={() => setHoveredValue(undefined)}
592
565
  />
593
566
  );
594
567
  }),
@@ -0,0 +1,54 @@
1
+ import { useMemo } from "react";
2
+ import { Area, AreaChart, CartesianGrid, ResponsiveContainer } from "recharts";
3
+ import { useTheme } from "styled-components";
4
+ import { chartColors } from "../../style/theme";
5
+ import { addMissingDataPoint } from "../linetemporalchart/ChartUtil";
6
+
7
+ type SparklineProps = {
8
+ serie: {
9
+ data: [number, number|null][],
10
+ color?: string, // exa color code like '#ff0000'
11
+ },
12
+ startingTimeStamp: number,
13
+ sampleDuration: number,
14
+ sampleInterval: number
15
+ };
16
+
17
+ /**
18
+ * Sparkline is a simple dynamically sized area chart.
19
+ * Used to show trends in data over time.
20
+ */
21
+ export function Sparkline({ serie, startingTimeStamp, sampleDuration, sampleInterval }: SparklineProps) {
22
+ const data = useMemo(
23
+ () => {
24
+ const dataMdp = addMissingDataPoint(serie.data, startingTimeStamp, sampleDuration, sampleInterval);
25
+ return dataMdp.map(([x, y]) => ({ x, y }));
26
+ },
27
+ [serie.data]
28
+ );
29
+ const color = serie.color ?? chartColors.lineColor1;
30
+ const strokeGridColor = useTheme().border;
31
+
32
+ return (
33
+ <ResponsiveContainer>
34
+ <AreaChart data={data}>
35
+ <defs>
36
+ <linearGradient id={`gradient-${color}`} x1="0" y1="0" x2="0" y2="1">
37
+ <stop offset="0%" stopColor={color} stopOpacity={0.7} />
38
+ <stop offset="100%" stopColor={color} stopOpacity={0.1} />
39
+ </linearGradient>
40
+ </defs>
41
+ <CartesianGrid horizontal={false} stroke={strokeGridColor} strokeOpacity={0.5} />
42
+ <Area
43
+ type="linear"
44
+ dataKey="y"
45
+ stroke={color}
46
+ fill={`url(#gradient-${color})`}
47
+ dot={false}
48
+ activeDot={false}
49
+ isAnimationActive={false}
50
+ />
51
+ </AreaChart>
52
+ </ResponsiveContainer>
53
+ );
54
+ }
@@ -8,7 +8,8 @@ export type TextVariant =
8
8
  | 'Basic'
9
9
  | 'Smaller'
10
10
  | 'Larger'
11
- | 'Large';
11
+ | 'Large'
12
+ | 'Small';
12
13
 
13
14
  type Status = 'unknown' | 'healthy' | 'warning' | 'critical';
14
15
  type Props = {
@@ -158,7 +159,12 @@ export const Text = styled.span<{
158
159
  line-height: 1.4;
159
160
  letter-spacing: 2%;// to be defined, percentage value is not valid
160
161
  `
161
- : `
162
+ : props.variant === 'Small'
163
+ ? `
164
+ font-size: 0.85rem;
165
+ line-height: 1.4;
166
+ `
167
+ : `
162
168
  font-size: 1rem;
163
169
  line-height: ${spacing.r24};
164
170
  `}
package/src/lib/next.ts CHANGED
@@ -21,11 +21,18 @@ export {
21
21
  BarchartSortFn,
22
22
  BarchartTooltipFn,
23
23
  } from './components/barchartv2/Barchart.component';
24
- export { ChartTooltip } from './components/barchartv2/ChartTooltip';
24
+ export { BarchartTooltip } from './components/barchartv2/BarchartTooltip';
25
25
  export {
26
26
  ChartLegendWrapper,
27
27
  useChartId,
28
28
  } from './components/chartlegend/ChartLegendWrapper';
29
29
  export { ChartLegend } from './components/chartlegend/ChartLegend';
30
30
  export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
31
+ export {
32
+ ChartTooltipContainer,
33
+ ChartTooltipItem,
34
+ ChartTooltipHeader,
35
+ ChartTooltipItemsContainer,
36
+ } from './components/charttooltip/ChartTooltip';
31
37
  export { CoreUITheme } from './style/theme';
38
+ export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBarRecharts.component';
@@ -0,0 +1,145 @@
1
+ import React, { useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+ import {
4
+ Alert,
5
+ GlobalHealthBar,
6
+ GlobalHealthProps,
7
+ } from '../../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component';
8
+
9
+ import {
10
+ DATE_FORMATER,
11
+ TIME_SECOND_FORMATER,
12
+ } from '../../src/lib/components/date/FormattedDateTime';
13
+ import {
14
+ MetricsTimeSpanProvider,
15
+ useMetricsTimeSpan,
16
+ } from '../../src/lib/next';
17
+ import { Dropdown, Icon, Stack } from '../../src/lib';
18
+ import {
19
+ LAST_ONE_HOUR,
20
+ LAST_SEVEN_DAYS,
21
+ LAST_TWENTY_FOUR_HOURS,
22
+ SAMPLE_DURATION_LAST_ONE_HOUR,
23
+ SAMPLE_DURATION_LAST_SEVEN_DAYS,
24
+ SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
25
+ } from '../../src/lib/components/constants';
26
+
27
+ type Story = StoryObj<GlobalHealthProps>;
28
+
29
+ const meta: Meta<GlobalHealthProps> = {
30
+ title: 'Components/GlobalHealthBarRecharts',
31
+ component: GlobalHealthBar,
32
+ };
33
+ export default meta;
34
+
35
+ const start = '2021-01-30T23:00:00Z'; // UTC time
36
+ const end = '2021-02-06T23:00:00Z';
37
+ const start2 = '2021-01-29T14:00:00Z';
38
+ const end2 = '2021-02-05T14:00:00Z';
39
+ const startLast24h = '2021-02-01T00:00:00Z';
40
+ const endLast24h = '2021-02-02T00:00:00Z';
41
+ const startLastHour = '2021-02-01T00:00:00Z';
42
+ const endLastHour = '2021-02-01T01:00:00Z';
43
+
44
+ const alerts = [
45
+ {
46
+ id: '0',
47
+ severity: 'unavailable',
48
+ startsAt: '2021-02-01T00:00:00Z',
49
+ endsAt: '2021-02-01T01:00:00Z',
50
+ description: 'Global health unavailable',
51
+ },
52
+ {
53
+ id: '1',
54
+ severity: 'critical',
55
+ startsAt: '2021-02-01T11:00:00Z',
56
+ endsAt: '2021-02-02T11:00:00Z',
57
+ description: 'Global health critical',
58
+ },
59
+ {
60
+ id: '2',
61
+ severity: 'warning',
62
+ startsAt: '2021-02-01T23:00:00Z',
63
+ endsAt: '2021-02-02T22:00:00Z',
64
+ description: 'Global health warning',
65
+ },
66
+ {
67
+ severity: 'critical',
68
+ startsAt: '2021-02-03T00:00:00Z',
69
+ endsAt: '2021-02-04T00:00:00Z',
70
+ description:
71
+ 'Global health critical Long descritpion so it takes more space. Add more text to see how it wraps.',
72
+ },
73
+ {
74
+ id: '4',
75
+ severity: 'warning',
76
+ startsAt: '2021-02-04T10:00:00Z',
77
+ endsAt: '2021-02-06T00:00:00Z',
78
+ description:
79
+ 'Global health warning Long descritpion so it takes more space. Add more text to see how it wraps.',
80
+ },
81
+ {
82
+ id: '5',
83
+ severity: 'warning',
84
+ startsAt: '2021-02-06T12:00:00Z',
85
+ endsAt: '2021-02-07T00:00:00Z',
86
+ description:
87
+ 'Global health warning Long descritpion so it takes more space. Add more text to see how it wraps.',
88
+ },
89
+ {
90
+ id: '6',
91
+ severity: 'warning',
92
+ startsAt: '2021-01-30T22:00:00Z',
93
+ endsAt: '2021-01-30T23:00:00Z',
94
+ description:
95
+ 'Global health warning Long descritpion so it takes more space. Add more text to see how it wraps.',
96
+ },
97
+ {
98
+ id: '7',
99
+ severity: 'warning',
100
+ startsAt: '2021-02-01T00:47:30Z',
101
+ endsAt: '2021-02-01T01:30:00Z',
102
+ description:
103
+ 'Global health warning Long descritpion so it takes more space. Add more text to see how it wraps.',
104
+ },
105
+ ];
106
+
107
+ export const Default: Story = {
108
+ args: {
109
+ start: new Date(start),
110
+ end: new Date(end),
111
+ alerts: alerts as Alert[],
112
+ },
113
+ };
114
+
115
+ export const Last24Hours: Story = {
116
+ render: () => {
117
+ return (
118
+ <div style={{ width: '350px', height: '1000px', overflow: 'hidden' }}>
119
+ <div style={{ width: '500px', height: '400px' }} />
120
+ <GlobalHealthBar
121
+ start={new Date(startLast24h)}
122
+ end={new Date(endLast24h)}
123
+ alerts={alerts as Alert[]}
124
+ id="1"
125
+ />
126
+ </div>
127
+ );
128
+ },
129
+ };
130
+
131
+ export const LastHour: Story = {
132
+ render: () => {
133
+ return (
134
+ <div style={{ width: '250px', height: '1000px', overflow: 'hidden' }}>
135
+ <div style={{ width: '400px', height: '400px' }} />
136
+ <GlobalHealthBar
137
+ start={new Date(startLastHour)}
138
+ end={new Date(endLastHour)}
139
+ alerts={alerts as Alert[]}
140
+ id="1"
141
+ />
142
+ </div>
143
+ );
144
+ },
145
+ };
@@ -0,0 +1,5 @@
1
+ import { Meta } from '@storybook/blocks';
2
+ import { GlobalHealthBar } from '../../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component';
3
+ import * as GlobalHealthBarStories from './globalhealthbarRecharts.stories';
4
+
5
+ <Meta name="Guideline" of={GlobalHealthBarStories} />
@@ -26,7 +26,13 @@ export default {
26
26
  });
27
27
  },
28
28
  });
29
- return <InlineInput {...args} changeMutation={changeMutation} />;
29
+ return (
30
+ <InlineInput
31
+ id="inline-input-story"
32
+ {...args}
33
+ changeMutation={changeMutation}
34
+ />
35
+ );
30
36
  },
31
37
  };
32
38
 
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import { GlobalHealthBar } from '../src/lib/components/globalhealthbar/GlobalHealthBar.component';
2
+ import { GlobalHealthBar } from '../src/lib/components/globalhealthbar/GlobalHealthBarRecharts.component';
3
+ import { GlobalHealthBar as VegaGlobalHealthBar } from '../src/lib/components/globalhealthbar/GlobalHealthBar.component';
3
4
  import { SyncedCursorCharts } from '../src/lib/components/vegachartv2/SyncedCursorCharts';
4
5
  import { Wrapper } from './common';
6
+ import { Stack } from '../src/lib/spacing';
5
7
  const alerts = [
6
8
  {
7
9
  id: '1',
@@ -34,10 +36,17 @@ const alerts = [
34
36
  {
35
37
  id: '5',
36
38
  severity: 'warning',
37
- startsAt: '2021-02-06T12:00:00Z',
39
+ startsAt: '2021-02-06T10:00:00Z',
38
40
  endsAt: '2021-02-06T20:00:00Z',
39
41
  description: 'Global health warning',
40
42
  },
43
+ {
44
+ id: '6',
45
+ severity: 'warning',
46
+ startsAt: '2021-02-06T12:00:00Z',
47
+ endsAt: '2021-02-06T22:30:00Z',
48
+ description: 'Global health warning',
49
+ },
41
50
  ];
42
51
  const alertsLast24h = [
43
52
  {
@@ -75,7 +84,7 @@ const alertRetrieveBefore = [
75
84
  id: '2',
76
85
  severity: 'critical',
77
86
  startsAt: '2021-02-05T23:00:00Z',
78
- endsAt: '2021-02-06T21:00:00Z',
87
+ endsAt: '2021-02-07T00:00:00Z',
79
88
  description: 'Global health warning',
80
89
  },
81
90
  ];
@@ -105,13 +114,18 @@ const endNotFirstDay = '2021-03-01T23:00:00Z';
105
114
 
106
115
  export default {
107
116
  title: 'Components/Data Display/Charts/GlobalHealthBar',
108
- component: GlobalHealthBar,
117
+ component: (props) => (
118
+ <Stack direction="vertical">
119
+ <GlobalHealthBar {...props} />
120
+ <VegaGlobalHealthBar {...props} />
121
+ </Stack>
122
+ ),
109
123
  decorators: [
110
124
  (story) => (
111
125
  <Wrapper
112
126
  style={{ minHeight: '50vh', display: 'flex', alignItems: 'center' }}
113
127
  >
114
- <div style={{ width: '500px' }}>
128
+ <div style={{ width: '500px', height: '400px' }}>
115
129
  <SyncedCursorCharts>{story()}</SyncedCursorCharts>
116
130
  </div>
117
131
  </Wrapper>
@@ -120,6 +134,7 @@ export default {
120
134
  args: {
121
135
  start,
122
136
  end,
137
+ width: 500,
123
138
  },
124
139
  argTypes: {
125
140
  start: {
@@ -135,6 +150,7 @@ export const GlobalHealthComponentDemo = {
135
150
  args: {
136
151
  id: 'vis_globalhealth',
137
152
  alerts,
153
+ width: 500,
138
154
  },
139
155
  };
140
156
 
@@ -144,12 +160,14 @@ export const GlobalHealthLast24Hours = {
144
160
  alerts: alertsLast24h,
145
161
  start: startLast24h,
146
162
  end: endLast24h,
163
+ width: 500,
147
164
  },
148
165
  };
149
166
  export const GlobalHealthEmpty = {
150
167
  args: {
151
168
  id: 'vis_globalhealth_empty',
152
169
  alerts: emptyAlert,
170
+ width: 500,
153
171
  },
154
172
  };
155
173
 
@@ -157,6 +175,7 @@ export const AlertTriggeredEarlierThanTheStartingTime = {
157
175
  args: {
158
176
  id: 'vis_globalhealth_alert_retrieve_before',
159
177
  alerts: alertRetrieveBefore,
178
+ width: 500,
160
179
  },
161
180
  };
162
181
 
@@ -167,5 +186,6 @@ export const FirstLabel = {
167
186
  alerts: alertTriggerNotFirstDay,
168
187
  start: startNotFirstDay,
169
188
  end: endNotFirstDay,
189
+ width: 500,
170
190
  },
171
191
  };