@scality/core-ui 0.185.0 → 0.187.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.
- package/.storybook/preview.js +1 -7
- package/dist/components/{linetemporalchart/MetricTimespanProvider.d.ts → charts/MetricsTimeSpanProvider.d.ts} +1 -1
- package/dist/components/charts/MetricsTimeSpanProvider.d.ts.map +1 -0
- package/dist/components/{barchartv2/Barchart.component.d.ts → charts/barchart/Barchart.d.ts} +2 -33
- package/dist/components/charts/barchart/Barchart.d.ts.map +1 -0
- package/dist/components/charts/barchart/Barchart.js +56 -0
- package/dist/components/{barchartv2/utils.d.ts → charts/barchart/Barchart.utils.d.ts} +8 -35
- package/dist/components/charts/barchart/Barchart.utils.d.ts.map +1 -0
- package/dist/components/{barchartv2/utils.js → charts/barchart/Barchart.utils.js} +7 -88
- package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.d.ts +2 -1
- package/dist/components/charts/barchart/BarchartTooltip.d.ts.map +1 -0
- package/dist/components/{barchartv2 → charts/barchart}/BarchartTooltip.js +3 -3
- package/dist/components/{charttooltip → charts/common}/ChartTooltip.d.ts +9 -2
- package/dist/components/charts/common/ChartTooltip.d.ts.map +1 -0
- package/dist/components/{charttooltip → charts/common}/ChartTooltip.js +11 -15
- package/dist/components/charts/common/SharedComponents.d.ts +47 -0
- package/dist/components/charts/common/SharedComponents.d.ts.map +1 -0
- package/dist/components/charts/common/SharedComponents.js +73 -0
- package/dist/components/charts/common/chartUtils.d.ts +91 -0
- package/dist/components/charts/common/chartUtils.d.ts.map +1 -0
- package/dist/components/charts/common/chartUtils.js +243 -0
- package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.d.ts → charts/globalhealthbar/GlobalHealthBar.d.ts} +2 -2
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.d.ts.map +1 -0
- package/dist/components/{globalhealthbar/useHealthBarData.d.ts → charts/globalhealthbar/GlobalHealthBar.hooks.d.ts} +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.hooks.d.ts.map +1 -0
- package/dist/components/{globalhealthbar/GlobalHealthBarRecharts.component.js → charts/globalhealthbar/GlobalHealthBar.js} +4 -4
- package/dist/components/{globalhealthbar/healthBarUtils.d.ts → charts/globalhealthbar/GlobalHealthBar.utils.d.ts} +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBar.utils.d.ts.map +1 -0
- package/dist/components/{globalhealthbar/healthBarUtils.js → charts/globalhealthbar/GlobalHealthBar.utils.js} +1 -1
- package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.d.ts +1 -1
- package/dist/components/charts/globalhealthbar/GlobalHealthBarTooltip.d.ts.map +1 -0
- package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.js +7 -3
- package/dist/components/charts/globalhealthbar/HealthBarXAxis.d.ts.map +1 -0
- package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.js +1 -1
- package/dist/components/charts/index.d.ts +16 -0
- package/dist/components/charts/index.d.ts.map +1 -0
- package/dist/components/charts/index.js +15 -0
- package/dist/components/{chartlegend → charts/legend}/ChartLegend.d.ts +1 -1
- package/dist/components/charts/legend/ChartLegend.d.ts.map +1 -0
- package/dist/components/{chartlegend → charts/legend}/ChartLegend.js +2 -2
- package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.d.ts +1 -1
- package/dist/components/charts/legend/ChartLegendWrapper.d.ts.map +1 -0
- package/dist/components/{linetimeseriechart/linetimeseriechart.component.d.ts → charts/linetimeseries/LineTimeSerieChart.d.ts} +12 -2
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.d.ts.map +1 -0
- package/dist/components/{linetimeseriechart/linetimeseriechart.component.js → charts/linetimeseries/LineTimeSerieChart.js} +34 -35
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts +14 -0
- package/dist/components/charts/linetimeseries/LineTimeSerieChart.utils.d.ts.map +1 -0
- package/dist/components/{linetimeseriechart/utils.js → charts/linetimeseries/LineTimeSerieChart.utils.js} +4 -6
- package/dist/components/charts/sparkline/Sparkline.d.ts +23 -0
- package/dist/components/charts/sparkline/Sparkline.d.ts.map +1 -0
- package/dist/components/{sparkline/sparkline.component.js → charts/sparkline/Sparkline.js} +12 -6
- package/dist/components/charts/types.d.ts +34 -0
- package/dist/components/charts/types.d.ts.map +1 -0
- package/dist/components/charts/types.js +4 -0
- package/dist/components/icon/Icon.component.d.ts +1 -0
- package/dist/components/icon/Icon.component.d.ts.map +1 -1
- package/dist/components/icon/Icon.component.js +2 -2
- package/dist/components/textbadge/TextBadge.component.d.ts +1 -1
- package/dist/components/textbadge/TextBadge.component.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip/Tooltip.component.js +16 -29
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/next.d.ts +3 -11
- package/dist/next.d.ts.map +1 -1
- package/dist/next.js +4 -11
- package/package.json +2 -6
- package/src/lib/components/{barchartv2/Barchart.component.test.tsx → charts/barchart/Barchart.test.tsx} +35 -10
- package/src/lib/components/{barchartv2/Barchart.component.tsx → charts/barchart/Barchart.tsx} +42 -207
- package/src/lib/components/{barchartv2/utils.test.ts → charts/barchart/Barchart.utils.test.ts} +2 -141
- package/src/lib/components/{barchartv2/utils.ts → charts/barchart/Barchart.utils.ts} +17 -143
- package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.tsx +5 -9
- package/src/lib/components/{charttooltip → charts/common}/ChartTooltip.tsx +13 -20
- package/src/lib/components/charts/common/SharedComponents.tsx +180 -0
- package/src/lib/components/charts/common/chartUtils.test.ts +402 -0
- package/src/lib/components/charts/common/chartUtils.ts +334 -0
- package/src/lib/components/{globalhealthbar/useHealthBarData.spec.tsx → charts/globalhealthbar/GlobalHealthBar.hooks.test.tsx} +1 -1
- package/src/lib/components/{globalhealthbar/GlobalHealthBarRecharts.component.tsx → charts/globalhealthbar/GlobalHealthBar.tsx} +4 -4
- package/src/lib/components/{globalhealthbar/healthBarUtils.spec.ts → charts/globalhealthbar/GlobalHealthBar.utils.test.ts} +1 -1
- package/src/lib/components/{globalhealthbar/healthBarUtils.ts → charts/globalhealthbar/GlobalHealthBar.utils.ts} +1 -1
- package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/GlobalHealthBarTooltip.tsx +8 -4
- package/src/lib/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.tsx +1 -1
- package/src/lib/components/charts/index.ts +59 -0
- package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.tsx +2 -2
- package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.tsx +1 -1
- package/src/lib/components/{linetimeseriechart/linetimeseriechart.test.tsx → charts/linetimeseries/LineTimeSerieChart.test.tsx} +3 -6
- package/src/lib/components/{linetimeseriechart/linetimeseriechart.component.tsx → charts/linetimeseries/LineTimeSerieChart.tsx} +48 -44
- package/src/lib/components/{linetimeseriechart/utils.test.ts → charts/linetimeseries/LineTimeSerieChart.utils.test.ts} +1 -1
- package/src/lib/components/{linetimeseriechart/utils.ts → charts/linetimeseries/LineTimeSerieChart.utils.ts} +4 -6
- package/src/lib/components/charts/sparkline/Sparkline.tsx +80 -0
- package/src/lib/components/charts/types.ts +36 -0
- package/src/lib/components/icon/Icon.component.tsx +12 -8
- package/src/lib/components/textbadge/TextBadge.component.tsx +1 -1
- package/src/lib/components/tooltip/Tooltip.component.tsx +37 -47
- package/src/lib/index.ts +4 -2
- package/src/lib/next.ts +26 -13
- package/stories/BarChart/barchart.stories.tsx +10 -9
- package/stories/GlobalHealthBar/{globalhealthbarRecharts.stories.tsx → globalhealthbar.stories.tsx} +3 -21
- package/stories/GlobalHealthBar/globalheathbarrecharts.guideline.mdx +2 -2
- package/stories/common.tsx +1 -1
- package/stories/guideline/chart-guideline.mdx +1 -38
- package/stories/linetimeseriechart.stories.tsx +4 -6
- package/stories/sparkline.stories.tsx +13 -11
- package/stories/tablev2.stories.tsx +1 -1
- package/stories/textbadge.stories.tsx +15 -0
- package/dist/components/barchart/BarChart.component.d.ts +0 -17
- package/dist/components/barchart/BarChart.component.d.ts.map +0 -1
- package/dist/components/barchart/BarChart.component.js +0 -27
- package/dist/components/barchartv2/Barchart.component.d.ts.map +0 -1
- package/dist/components/barchartv2/Barchart.component.js +0 -122
- package/dist/components/barchartv2/BarchartTooltip.d.ts.map +0 -1
- package/dist/components/barchartv2/utils.d.ts.map +0 -1
- package/dist/components/chartlegend/ChartLegend.d.ts.map +0 -1
- package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +0 -1
- package/dist/components/charttooltip/ChartTooltip.d.ts.map +0 -1
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts +0 -23
- package/dist/components/globalhealthbar/GlobalHealthBar.component.d.ts.map +0 -1
- package/dist/components/globalhealthbar/GlobalHealthBar.component.js +0 -173
- package/dist/components/globalhealthbar/GlobalHealthBarRecharts.component.d.ts.map +0 -1
- package/dist/components/globalhealthbar/components/GlobalHealthBarTooltip.d.ts.map +0 -1
- package/dist/components/globalhealthbar/components/HealthBarXAxis.d.ts.map +0 -1
- package/dist/components/globalhealthbar/healthBarUtils.d.ts.map +0 -1
- package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts +0 -2
- package/dist/components/globalhealthbar/healthBarUtils.spec.d.ts.map +0 -1
- package/dist/components/globalhealthbar/healthBarUtils.spec.js +0 -391
- package/dist/components/globalhealthbar/tooltip/index.d.ts +0 -8
- package/dist/components/globalhealthbar/tooltip/index.d.ts.map +0 -1
- package/dist/components/globalhealthbar/tooltip/index.js +0 -55
- package/dist/components/globalhealthbar/useHealthBarData.d.ts.map +0 -1
- package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts +0 -2
- package/dist/components/globalhealthbar/useHealthBarData.spec.d.ts.map +0 -1
- package/dist/components/globalhealthbar/useHealthBarData.spec.js +0 -209
- package/dist/components/linetemporalchart/ChartUtil.d.ts +0 -41
- package/dist/components/linetemporalchart/ChartUtil.d.ts.map +0 -1
- package/dist/components/linetemporalchart/ChartUtil.js +0 -148
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts +0 -46
- package/dist/components/linetemporalchart/LineTemporalChart.component.d.ts.map +0 -1
- package/dist/components/linetemporalchart/LineTemporalChart.component.js +0 -579
- package/dist/components/linetemporalchart/MetricTimespanProvider.d.ts.map +0 -1
- package/dist/components/linetemporalchart/tooltip/index.d.ts +0 -30
- package/dist/components/linetemporalchart/tooltip/index.d.ts.map +0 -1
- package/dist/components/linetemporalchart/tooltip/index.js +0 -104
- package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +0 -1
- package/dist/components/linetimeseriechart/utils.d.ts +0 -16
- package/dist/components/linetimeseriechart/utils.d.ts.map +0 -1
- package/dist/components/sparkline/sparkline.component.d.ts +0 -17
- package/dist/components/sparkline/sparkline.component.d.ts.map +0 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts +0 -12
- package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +0 -1
- package/dist/components/vegachartv2/SyncedCursorCharts.js +0 -15
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts +0 -15
- package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +0 -1
- package/dist/components/vegachartv2/VegaChartV2.component.js +0 -218
- package/src/lib/components/barchart/BarChart.component.tsx +0 -51
- package/src/lib/components/globalhealthbar/GlobalHealthBar.component.tsx +0 -204
- package/src/lib/components/globalhealthbar/tooltip/index.ts +0 -72
- package/src/lib/components/linetemporalchart/ChartUtil.test.ts +0 -250
- package/src/lib/components/linetemporalchart/ChartUtil.ts +0 -225
- package/src/lib/components/linetemporalchart/LineTemporalChart.component.tsx +0 -800
- package/src/lib/components/linetemporalchart/tooltip/index.ts +0 -178
- package/src/lib/components/sparkline/sparkline.component.tsx +0 -56
- package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +0 -28
- package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +0 -276
- package/stories/barchart.stories.tsx +0 -142
- package/stories/globalhealthbar.stories.tsx +0 -191
- package/stories/guideline/mdxExampleComponents.tsx +0 -57
- package/stories/linecharttemporal.stories.tsx +0 -88
- /package/dist/components/{linetemporalchart/MetricTimespanProvider.js → charts/MetricsTimeSpanProvider.js} +0 -0
- /package/dist/components/{globalhealthbar/useHealthBarData.js → charts/globalhealthbar/GlobalHealthBar.hooks.js} +0 -0
- /package/dist/components/{globalhealthbar/components → charts/globalhealthbar}/HealthBarXAxis.d.ts +0 -0
- /package/dist/components/{chartlegend → charts/legend}/ChartLegendWrapper.js +0 -0
- /package/src/lib/components/{linetemporalchart/MetricTimespanProvider.tsx → charts/MetricsTimeSpanProvider.tsx} +0 -0
- /package/src/lib/components/{barchartv2 → charts/barchart}/BarchartTooltip.test.tsx +0 -0
- /package/src/lib/components/{globalhealthbar/useHealthBarData.ts → charts/globalhealthbar/GlobalHealthBar.hooks.ts} +0 -0
- /package/src/lib/components/{chartlegend → charts/legend}/ChartLegend.test.tsx +0 -0
- /package/src/lib/components/{chartlegend → charts/legend}/ChartLegendWrapper.test.tsx +0 -0
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
TIME_FORMATER,
|
|
3
3
|
DAY_MONTH_ABBREVIATED_YEAR,
|
|
4
4
|
DAY_MONTH_ABBREVIATED_HOUR_MINUTE,
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../date/FormattedDateTime';
|
|
6
6
|
|
|
7
7
|
export const ONE_YEAR_MILLISECONDS = 366 * 24 * 60 * 60 * 1000;
|
|
8
8
|
|
|
@@ -11,13 +11,11 @@ export type ChartDataPoint = {
|
|
|
11
11
|
} & Record<string, number | null>;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Formats timestamp for X-axis labels based on
|
|
15
|
-
*
|
|
16
|
-
* For 'date' format, return YYYY-MM-DD format if time range is greater than 1 year, otherwise return MM-DD format
|
|
14
|
+
* Formats timestamp for X-axis labels based on duration
|
|
15
|
+
*
|
|
17
16
|
*
|
|
18
17
|
* @param timestamp - The timestamp to format in milliseconds
|
|
19
|
-
* @param
|
|
20
|
-
* @param chartData - The chart data to determine time range for optimal formatting
|
|
18
|
+
* @param duration - The duration in seconds
|
|
21
19
|
* @returns Formatted string for display on X-axis
|
|
22
20
|
*/
|
|
23
21
|
export const formatXAxisLabel = (
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Area,
|
|
4
|
+
AreaChart,
|
|
5
|
+
CartesianGrid,
|
|
6
|
+
ResponsiveContainer,
|
|
7
|
+
YAxis,
|
|
8
|
+
} from 'recharts';
|
|
9
|
+
import { useTheme } from 'styled-components';
|
|
10
|
+
import { chartColors } from '../../../style/theme';
|
|
11
|
+
import { addMissingDataPoint } from '../common/chartUtils';
|
|
12
|
+
|
|
13
|
+
type SparklineProps = {
|
|
14
|
+
serie: {
|
|
15
|
+
data: [number, number | null][];
|
|
16
|
+
color?: string; // exa color code like '#ff0000'
|
|
17
|
+
};
|
|
18
|
+
startingTimeStamp: number;
|
|
19
|
+
sampleDuration: number;
|
|
20
|
+
sampleInterval: number;
|
|
21
|
+
yAxisType?: 'default' | 'percentage';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sparkline is a simple dynamically sized area chart.
|
|
26
|
+
* Used to show trends in data over time.
|
|
27
|
+
* @param serie - The data series to display
|
|
28
|
+
* @param startingTimeStamp - The starting timestamp in seconds
|
|
29
|
+
* @param sampleDuration - The total duration in seconds to cover in the sparkline
|
|
30
|
+
* @param sampleInterval - The interval in seconds between data points
|
|
31
|
+
* @param yAxisType - The type of y-axis to display
|
|
32
|
+
* @returns The sparkline component
|
|
33
|
+
*/
|
|
34
|
+
export function Sparkline({
|
|
35
|
+
serie,
|
|
36
|
+
startingTimeStamp,
|
|
37
|
+
sampleDuration,
|
|
38
|
+
sampleInterval,
|
|
39
|
+
yAxisType,
|
|
40
|
+
}: SparklineProps) {
|
|
41
|
+
const data = useMemo(() => {
|
|
42
|
+
const dataMdp = addMissingDataPoint(
|
|
43
|
+
serie.data,
|
|
44
|
+
startingTimeStamp,
|
|
45
|
+
sampleDuration,
|
|
46
|
+
sampleInterval,
|
|
47
|
+
);
|
|
48
|
+
return dataMdp.map(([x, y]) => ({ x, y }));
|
|
49
|
+
}, [serie.data]);
|
|
50
|
+
const color = serie.color ?? chartColors.lineColor1;
|
|
51
|
+
const strokeGridColor = useTheme().border;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ResponsiveContainer>
|
|
55
|
+
<AreaChart data={data}>
|
|
56
|
+
<defs>
|
|
57
|
+
<linearGradient id={`gradient-${color}`} x1="0" y1="0" x2="0" y2="1">
|
|
58
|
+
<stop offset="0%" stopColor={color} stopOpacity={0.7} />
|
|
59
|
+
<stop offset="100%" stopColor={color} stopOpacity={0.1} />
|
|
60
|
+
</linearGradient>
|
|
61
|
+
</defs>
|
|
62
|
+
<CartesianGrid
|
|
63
|
+
horizontal={false}
|
|
64
|
+
stroke={strokeGridColor}
|
|
65
|
+
strokeOpacity={0.5}
|
|
66
|
+
/>
|
|
67
|
+
<Area
|
|
68
|
+
type="linear"
|
|
69
|
+
dataKey="y"
|
|
70
|
+
stroke={color}
|
|
71
|
+
fill={`url(#gradient-${color})`}
|
|
72
|
+
dot={false}
|
|
73
|
+
activeDot={false}
|
|
74
|
+
isAnimationActive={false}
|
|
75
|
+
/>
|
|
76
|
+
{yAxisType === 'percentage' && <YAxis domain={[0, 100]} hide />}
|
|
77
|
+
</AreaChart>
|
|
78
|
+
</ResponsiveContainer>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types used across chart components
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Unit range configuration for automatic unit scaling
|
|
7
|
+
* Should at least have base unit with threshold 1
|
|
8
|
+
* @example [{ threshold: 1, label: 'B' }, { threshold: 1000, label: 'kB' }]
|
|
9
|
+
*/
|
|
10
|
+
export type UnitRange = {
|
|
11
|
+
threshold: number;
|
|
12
|
+
label: string;
|
|
13
|
+
}[];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Time-based chart configuration
|
|
17
|
+
* @param startDate - Start date
|
|
18
|
+
* @param endDate - End date
|
|
19
|
+
* @param interval - Interval in milliseconds
|
|
20
|
+
*/
|
|
21
|
+
export type TimeType = {
|
|
22
|
+
type: 'time';
|
|
23
|
+
timeRange: {
|
|
24
|
+
startDate: Date;
|
|
25
|
+
endDate: Date;
|
|
26
|
+
interval: number;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Category-based chart configuration
|
|
32
|
+
*/
|
|
33
|
+
export type CategoryType = {
|
|
34
|
+
type: 'category';
|
|
35
|
+
gap?: number;
|
|
36
|
+
};
|
|
@@ -143,6 +143,7 @@ export const iconTable = {
|
|
|
143
143
|
ThumbsUp: 'far faThumbsUp',
|
|
144
144
|
ThumbsDown: 'far faThumbsDown',
|
|
145
145
|
Sidebar: 'fas faColumns',
|
|
146
|
+
Bookopen: 'fas faBookOpen',
|
|
146
147
|
};
|
|
147
148
|
|
|
148
149
|
type IconProps = {
|
|
@@ -153,7 +154,10 @@ type IconProps = {
|
|
|
153
154
|
title?: string;
|
|
154
155
|
};
|
|
155
156
|
|
|
156
|
-
export const customIcons: Record<
|
|
157
|
+
export const customIcons: Record<
|
|
158
|
+
string,
|
|
159
|
+
((props: IconProps) => JSX.Element) & { displayName?: string }
|
|
160
|
+
> = {
|
|
157
161
|
'Remote-user': ({ 'aria-label': ariaLabel, color, size }) => (
|
|
158
162
|
<RemoteUser ariaLabel={ariaLabel} color={color} size={size} />
|
|
159
163
|
),
|
|
@@ -259,7 +263,8 @@ function NonWrappedIcon({
|
|
|
259
263
|
}
|
|
260
264
|
|
|
261
265
|
const [iconType, iconClass] = iconInfo.split(' ');
|
|
262
|
-
const fontAwesomeType =
|
|
266
|
+
const fontAwesomeType =
|
|
267
|
+
iconType === 'far' ? 'free-regular-svg-icons' : 'free-solid-svg-icons';
|
|
263
268
|
const cacheKey = `${fontAwesomeType}/${iconClass}`;
|
|
264
269
|
if (iconCache[cacheKey]) {
|
|
265
270
|
setIcon(iconCache[cacheKey]);
|
|
@@ -267,11 +272,10 @@ function NonWrappedIcon({
|
|
|
267
272
|
}
|
|
268
273
|
|
|
269
274
|
// Handle FontAwesome icons with dynamic import
|
|
270
|
-
import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
275
|
+
import(`@fortawesome/${fontAwesomeType}/${iconClass}.js`).then((module) => {
|
|
276
|
+
setIcon(module[iconClass]);
|
|
277
|
+
iconCache[cacheKey] = module[iconClass];
|
|
278
|
+
});
|
|
275
279
|
return () => setIcon(undefined);
|
|
276
280
|
}, [name, iconInfo]);
|
|
277
281
|
|
|
@@ -292,7 +296,7 @@ function NonWrappedIcon({
|
|
|
292
296
|
title={title}
|
|
293
297
|
aria-label={`${name} ${ariaLabel}`}
|
|
294
298
|
{...rest}
|
|
295
|
-
|
|
299
|
+
/>
|
|
296
300
|
);
|
|
297
301
|
}
|
|
298
302
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CSSProperties,
|
|
1
|
+
import { flip, offset, shift, useFloating } from '@floating-ui/react';
|
|
2
|
+
import { CSSProperties, useState } from 'react';
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
3
4
|
import styled from 'styled-components';
|
|
4
5
|
import { spacing } from '../../spacing';
|
|
5
6
|
import { fontSize, zIndex } from '../../style/theme';
|
|
@@ -44,8 +45,6 @@ const TooltipOverLayContainer = styled.div<{
|
|
|
44
45
|
style?: CSSProperties;
|
|
45
46
|
}>`
|
|
46
47
|
display: inline-block;
|
|
47
|
-
opacity: 0;
|
|
48
|
-
position: fixed;
|
|
49
48
|
width: max-content;
|
|
50
49
|
border: 1px solid ${getThemePropSelector('border')};
|
|
51
50
|
background-color: ${(props) =>
|
|
@@ -85,51 +84,42 @@ function Tooltip({
|
|
|
85
84
|
overlay,
|
|
86
85
|
...rest
|
|
87
86
|
}: Props) {
|
|
88
|
-
const childrenRef = useRef<HTMLDivElement | null>(null);
|
|
89
|
-
const tooltipRef = useRef<HTMLDivElement | null>(null);
|
|
90
|
-
|
|
91
87
|
const [isTooltipVisible, setIsTooltipVisible] = useState(false);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (tooltipRef.current) {
|
|
99
|
-
Object.assign(tooltipRef.current.style, {
|
|
100
|
-
opacity: '1',
|
|
101
|
-
// we set opacity to 1 to make sure the tooltip is not displayed before the position is computed
|
|
102
|
-
left: `${x}px`,
|
|
103
|
-
top: `${y}px`,
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}, [tooltipRef.current, childrenRef.current, isTooltipVisible]);
|
|
88
|
+
|
|
89
|
+
const { refs, floatingStyles } = useFloating({
|
|
90
|
+
placement,
|
|
91
|
+
open: isTooltipVisible,
|
|
92
|
+
middleware: [offset(5), shift(), flip()],
|
|
93
|
+
});
|
|
109
94
|
return (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
95
|
+
<>
|
|
96
|
+
<TooltipContainer
|
|
97
|
+
className="sc-tooltip"
|
|
98
|
+
onPointerEnter={() => {
|
|
99
|
+
setIsTooltipVisible(true);
|
|
100
|
+
}}
|
|
101
|
+
onPointerLeave={() => {
|
|
102
|
+
setIsTooltipVisible(false);
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
<div ref={refs.setReference}>{children}</div>
|
|
106
|
+
</TooltipContainer>
|
|
107
|
+
{isTooltipVisible &&
|
|
108
|
+
overlay &&
|
|
109
|
+
createPortal(
|
|
110
|
+
<TooltipOverLayContainer
|
|
111
|
+
ref={refs.setFloating}
|
|
112
|
+
className="sc-tooltip-overlay"
|
|
113
|
+
placement={placement}
|
|
114
|
+
style={{ ...floatingStyles, ...overlayStyle }}
|
|
115
|
+
>
|
|
116
|
+
<TooltipText className="sc-tooltip-overlay-text">
|
|
117
|
+
{overlay}
|
|
118
|
+
</TooltipText>
|
|
119
|
+
</TooltipOverLayContainer>,
|
|
120
|
+
document.body,
|
|
121
|
+
)}
|
|
122
|
+
</>
|
|
133
123
|
);
|
|
134
124
|
}
|
|
135
125
|
|
package/src/lib/index.ts
CHANGED
|
@@ -28,11 +28,13 @@ export { Tooltip } from './components/tooltip/Tooltip.component';
|
|
|
28
28
|
export { ProgressBar } from './components/progressbar/ProgressBar.component';
|
|
29
29
|
export { TextArea } from './components/textarea/TextArea.component';
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
// BarChart (deprecated) - Use Barchart from @scality/core-ui/dist/next instead
|
|
32
|
+
// export { BarChart } from './components/barchart/BarChart.component';
|
|
32
33
|
export { CircularProgressBar } from './components/circularprogressbar/CircularProgressBar.component';
|
|
33
34
|
|
|
34
35
|
export { LateralNavbarLayout } from './components/lateralnavbarlayout/LateralNavbarLayout.component';
|
|
35
|
-
|
|
36
|
+
// GlobalHealthBar (deprecated vega version) - Use GlobalHealthBar from @scality/core-ui/dist/next instead
|
|
37
|
+
// export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBar.component';
|
|
36
38
|
export { ConstrainedText } from './components/constrainedtext/Constrainedtext.component';
|
|
37
39
|
export { EmptyState } from './components/emptystate/Emptystate.component';
|
|
38
40
|
export { EmptyTable } from './components/emptytable/Emptytable.component';
|
package/src/lib/next.ts
CHANGED
|
@@ -4,36 +4,49 @@ export { Button } from './components/buttonv2/Buttonv2.component';
|
|
|
4
4
|
export { CopyButton } from './components/buttonv2/CopyButton.component';
|
|
5
5
|
export { Tabs, Tab } from './components/tabsv2/Tabsv2.component';
|
|
6
6
|
export { Table } from './components/tablev2/Tablev2.component';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
// Keep MetricsTimeSpanProvider for backward compatibility (still used in external projects)
|
|
8
9
|
export {
|
|
9
10
|
MetricsTimeSpanProvider,
|
|
10
11
|
useMetricsTimeSpan,
|
|
11
|
-
} from './components/
|
|
12
|
-
|
|
12
|
+
} from './components/charts/MetricsTimeSpanProvider';
|
|
13
|
+
|
|
13
14
|
export { Select } from './components/selectv2/Selectv2.component';
|
|
14
15
|
export { HealthSelector } from './components/healthselectorv2/HealthSelector.component';
|
|
15
16
|
export { CoreUiThemeProvider } from './components/coreuithemeprovider/CoreUiThemeProvider';
|
|
16
17
|
export { Box } from './components/box/Box';
|
|
17
18
|
export { Input } from './components/inputv2/inputv2';
|
|
18
19
|
export { Accordion } from './components/accordion/Accordion.component';
|
|
20
|
+
|
|
21
|
+
// Export all chart components from the consolidated charts folder
|
|
19
22
|
export {
|
|
20
23
|
Barchart,
|
|
21
24
|
BarchartSortFn,
|
|
22
25
|
BarchartTooltipFn,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
BarchartTooltip,
|
|
27
|
+
LineTimeSerieChart,
|
|
28
|
+
GlobalHealthBar,
|
|
29
|
+
Sparkline,
|
|
30
|
+
ChartLegend,
|
|
26
31
|
ChartLegendWrapper,
|
|
27
32
|
useChartId,
|
|
28
|
-
|
|
29
|
-
export { ChartLegend } from './components/chartlegend/ChartLegend';
|
|
30
|
-
export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
|
|
31
|
-
export {
|
|
33
|
+
useChartLegend,
|
|
32
34
|
ChartTooltipContainer,
|
|
33
35
|
ChartTooltipItem,
|
|
34
36
|
ChartTooltipHeader,
|
|
35
37
|
ChartTooltipItemsContainer,
|
|
36
|
-
} from './components/
|
|
38
|
+
} from './components/charts';
|
|
39
|
+
|
|
40
|
+
export type {
|
|
41
|
+
BarchartProps,
|
|
42
|
+
BarchartBars,
|
|
43
|
+
LineChartProps,
|
|
44
|
+
Serie,
|
|
45
|
+
GlobalHealthProps,
|
|
46
|
+
Alert,
|
|
47
|
+
UnitRange,
|
|
48
|
+
TimeType,
|
|
49
|
+
CategoryType,
|
|
50
|
+
} from './components/charts';
|
|
51
|
+
|
|
37
52
|
export { CoreUITheme } from './style/theme';
|
|
38
|
-
export { GlobalHealthBar } from './components/globalhealthbar/GlobalHealthBarRecharts.component';
|
|
39
|
-
export { Sparkline } from './components/sparkline/sparkline.component';
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
BarchartProps,
|
|
7
7
|
BarchartSortFn,
|
|
8
8
|
BarchartTooltipFn,
|
|
9
|
-
|
|
9
|
+
ChartLegendWrapper,
|
|
10
|
+
ChartLegend,
|
|
11
|
+
} from '../../src/lib/components/charts';
|
|
10
12
|
import { Button } from '../../src/lib/components/buttonv2/Buttonv2.component';
|
|
11
13
|
import { Text } from '../../src/lib/components/text/Text.component';
|
|
12
14
|
import { spacing, Stack, Wrap } from '../../src/lib/spacing';
|
|
13
15
|
import { CoreUITheme } from '../../src/lib/style/theme';
|
|
14
16
|
import { Wrapper } from '../common';
|
|
15
|
-
import { ChartLegendWrapper } from '../../src/lib/components/chartlegend/ChartLegendWrapper';
|
|
16
|
-
import { ChartLegend } from '../../src/lib/components/chartlegend/ChartLegend';
|
|
17
17
|
|
|
18
18
|
type Story = StoryObj<typeof Barchart>;
|
|
19
19
|
|
|
@@ -39,17 +39,17 @@ export const Playground: Story = {
|
|
|
39
39
|
{
|
|
40
40
|
label: 'Success',
|
|
41
41
|
data: [
|
|
42
|
-
['category1',
|
|
43
|
-
['category2',
|
|
44
|
-
['category3',
|
|
42
|
+
['category1', 0.001],
|
|
43
|
+
['category2', 0.005],
|
|
44
|
+
['category3', 0.002],
|
|
45
45
|
],
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
label: 'Failed',
|
|
49
49
|
data: [
|
|
50
|
-
['category1',
|
|
51
|
-
['category2',
|
|
52
|
-
['category3',
|
|
50
|
+
['category1', 0.01],
|
|
51
|
+
['category2', 0.05],
|
|
52
|
+
['category3', 0.02],
|
|
53
53
|
],
|
|
54
54
|
},
|
|
55
55
|
] as const;
|
|
@@ -197,6 +197,7 @@ export const Time7DaysWithMissingData: Story = {
|
|
|
197
197
|
Success: theme.statusHealthy,
|
|
198
198
|
Failed: theme.statusCritical,
|
|
199
199
|
}}
|
|
200
|
+
sortOrder="status"
|
|
200
201
|
>
|
|
201
202
|
<Barchart
|
|
202
203
|
title="Time 7 Days With Missing Data"
|
package/stories/GlobalHealthBar/{globalhealthbarRecharts.stories.tsx → globalhealthbar.stories.tsx}
RENAMED
|
@@ -1,33 +1,15 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
1
|
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import {
|
|
4
4
|
Alert,
|
|
5
5
|
GlobalHealthBar,
|
|
6
6
|
GlobalHealthProps,
|
|
7
|
-
} from '../../src/lib/components/
|
|
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';
|
|
7
|
+
} from '../../src/lib/components/charts';
|
|
26
8
|
|
|
27
9
|
type Story = StoryObj<GlobalHealthProps>;
|
|
28
10
|
|
|
29
11
|
const meta: Meta<GlobalHealthProps> = {
|
|
30
|
-
title: 'Components/
|
|
12
|
+
title: 'Components/DataDisplay/Charts/GlobalHealthBar',
|
|
31
13
|
component: GlobalHealthBar,
|
|
32
14
|
};
|
|
33
15
|
export default meta;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta } from '@storybook/blocks';
|
|
2
|
-
import { GlobalHealthBar } from '../../src/lib/components/
|
|
3
|
-
import * as GlobalHealthBarStories from './
|
|
2
|
+
import { GlobalHealthBar } from '../../src/lib/components/charts';
|
|
3
|
+
import * as GlobalHealthBarStories from './globalhealthbar.stories';
|
|
4
4
|
|
|
5
5
|
<Meta name="Guideline" of={GlobalHealthBarStories} />
|
package/stories/common.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Meta, Story } from '@storybook/blocks';
|
|
2
|
-
import { ChartExample } from './mdxExampleComponents';
|
|
3
2
|
import { SuccessBanner } from '../banner.stories';
|
|
4
3
|
|
|
5
4
|
<Meta title="Guidelines/Chart" />
|
|
@@ -14,10 +13,6 @@ Used mostly for monitoring-related tasks.
|
|
|
14
13
|
|
|
15
14
|
Don’t depend too heavily on tooltips. They are as providing supplemental or expanded information, but shouldn’t be the only way a user can see the plotted value.
|
|
16
15
|
|
|
17
|
-
### Grid lines
|
|
18
|
-
|
|
19
|
-
Only use grid lines when it’s helpful. Possible to use only horizontal or vertical.
|
|
20
|
-
|
|
21
16
|
### Elements
|
|
22
17
|
|
|
23
18
|
- Title
|
|
@@ -28,36 +23,4 @@ _produce an example WIP_
|
|
|
28
23
|
|
|
29
24
|
## Type
|
|
30
25
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Pie charts
|
|
34
|
-
|
|
35
|
-
- No more than 6 categories
|
|
36
|
-
- Values should be different enough (otherwise select Bar charts)
|
|
37
|
-
- Should be a 100% total
|
|
38
|
-
- Categories in the desc order
|
|
39
|
-
|
|
40
|
-
_produce an example WIP_
|
|
41
|
-
|
|
42
|
-
_(Currently, there is no Pie chart in the UI)_
|
|
43
|
-
|
|
44
|
-
### Bar and column charts
|
|
45
|
-
|
|
46
|
-
- Should start at a baseline of zero.
|
|
47
|
-
{/* <ChartExample /> */}
|
|
48
|
-
|
|
49
|
-
### Line charts
|
|
50
|
-
|
|
51
|
-
- No more than 5–7 different lines
|
|
52
|
-
- Avoid randomly chosen color (otherwise risk of contrast issues)
|
|
53
|
-
|
|
54
|
-
Here, the colors for Get and List are too close.
|
|
55
|
-
|
|
56
|
-
Components/Chart/LineChart
|
|
57
|
-
|
|
58
|
-
Area charts
|
|
59
|
-
|
|
60
|
-
- Could be a single area, overlapping area, or stacked area
|
|
61
|
-
- Max 3-4 categories
|
|
62
|
-
|
|
63
|
-
{/* <SuccessBanner /> */}
|
|
26
|
+
{/* TODO: add Guidelines for charts types and add date format guidelines here or in format.mdx */}
|
|
@@ -3,14 +3,12 @@ import { Meta, StoryObj } from '@storybook/react';
|
|
|
3
3
|
import {
|
|
4
4
|
LineTimeSerieChart,
|
|
5
5
|
Serie,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
|
|
9
|
-
import { ChartLegend } from '../src/lib/components/chartlegend/ChartLegend';
|
|
10
|
-
import {
|
|
6
|
+
ChartLegendWrapper,
|
|
7
|
+
ChartLegend,
|
|
11
8
|
useChartId,
|
|
12
9
|
useChartLegend,
|
|
13
|
-
} from '../src/lib/components/
|
|
10
|
+
} from '../src/lib/components/charts';
|
|
11
|
+
import { lineTimeSeriesColorRange } from '../src/lib/style/theme';
|
|
14
12
|
import { useEffect } from 'react';
|
|
15
13
|
import {
|
|
16
14
|
SAMPLE_DURATION_LAST_TWENTY_FOUR_HOURS,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Sparkline } from '../src/lib/components/charts';
|
|
3
4
|
import { lineColor5, lineColor6 } from '../src/lib/style/theme';
|
|
4
5
|
|
|
5
6
|
const meta: Meta<typeof Sparkline> = {
|
|
@@ -10,21 +11,21 @@ const meta: Meta<typeof Sparkline> = {
|
|
|
10
11
|
},
|
|
11
12
|
tags: ['autodocs'],
|
|
12
13
|
argTypes: {
|
|
13
|
-
serie: {
|
|
14
|
+
serie: {
|
|
14
15
|
control: 'object',
|
|
15
|
-
description: 'Data series containing array of [timestamp, value] pairs'
|
|
16
|
+
description: 'Data series containing array of [timestamp, value] pairs',
|
|
16
17
|
},
|
|
17
|
-
startingTimeStamp: {
|
|
18
|
+
startingTimeStamp: {
|
|
18
19
|
control: 'number',
|
|
19
|
-
description: 'Starting timestamp in seconds for the data series'
|
|
20
|
+
description: 'Starting timestamp in seconds for the data series',
|
|
20
21
|
},
|
|
21
|
-
sampleDuration: {
|
|
22
|
+
sampleDuration: {
|
|
22
23
|
control: 'number',
|
|
23
|
-
description: 'Total duration in seconds to cover in the sparkline'
|
|
24
|
+
description: 'Total duration in seconds to cover in the sparkline',
|
|
24
25
|
},
|
|
25
|
-
sampleInterval: {
|
|
26
|
+
sampleInterval: {
|
|
26
27
|
control: 'number',
|
|
27
|
-
description: 'Interval in seconds between data points'
|
|
28
|
+
description: 'Interval in seconds between data points',
|
|
28
29
|
},
|
|
29
30
|
},
|
|
30
31
|
decorators: [
|
|
@@ -82,7 +83,7 @@ const trendingDownData: [number, number][] = [
|
|
|
82
83
|
[1740412800, 22.1],
|
|
83
84
|
];
|
|
84
85
|
|
|
85
|
-
const flatData: [number, number|null][] = [
|
|
86
|
+
const flatData: [number, number | null][] = [
|
|
86
87
|
[1740405600, 50.0],
|
|
87
88
|
[1740406320, 50.0],
|
|
88
89
|
[1740407760, 50.0],
|
|
@@ -105,7 +106,8 @@ export const Default: Story = {
|
|
|
105
106
|
parameters: {
|
|
106
107
|
docs: {
|
|
107
108
|
description: {
|
|
108
|
-
story:
|
|
109
|
+
story:
|
|
110
|
+
'Sparkline displaying highly volatile data with frequent peaks and valleys.',
|
|
109
111
|
},
|
|
110
112
|
},
|
|
111
113
|
},
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextBadge } from '../src/lib/components/textbadge/TextBadge.component';
|
|
3
3
|
import { Wrapper, Title } from './common';
|
|
4
|
+
import { IconHelp } from '../src/lib/components/iconhelper/IconHelper';
|
|
5
|
+
import { Text } from '../src/lib/components/text/Text.component';
|
|
4
6
|
export default {
|
|
5
7
|
title: 'Components/TextBadge',
|
|
6
8
|
component: TextBadge,
|
|
@@ -21,6 +23,19 @@ export const Default = {
|
|
|
21
23
|
<TextBadge text="2" variant="statusWarning" />
|
|
22
24
|
<TextBadge text="3" variant="statusCritical" />
|
|
23
25
|
<TextBadge text="Badge" variant="infoSecondary" />
|
|
26
|
+
<TextBadge
|
|
27
|
+
text={
|
|
28
|
+
<>
|
|
29
|
+
<Text>This is a badge with a tooltip</Text>
|
|
30
|
+
<span style={{ marginLeft: '8px' }}>
|
|
31
|
+
<IconHelp
|
|
32
|
+
tooltipMessage={<div>This is a tooltip</div>}
|
|
33
|
+
title="Info"
|
|
34
|
+
/>
|
|
35
|
+
</span>
|
|
36
|
+
</>
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
24
39
|
</Wrapper>
|
|
25
40
|
);
|
|
26
41
|
},
|