@ssa-ui-kit/core 1.0.19 → 1.1.1
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/style.css +4 -0
- package/dist/components/Badge/types.d.ts +1 -1
- package/dist/components/Button/fixtures.d.ts +16 -16
- package/dist/components/FullscreenModeContext.d.ts +14 -0
- package/dist/components/Icon/icons/Maximize.d.ts +3 -0
- package/dist/components/Icon/icons/all.d.ts +1 -0
- package/dist/components/Icon/icons/iconsList.d.ts +1 -1
- package/dist/components/PieChart/PieChart.d.ts +4 -1
- package/dist/components/PieChart/PieChartBases.d.ts +5 -0
- package/dist/components/PieChart/PieChartHeader.d.ts +2 -0
- package/dist/components/PieChart/PieChartLegend.d.ts +1 -1
- package/dist/components/PieChart/PieChartLegendList.d.ts +2 -0
- package/dist/components/PieChart/PieChartLegendListItem.d.ts +13 -0
- package/dist/components/PieChart/PieChartLegendMarker.d.ts +1 -0
- package/dist/components/PieChart/stories/fixtures.d.ts +5 -0
- package/dist/components/PieChart/styles.d.ts +3 -0
- package/dist/components/PieChart/types.d.ts +11 -4
- package/dist/components/WidgetCard/Content.d.ts +5 -0
- package/dist/components/WidgetCard/Header.d.ts +9 -0
- package/dist/components/WidgetCard/Title.d.ts +3 -0
- package/dist/components/WidgetCard/WidgetCard.d.ts +2 -0
- package/dist/components/WidgetCard/WidgetCardBase.d.ts +6 -0
- package/dist/components/WidgetCard/WithWidgetCard.d.ts +4 -0
- package/dist/components/WidgetCard/index.d.ts +5 -0
- package/dist/components/WidgetCard/types.d.ts +13 -0
- package/dist/components/WithLink.d.ts +7 -0
- package/dist/components/index.d.ts +59 -56
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/emotion.d.ts +1 -0
- package/package.json +3 -3
- package/src/components/Badge/Badge.stories.tsx +8 -0
- package/src/components/Badge/Badge.tsx +11 -1
- package/src/components/Badge/types.ts +1 -1
- package/src/components/FullscreenModeContext.tsx +62 -0
- package/src/components/Icon/icons/Maximize.tsx +26 -0
- package/src/components/Icon/icons/all.ts +1 -0
- package/src/components/Pagination/components/RowsPerPageDropdown/RowsPerPageDropdown.tsx +5 -7
- package/src/components/PieChart/PieChart.stories.tsx +198 -77
- package/src/components/PieChart/PieChart.tsx +83 -25
- package/src/components/PieChart/PieChartBases.tsx +32 -5
- package/src/components/PieChart/PieChartHeader.tsx +43 -0
- package/src/components/PieChart/PieChartLegend.tsx +83 -20
- package/src/components/PieChart/PieChartLegendList.tsx +10 -6
- package/src/components/PieChart/PieChartLegendListItem.tsx +30 -0
- package/src/components/PieChart/PieChartLegendMarker.tsx +9 -3
- package/src/components/PieChart/colorPalettes.ts +4 -0
- package/src/components/PieChart/stories/fixtures.ts +53 -0
- package/src/components/PieChart/styles.ts +24 -0
- package/src/components/PieChart/types.ts +14 -4
- package/src/components/SegmentedPieChart/SegmentedPieChart.tsx +1 -1
- package/src/components/WidgetCard/Content.tsx +19 -0
- package/src/components/WidgetCard/Header.tsx +45 -0
- package/src/components/WidgetCard/Title.tsx +10 -0
- package/src/components/WidgetCard/WidgetCard.tsx +38 -0
- package/src/components/WidgetCard/WidgetCardBase.tsx +27 -0
- package/src/components/WidgetCard/WithWidgetCard.tsx +18 -0
- package/src/components/WidgetCard/index.ts +5 -0
- package/src/components/WidgetCard/types.ts +14 -0
- package/src/components/WithLink.tsx +30 -0
- package/src/components/index.ts +59 -56
- package/src/themes/main.ts +1 -0
- package/src/types/emotion.ts +1 -0
- package/tsbuildcache +1 -1
- package/tsconfig.build.json +2 -0
- /package/src/components/LinksTabBar/{LinksTabBar.spec.tsx → LinksTabBar.specBackup.tsx} +0 -0
- /package/src/components/WithVisibleLG/{WithVisibleLG.spec.tsx → WithVisibleLG.specBackup.tsx} +0 -0
- /package/src/components/WithVisibleMD/{WithVisibleMD.spec.tsx → WithVisibleMD.specBackup.tsx} +0 -0
- /package/src/components/WithVisibleSM/{WithVisibleSM.spec.tsx → WithVisibleSM.specBackup.tsx} +0 -0
- /package/src/components/WithVisibleUpToLG/{WithVisibleUpToLG.spec.tsx → WithVisibleUpToLG.specBackup.tsx} +0 -0
package/dist/types/emotion.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssa-ui-kit/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"private": false,
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"@emotion/css": "^11.11.0",
|
|
55
55
|
"@emotion/react": "^11.10.5",
|
|
56
56
|
"@emotion/styled": "^11.10.5",
|
|
57
|
-
"@nivo/core": "^0.
|
|
58
|
-
"@nivo/pie": "0.
|
|
57
|
+
"@nivo/core": "^0.84.0",
|
|
58
|
+
"@nivo/pie": "0.84.0",
|
|
59
59
|
"react": "18.x",
|
|
60
60
|
"react-dom": "18.x",
|
|
61
61
|
"react-hook-form": "^7.46.1",
|
|
@@ -36,7 +36,17 @@ const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(function Badge(
|
|
|
36
36
|
ref,
|
|
37
37
|
) {
|
|
38
38
|
return (
|
|
39
|
-
<BadgeBase
|
|
39
|
+
<BadgeBase
|
|
40
|
+
ref={ref}
|
|
41
|
+
css={[
|
|
42
|
+
color in mapColors
|
|
43
|
+
? mapColors[color as keyof MainColors]
|
|
44
|
+
: {
|
|
45
|
+
background: color,
|
|
46
|
+
},
|
|
47
|
+
mapSizes[size],
|
|
48
|
+
]}
|
|
49
|
+
{...props}>
|
|
40
50
|
{children ? children : null}
|
|
41
51
|
</BadgeBase>
|
|
42
52
|
);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
export type FullscreenModeContextType = {
|
|
4
|
+
isFullscreenMode: boolean;
|
|
5
|
+
activeId: null | number | string;
|
|
6
|
+
toggleFullscreenMode: () => void;
|
|
7
|
+
setFullscreenMode: (isFullscreenMode: boolean) => void;
|
|
8
|
+
setActiveId: (activeId: null | number | string) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const FullscreenModeContext = createContext<FullscreenModeContextType>({
|
|
12
|
+
isFullscreenMode: false,
|
|
13
|
+
activeId: null,
|
|
14
|
+
toggleFullscreenMode: () => {
|
|
15
|
+
// no-op
|
|
16
|
+
},
|
|
17
|
+
setFullscreenMode: () => {
|
|
18
|
+
// no-op
|
|
19
|
+
},
|
|
20
|
+
setActiveId: () => {
|
|
21
|
+
// no-op
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const FullscreenModeProvider = ({
|
|
26
|
+
children,
|
|
27
|
+
}: React.PropsWithChildren) => {
|
|
28
|
+
const [isFullscreenMode, setFullscreenMode] = useState(false);
|
|
29
|
+
const [activeId, setActiveId] =
|
|
30
|
+
useState<FullscreenModeContextType['activeId']>(null);
|
|
31
|
+
const toggleFullscreenMode = () => {
|
|
32
|
+
setFullscreenMode((prevState) => !prevState);
|
|
33
|
+
};
|
|
34
|
+
return (
|
|
35
|
+
<FullscreenModeContext.Provider
|
|
36
|
+
value={{
|
|
37
|
+
isFullscreenMode,
|
|
38
|
+
activeId,
|
|
39
|
+
setFullscreenMode,
|
|
40
|
+
toggleFullscreenMode,
|
|
41
|
+
setActiveId,
|
|
42
|
+
}}>
|
|
43
|
+
{children}
|
|
44
|
+
</FullscreenModeContext.Provider>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const useFullscreenMode = () => useContext(FullscreenModeContext);
|
|
49
|
+
|
|
50
|
+
export const WithFullscreenMode = <T extends object>(
|
|
51
|
+
Component: React.ComponentType<T>,
|
|
52
|
+
rest?: Parameters<typeof FullscreenModeProvider>[0],
|
|
53
|
+
) => {
|
|
54
|
+
const decoratedComp = (props: T) => (
|
|
55
|
+
<FullscreenModeProvider {...rest}>
|
|
56
|
+
<Component {...props} />
|
|
57
|
+
</FullscreenModeProvider>
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
decoratedComp.displayName = `WithFullscreenMode(${Component.displayName})`;
|
|
61
|
+
return decoratedComp;
|
|
62
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SVGProps } from '@components/Icon/types';
|
|
2
|
+
|
|
3
|
+
export const Maximize = ({
|
|
4
|
+
fill = '#000',
|
|
5
|
+
size = 24,
|
|
6
|
+
tooltip = 'Maximize',
|
|
7
|
+
...props
|
|
8
|
+
}: SVGProps) => (
|
|
9
|
+
<svg
|
|
10
|
+
width={`${size}px`}
|
|
11
|
+
height={`${size}px`}
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
14
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
15
|
+
{...props}>
|
|
16
|
+
<title>{tooltip}</title>
|
|
17
|
+
<path
|
|
18
|
+
fillRule="evenodd"
|
|
19
|
+
clipRule="evenodd"
|
|
20
|
+
d="M2.30005 4.00005C2.30005 3.06116 3.06116 2.30005 4.00005 2.30005H8.00005C8.38665 2.30005 8.70005 2.61345 8.70005 3.00005C8.70005 3.38665 8.38665 3.70005 8.00005 3.70005H4.00005C3.83436 3.70005 3.70005 3.83436 3.70005 4.00005V8.00005C3.70005 8.38665 3.38665 8.70005 3.00005 8.70005C2.61345 8.70005 2.30005 8.38665 2.30005 8.00005V4.00005ZM15.3 3.00005C15.3 2.61345 15.6134 2.30005 16 2.30005H20C20.9389 2.30005 21.7001 3.06116 21.7001 4.00005V8.00005C21.7001 8.38665 21.3866 8.70005 21 8.70005C20.6135 8.70005 20.3 8.38665 20.3 8.00005V4.00005C20.3 3.83436 20.1657 3.70005 20 3.70005H16C15.6134 3.70005 15.3 3.38665 15.3 3.00005ZM3.00005 15.3C3.38665 15.3 3.70005 15.6134 3.70005 16V20C3.70005 20.1657 3.83436 20.3 4.00005 20.3H8.00005C8.38665 20.3 8.70005 20.6135 8.70005 21C8.70005 21.3866 8.38665 21.7001 8.00005 21.7001H4.00005C3.06116 21.7001 2.30005 20.9389 2.30005 20V16C2.30005 15.6134 2.61345 15.3 3.00005 15.3ZM21 15.3C21.3866 15.3 21.7001 15.6134 21.7001 16V20C21.7001 20.9389 20.9389 21.7001 20 21.7001H16C15.6134 21.7001 15.3 21.3866 15.3 21C15.3 20.6135 15.6134 20.3 16 20.3H20C20.1657 20.3 20.3 20.1657 20.3 20V16C20.3 15.6134 20.6135 15.3 21 15.3Z"
|
|
21
|
+
fill={fill}
|
|
22
|
+
/>
|
|
23
|
+
</svg>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const ICON_NAME = 'maximize';
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { useTheme } from '@emotion/react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
usePaginationContext,
|
|
8
|
-
} from '@components';
|
|
2
|
+
import DropdownOption from '@components/DropdownOption/DropdownOption';
|
|
3
|
+
import Typography from '@components/Typography/Typography';
|
|
4
|
+
import Wrapper from '@components/Wrapper/Wrapper';
|
|
5
|
+
import Dropdown from '@components/Dropdown/Dropdown';
|
|
6
|
+
import { usePaginationContext } from '@components/Pagination/PaginationContext';
|
|
9
7
|
import { RowsPerPageDropdownProps } from './types';
|
|
10
8
|
import { DEFAULT_PER_PAGE_VALUE, ROWS_PER_PAGE_LIST } from '../../constants';
|
|
11
9
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { Fragment, useState } from 'react';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
3
|
import { css, useTheme } from '@emotion/react';
|
|
3
4
|
import Typography from '@components/Typography';
|
|
4
|
-
|
|
5
5
|
import { PieChart, PieChartLegend, pieChartPalettes } from './index';
|
|
6
|
-
import { fitnessData, accountData } from './stories/fixtures';
|
|
6
|
+
import { fitnessData, accountData, eventsDataBig } from './stories/fixtures';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Charts/PieChart',
|
|
@@ -21,49 +21,47 @@ export const FitnessExample: StoryObj<typeof PieChart> = () => {
|
|
|
21
21
|
] as unknown as string[];
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
<PieChart
|
|
25
|
+
data={fitnessData}
|
|
26
|
+
colors={pieChartColors}
|
|
27
|
+
animate={false}
|
|
28
|
+
title={
|
|
29
|
+
<Typography
|
|
30
|
+
variant="body2"
|
|
31
|
+
weight="regular"
|
|
32
|
+
color={theme.colors.greyDarker60}
|
|
33
|
+
css={css`
|
|
34
|
+
font-size: 16px;
|
|
35
|
+
line-height: 16px;
|
|
36
|
+
margin-top: -5px;
|
|
37
|
+
`}>
|
|
38
|
+
Total
|
|
30
39
|
<Typography
|
|
31
40
|
variant="body2"
|
|
32
|
-
weight="
|
|
33
|
-
color={theme.colors.
|
|
41
|
+
weight="bold"
|
|
42
|
+
color={theme.colors.greyDarker}
|
|
34
43
|
css={css`
|
|
35
|
-
font-size:
|
|
36
|
-
line-height:
|
|
37
|
-
margin-top: -5px;
|
|
44
|
+
font-size: 27.65px;
|
|
45
|
+
line-height: 35px;
|
|
38
46
|
`}>
|
|
39
|
-
|
|
47
|
+
143
|
|
40
48
|
<Typography
|
|
41
49
|
variant="body2"
|
|
42
|
-
weight="
|
|
43
|
-
|
|
50
|
+
weight="regular"
|
|
51
|
+
as="span"
|
|
52
|
+
color={theme.colors.greyDarker60}
|
|
44
53
|
css={css`
|
|
45
|
-
font-size:
|
|
46
|
-
|
|
54
|
+
font-size: 16px;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
margin-left: 3px;
|
|
47
57
|
`}>
|
|
48
|
-
|
|
49
|
-
<Typography
|
|
50
|
-
variant="body2"
|
|
51
|
-
weight="regular"
|
|
52
|
-
as="span"
|
|
53
|
-
color={theme.colors.greyDarker60}
|
|
54
|
-
css={css`
|
|
55
|
-
font-size: 16px;
|
|
56
|
-
font-weight: 600;
|
|
57
|
-
margin-left: 3px;
|
|
58
|
-
`}>
|
|
59
|
-
hrs
|
|
60
|
-
</Typography>
|
|
58
|
+
hrs
|
|
61
59
|
</Typography>
|
|
62
60
|
</Typography>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</
|
|
61
|
+
</Typography>
|
|
62
|
+
}>
|
|
63
|
+
<PieChartLegend data={fitnessData} colors={colorNames} />
|
|
64
|
+
</PieChart>
|
|
67
65
|
);
|
|
68
66
|
};
|
|
69
67
|
FitnessExample.args = {};
|
|
@@ -74,56 +72,179 @@ export const AccountExample: StoryObj<typeof PieChart> = () => {
|
|
|
74
72
|
pieChartPalettes.getBalancePalette(theme);
|
|
75
73
|
|
|
76
74
|
return (
|
|
77
|
-
<
|
|
78
|
-
|
|
75
|
+
<PieChart
|
|
76
|
+
data={accountData}
|
|
77
|
+
colors={pieChartColors}
|
|
78
|
+
animate={false}
|
|
79
|
+
title={
|
|
80
|
+
<Typography
|
|
81
|
+
variant="body2"
|
|
82
|
+
weight="bold"
|
|
83
|
+
color={theme.colors.greyDarker}
|
|
84
|
+
css={css`
|
|
85
|
+
font-size: 20px;
|
|
86
|
+
line-height: 25px;
|
|
87
|
+
`}>
|
|
88
|
+
18183
|
|
89
|
+
<Typography
|
|
90
|
+
variant="body2"
|
|
91
|
+
weight="regular"
|
|
92
|
+
as="span"
|
|
93
|
+
color={theme.colors.greyDarker80}
|
|
94
|
+
css={css`
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
`}>
|
|
97
|
+
USDT
|
|
98
|
+
</Typography>
|
|
99
|
+
</Typography>
|
|
100
|
+
}>
|
|
101
|
+
<PieChartLegend
|
|
79
102
|
data={accountData}
|
|
80
|
-
colors={
|
|
81
|
-
|
|
82
|
-
|
|
103
|
+
colors={legendColorNames}
|
|
104
|
+
renderValue={({ value, label }) =>
|
|
105
|
+
label === 'Other' ? value + ' USD' : value + ' ' + label
|
|
106
|
+
}
|
|
107
|
+
markerStyles={css`
|
|
108
|
+
width: 10px;
|
|
109
|
+
height: 10px;
|
|
110
|
+
`}
|
|
111
|
+
labelListStyles={css`
|
|
112
|
+
h6 {
|
|
113
|
+
font-weight: 700;
|
|
114
|
+
}
|
|
115
|
+
`}
|
|
116
|
+
valueListStyles={css`
|
|
117
|
+
h6 {
|
|
118
|
+
color: ${theme.colors.greyDarker80};
|
|
119
|
+
}
|
|
120
|
+
`}
|
|
121
|
+
/>
|
|
122
|
+
</PieChart>
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
AccountExample.args = {};
|
|
126
|
+
|
|
127
|
+
export const CustomColors: StoryObj<typeof PieChart> = () => {
|
|
128
|
+
const theme = useTheme();
|
|
129
|
+
const colors = ['#F7931A', '#50AF95', '#6f93d1', '#d37070'];
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<PieChart
|
|
133
|
+
data={accountData}
|
|
134
|
+
colors={colors}
|
|
135
|
+
animate={false}
|
|
136
|
+
title={
|
|
137
|
+
<Typography
|
|
138
|
+
variant="body2"
|
|
139
|
+
weight="bold"
|
|
140
|
+
color={theme.colors.greyDarker}
|
|
141
|
+
css={css`
|
|
142
|
+
font-size: 20px;
|
|
143
|
+
line-height: 25px;
|
|
144
|
+
`}>
|
|
145
|
+
18183
|
|
83
146
|
<Typography
|
|
84
147
|
variant="body2"
|
|
85
|
-
weight="
|
|
86
|
-
|
|
148
|
+
weight="regular"
|
|
149
|
+
as="span"
|
|
150
|
+
color={theme.colors.greyDarker80}
|
|
87
151
|
css={css`
|
|
88
|
-
font-size:
|
|
89
|
-
line-height: 25px;
|
|
152
|
+
font-size: 14px;
|
|
90
153
|
`}>
|
|
91
|
-
|
|
92
|
-
<Typography
|
|
93
|
-
variant="body2"
|
|
94
|
-
weight="regular"
|
|
95
|
-
as="span"
|
|
96
|
-
color={theme.colors.greyDarker80}
|
|
97
|
-
css={css`
|
|
98
|
-
font-size: 14px;
|
|
99
|
-
`}>
|
|
100
|
-
USDT
|
|
101
|
-
</Typography>
|
|
154
|
+
USDT
|
|
102
155
|
</Typography>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
156
|
+
</Typography>
|
|
157
|
+
}>
|
|
158
|
+
<PieChartLegend
|
|
159
|
+
data={accountData}
|
|
160
|
+
backgroundColors={colors}
|
|
161
|
+
renderValue={({ value, label }) =>
|
|
162
|
+
label === 'Other' ? value + ' USD' : value + ' ' + label
|
|
163
|
+
}
|
|
164
|
+
markerStyles={css`
|
|
165
|
+
width: 10px;
|
|
166
|
+
height: 10px;
|
|
167
|
+
`}
|
|
168
|
+
labelListStyles={css`
|
|
169
|
+
h6 {
|
|
170
|
+
font-weight: 700;
|
|
109
171
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
172
|
+
`}
|
|
173
|
+
valueListStyles={css`
|
|
174
|
+
h6 {
|
|
175
|
+
color: ${theme.colors.greyDarker80};
|
|
176
|
+
}
|
|
177
|
+
`}
|
|
178
|
+
/>
|
|
179
|
+
</PieChart>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
CustomColors.args = {};
|
|
183
|
+
|
|
184
|
+
export const FullscreenAndTitle: StoryObj<typeof PieChart> = () => {
|
|
185
|
+
const theme = useTheme();
|
|
186
|
+
const [isFullscreenMode, setFullscreenMode] = useState(false);
|
|
187
|
+
const { legendColorNames, pieChartColors } =
|
|
188
|
+
pieChartPalettes.getBalancePalette(theme);
|
|
189
|
+
|
|
190
|
+
return (
|
|
191
|
+
<PieChart
|
|
192
|
+
data={eventsDataBig}
|
|
193
|
+
onFullscreenModeChange={setFullscreenMode}
|
|
194
|
+
colors={pieChartColors}
|
|
195
|
+
activeHighlight
|
|
196
|
+
isInteractive
|
|
197
|
+
innerRadius={0}
|
|
198
|
+
padAngle={0}
|
|
199
|
+
cornerRadius={0}
|
|
200
|
+
css={{
|
|
201
|
+
padding: 20,
|
|
202
|
+
}}
|
|
203
|
+
activeInnerRadiusOffset={0}
|
|
204
|
+
activeOuterRadiusOffset={isFullscreenMode ? 40 : 7}
|
|
205
|
+
features={['header', 'fullscreenMode']}
|
|
206
|
+
cardProps={{
|
|
207
|
+
title: 'Events',
|
|
208
|
+
}}
|
|
209
|
+
tooltip={() => <Fragment></Fragment>}>
|
|
210
|
+
<PieChartLegend
|
|
211
|
+
data={eventsDataBig}
|
|
212
|
+
colors={legendColorNames}
|
|
213
|
+
activeHighlight
|
|
214
|
+
markerStyles={css`
|
|
215
|
+
width: 10px;
|
|
216
|
+
height: 10px;
|
|
217
|
+
`}
|
|
218
|
+
labelListStyles={css`
|
|
219
|
+
li {
|
|
220
|
+
height: ${isFullscreenMode ? 'auto' : '34px'};
|
|
221
|
+
}
|
|
222
|
+
h6 {
|
|
223
|
+
color: ${theme.colors.greyDarker};
|
|
224
|
+
line-height: 34px;
|
|
225
|
+
font-size: 14px;
|
|
226
|
+
&:nth-of-type(1) {
|
|
227
|
+
font-weight: 500;
|
|
117
228
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
color: ${theme.colors.greyDarker80};
|
|
229
|
+
&:nth-of-type(2) {
|
|
230
|
+
font-weight: 700;
|
|
231
|
+
font-size: 12px;
|
|
122
232
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
233
|
+
}
|
|
234
|
+
`}
|
|
235
|
+
valueListStyles={css`
|
|
236
|
+
li {
|
|
237
|
+
justify-content: flex-end;
|
|
238
|
+
height: ${isFullscreenMode ? 'auto' : '34px'};
|
|
239
|
+
}
|
|
240
|
+
h6 {
|
|
241
|
+
color: ${theme.colors.greyDarker};
|
|
242
|
+
font-weight: 700;
|
|
243
|
+
font-size: 12px;
|
|
244
|
+
}
|
|
245
|
+
`}
|
|
246
|
+
/>
|
|
247
|
+
</PieChart>
|
|
127
248
|
);
|
|
128
249
|
};
|
|
129
|
-
|
|
250
|
+
FullscreenAndTitle.args = {};
|
|
@@ -1,38 +1,96 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
1
2
|
import { ResponsivePie } from '@nivo/pie';
|
|
3
|
+
import {
|
|
4
|
+
useFullscreenMode,
|
|
5
|
+
WithFullscreenMode,
|
|
6
|
+
} from '@components/FullscreenModeContext';
|
|
7
|
+
import { WithWidgetCard } from '@components/WidgetCard';
|
|
2
8
|
import { PieChartProps } from './types';
|
|
3
|
-
|
|
4
9
|
import { PieChartBase, PieChartTextBase } from './PieChartBases';
|
|
10
|
+
import { PieChartHeader } from './PieChartHeader';
|
|
5
11
|
|
|
6
|
-
|
|
12
|
+
const PieChartComponent = ({
|
|
7
13
|
as,
|
|
8
14
|
className,
|
|
9
15
|
title,
|
|
10
16
|
children,
|
|
17
|
+
width = '400px',
|
|
18
|
+
features = [],
|
|
19
|
+
cardProps,
|
|
20
|
+
activeHighlight = false,
|
|
21
|
+
onFullscreenModeChange,
|
|
11
22
|
...chartProps
|
|
12
23
|
}: PieChartProps) => {
|
|
24
|
+
const { isFullscreenMode, activeId, setActiveId } = useFullscreenMode();
|
|
25
|
+
const {
|
|
26
|
+
activeInnerRadiusOffset = 0,
|
|
27
|
+
activeOuterRadiusOffset = 0,
|
|
28
|
+
isInteractive = false,
|
|
29
|
+
} = chartProps;
|
|
30
|
+
|
|
31
|
+
let internalOffset = 0;
|
|
32
|
+
if (isInteractive) {
|
|
33
|
+
internalOffset = Math.max(
|
|
34
|
+
...[activeInnerRadiusOffset, activeOuterRadiusOffset],
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
onFullscreenModeChange?.(isFullscreenMode);
|
|
40
|
+
}, [isFullscreenMode]);
|
|
41
|
+
|
|
13
42
|
return (
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
<WithWidgetCard
|
|
44
|
+
features={features}
|
|
45
|
+
width={`calc(${width} + ${internalOffset}px)`}
|
|
46
|
+
cardProps={{
|
|
47
|
+
headerContent: <PieChartHeader features={features} />,
|
|
48
|
+
...cardProps,
|
|
49
|
+
}}>
|
|
50
|
+
<PieChartBase
|
|
51
|
+
as={as}
|
|
52
|
+
className={className}
|
|
53
|
+
width={`calc(${width} + ${internalOffset}px)`}
|
|
54
|
+
isFullscreenMode={isFullscreenMode}>
|
|
55
|
+
<div className="pie-chart-wrapper">
|
|
56
|
+
<ResponsivePie
|
|
57
|
+
isInteractive={false}
|
|
58
|
+
margin={{
|
|
59
|
+
top: internalOffset,
|
|
60
|
+
right: internalOffset,
|
|
61
|
+
bottom: internalOffset,
|
|
62
|
+
left: internalOffset,
|
|
63
|
+
}}
|
|
64
|
+
innerRadius={0.8}
|
|
65
|
+
enableArcLinkLabels={false}
|
|
66
|
+
enableArcLabels={false}
|
|
67
|
+
padAngle={2}
|
|
68
|
+
cornerRadius={16}
|
|
69
|
+
activeInnerRadiusOffset={0}
|
|
70
|
+
activeOuterRadiusOffset={0}
|
|
71
|
+
colors={{ datum: 'data.color' }}
|
|
72
|
+
arcLinkLabelsSkipAngle={10}
|
|
73
|
+
arcLinkLabelsTextColor="#333333"
|
|
74
|
+
arcLinkLabelsThickness={2}
|
|
75
|
+
arcLinkLabelsColor={{ from: 'color' }}
|
|
76
|
+
arcLabelsSkipAngle={10}
|
|
77
|
+
layers={['arcs', 'arcLinkLabels', 'arcLabels']}
|
|
78
|
+
activeId={activeId}
|
|
79
|
+
onActiveIdChange={(activeId: string | number | null) => {
|
|
80
|
+
activeHighlight && setActiveId(activeId);
|
|
81
|
+
}}
|
|
82
|
+
{...chartProps}
|
|
83
|
+
/>
|
|
84
|
+
{title && (
|
|
85
|
+
<PieChartTextBase isFullscreenMode={isFullscreenMode}>
|
|
86
|
+
{title}
|
|
87
|
+
</PieChartTextBase>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
{children}
|
|
91
|
+
</PieChartBase>
|
|
92
|
+
</WithWidgetCard>
|
|
37
93
|
);
|
|
38
94
|
};
|
|
95
|
+
|
|
96
|
+
export const PieChart = WithFullscreenMode(PieChartComponent);
|
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
|
|
3
|
-
export const PieChartBase = styled.div
|
|
3
|
+
export const PieChartBase = styled.div<{
|
|
4
|
+
isFullscreenMode: boolean;
|
|
5
|
+
width?: string;
|
|
6
|
+
}>`
|
|
4
7
|
display: flex;
|
|
5
|
-
flex-direction: row;
|
|
6
8
|
justify-content: space-between;
|
|
7
9
|
align-items: center;
|
|
8
10
|
|
|
11
|
+
flex-direction: ${({ isFullscreenMode }) =>
|
|
12
|
+
isFullscreenMode ? 'column' : 'row'};
|
|
13
|
+
|
|
14
|
+
width: ${({ isFullscreenMode, width }) =>
|
|
15
|
+
isFullscreenMode ? '100%' : width};
|
|
16
|
+
height: 100%;
|
|
17
|
+
|
|
18
|
+
height: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : 'auto')};
|
|
19
|
+
max-height: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : 'none')};
|
|
20
|
+
|
|
9
21
|
& > .pie-chart-wrapper {
|
|
10
22
|
position: relative;
|
|
11
|
-
width: 160px;
|
|
12
|
-
|
|
23
|
+
width: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : '160px')};
|
|
24
|
+
|
|
25
|
+
${({ theme }) => theme.mediaQueries.md} {
|
|
26
|
+
margin-bottom: 6px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
${({ theme }) => theme.mediaQueries.lg} {
|
|
30
|
+
margin-bottom: 0;
|
|
31
|
+
}
|
|
32
|
+
height: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : '160px')};
|
|
33
|
+
|
|
34
|
+
& > div > div {
|
|
35
|
+
display: ${({ isFullscreenMode }) =>
|
|
36
|
+
isFullscreenMode ? 'flex' : 'block'};
|
|
37
|
+
justify-content: ${({ isFullscreenMode }) =>
|
|
38
|
+
isFullscreenMode ? 'center' : 'unset'};
|
|
39
|
+
}
|
|
13
40
|
}
|
|
14
41
|
`;
|
|
15
42
|
|
|
16
|
-
export const PieChartTextBase = styled.div
|
|
43
|
+
export const PieChartTextBase = styled.div<{ isFullscreenMode: boolean }>`
|
|
17
44
|
position: absolute;
|
|
18
45
|
display: flex;
|
|
19
46
|
align-items: center;
|