@ssa-ui-kit/widgets 0.0.15-alpha → 0.0.16-alpha

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 (110) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/AccountBalance/AccountBalance.d.ts +1 -1
  3. package/dist/components/AccountBalance/BalancePieChart.d.ts +1 -1
  4. package/dist/components/AccountBalance/BalancePieChartTitle.d.ts +1 -1
  5. package/dist/components/AccountBalance/types.d.ts +4 -1
  6. package/dist/components/PieChart/PieChartLegend.d.ts +1 -1
  7. package/dist/components/PieChart/types.d.ts +2 -0
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/package.json +2 -2
  11. package/src/components/AccountBalance/AccountBalance.spec.tsx +29 -0
  12. package/src/components/AccountBalance/AccountBalance.stories.tsx +42 -0
  13. package/src/components/AccountBalance/AccountBalance.tsx +2 -1
  14. package/src/components/AccountBalance/BalancePieChart.tsx +13 -4
  15. package/src/components/AccountBalance/types.ts +4 -1
  16. package/src/components/PieChart/PieChartLegend.tsx +38 -15
  17. package/src/components/PieChart/types.ts +2 -0
  18. package/tsbuildcache +1 -1
  19. package/storybook-static/0.19f2e251.iframe.bundle.js +0 -1
  20. package/storybook-static/106.f1e6d14d.iframe.bundle.js +0 -44
  21. package/storybook-static/106.f1e6d14d.iframe.bundle.js.map +0 -1
  22. package/storybook-static/162.50e9b926.iframe.bundle.js +0 -1
  23. package/storybook-static/291.c8585ee9.iframe.bundle.js +0 -1
  24. package/storybook-static/293.c50861da.iframe.bundle.js +0 -2
  25. package/storybook-static/293.c50861da.iframe.bundle.js.LICENSE.txt +0 -9
  26. package/storybook-static/36.713e1566.iframe.bundle.js +0 -1
  27. package/storybook-static/460.8dc4e7c6.iframe.bundle.js +0 -402
  28. package/storybook-static/460.8dc4e7c6.iframe.bundle.js.LICENSE.txt +0 -64
  29. package/storybook-static/460.8dc4e7c6.iframe.bundle.js.map +0 -1
  30. package/storybook-static/576.98c3eb27.iframe.bundle.js +0 -1
  31. package/storybook-static/620.61fd9060.iframe.bundle.js +0 -1
  32. package/storybook-static/696.e559304f.iframe.bundle.js +0 -2
  33. package/storybook-static/696.e559304f.iframe.bundle.js.LICENSE.txt +0 -32
  34. package/storybook-static/710.ab631936.iframe.bundle.js +0 -1
  35. package/storybook-static/829.7385f99b.iframe.bundle.js +0 -139
  36. package/storybook-static/829.7385f99b.iframe.bundle.js.map +0 -1
  37. package/storybook-static/834.04cdfc87.iframe.bundle.js +0 -1
  38. package/storybook-static/945.ddb2ee2f.iframe.bundle.js +0 -1
  39. package/storybook-static/components-Activity-Activity-stories.107a3fa3.iframe.bundle.js +0 -1
  40. package/storybook-static/components-Bmi-Bmi-stories.b8c54168.iframe.bundle.js +0 -1
  41. package/storybook-static/components-Calories-Calories-stories.8851a637.iframe.bundle.js +0 -1
  42. package/storybook-static/components-CardList-CardList-stories.963f2911.iframe.bundle.js +0 -1
  43. package/storybook-static/components-HeartRate-HeartRate-stories.f9844316.iframe.bundle.js +0 -1
  44. package/storybook-static/components-ListGoals-ListGoals-stories.ca994275.iframe.bundle.js +0 -1
  45. package/storybook-static/components-MealNutrients-MealNutrients-stories.1850ecb0.iframe.bundle.js +0 -1
  46. package/storybook-static/components-MealPlanner-MealPlanner-stories.542c85fc.iframe.bundle.js +0 -1
  47. package/storybook-static/components-NavBar-NavBar-stories.73f09876.iframe.bundle.js +0 -1
  48. package/storybook-static/components-ProgressInfo-ProgressInfo-stories.f6b5466e.iframe.bundle.js +0 -1
  49. package/storybook-static/components-StepsCounter-StepsCounter-stories.967e384f.iframe.bundle.js +0 -1
  50. package/storybook-static/components-UpcomingWorkouts-UpcomingWorkouts-stories.ba735508.iframe.bundle.js +0 -1
  51. package/storybook-static/components-WaterConsume-WaterConsume-stories.4b5e8cb5.iframe.bundle.js +0 -1
  52. package/storybook-static/favicon.svg +0 -7
  53. package/storybook-static/iframe.html +0 -355
  54. package/storybook-static/index.html +0 -126
  55. package/storybook-static/index.json +0 -1
  56. package/storybook-static/main.912c7e67.iframe.bundle.js +0 -1
  57. package/storybook-static/project.json +0 -1
  58. package/storybook-static/runtime~main.e664d5e5.iframe.bundle.js +0 -1
  59. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js +0 -4
  60. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.LEGAL.txt +0 -0
  61. package/storybook-static/sb-addons/essentials-actions-2/manager-bundle.js.map +0 -7
  62. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js +0 -13
  63. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.LEGAL.txt +0 -0
  64. package/storybook-static/sb-addons/essentials-backgrounds-3/manager-bundle.js.map +0 -7
  65. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js +0 -117
  66. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.LEGAL.txt +0 -18
  67. package/storybook-static/sb-addons/essentials-controls-1/manager-bundle.js.map +0 -7
  68. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js +0 -4
  69. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.LEGAL.txt +0 -0
  70. package/storybook-static/sb-addons/essentials-measure-6/manager-bundle.js.map +0 -7
  71. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js +0 -4
  72. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.LEGAL.txt +0 -0
  73. package/storybook-static/sb-addons/essentials-outline-7/manager-bundle.js.map +0 -7
  74. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js +0 -4
  75. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.LEGAL.txt +0 -0
  76. package/storybook-static/sb-addons/essentials-toolbars-5/manager-bundle.js.map +0 -7
  77. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js +0 -4
  78. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.LEGAL.txt +0 -0
  79. package/storybook-static/sb-addons/essentials-viewport-4/manager-bundle.js.map +0 -7
  80. package/storybook-static/sb-addons/interactions-8/manager-bundle.js +0 -28
  81. package/storybook-static/sb-addons/interactions-8/manager-bundle.js.LEGAL.txt +0 -0
  82. package/storybook-static/sb-addons/interactions-8/manager-bundle.js.map +0 -7
  83. package/storybook-static/sb-addons/links-0/manager-bundle.js +0 -4
  84. package/storybook-static/sb-addons/links-0/manager-bundle.js.LEGAL.txt +0 -0
  85. package/storybook-static/sb-addons/links-0/manager-bundle.js.map +0 -7
  86. package/storybook-static/sb-common-assets/fonts.css +0 -31
  87. package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
  88. package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
  89. package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
  90. package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
  91. package/storybook-static/sb-manager/GlobalScrollAreaStyles-DZEYMYDM-UAEZM2KF.js +0 -7
  92. package/storybook-static/sb-manager/OverlayScrollbars-OGE3XJTA-T3S33YR7.js +0 -1
  93. package/storybook-static/sb-manager/WithTooltip-I4CCNYWD-ZW5IOTVO.js +0 -1
  94. package/storybook-static/sb-manager/chunk-3FAXWWKG.js +0 -15
  95. package/storybook-static/sb-manager/chunk-AA6TEL5N.js +0 -207
  96. package/storybook-static/sb-manager/chunk-AM2ZNZZH.js +0 -136
  97. package/storybook-static/sb-manager/chunk-AS2AMEUR.js +0 -1
  98. package/storybook-static/sb-manager/chunk-FPTBIX6P.js +0 -403
  99. package/storybook-static/sb-manager/chunk-IPZYHIL3.js +0 -7
  100. package/storybook-static/sb-manager/chunk-QPL63VNK.js +0 -1
  101. package/storybook-static/sb-manager/chunk-R5BIZIS3.js +0 -1
  102. package/storybook-static/sb-manager/formatter-OJ5LH2CX-IQX6U4TO.js +0 -156
  103. package/storybook-static/sb-manager/globals.js +0 -1
  104. package/storybook-static/sb-manager/index.js +0 -1
  105. package/storybook-static/sb-manager/runtime.js +0 -1
  106. package/storybook-static/sb-manager/syntaxhighlighter-SIPZPD4I-WOB5MYBW.js +0 -1
  107. package/storybook-static/sb-preview/globals.js +0 -1
  108. package/storybook-static/sb-preview/runtime.js +0 -105
  109. package/storybook-static/stories.json +0 -1
  110. package/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssa-ui-kit/widgets",
3
- "version": "0.0.15-alpha",
3
+ "version": "0.0.16-alpha",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "private": false,
@@ -29,7 +29,7 @@
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": "^0.0.10-alpha",
32
+ "@ssa-ui-kit/core": "^0.0.12-alpha",
33
33
  "@ssa-ui-kit/hooks": "^0.0.1-alpha",
34
34
  "@ssa-ui-kit/utils": "^0.0.1-alpha"
35
35
  },
@@ -79,4 +79,33 @@ describe('AccountBalance', () => {
79
79
  await fireEvent.click(linkEl);
80
80
  expect(onClick).toHaveBeenCalledTimes(1);
81
81
  });
82
+
83
+ it('Renders without value list', () => {
84
+ const { getByText } = render(
85
+ <AccountBalance
86
+ total="798"
87
+ currency="USDT"
88
+ variant="withoutValueList"
89
+ data={[
90
+ {
91
+ id: 'BTC',
92
+ label: 'BTC',
93
+ legendValue: 1,
94
+ value: 871.23,
95
+ },
96
+ {
97
+ id: 'LTC',
98
+ label: 'LTC',
99
+ legendValue: 7,
100
+ value: 530.25,
101
+ },
102
+ ]}
103
+ />,
104
+ );
105
+
106
+ getByText('1 BTC');
107
+ getByText('871.23 USDT');
108
+ getByText('7 LTC');
109
+ getByText('530.25 USDT');
110
+ });
82
111
  });
@@ -1,5 +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';
4
+ import { mainTheme } from '@ssa-ui-kit/core';
3
5
 
4
6
  import { data } from './stories/fixtures';
5
7
 
@@ -33,3 +35,43 @@ WithLink.args = {
33
35
  ...Default.args,
34
36
  link: '/',
35
37
  };
38
+
39
+ export const Custom: StoryObj<typeof AccountBalance> = (
40
+ args: AccountBalanceProps,
41
+ ) => {
42
+ return (
43
+ <AccountBalance
44
+ {...args}
45
+ css={css`
46
+ ul li {
47
+ height: auto;
48
+ }
49
+ `}
50
+ />
51
+ );
52
+ };
53
+
54
+ Custom.args = {
55
+ total: 48700.53569,
56
+ currency: 'USDT',
57
+ variant: 'withoutValueList',
58
+ chartColorPalette: [
59
+ mainTheme.colors.blue as string,
60
+ mainTheme.colors.green as string,
61
+ ],
62
+ legendColorPalette: ['blue', 'green'],
63
+ data: [
64
+ {
65
+ id: 'BTC',
66
+ label: 'BTC',
67
+ value: 571.23,
68
+ legendValue: 12323,
69
+ },
70
+ {
71
+ id: 'LTC',
72
+ label: 'LTC',
73
+ value: 530.25,
74
+ legendValue: 12323,
75
+ },
76
+ ],
77
+ };
@@ -9,6 +9,7 @@ export const AccountBalance = ({
9
9
  className,
10
10
  onClick,
11
11
  link,
12
+ variant = 'valueList',
12
13
  ...props
13
14
  }: AccountBalanceProps) => {
14
15
  const theme = useTheme();
@@ -55,7 +56,7 @@ export const AccountBalance = ({
55
56
  width: 100%;
56
57
  display: block;
57
58
  `}>
58
- <BalancePieChart theme={theme} {...props} />
59
+ <BalancePieChart theme={theme} variant={variant} {...props} />
59
60
  </CardContent>
60
61
  </Card>
61
62
  </WithLink>
@@ -10,14 +10,21 @@ import { BalancePieChartTitle } from './BalancePieChartTitle';
10
10
  import { BalancePieChartProps } from './types';
11
11
 
12
12
  export const BalancePieChart = withTheme(
13
- ({ total, currency, data, theme }: BalancePieChartProps) => {
13
+ ({
14
+ total,
15
+ currency,
16
+ data,
17
+ theme,
18
+ chartColorPalette,
19
+ legendColorPalette,
20
+ variant = 'valueList',
21
+ }: BalancePieChartProps) => {
14
22
  const { legendColorNames, pieChartColors } =
15
23
  pieChartPalettes.getBalancePalette(theme);
16
-
17
24
  return (
18
25
  <PieChart
19
26
  data={data}
20
- colors={pieChartColors}
27
+ colors={chartColorPalette || pieChartColors}
21
28
  animate={false}
22
29
  title={
23
30
  <BalancePieChartTitle
@@ -41,7 +48,9 @@ export const BalancePieChart = withTheme(
41
48
  `}>
42
49
  <PieChartLegend
43
50
  data={data}
44
- colors={legendColorNames}
51
+ colors={legendColorPalette || legendColorNames}
52
+ variant={variant}
53
+ currency={currency}
45
54
  markerStyles={css`
46
55
  width: 10px;
47
56
  height: 10px;
@@ -1,4 +1,4 @@
1
- import { Theme } from '@ssa-ui-kit/core';
1
+ import { MainColors, Theme } from '@ssa-ui-kit/core';
2
2
  import type { To } from 'react-router-dom';
3
3
 
4
4
  interface WithTheme {
@@ -8,6 +8,9 @@ interface WithTheme {
8
8
  type BalanceBase = {
9
9
  total: number | string;
10
10
  currency: string;
11
+ legendColorPalette?: Array<keyof MainColors>;
12
+ chartColorPalette?: string[];
13
+ variant?: 'valueList' | 'withoutValueList';
11
14
  data: Array<{
12
15
  id: string | number;
13
16
  value: number;
@@ -12,15 +12,18 @@ export const PieChartLegend = ({
12
12
  renderLabel,
13
13
  renderValue,
14
14
  markerStyles,
15
+ currency,
15
16
  labelListStyles,
16
17
  valueListStyles,
18
+ variant = 'valueList',
17
19
  }: PieChartLegendProps) => {
18
20
  const theme = useTheme();
21
+ const isValueList = variant === 'valueList';
19
22
  return (
20
23
  <Fragment>
21
24
  <PieChartLegendList css={labelListStyles}>
22
25
  {data.map((item, index) => {
23
- const { id, label } = item;
26
+ const { id, label, value, legendValue } = item;
24
27
  return (
25
28
  <li key={`tag-${id}`}>
26
29
  <PieChartLegendMarker
@@ -28,24 +31,44 @@ export const PieChartLegend = ({
28
31
  as={'span'}
29
32
  css={markerStyles}
30
33
  />
31
- <Typography variant="h6">
32
- {typeof renderLabel === 'function' ? renderLabel(item) : label}
33
- </Typography>
34
+ {isValueList ? (
35
+ <Typography variant="h6">
36
+ {typeof renderLabel === 'function'
37
+ ? renderLabel(item)
38
+ : label}
39
+ </Typography>
40
+ ) : (
41
+ <Typography
42
+ variant="subtitle"
43
+ css={{
44
+ display: 'flex',
45
+ flexDirection: 'column',
46
+ }}>
47
+ <span>
48
+ {legendValue as React.ReactNode} {label}
49
+ </span>
50
+ <span css={{ fontWeight: '400' }}>
51
+ {value} {currency}
52
+ </span>
53
+ </Typography>
54
+ )}
34
55
  </li>
35
56
  );
36
57
  })}
37
58
  </PieChartLegendList>
38
- <PieChartLegendList css={valueListStyles}>
39
- {data.map((item) => (
40
- <li key={`subtitle-${item.id}`}>
41
- <Typography variant="subtitle" color={theme.colors.greyDarker60}>
42
- {typeof renderValue === 'function'
43
- ? renderValue(item)
44
- : item.value}
45
- </Typography>
46
- </li>
47
- ))}
48
- </PieChartLegendList>
59
+ {isValueList && (
60
+ <PieChartLegendList css={valueListStyles}>
61
+ {data.map((item) => (
62
+ <li key={`subtitle-${item.id}`}>
63
+ <Typography variant="subtitle" color={theme.colors.greyDarker60}>
64
+ {typeof renderValue === 'function'
65
+ ? renderValue(item)
66
+ : item.value}
67
+ </Typography>
68
+ </li>
69
+ ))}
70
+ </PieChartLegendList>
71
+ )}
49
72
  </Fragment>
50
73
  );
51
74
  };
@@ -23,6 +23,8 @@ export interface PieChartLegendProps {
23
23
  renderLabel?: (item: PieChartLegendItem) => NonNullable<React.ReactNode>;
24
24
  className?: string;
25
25
  markerStyles?: SerializedStyles;
26
+ currency?: string;
26
27
  labelListStyles?: SerializedStyles;
27
28
  valueListStyles?: SerializedStyles;
29
+ variant?: 'valueList' | 'withoutValueList';
28
30
  }