@ssa-ui-kit/widgets 1.0.9 → 1.0.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/widgets",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -29,8 +29,8 @@
29
29
  "js-tokens": "^4.0.0",
30
30
  "loose-envify": "^1.4.0",
31
31
  "scheduler": "^0.23.0",
32
+ "@ssa-ui-kit/core": "^1.1.7",
32
33
  "@ssa-ui-kit/hooks": "^1.0.0",
33
- "@ssa-ui-kit/core": "^1.1.6",
34
34
  "@ssa-ui-kit/utils": "^1.0.0"
35
35
  },
36
36
  "browserslist": [
@@ -1,6 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
  import { MemoryRouter, Route, Routes } from 'react-router-dom';
3
- import { css } from '@emotion/react';
3
+ import { css as cssReact } from '@emotion/react';
4
+ import { css } from '@emotion/css';
4
5
  import { mainTheme } from '@ssa-ui-kit/core';
5
6
 
6
7
  import { data } from './stories/fixtures';
@@ -14,9 +15,15 @@ export default {
14
15
 
15
16
  export const Default: StoryObj<typeof AccountBalance> = {};
16
17
  Default.args = {
17
- total: 48700.53569,
18
+ total: 48700.53,
18
19
  currency: 'USDT',
19
20
  onClick: () => alert('Clicked!'),
21
+ widgetMaxWidth: '290px',
22
+ className: css`
23
+ & .pie-chart-wrapper p {
24
+ font-size: 12px;
25
+ }
26
+ `,
20
27
  data,
21
28
  };
22
29
 
@@ -48,17 +55,20 @@ export const Custom: StoryObj<typeof AccountBalance> = (
48
55
  return (
49
56
  <AccountBalance
50
57
  {...args}
51
- css={css`
58
+ css={cssReact`
52
59
  ul li {
53
60
  height: auto;
54
61
  }
62
+ & .pie-chart-wrapper p {
63
+ font-size: 12px;
64
+ }
55
65
  `}
56
66
  />
57
67
  );
58
68
  };
59
69
 
60
70
  Custom.args = {
61
- total: 48700.53569,
71
+ total: 48700.53,
62
72
  currency: 'USDT',
63
73
  variant: 'withoutValueList',
64
74
  chartColorPalette: [
@@ -66,6 +76,7 @@ Custom.args = {
66
76
  mainTheme.colors.green as string,
67
77
  ],
68
78
  legendColorPalette: ['blue', 'green'],
79
+ widgetMaxWidth: '240px',
69
80
  data: [
70
81
  {
71
82
  id: 'BTC',
@@ -88,17 +99,20 @@ export const WithoutPaletteColors: StoryObj<typeof AccountBalance> = (
88
99
  return (
89
100
  <AccountBalance
90
101
  {...args}
91
- css={css`
102
+ css={cssReact`
92
103
  ul li {
93
104
  height: auto;
94
105
  }
106
+ & .pie-chart-wrapper p {
107
+ font-size: 12px;
108
+ }
95
109
  `}
96
110
  />
97
111
  );
98
112
  };
99
113
 
100
114
  WithoutPaletteColors.args = {
101
- total: 48700.53569,
115
+ total: 48700.53,
102
116
  currency: 'USDT',
103
117
  variant: 'withoutValueList',
104
118
  chartColorPalette: ['#F7931A', '#50AF95'],
@@ -106,6 +120,7 @@ WithoutPaletteColors.args = {
106
120
  'linear-gradient(243.84deg, rgb(235, 117, 86), rgb(242, 136, 142))',
107
121
  '#50AF95',
108
122
  ],
123
+ widgetMaxWidth: '240px',
109
124
  data: [
110
125
  {
111
126
  id: 'BTC',
@@ -1,3 +1,4 @@
1
+ import { useState } from 'react';
1
2
  import { useTheme } from '@emotion/react';
2
3
  import { css } from '@emotion/css';
3
4
  import { WithLink } from '@ssa-ui-kit/core';
@@ -12,9 +13,11 @@ export const AccountBalance = ({
12
13
  variant = 'valueList',
13
14
  fullscreenModeFeature = false,
14
15
  activeHighlight = true,
16
+ widgetMaxWidth = '280px',
15
17
  ...props
16
18
  }: AccountBalanceProps) => {
17
19
  const theme = useTheme();
20
+ const [isFullscreenMode, setIsFullscreenMode] = useState(false);
18
21
 
19
22
  return (
20
23
  <WithLink link={link} onClick={onClick}>
@@ -23,10 +26,19 @@ export const AccountBalance = ({
23
26
  variant={variant}
24
27
  fullscreenModeFeature={fullscreenModeFeature}
25
28
  activeHighlight={activeHighlight}
29
+ onFullscreenModeChange={setIsFullscreenMode}
26
30
  pieChartProps={{
31
+ width: '100%',
27
32
  cardProps: {
28
33
  title,
29
- className,
34
+ className: [
35
+ css`
36
+ & > div:last-of-type {
37
+ max-width: ${isFullscreenMode ? '100%' : widgetMaxWidth};
38
+ }
39
+ `,
40
+ className,
41
+ ].join(' '),
30
42
  headerClassName: css([
31
43
  {
32
44
  fontSize: 11,
@@ -22,6 +22,7 @@ export const BalancePieChart = withTheme(
22
22
  pieChartProps = {},
23
23
  fullscreenModeFeature = false,
24
24
  activeHighlight = false,
25
+ onFullscreenModeChange,
25
26
  }: BalancePieChartProps) => {
26
27
  const [isFullscreenMode, setFullscreenMode] = useState(false);
27
28
  const { legendColorNames, pieChartColors } =
@@ -38,6 +39,7 @@ export const BalancePieChart = withTheme(
38
39
 
39
40
  const handleFullscreenModeChange = (pieChartFullscreenMode: boolean) => {
40
41
  setFullscreenMode(pieChartFullscreenMode);
42
+ onFullscreenModeChange?.(pieChartFullscreenMode);
41
43
  };
42
44
  return (
43
45
  <PieChart
@@ -1,15 +1,12 @@
1
1
  import { withTheme, css } from '@emotion/react';
2
2
  import { Typography, useFullscreenMode } from '@ssa-ui-kit/core';
3
- import { useTextSizeDecrease } from '@ssa-ui-kit/hooks';
4
3
  import { BalancePieChartTitleProps } from './types';
5
4
 
6
5
  export const BalancePieChartTitle = withTheme(
7
6
  ({ total, currency, theme }: BalancePieChartTitleProps) => {
8
- const ref = useTextSizeDecrease();
9
7
  const { isFullscreenMode } = useFullscreenMode();
10
8
  return (
11
9
  <Typography
12
- ref={ref}
13
10
  variant="body2"
14
11
  weight="bold"
15
12
  color={theme.colors.greyDarker}
@@ -20,7 +17,7 @@ export const BalancePieChartTitle = withTheme(
20
17
  font-weight: 500;
21
18
  `
22
19
  : css`
23
- font-size: 13px;
20
+ font-size: 12px;
24
21
  padding: 0 14px;
25
22
  line-height: 1;
26
23
  `
@@ -23,6 +23,7 @@ type BalanceBase = {
23
23
  export interface BalancePieChartProps extends WithTheme, BalanceBase {
24
24
  pieChartProps?: Partial<PieChartProps>;
25
25
  activeHighlight?: boolean;
26
+ onFullscreenModeChange?: (isFullscreenMode: boolean) => void;
26
27
  }
27
28
 
28
29
  export interface AccountBalanceProps extends BalanceBase {
@@ -31,6 +32,7 @@ export interface AccountBalanceProps extends BalanceBase {
31
32
  onClick?: () => void;
32
33
  link?: To;
33
34
  activeHighlight?: boolean;
35
+ widgetMaxWidth?: string;
34
36
  }
35
37
 
36
38
  export type BalancePieChartTitleProps = Pick<
@@ -1,6 +1,7 @@
1
1
  import { MemoryRouter, Route, Routes } from 'react-router-dom';
2
2
  import type { Meta, StoryObj } from '@storybook/react';
3
3
  import { css, useTheme } from '@emotion/react';
4
+ import { css as cssClassname } from '@emotion/css';
4
5
  import { Icon, AddNewAccountCard } from '@ssa-ui-kit/core';
5
6
  import { ExchangeAccount } from './ExchangeAccount';
6
7
  import { dataValues } from './helpers';
@@ -19,6 +20,12 @@ export const Default: StoryObj<typeof ExchangeAccount> = () => {
19
20
  data={dataValues[0].data}
20
21
  onClick={() => alert('Card is clicked!')}
21
22
  onDelete={() => alert('Card is deleted!')}
23
+ pieChartProps={{
24
+ className: cssClassname`
25
+ align-self: center;
26
+ max-width: 300px;
27
+ `,
28
+ }}
22
29
  />
23
30
  );
24
31
  };
@@ -40,6 +47,12 @@ export const WithLink: StoryObj<typeof ExchangeAccount> = () => {
40
47
  link="/link"
41
48
  onClick={() => alert('Card is clicked!')}
42
49
  onDelete={() => alert('Card is deleted!')}
50
+ pieChartProps={{
51
+ className: cssClassname`
52
+ align-self: center;
53
+ max-width: 300px;
54
+ `,
55
+ }}
43
56
  />
44
57
  }
45
58
  />
@@ -79,6 +92,12 @@ export const List: StoryObj<typeof ExchangeAccount> = () => {
79
92
  data={item.data}
80
93
  onClick={() => alert('Card is clicked!')}
81
94
  onDelete={() => alert('Card is deleted!')}
95
+ pieChartProps={{
96
+ className: cssClassname`
97
+ align-self: center;
98
+ max-width: 300px;
99
+ `,
100
+ }}
82
101
  />
83
102
  );
84
103
  })}
@@ -19,6 +19,7 @@ export const ExchangeAccount = ({
19
19
  status,
20
20
  link,
21
21
  data,
22
+ pieChartProps,
22
23
  onClick,
23
24
  onDelete,
24
25
  }: ExchangeAccountProps) => {
@@ -69,7 +70,6 @@ export const ExchangeAccount = ({
69
70
  <CardContent css={S.CardContent} direction="column">
70
71
  <BalancePieChart
71
72
  theme={theme}
72
- {...data}
73
73
  pieChartProps={{
74
74
  className: css`
75
75
  ${theme.mediaQueries.md} {
@@ -79,7 +79,9 @@ export const ExchangeAccount = ({
79
79
  flex-direction: column;
80
80
  }
81
81
  `,
82
+ ...pieChartProps,
82
83
  }}
84
+ {...data}
83
85
  />
84
86
  </CardContent>
85
87
  </CardBase>
@@ -15,7 +15,7 @@ export const dataValues: Array<
15
15
  title: 'Account Name',
16
16
  status: 'Active',
17
17
  data: {
18
- total: 48000.53032,
18
+ total: 48000.53,
19
19
  currency: 'USDT',
20
20
  data: [
21
21
  {
@@ -120,7 +120,7 @@ export const dataValues: Array<
120
120
  title: 'Name#4',
121
121
  status: 'Active',
122
122
  data: {
123
- total: 9000.53032,
123
+ total: 9000.53,
124
124
  currency: 'USDT',
125
125
  data: [
126
126
  {
@@ -1,4 +1,5 @@
1
1
  import { To } from 'react-router-dom';
2
+ import { PieChartProps } from '@ssa-ui-kit/core';
2
3
  import { AccountBalanceProps } from '@components/AccountBalance';
3
4
 
4
5
  export interface ExchangeAccountProps {
@@ -9,4 +10,5 @@ export interface ExchangeAccountProps {
9
10
  onDelete: () => void;
10
11
  link?: To;
11
12
  data: Omit<AccountBalanceProps, 'title' | 'className' | 'onClick' | 'link'>;
13
+ pieChartProps?: Partial<PieChartProps>;
12
14
  }