@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
@@ -0,0 +1,43 @@
1
+ import { Fragment } from 'react';
2
+ import { useTheme } from '@emotion/react';
3
+ import Icon from '@components/Icon';
4
+ import Wrapper from '@components/Wrapper';
5
+ import { useFullscreenMode } from '@components/FullscreenModeContext';
6
+ import { PieChartProps } from './types';
7
+ import { PieChartButton } from './styles';
8
+
9
+ export const PieChartHeader = ({
10
+ features = [],
11
+ }: Pick<PieChartProps, 'features'>) => {
12
+ const theme = useTheme();
13
+ const { toggleFullscreenMode, isFullscreenMode } = useFullscreenMode();
14
+
15
+ const handleToggleFullscreenMode = (
16
+ event: React.MouseEvent<HTMLButtonElement>,
17
+ ) => {
18
+ event.stopPropagation();
19
+ event.preventDefault();
20
+ toggleFullscreenMode();
21
+ };
22
+
23
+ if (!features.length) {
24
+ return <Fragment></Fragment>;
25
+ }
26
+ return (
27
+ <Wrapper css={{ width: 'auto', marginLeft: 'auto' }}>
28
+ {features.includes('fullscreenMode') && (
29
+ <PieChartButton variant="tertiary" onClick={handleToggleFullscreenMode}>
30
+ <Icon
31
+ name={isFullscreenMode ? 'cross' : 'maximize'}
32
+ css={{
33
+ cursor: 'pointer',
34
+ }}
35
+ tooltip={isFullscreenMode ? 'Close' : 'Maximize'}
36
+ size={18}
37
+ color={theme.colors.greyFilterIcon}
38
+ />
39
+ </PieChartButton>
40
+ )}
41
+ </Wrapper>
42
+ );
43
+ };
@@ -1,32 +1,56 @@
1
1
  import { useTheme } from '@emotion/react';
2
- import { Fragment } from 'react';
3
2
  import Typography from '@components/Typography';
4
3
 
4
+ import { useFullscreenMode } from '@components/FullscreenModeContext';
5
+ import Wrapper from '@components/Wrapper';
5
6
  import { PieChartLegendMarker } from './PieChartLegendMarker';
6
7
  import { PieChartLegendList } from './PieChartLegendList';
7
8
  import { PieChartLegendProps } from './types';
9
+ import {
10
+ PieChartLegendListItem,
11
+ PieChartLegendListValueListItem,
12
+ } from './PieChartLegendListItem';
8
13
 
9
14
  export const PieChartLegend = ({
10
15
  data,
11
16
  colors,
12
17
  backgroundColors,
13
- renderLabel,
14
- renderValue,
15
18
  markerStyles,
16
19
  currency,
17
20
  labelListStyles,
18
21
  valueListStyles,
19
22
  variant = 'valueList',
23
+ activeHighlight = false,
24
+ renderLabel,
25
+ renderValue,
20
26
  }: PieChartLegendProps) => {
21
27
  const theme = useTheme();
22
28
  const isValueList = variant === 'valueList';
29
+ const { isFullscreenMode, activeId, setActiveId } = useFullscreenMode();
30
+ const handleActiveIdChange = (newActiveId: null | number | string) => {
31
+ if (activeHighlight) {
32
+ setActiveId(newActiveId);
33
+ }
34
+ };
23
35
  return (
24
- <Fragment>
25
- <PieChartLegendList css={labelListStyles}>
36
+ <Wrapper css={{ width: 'auto' }}>
37
+ <PieChartLegendList
38
+ css={labelListStyles}
39
+ isFullscreenMode={isFullscreenMode}>
26
40
  {data.map((item, index) => {
27
41
  const { id, label, value, legendValue } = item;
42
+ const isActive = id === activeId;
28
43
  return (
29
- <li key={`tag-${id}`}>
44
+ <PieChartLegendListItem
45
+ key={`tag-${id}`}
46
+ isActive={isActive}
47
+ isFullscreenMode={isFullscreenMode}
48
+ onMouseEnter={() => {
49
+ handleActiveIdChange(id);
50
+ }}
51
+ onMouseLeave={() => {
52
+ handleActiveIdChange(null);
53
+ }}>
30
54
  <PieChartLegendMarker
31
55
  color={
32
56
  backgroundColors ? undefined : colors?.[index] || 'purple'
@@ -36,9 +60,18 @@ export const PieChartLegend = ({
36
60
  }
37
61
  as={'span'}
38
62
  css={markerStyles}
63
+ isFullscreenMode={isFullscreenMode}
39
64
  />
40
65
  {isValueList ? (
41
- <Typography variant="h6">
66
+ <Typography
67
+ variant="h6"
68
+ css={{
69
+ alignSelf: 'start',
70
+ marginRight: 5,
71
+ height: 'auto',
72
+ lineHeight: '34px',
73
+ alignContent: 'center',
74
+ }}>
42
75
  {typeof renderLabel === 'function'
43
76
  ? renderLabel(item)
44
77
  : label}
@@ -58,23 +91,53 @@ export const PieChartLegend = ({
58
91
  </span>
59
92
  </Typography>
60
93
  )}
61
- </li>
94
+ {isValueList && isFullscreenMode && (
95
+ <Typography
96
+ variant="subtitle"
97
+ color={theme.colors.greyDarker60}
98
+ css={{
99
+ fontSize: isFullscreenMode ? '12px' : '0.833rem',
100
+ alignContent: isFullscreenMode && 'center',
101
+ }}>
102
+ {typeof renderValue === 'function'
103
+ ? renderValue(item)
104
+ : item.value}
105
+ </Typography>
106
+ )}
107
+ </PieChartLegendListItem>
62
108
  );
63
109
  })}
64
110
  </PieChartLegendList>
65
- {isValueList && (
66
- <PieChartLegendList css={valueListStyles}>
67
- {data.map((item) => (
68
- <li key={`subtitle-${item.id}`}>
69
- <Typography variant="subtitle" color={theme.colors.greyDarker60}>
70
- {typeof renderValue === 'function'
71
- ? renderValue(item)
72
- : item.value}
73
- </Typography>
74
- </li>
75
- ))}
111
+ {isValueList && !isFullscreenMode && (
112
+ <PieChartLegendList
113
+ css={valueListStyles}
114
+ isFullscreenMode={isFullscreenMode}>
115
+ {data.map((item) => {
116
+ const { id } = item;
117
+ const isActive = id === activeId;
118
+ return (
119
+ <PieChartLegendListValueListItem
120
+ key={`subtitle-${id}`}
121
+ isActive={isActive}
122
+ css={{ paddingLeft: 20 }}
123
+ onMouseEnter={() => {
124
+ handleActiveIdChange(id);
125
+ }}
126
+ onMouseLeave={() => {
127
+ handleActiveIdChange(null);
128
+ }}>
129
+ <Typography
130
+ variant="subtitle"
131
+ color={theme.colors.greyDarker60}>
132
+ {typeof renderValue === 'function'
133
+ ? renderValue(item)
134
+ : item.value}
135
+ </Typography>
136
+ </PieChartLegendListValueListItem>
137
+ );
138
+ })}
76
139
  </PieChartLegendList>
77
140
  )}
78
- </Fragment>
141
+ </Wrapper>
79
142
  );
80
143
  };
@@ -1,19 +1,23 @@
1
1
  import styled from '@emotion/styled';
2
2
 
3
- export const PieChartLegendList = styled.ul`
3
+ export const PieChartLegendList = styled.ul<{ isFullscreenMode?: boolean }>`
4
4
  display: flex;
5
- flex-flow: column;
6
5
  justify-content: center;
7
6
  list-style: none;
7
+ flex-flow: ${({ isFullscreenMode }) =>
8
+ isFullscreenMode ? 'row wrap' : 'column nowrap'};
8
9
 
9
- height: 100%;
10
10
  padding: 0;
11
- margin: 0;
12
- gap: 14px;
11
+ height: ${({ isFullscreenMode }) => (isFullscreenMode ? 'auto' : '100%')};
12
+ margin: ${({ isFullscreenMode }) => (isFullscreenMode ? '40px 0 50px' : 0)};
13
+ gap: ${({ isFullscreenMode }) => (isFullscreenMode ? '0 20px' : 0)};
13
14
 
14
15
  li {
16
+ height: 34px;
15
17
  display: flex;
16
18
  align-items: center;
17
- height: 20px;
19
+ text-align: left;
20
+ white-space: nowrap;
21
+ padding-right: ${({ isFullscreenMode }) => isFullscreenMode && '12px'};
18
22
  }
19
23
  `;
@@ -0,0 +1,30 @@
1
+ import styled from '@emotion/styled';
2
+
3
+ export const PieChartLegendListItem = styled.li<{
4
+ isFullscreenMode?: boolean;
5
+ isActive?: boolean;
6
+ }>`
7
+ display: flex;
8
+ align-items: center;
9
+ height: ${({ isFullscreenMode }) => (isFullscreenMode ? 'auto' : '22px')};
10
+ padding-right: ${({ isFullscreenMode }) => !isFullscreenMode && '5px'};
11
+ background: ${({ isActive, theme }) =>
12
+ isActive && `${theme.colors.greyLighter}`};
13
+ border-radius: ${({ isFullscreenMode, isActive }) =>
14
+ isFullscreenMode && isActive && '5px'};
15
+ border-top-left-radius: ${({ isFullscreenMode, isActive }) =>
16
+ !isFullscreenMode && isActive && '5px'};
17
+ border-bottom-left-radius: ${({ isFullscreenMode, isActive }) =>
18
+ !isFullscreenMode && isActive && '5px'};
19
+ `;
20
+
21
+ export const PieChartLegendListValueListItem = styled.li<{
22
+ isActive?: boolean;
23
+ }>`
24
+ padding: 0 12px 0 20px;
25
+ justify-content: flex-start;
26
+ background: ${({ isActive, theme }) =>
27
+ isActive && `${theme.colors.greyLighter}`};
28
+ border-top-right-radius: ${({ isActive }) => isActive && '5px'};
29
+ border-bottom-right-radius: ${({ isActive }) => isActive && '5px'};
30
+ `;
@@ -1,11 +1,17 @@
1
1
  import styled from '@emotion/styled';
2
2
  import Badge from '@components/Badge';
3
3
 
4
- export const PieChartLegendMarker = styled(Badge)<{ background?: string }>`
5
- display: inline-block;
4
+ export const PieChartLegendMarker = styled(Badge)<{
5
+ background?: string;
6
+ isFullscreenMode?: boolean;
7
+ }>`
8
+ display: flex;
9
+ align-self: center;
10
+ margin-right: 12px;
11
+ margin-left: 12px;
12
+ margin-top: ${({ isFullscreenMode }) => !isFullscreenMode && '2px'};
6
13
 
7
14
  padding: 0;
8
- margin-right: 12px;
9
15
 
10
16
  width: 8px;
11
17
  height: 8px;
@@ -10,6 +10,8 @@ export const getBalancePalette = (theme: Theme) => {
10
10
  'turquoise',
11
11
  'pink',
12
12
  'purple',
13
+ '#6C94F7',
14
+ '#55D6D2',
13
15
  ] as unknown as Array<keyof MainColors>;
14
16
 
15
17
  const pieChartColors = [
@@ -21,6 +23,8 @@ export const getBalancePalette = (theme: Theme) => {
21
23
  theme.colors.turquoise,
22
24
  theme.colors.pink,
23
25
  theme.colors.purple,
26
+ '#6C94F7',
27
+ '#55D6D2',
24
28
  ] as unknown as string[];
25
29
 
26
30
  return { legendColorNames, pieChartColors };
@@ -37,3 +37,56 @@ export const accountData = [
37
37
  label: 'Other',
38
38
  },
39
39
  ];
40
+
41
+ export const eventsDataBig = [
42
+ {
43
+ id: 1,
44
+ value: 500,
45
+ label: 'Event first',
46
+ },
47
+ {
48
+ id: 2,
49
+ value: 305,
50
+ label: 'Event second',
51
+ },
52
+ {
53
+ id: 3,
54
+ value: 789,
55
+ label: 'Event third',
56
+ },
57
+ {
58
+ id: 4,
59
+ value: 120,
60
+ label: 'Event fourth',
61
+ },
62
+ {
63
+ id: 5,
64
+ value: 39,
65
+ label: 'Event fifth',
66
+ },
67
+ {
68
+ id: 6,
69
+ value: 995,
70
+ label: 'Event sixth',
71
+ },
72
+ {
73
+ id: 7,
74
+ value: 753,
75
+ label: 'Event seventh',
76
+ },
77
+ {
78
+ id: 8,
79
+ value: 183,
80
+ label: 'Event eighth',
81
+ },
82
+ {
83
+ id: 9,
84
+ value: 683,
85
+ label: 'Event ninth',
86
+ },
87
+ {
88
+ id: 10,
89
+ value: 359,
90
+ label: 'Event tenth',
91
+ },
92
+ ];
@@ -0,0 +1,24 @@
1
+ import styled from '@emotion/styled';
2
+ import Button from '@components/Button';
3
+
4
+ export const PieChartButton = styled(Button)`
5
+ height: auto;
6
+ padding: 0;
7
+ background: none;
8
+ box-shadow: none;
9
+
10
+ &:hover,
11
+ &:focus {
12
+ background: none;
13
+ box-shadow: none;
14
+ &:before {
15
+ display: none;
16
+ }
17
+ }
18
+
19
+ &:hover {
20
+ svg path {
21
+ fill: ${({ theme }) => theme.colors.greyDarker};
22
+ }
23
+ }
24
+ `;
@@ -1,12 +1,21 @@
1
1
  import { SerializedStyles } from '@emotion/react';
2
2
  import { ResponsivePie, MayHaveLabel } from '@nivo/pie';
3
- import { CommonProps } from '../..';
3
+ import { CommonProps, WidgetCardProps } from '../..';
4
4
 
5
+ export type PieChartFeatures =
6
+ | 'header'
7
+ | 'fullscreenMode'
8
+ | 'activeItemAnimation';
5
9
  export interface PieChartProps
6
10
  extends CommonProps,
7
11
  React.ComponentProps<typeof ResponsivePie> {
8
12
  title?: React.ReactNode;
9
13
  children?: React.ReactNode;
14
+ width?: string;
15
+ features?: Array<PieChartFeatures>;
16
+ cardProps?: Omit<WidgetCardProps, 'children'>;
17
+ activeHighlight?: boolean;
18
+ onFullscreenModeChange?: (isFullscreenMode: boolean) => void;
10
19
  }
11
20
 
12
21
  export interface PieChartLegendItem extends MayHaveLabel {
@@ -18,14 +27,15 @@ export interface PieChartLegendItem extends MayHaveLabel {
18
27
 
19
28
  export interface PieChartLegendProps {
20
29
  data: Array<PieChartLegendItem>;
21
- colors?: Array<keyof MainColors>;
30
+ activeHighlight?: boolean;
31
+ colors?: Array<keyof MainColors | string>;
22
32
  backgroundColors?: Array<string>;
23
- renderValue?: (item: PieChartLegendItem) => NonNullable<React.ReactNode>;
24
- renderLabel?: (item: PieChartLegendItem) => NonNullable<React.ReactNode>;
25
33
  className?: string;
26
34
  markerStyles?: SerializedStyles;
27
35
  currency?: string;
28
36
  labelListStyles?: SerializedStyles;
29
37
  valueListStyles?: SerializedStyles;
30
38
  variant?: 'valueList' | 'withoutValueList';
39
+ renderValue?: (item: PieChartLegendItem) => NonNullable<React.ReactNode>;
40
+ renderLabel?: (item: PieChartLegendItem) => NonNullable<React.ReactNode>;
31
41
  }
@@ -52,7 +52,7 @@ export const SegmentedPieChart = ({
52
52
  data={balanceDataForTheGraph}
53
53
  animate={true}
54
54
  css={{
55
- width: 400,
55
+ width: '400px',
56
56
  margin: '40px 120px',
57
57
  }}
58
58
  isInteractive
@@ -0,0 +1,19 @@
1
+ import styled from '@emotion/styled';
2
+ import CardContent from '@components/CardContent';
3
+
4
+ export const Content = styled(CardContent)<{ isFullscreenMode?: boolean }>`
5
+ max-width: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : '406px')};
6
+ width: 100%;
7
+ display: flex;
8
+ justify-content: space-between;
9
+ gap: 5px;
10
+ height: ${({ isFullscreenMode }) => (isFullscreenMode ? '100%' : 'auto')};
11
+
12
+ ${({ theme }) => theme.mediaQueries.md} {
13
+ max-width: initial;
14
+ flex-direction: column;
15
+ justify-content: flex-start;
16
+ align-items: flex-start;
17
+ gap: initial;
18
+ }
19
+ `;
@@ -0,0 +1,45 @@
1
+ import { Fragment } from 'react';
2
+ import { Interpolation, Theme, css, useTheme } from '@emotion/react';
3
+ import CardHeader from '@components/CardHeader';
4
+ import { WidgetCardTitle } from './Title';
5
+ import { WidgetCardProps } from './types';
6
+
7
+ type HeaderProps = {
8
+ className?: string;
9
+ children?: React.ReactNode;
10
+ titleCSS?: Interpolation<Theme>;
11
+ } & Pick<WidgetCardProps, 'title'>;
12
+
13
+ export const Header = ({
14
+ title,
15
+ className,
16
+ children,
17
+ titleCSS,
18
+ }: HeaderProps) => {
19
+ const theme = useTheme();
20
+
21
+ return (
22
+ <CardHeader
23
+ css={css`
24
+ margin-bottom: 5px;
25
+ ${theme.mediaQueries.md} {
26
+ margin-bottom: 10px;
27
+ }
28
+ `}
29
+ className={className}>
30
+ <WidgetCardTitle
31
+ variant="h3"
32
+ weight="bold"
33
+ css={[
34
+ css`
35
+ flex-direction: row;
36
+ width: 100%;
37
+ `,
38
+ titleCSS,
39
+ ]}>
40
+ {title}
41
+ {children && <Fragment>{children}</Fragment>}
42
+ </WidgetCardTitle>
43
+ </CardHeader>
44
+ );
45
+ };
@@ -0,0 +1,10 @@
1
+ import styled from '@emotion/styled';
2
+ import Typography from '@components/Typography';
3
+
4
+ export const WidgetCardTitle = styled(Typography)`
5
+ display: flex;
6
+ font-size: 16px;
7
+ ${({ theme }) => theme.mediaQueries.md} {
8
+ font-size: 20px;
9
+ }
10
+ `;
@@ -0,0 +1,38 @@
1
+ import { useFullscreenMode, WithLink } from '@components';
2
+ import { WidgetCardBase } from './WidgetCardBase';
3
+ import { Header } from './Header';
4
+ import { Content } from './Content';
5
+ import { WidgetCardProps } from './types';
6
+
7
+ export const WidgetCard = ({
8
+ title,
9
+ className,
10
+ wrapperClassName,
11
+ contentClassName,
12
+ headerClassName,
13
+ headerContent,
14
+ link,
15
+ width,
16
+ children,
17
+ onClick,
18
+ }: WidgetCardProps) => {
19
+ const { isFullscreenMode } = useFullscreenMode();
20
+ return (
21
+ <WithLink link={link} onClick={onClick} className={wrapperClassName}>
22
+ <WidgetCardBase
23
+ className={className}
24
+ onClick={link ? undefined : onClick}
25
+ isFullscreenMode={isFullscreenMode}
26
+ width={width}>
27
+ <Header title={title} className={headerClassName}>
28
+ {headerContent}
29
+ </Header>
30
+ <Content
31
+ className={contentClassName}
32
+ isFullscreenMode={isFullscreenMode}>
33
+ {children}
34
+ </Content>
35
+ </WidgetCardBase>
36
+ </WithLink>
37
+ );
38
+ };
@@ -0,0 +1,27 @@
1
+ import styled from '@emotion/styled';
2
+ import Card from '@components/Card';
3
+
4
+ export const WidgetCardBase = styled(Card)<{
5
+ isFullscreenMode?: boolean;
6
+ width?: string;
7
+ }>`
8
+ border-radius: 20px;
9
+ padding: 5px 10px;
10
+ width: ${({ isFullscreenMode, width }) =>
11
+ isFullscreenMode ? '100%' : width};
12
+ height: 100%;
13
+ position: ${({ isFullscreenMode }) =>
14
+ isFullscreenMode ? 'absolute' : 'static'};
15
+ top: ${({ isFullscreenMode }) => isFullscreenMode && 0};
16
+ left: ${({ isFullscreenMode }) => isFullscreenMode && 0};
17
+
18
+ ${({ theme }) => theme.mediaQueries.md} {
19
+ padding: 10px;
20
+ }
21
+
22
+ ${({ theme }) => theme.mediaQueries.lg} {
23
+ padding: 12px 20px 11px;
24
+ }
25
+
26
+ box-shadow: 0 10px 40px 0 ${({ theme }) => theme.colors.greyShadow};
27
+ `;
@@ -0,0 +1,18 @@
1
+ import { PieChartProps } from '@components/PieChart';
2
+ import { WidgetCard } from './WidgetCard';
3
+
4
+ export const WithWidgetCard = ({
5
+ children,
6
+ features = [],
7
+ cardProps = {},
8
+ width,
9
+ }: {
10
+ children: React.ReactNode;
11
+ } & Pick<PieChartProps, 'features' | 'cardProps' | 'width'>) =>
12
+ features && features.includes('header') ? (
13
+ <WidgetCard {...cardProps} width={width}>
14
+ {children}
15
+ </WidgetCard>
16
+ ) : (
17
+ children
18
+ );
@@ -0,0 +1,5 @@
1
+ export * from './WidgetCard';
2
+ export * from './WithWidgetCard';
3
+ export * from './WidgetCardBase';
4
+ export * from './Title';
5
+ export * from './types';
@@ -0,0 +1,14 @@
1
+ import type { To } from 'react-router-dom';
2
+
3
+ export type WidgetCardProps = {
4
+ title?: React.ReactNode;
5
+ className?: string;
6
+ wrapperClassName?: string;
7
+ contentClassName?: string;
8
+ headerClassName?: string;
9
+ headerContent?: React.ReactNode;
10
+ link?: To;
11
+ children?: React.ReactNode;
12
+ width?: string;
13
+ onClick?: () => void;
14
+ };
@@ -0,0 +1,30 @@
1
+ import { Link, To } from 'react-router-dom';
2
+ import { css } from '@emotion/react';
3
+
4
+ export const WithLink = ({
5
+ link,
6
+ onClick,
7
+ children,
8
+ className,
9
+ }: {
10
+ children: React.ReactNode;
11
+ className?: string;
12
+ onClick?: () => void;
13
+ link?: To;
14
+ }) =>
15
+ link ? (
16
+ <Link
17
+ to={link}
18
+ onClick={onClick}
19
+ className={className}
20
+ css={css`
21
+ text-decoration: none;
22
+ div {
23
+ cursor: pointer;
24
+ }
25
+ `}>
26
+ {children}
27
+ </Link>
28
+ ) : (
29
+ children
30
+ );