@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.
Files changed (70) hide show
  1. package/.storybook/style.css +4 -0
  2. package/dist/components/Badge/types.d.ts +1 -1
  3. package/dist/components/Button/fixtures.d.ts +16 -16
  4. package/dist/components/FullscreenModeContext.d.ts +14 -0
  5. package/dist/components/Icon/icons/Maximize.d.ts +3 -0
  6. package/dist/components/Icon/icons/all.d.ts +1 -0
  7. package/dist/components/Icon/icons/iconsList.d.ts +1 -1
  8. package/dist/components/PieChart/PieChart.d.ts +4 -1
  9. package/dist/components/PieChart/PieChartBases.d.ts +5 -0
  10. package/dist/components/PieChart/PieChartHeader.d.ts +2 -0
  11. package/dist/components/PieChart/PieChartLegend.d.ts +1 -1
  12. package/dist/components/PieChart/PieChartLegendList.d.ts +2 -0
  13. package/dist/components/PieChart/PieChartLegendListItem.d.ts +13 -0
  14. package/dist/components/PieChart/PieChartLegendMarker.d.ts +1 -0
  15. package/dist/components/PieChart/stories/fixtures.d.ts +5 -0
  16. package/dist/components/PieChart/styles.d.ts +3 -0
  17. package/dist/components/PieChart/types.d.ts +11 -4
  18. package/dist/components/WidgetCard/Content.d.ts +5 -0
  19. package/dist/components/WidgetCard/Header.d.ts +9 -0
  20. package/dist/components/WidgetCard/Title.d.ts +3 -0
  21. package/dist/components/WidgetCard/WidgetCard.d.ts +2 -0
  22. package/dist/components/WidgetCard/WidgetCardBase.d.ts +6 -0
  23. package/dist/components/WidgetCard/WithWidgetCard.d.ts +4 -0
  24. package/dist/components/WidgetCard/index.d.ts +5 -0
  25. package/dist/components/WidgetCard/types.d.ts +13 -0
  26. package/dist/components/WithLink.d.ts +7 -0
  27. package/dist/components/index.d.ts +59 -56
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/types/emotion.d.ts +1 -0
  31. package/package.json +3 -3
  32. package/src/components/Badge/Badge.stories.tsx +8 -0
  33. package/src/components/Badge/Badge.tsx +11 -1
  34. package/src/components/Badge/types.ts +1 -1
  35. package/src/components/FullscreenModeContext.tsx +62 -0
  36. package/src/components/Icon/icons/Maximize.tsx +26 -0
  37. package/src/components/Icon/icons/all.ts +1 -0
  38. package/src/components/Pagination/components/RowsPerPageDropdown/RowsPerPageDropdown.tsx +5 -7
  39. package/src/components/PieChart/PieChart.stories.tsx +198 -77
  40. package/src/components/PieChart/PieChart.tsx +83 -25
  41. package/src/components/PieChart/PieChartBases.tsx +32 -5
  42. package/src/components/PieChart/PieChartHeader.tsx +43 -0
  43. package/src/components/PieChart/PieChartLegend.tsx +83 -20
  44. package/src/components/PieChart/PieChartLegendList.tsx +10 -6
  45. package/src/components/PieChart/PieChartLegendListItem.tsx +30 -0
  46. package/src/components/PieChart/PieChartLegendMarker.tsx +9 -3
  47. package/src/components/PieChart/colorPalettes.ts +4 -0
  48. package/src/components/PieChart/stories/fixtures.ts +53 -0
  49. package/src/components/PieChart/styles.ts +24 -0
  50. package/src/components/PieChart/types.ts +14 -4
  51. package/src/components/SegmentedPieChart/SegmentedPieChart.tsx +1 -1
  52. package/src/components/WidgetCard/Content.tsx +19 -0
  53. package/src/components/WidgetCard/Header.tsx +45 -0
  54. package/src/components/WidgetCard/Title.tsx +10 -0
  55. package/src/components/WidgetCard/WidgetCard.tsx +38 -0
  56. package/src/components/WidgetCard/WidgetCardBase.tsx +27 -0
  57. package/src/components/WidgetCard/WithWidgetCard.tsx +18 -0
  58. package/src/components/WidgetCard/index.ts +5 -0
  59. package/src/components/WidgetCard/types.ts +14 -0
  60. package/src/components/WithLink.tsx +30 -0
  61. package/src/components/index.ts +59 -56
  62. package/src/themes/main.ts +1 -0
  63. package/src/types/emotion.ts +1 -0
  64. package/tsbuildcache +1 -1
  65. package/tsconfig.build.json +2 -0
  66. /package/src/components/LinksTabBar/{LinksTabBar.spec.tsx → LinksTabBar.specBackup.tsx} +0 -0
  67. /package/src/components/WithVisibleLG/{WithVisibleLG.spec.tsx → WithVisibleLG.specBackup.tsx} +0 -0
  68. /package/src/components/WithVisibleMD/{WithVisibleMD.spec.tsx → WithVisibleMD.specBackup.tsx} +0 -0
  69. /package/src/components/WithVisibleSM/{WithVisibleSM.spec.tsx → WithVisibleSM.specBackup.tsx} +0 -0
  70. /package/src/components/WithVisibleUpToLG/{WithVisibleUpToLG.spec.tsx → WithVisibleUpToLG.specBackup.tsx} +0 -0
@@ -18,6 +18,7 @@ type Colors = MakeColors<[
18
18
  'grey',
19
19
  'grey20',
20
20
  'grey40',
21
+ 'greyShadow16',
21
22
  'greyShadow24',
22
23
  'greyDarker',
23
24
  'greyDarker40',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/core",
3
- "version": "1.0.19",
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.83.0",
58
- "@nivo/pie": "0.83.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",
@@ -154,3 +154,11 @@ WithIcon.argTypes = {
154
154
  control: false,
155
155
  },
156
156
  };
157
+
158
+ export const WithCustomColor = () => {
159
+ return (
160
+ <Badge color={'#F7931A'} size="medium">
161
+ Custom color
162
+ </Badge>
163
+ );
164
+ };
@@ -36,7 +36,17 @@ const Badge = React.forwardRef<HTMLDivElement, BadgeProps>(function Badge(
36
36
  ref,
37
37
  ) {
38
38
  return (
39
- <BadgeBase ref={ref} css={[mapColors[color], mapSizes[size]]} {...props}>
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
  );
@@ -1,5 +1,5 @@
1
1
  export interface BadgeProps {
2
- color?: keyof MainColors;
2
+ color?: keyof MainColors | string;
3
3
  size?: keyof MainSizes;
4
4
  children?: React.ReactNode;
5
5
  as?: React.ElementType;
@@ -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';
@@ -57,3 +57,4 @@ export * as Edit from './Edit';
57
57
  export * as Import from './Import';
58
58
  export * as Pages from './Pages';
59
59
  export * as Roles from './Roles';
60
+ export * as Maximize from './Maximize';
@@ -1,11 +1,9 @@
1
1
  import { useTheme } from '@emotion/react';
2
- import {
3
- DropdownOption,
4
- Typography,
5
- Wrapper,
6
- Dropdown,
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
- <div style={{ width: '400px' }}>
25
- <PieChart
26
- data={fitnessData}
27
- colors={pieChartColors}
28
- animate={false}
29
- title={
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="regular"
33
- color={theme.colors.greyDarker60}
41
+ weight="bold"
42
+ color={theme.colors.greyDarker}
34
43
  css={css`
35
- font-size: 16px;
36
- line-height: 16px;
37
- margin-top: -5px;
44
+ font-size: 27.65px;
45
+ line-height: 35px;
38
46
  `}>
39
- Total
47
+ 143
40
48
  <Typography
41
49
  variant="body2"
42
- weight="bold"
43
- color={theme.colors.greyDarker}
50
+ weight="regular"
51
+ as="span"
52
+ color={theme.colors.greyDarker60}
44
53
  css={css`
45
- font-size: 27.65px;
46
- line-height: 35px;
54
+ font-size: 16px;
55
+ font-weight: 600;
56
+ margin-left: 3px;
47
57
  `}>
48
- 143
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
- <PieChartLegend data={fitnessData} colors={colorNames} />
65
- </PieChart>
66
- </div>
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
- <div style={{ width: '400px' }}>
78
- <PieChart
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 &nbsp;
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={pieChartColors}
81
- animate={false}
82
- title={
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 &nbsp;
83
146
  <Typography
84
147
  variant="body2"
85
- weight="bold"
86
- color={theme.colors.greyDarker}
148
+ weight="regular"
149
+ as="span"
150
+ color={theme.colors.greyDarker80}
87
151
  css={css`
88
- font-size: 20px;
89
- line-height: 25px;
152
+ font-size: 14px;
90
153
  `}>
91
- 18183 &nbsp;
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
- <PieChartLegend
105
- data={accountData}
106
- colors={legendColorNames}
107
- renderValue={({ value, label }) =>
108
- label === 'Other' ? value + ' USD' : value + ' ' + label
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
- markerStyles={css`
111
- width: 10px;
112
- height: 10px;
113
- `}
114
- labelListStyles={css`
115
- h6 {
116
- font-weight: 700;
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
- valueListStyles={css`
120
- h6 {
121
- color: ${theme.colors.greyDarker80};
229
+ &:nth-of-type(2) {
230
+ font-weight: 700;
231
+ font-size: 12px;
122
232
  }
123
- `}
124
- />
125
- </PieChart>
126
- </div>
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
- AccountExample.args = {};
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
- export const PieChart = ({
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
- <PieChartBase as={as} className={className}>
15
- <div className="pie-chart-wrapper">
16
- <ResponsivePie
17
- isInteractive={false}
18
- innerRadius={0.8}
19
- enableArcLinkLabels={false}
20
- enableArcLabels={false}
21
- padAngle={2}
22
- cornerRadius={16}
23
- activeOuterRadiusOffset={8}
24
- colors={{ datum: 'data.color' }}
25
- arcLinkLabelsSkipAngle={10}
26
- arcLinkLabelsTextColor="#333333"
27
- arcLinkLabelsThickness={2}
28
- arcLinkLabelsColor={{ from: 'color' }}
29
- arcLabelsSkipAngle={10}
30
- layers={['arcs', 'arcLinkLabels', 'arcLabels']}
31
- {...chartProps}
32
- />
33
- {title && <PieChartTextBase>{title}</PieChartTextBase>}
34
- </div>
35
- {children}
36
- </PieChartBase>
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
- height: 160px;
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;