@pushwoosh/dumb-components 0.0.11 → 0.0.13
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/StatisticCard/StatisticCard.d.ts +3 -0
- package/StatisticCard/StatisticCard.js +48 -0
- package/StatisticCard/helpers.d.ts +1 -0
- package/StatisticCard/helpers.js +1 -0
- package/StatisticCard/index.d.ts +1 -0
- package/StatisticCard/index.js +1 -0
- package/StatisticCard/styles.d.ts +9 -0
- package/StatisticCard/styles.js +33 -0
- package/StatisticCard/types.d.ts +21 -0
- package/StatisticCard/types.js +1 -0
- package/common.d.ts +8 -0
- package/common.js +17 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Spinner } from '@pushwoosh/kit-spinner';
|
|
5
|
+
import { Container, RightSlotContainer, StatValue, Title } from './styles';
|
|
6
|
+
import { LockedText } from '../common';
|
|
7
|
+
import { formatNumberWithSpaces } from './helpers';
|
|
8
|
+
export const StatisticCard = ({
|
|
9
|
+
title,
|
|
10
|
+
value,
|
|
11
|
+
valueSubtext,
|
|
12
|
+
footer,
|
|
13
|
+
active,
|
|
14
|
+
selectable,
|
|
15
|
+
rightSlot,
|
|
16
|
+
width,
|
|
17
|
+
isLoading,
|
|
18
|
+
onClick,
|
|
19
|
+
...rest
|
|
20
|
+
}) => {
|
|
21
|
+
const statisticValue = useMemo(() => {
|
|
22
|
+
if (isLoading) {
|
|
23
|
+
return React.createElement(Spinner, {
|
|
24
|
+
size: "small"
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (valueSubtext) {
|
|
28
|
+
return React.createElement(Horizontal, {
|
|
29
|
+
"$alignItems": "start",
|
|
30
|
+
"$gap": Spacing.S1
|
|
31
|
+
}, React.createElement(StatValue, null, formatNumberWithSpaces(value)), React.createElement(LockedText, {
|
|
32
|
+
"$small": true
|
|
33
|
+
}, valueSubtext));
|
|
34
|
+
}
|
|
35
|
+
return React.createElement(StatValue, null, formatNumberWithSpaces(value));
|
|
36
|
+
}, [isLoading, value, valueSubtext]);
|
|
37
|
+
return React.createElement(Container, {
|
|
38
|
+
"$active": active,
|
|
39
|
+
"$selectable": selectable,
|
|
40
|
+
"$width": width,
|
|
41
|
+
onClick: onClick,
|
|
42
|
+
...rest
|
|
43
|
+
}, React.createElement(Title, null, title), rightSlot && React.createElement(RightSlotContainer, {
|
|
44
|
+
onClick: e => e.stopPropagation()
|
|
45
|
+
}, rightSlot), statisticValue, footer && React.createElement(LockedText, {
|
|
46
|
+
"$small": true
|
|
47
|
+
}, footer));
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const formatNumberWithSpaces: (number: number) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const formatNumberWithSpaces = number => number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatisticCard';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StatisticCard';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { H2, H5 } from '@pushwoosh/kit-typography';
|
|
2
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
$active?: boolean;
|
|
4
|
+
$selectable?: boolean;
|
|
5
|
+
$width?: string;
|
|
6
|
+
}, never>;
|
|
7
|
+
export declare const Title: import("styled-components").StyledComponent<typeof H5, any, {}, never>;
|
|
8
|
+
export declare const StatValue: import("styled-components").StyledComponent<typeof H2, any, {}, never>;
|
|
9
|
+
export declare const RightSlotContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontWeight, ShapeRadius, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { H2, H5 } from '@pushwoosh/kit-typography';
|
|
4
|
+
export const Container = styled.div.withConfig({
|
|
5
|
+
displayName: "Container",
|
|
6
|
+
componentId: "sc-12f82mq-0"
|
|
7
|
+
})(["position:relative;display:flex;flex-direction:column;align-items:flex-start;border-radius:", ";width:", ";background:", ";padding:", ";border:", ";cursor:", ";"], ShapeRadius.SECTION, ({
|
|
8
|
+
$width
|
|
9
|
+
}) => $width || 'fit-content', ({
|
|
10
|
+
$selectable
|
|
11
|
+
}) => $selectable ? Color.CLEAR : Color.SOFT_LIGHT, Spacing.S5, ({
|
|
12
|
+
$active,
|
|
13
|
+
$selectable
|
|
14
|
+
}) => {
|
|
15
|
+
if ($active) {
|
|
16
|
+
return `3px solid ${Color.BRIGHT}`;
|
|
17
|
+
}
|
|
18
|
+
return $selectable ? `1px solid ${Color.DIVIDER}` : 'none';
|
|
19
|
+
}, ({
|
|
20
|
+
$selectable
|
|
21
|
+
}) => $selectable ? 'pointer' : 'auto');
|
|
22
|
+
export const Title = styled(H5).withConfig({
|
|
23
|
+
displayName: "Title",
|
|
24
|
+
componentId: "sc-12f82mq-1"
|
|
25
|
+
})(["text-transform:uppercase;color:", ";text-overflow:ellipsis;"], Color.MAIN);
|
|
26
|
+
export const StatValue = styled(H2).withConfig({
|
|
27
|
+
displayName: "StatValue",
|
|
28
|
+
componentId: "sc-12f82mq-2"
|
|
29
|
+
})(["font-weight:", ";"], FontWeight.BOLD);
|
|
30
|
+
export const RightSlotContainer = styled.div.withConfig({
|
|
31
|
+
displayName: "RightSlotContainer",
|
|
32
|
+
componentId: "sc-12f82mq-3"
|
|
33
|
+
})(["position:absolute;right:", ";top:", ";"], Spacing.S5, Spacing.S4);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type StatisticCardProps = CommonProps & (SelectableProps | NonSelectableProps);
|
|
3
|
+
export type CommonProps = {
|
|
4
|
+
title: string;
|
|
5
|
+
value: number;
|
|
6
|
+
valueSubtext?: string;
|
|
7
|
+
rightSlot?: ReactNode;
|
|
8
|
+
footer?: string;
|
|
9
|
+
isLoading?: boolean;
|
|
10
|
+
width?: string;
|
|
11
|
+
};
|
|
12
|
+
export type SelectableProps = {
|
|
13
|
+
selectable: true;
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type NonSelectableProps = {
|
|
18
|
+
selectable?: false;
|
|
19
|
+
onClick?: never;
|
|
20
|
+
active?: never;
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/common.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { H5 } from '@pushwoosh/kit-typography';
|
|
2
|
+
export declare const LockedTitle: import("styled-components").StyledComponent<typeof H5, any, {
|
|
3
|
+
$uppercase?: boolean;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const LockedText: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
$uppercase?: boolean;
|
|
7
|
+
$small?: boolean;
|
|
8
|
+
}, never>;
|
package/common.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontSize } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { H5 } from '@pushwoosh/kit-typography';
|
|
4
|
+
export const LockedTitle = styled(H5).withConfig({
|
|
5
|
+
displayName: "LockedTitle",
|
|
6
|
+
componentId: "sc-88o871-0"
|
|
7
|
+
})(["text-transform:", ";color:", ";text-overflow:ellipsis;"], ({
|
|
8
|
+
$uppercase
|
|
9
|
+
}) => $uppercase ? 'uppercase' : 'initial', Color.LOCKED);
|
|
10
|
+
export const LockedText = styled.div.withConfig({
|
|
11
|
+
displayName: "LockedText",
|
|
12
|
+
componentId: "sc-88o871-1"
|
|
13
|
+
})(["text-transform:", ";font-size:", ";color:", ";"], ({
|
|
14
|
+
$uppercase
|
|
15
|
+
}) => $uppercase ? 'uppercase' : 'initial', ({
|
|
16
|
+
$small
|
|
17
|
+
}) => $small ? FontSize.SMALL : 'initial', Color.LOCKED);
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/dumb-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "React components to build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@pushwoosh/frontend-builder-engine": "^1.0.8",
|
|
20
20
|
"@pushwoosh/kit-constants": "^1.6.7",
|
|
21
|
+
"@pushwoosh/kit-dropdown-menu": "^1.6.8",
|
|
21
22
|
"@types/lodash": "^4.17.13",
|
|
22
23
|
"@types/react": "^18.2.69",
|
|
23
24
|
"@types/react-dom": "^18.2.22",
|