@coinbase/cds-web-visualization 0.0.0 → 3.3.2
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/CHANGELOG.md +25 -0
- package/README.md +3 -0
- package/dts/index.d.ts +2 -0
- package/dts/index.d.ts.map +1 -0
- package/dts/sparkline/Counter.d.ts +8 -0
- package/dts/sparkline/Counter.d.ts.map +1 -0
- package/dts/sparkline/Sparkline.d.ts +32 -0
- package/dts/sparkline/Sparkline.d.ts.map +1 -0
- package/dts/sparkline/SparklineArea.d.ts +11 -0
- package/dts/sparkline/SparklineArea.d.ts.map +1 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts +9 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -0
- package/dts/sparkline/SparklineGradient.d.ts +18 -0
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -0
- package/dts/sparkline/SparklinePath.d.ts +12 -0
- package/dts/sparkline/SparklinePath.d.ts.map +1 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +2 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +1 -0
- package/dts/sparkline/generateSparklineWithId.d.ts +10 -0
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -0
- package/dts/sparkline/index.d.ts +6 -0
- package/dts/sparkline/index.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +190 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +23 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +5 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts +5 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +8 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +17 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +24 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts +30 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts +18 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +31 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/fade.d.ts +3 -0
- package/dts/sparkline/sparkline-interactive/fade.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +112 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +1 -0
- package/esm/index.js +1 -0
- package/esm/sparkline/Counter.css +3 -0
- package/esm/sparkline/Counter.js +35 -0
- package/esm/sparkline/Sparkline.js +50 -0
- package/esm/sparkline/SparklineArea.js +13 -0
- package/esm/sparkline/SparklineAreaPattern.js +35 -0
- package/esm/sparkline/SparklineGradient.js +72 -0
- package/esm/sparkline/SparklinePath.js +19 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +24 -0
- package/esm/sparkline/generateSparklineWithId.js +6 -0
- package/esm/sparkline/index.js +5 -0
- package/esm/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.js +21 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +313 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +105 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.css +2 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +26 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.css +2 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.js +24 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.css +4 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +65 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.css +1 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +84 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +52 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +70 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +45 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.css +5 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.js +199 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.js +39 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +92 -0
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +89 -0
- package/esm/sparkline/sparkline-interactive/fade.css +2 -0
- package/esm/sparkline/sparkline-interactive/fade.js +14 -0
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +28 -0
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +225 -0
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +108 -0
- package/package.json +64 -6
- package/index.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
type SparklineInteractiveScrubContextInterface = {
|
|
4
|
+
setLineDOMNode: Dispatch<SetStateAction<HTMLDivElement | null>>;
|
|
5
|
+
setMaskDOMNode: Dispatch<SetStateAction<HTMLDivElement | null>>;
|
|
6
|
+
setHoverDateDOMNode: Dispatch<SetStateAction<HTMLSpanElement | null>>;
|
|
7
|
+
setHoverPriceDOMNode: Dispatch<SetStateAction<HTMLSpanElement | null>>;
|
|
8
|
+
lineDOMNode: HTMLDivElement | null;
|
|
9
|
+
maskDOMNode: HTMLDivElement | null;
|
|
10
|
+
hoverDateDOMNode: HTMLSpanElement | null;
|
|
11
|
+
hoverPriceDOMNode: HTMLSpanElement | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const SparklineInteractiveScrubProvider: React.MemoExoticComponent<
|
|
14
|
+
({ children }: { children: React.ReactNode }) => import('react/jsx-runtime').JSX.Element
|
|
15
|
+
>;
|
|
16
|
+
export declare function useSparklineInteractiveScrubContext(): SparklineInteractiveScrubContextInterface;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=SparklineInteractiveScrubProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklineInteractiveScrubProvider.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6D,MAAM,OAAO,CAAC;AAClF,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGtD,KAAK,yCAAyC,GAAG;IAC/C,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC;IAChE,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC;IAChE,mBAAmB,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC;IACtE,oBAAoB,EAAE,QAAQ,CAAC,cAAc,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC;IACvE,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IACnC,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;IACnC,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,iBAAiB,EAAE,eAAe,GAAG,IAAI,CAAC;CAC3C,CAAC;AAaF,eAAO,MAAM,iCAAiC,2CAC7B;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,6CA0B7C,CAAC;AAEF,wBAAgB,mCAAmC,8CAElD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartDataPoint, ChartTimeseries } from '@coinbase/cds-common/types';
|
|
3
|
+
import type { Area, Line } from 'd3-shape';
|
|
4
|
+
export type TimeseriesPathOnRenderParams = {
|
|
5
|
+
path: string;
|
|
6
|
+
area: string;
|
|
7
|
+
};
|
|
8
|
+
export type TimeseriesPathProps = {
|
|
9
|
+
lineFn: Line<ChartDataPoint>;
|
|
10
|
+
areaFn: Area<ChartDataPoint>;
|
|
11
|
+
timeseries: ChartTimeseries;
|
|
12
|
+
initialPath: string;
|
|
13
|
+
onRender?: ({ path, area }: TimeseriesPathOnRenderParams) => void;
|
|
14
|
+
};
|
|
15
|
+
export type SparklineInteractiveTimeseriesPathsProps = {
|
|
16
|
+
initialPath: string;
|
|
17
|
+
data: ChartTimeseries[];
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
onRender: ({ path, area }: TimeseriesPathOnRenderParams) => void;
|
|
21
|
+
};
|
|
22
|
+
export declare const SparklineInteractiveTimeseriesPaths: React.MemoExoticComponent<
|
|
23
|
+
({
|
|
24
|
+
data,
|
|
25
|
+
width,
|
|
26
|
+
height,
|
|
27
|
+
initialPath,
|
|
28
|
+
onRender,
|
|
29
|
+
}: SparklineInteractiveTimeseriesPathsProps) => import('react/jsx-runtime').JSX.Element
|
|
30
|
+
>;
|
|
31
|
+
//# sourceMappingURL=SparklineInteractiveTimeseriesPaths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklineInteractiveTimeseriesPaths.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwD,MAAM,OAAO,CAAC;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlF,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAM3C,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7B,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IAC7B,UAAU,EAAE,eAAe,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,4BAA4B,KAAK,IAAI,CAAC;CACnE,CAAC;AA8CF,MAAM,MAAM,wCAAwC,GAAG;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,4BAA4B,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,mCAAmC,6EACG,wCAAwC,6CA2B1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklineInteractive.figma.d.ts","sourceRoot":"","sources":["../../../../src/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fade.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/fade.ts"],"names":[],"mappings":"AAqCA,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,QAGnD;AAED,wBAAgB,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,QAGlD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function useSparklineInteractiveConstants(): {
|
|
2
|
+
chartWidth: number;
|
|
3
|
+
chartHeight: number;
|
|
4
|
+
chartDimensionStyles: {
|
|
5
|
+
height: number;
|
|
6
|
+
width: number;
|
|
7
|
+
};
|
|
8
|
+
xRange: number[];
|
|
9
|
+
yRange: number[];
|
|
10
|
+
startX: number;
|
|
11
|
+
endX: number;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=useSparklineInteractiveConstants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSparklineInteractiveConstants.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive/useSparklineInteractiveConstants.ts"],"names":[],"mappings":"AASA,wBAAgB,gCAAgC;;;;;;;;;;;EAuB/C"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
SharedProps,
|
|
4
|
+
SparklineInteractiveHeaderSignVariant,
|
|
5
|
+
SparklineInteractiveHeaderVariant,
|
|
6
|
+
} from '@coinbase/cds-common/types';
|
|
7
|
+
export * from '@coinbase/cds-common/types/SparklineInteractiveHeaderBaseProps';
|
|
8
|
+
export type SparklineInteractiveSubHead = {
|
|
9
|
+
/**
|
|
10
|
+
* Free form percentage change
|
|
11
|
+
*/
|
|
12
|
+
percent: string;
|
|
13
|
+
/**
|
|
14
|
+
* Sign to denote the change in price
|
|
15
|
+
*/
|
|
16
|
+
sign: SparklineInteractiveHeaderSignVariant;
|
|
17
|
+
/**
|
|
18
|
+
* The variant to use for the price and percentage change
|
|
19
|
+
*/
|
|
20
|
+
variant: SparklineInteractiveHeaderVariant;
|
|
21
|
+
/**
|
|
22
|
+
* Show the dollar amount of price change
|
|
23
|
+
*/
|
|
24
|
+
priceChange?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The accessoryText to show after the price and / or percentage change. An example is "All time"
|
|
27
|
+
*/
|
|
28
|
+
accessoryText?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The accessibilityLabel to show for the price and / or percentage change. This should be localized
|
|
31
|
+
* @example
|
|
32
|
+
* // First, configure your i18n strings
|
|
33
|
+
* const messages = defineMessages({
|
|
34
|
+
* subHeadPrefix: {
|
|
35
|
+
* id: `${i18nKey}.subHeadPrefix`,
|
|
36
|
+
* defaultMessage: 'Price increase in the amount of',
|
|
37
|
+
* description: 'A prefix to make it clear which direction the price action was moving',
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // then provide the translated string the accessibilityLabel prop
|
|
42
|
+
* messages.subHeadPrefix
|
|
43
|
+
*/
|
|
44
|
+
accessibilityLabel?: string;
|
|
45
|
+
};
|
|
46
|
+
export type SparklineInteractiveHeaderValues = {
|
|
47
|
+
/**
|
|
48
|
+
* Describes what the Header represents e.g. Bitcoin Price
|
|
49
|
+
*/
|
|
50
|
+
label?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Main content of header, this is usually the price
|
|
53
|
+
*/
|
|
54
|
+
title?: React.ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Provides additional information about the title, such as a price change
|
|
57
|
+
*/
|
|
58
|
+
subHead?: SparklineInteractiveSubHead;
|
|
59
|
+
};
|
|
60
|
+
export type SparklineInteractiveHeaderRef = {
|
|
61
|
+
update: (params: SparklineInteractiveHeaderValues) => void;
|
|
62
|
+
};
|
|
63
|
+
export type SparklineInteractiveHeaderProps = SharedProps & {
|
|
64
|
+
/**
|
|
65
|
+
* Default title, changing this prop has no effect once the default is rendered. If you use a ReactNode that is not a string, then you cannot use the text based label that supports updates.
|
|
66
|
+
*/
|
|
67
|
+
defaultTitle: React.ReactNode;
|
|
68
|
+
/**
|
|
69
|
+
* Default label, changing this prop has no effect once the default is rendered.
|
|
70
|
+
*/
|
|
71
|
+
defaultLabel?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Default SubHead, changing this prop has no effect once the default is rendered.
|
|
74
|
+
*/
|
|
75
|
+
defaultSubHead?: SparklineInteractiveSubHead;
|
|
76
|
+
/**
|
|
77
|
+
* Adds a label node that allows React components. If you use this node then you cannot use the text based label that supports updates.
|
|
78
|
+
*/
|
|
79
|
+
labelNode?: React.ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* Reduce the font size used for the header itself.
|
|
82
|
+
*/
|
|
83
|
+
compact?: boolean;
|
|
84
|
+
};
|
|
85
|
+
export declare const interpolateSubHeadText: (subHead: SparklineInteractiveSubHead) => string;
|
|
86
|
+
export declare const SparklineInteractiveHeader: React.MemoExoticComponent<
|
|
87
|
+
React.ForwardRefExoticComponent<
|
|
88
|
+
SharedProps & {
|
|
89
|
+
/**
|
|
90
|
+
* Default title, changing this prop has no effect once the default is rendered. If you use a ReactNode that is not a string, then you cannot use the text based label that supports updates.
|
|
91
|
+
*/
|
|
92
|
+
defaultTitle: React.ReactNode;
|
|
93
|
+
/**
|
|
94
|
+
* Default label, changing this prop has no effect once the default is rendered.
|
|
95
|
+
*/
|
|
96
|
+
defaultLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Default SubHead, changing this prop has no effect once the default is rendered.
|
|
99
|
+
*/
|
|
100
|
+
defaultSubHead?: SparklineInteractiveSubHead;
|
|
101
|
+
/**
|
|
102
|
+
* Adds a label node that allows React components. If you use this node then you cannot use the text based label that supports updates.
|
|
103
|
+
*/
|
|
104
|
+
labelNode?: React.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Reduce the font size used for the header itself.
|
|
107
|
+
*/
|
|
108
|
+
compact?: boolean;
|
|
109
|
+
} & React.RefAttributes<SparklineInteractiveHeaderRef>
|
|
110
|
+
>
|
|
111
|
+
>;
|
|
112
|
+
//# sourceMappingURL=SparklineInteractiveHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklineInteractiveHeader.d.ts","sourceRoot":"","sources":["../../../src/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8E,MAAM,OAAO,CAAC;AAGnG,OAAO,KAAK,EACV,WAAW,EACX,qCAAqC,EACrC,iCAAiC,EAClC,MAAM,4BAA4B,CAAC;AAMpC,cAAc,gEAAgE,CAAC;AAQ/E,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,qCAAqC,CAAC;IAC5C;;OAEG;IACH,OAAO,EAAE,iCAAiC,CAAC;IAC3C;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;;;;;OAcG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG;IAC7C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,CAAC,MAAM,EAAE,gCAAgC,KAAK,IAAI,CAAC;CAC5D,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG,WAAW,GAAG;IAC1D;;OAEG;IACH,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,2BAA2B,CAAC;IAC7C;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,SAAS,2BAA2B,WAQ1E,CAAC;AA8KF,eAAO,MAAM,0BAA0B;IA5MrC;;OAEG;kBACW,KAAK,CAAC,SAAS;IAC7B;;OAEG;mBACY,MAAM;IACrB;;OAEG;qBACc,2BAA2B;IAC5C;;OAEG;gBACS,KAAK,CAAC,SAAS;IAC3B;;OAEG;cACO,OAAO;wDA6MlB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SparklineInteractiveHeader.figma.d.ts","sourceRoot":"","sources":["../../../../src/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.tsx"],"names":[],"mappings":""}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sparkline';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
.cds-containerCss-co2zq3s{position:relative;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
2
|
+
.cds-hiddenCss-h1nhoofs{visibility:hidden;}
|
|
3
|
+
.cds-visibleCss-vhca54u{position:absolute;top:0;left:0;width:100%;height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.cds-visibleCss-vhca54u > *{width:100%;height:100%;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { useCounter } from '@coinbase/cds-common/visualizations/useCounter';
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
const containerCss = "cds-containerCss-co2zq3s";
|
|
5
|
+
const hiddenCss = "cds-hiddenCss-h1nhoofs";
|
|
6
|
+
const visibleCss = "cds-visibleCss-vhca54u";
|
|
7
|
+
export const Counter = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
startNum,
|
|
10
|
+
endNum,
|
|
11
|
+
renderNum,
|
|
12
|
+
durationInMillis
|
|
13
|
+
} = _ref;
|
|
14
|
+
const count = useCounter({
|
|
15
|
+
startNum,
|
|
16
|
+
endNum,
|
|
17
|
+
durationInMillis
|
|
18
|
+
});
|
|
19
|
+
const renderFunction = useMemo(() => {
|
|
20
|
+
return num => {
|
|
21
|
+
return renderNum ? renderNum(num) : num;
|
|
22
|
+
};
|
|
23
|
+
}, [renderNum]);
|
|
24
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
25
|
+
className: containerCss,
|
|
26
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
27
|
+
className: hiddenCss,
|
|
28
|
+
children: renderFunction(endNum)
|
|
29
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
30
|
+
className: visibleCss,
|
|
31
|
+
children: renderFunction(count)
|
|
32
|
+
})]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
import "./Counter.css";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import React, { memo, useRef } from 'react';
|
|
7
|
+
import { getAccessibleColor } from '@coinbase/cds-common/utils/getAccessibleColor';
|
|
8
|
+
import { getSparklineTransform } from '@coinbase/cds-common/visualizations/getSparklineTransform';
|
|
9
|
+
import { generateRandomId } from '@coinbase/cds-utils';
|
|
10
|
+
import { useTheme } from '@coinbase/cds-web/hooks/useTheme';
|
|
11
|
+
import { generateSparklineAreaWithId } from './generateSparklineWithId';
|
|
12
|
+
import { SparklineAreaPattern } from './SparklineAreaPattern';
|
|
13
|
+
import { SparklinePath } from './SparklinePath';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
export const Sparkline = /*#__PURE__*/memo(_ref => {
|
|
16
|
+
let {
|
|
17
|
+
background,
|
|
18
|
+
color,
|
|
19
|
+
height,
|
|
20
|
+
path,
|
|
21
|
+
width,
|
|
22
|
+
yAxisScalingFactor,
|
|
23
|
+
children
|
|
24
|
+
} = _ref;
|
|
25
|
+
const theme = useTheme();
|
|
26
|
+
const patternId = useRef(generateRandomId());
|
|
27
|
+
const stroke = color !== 'auto' ? color : getAccessibleColor({
|
|
28
|
+
background: background !== null && background !== void 0 ? background : theme.color.bg,
|
|
29
|
+
foreground: 'auto',
|
|
30
|
+
usage: 'graphic'
|
|
31
|
+
});
|
|
32
|
+
const translateProps = getSparklineTransform(width, height, yAxisScalingFactor);
|
|
33
|
+
const defs = children ? /*#__PURE__*/_jsx("defs", {
|
|
34
|
+
children: /*#__PURE__*/_jsx(SparklineAreaPattern, {
|
|
35
|
+
color: stroke,
|
|
36
|
+
id: patternId.current
|
|
37
|
+
})
|
|
38
|
+
}) : null;
|
|
39
|
+
return /*#__PURE__*/_jsxs("svg", {
|
|
40
|
+
height: height,
|
|
41
|
+
width: width,
|
|
42
|
+
children: [defs, /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({}, translateProps), {}, {
|
|
43
|
+
children: [/*#__PURE__*/_jsx(SparklinePath, {
|
|
44
|
+
path: path,
|
|
45
|
+
stroke: stroke
|
|
46
|
+
}), generateSparklineAreaWithId(patternId.current, children)]
|
|
47
|
+
}))]
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
Sparkline.displayName = 'Sparkline';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { forwardRef, memo } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export const SparklineArea = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
4
|
+
let {
|
|
5
|
+
area,
|
|
6
|
+
patternId
|
|
7
|
+
} = _ref;
|
|
8
|
+
return /*#__PURE__*/_jsx("path", {
|
|
9
|
+
ref: ref,
|
|
10
|
+
d: area,
|
|
11
|
+
fill: "url(#".concat(patternId, ")")
|
|
12
|
+
});
|
|
13
|
+
}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSparklineAreaOpacity } from '@coinbase/cds-common/visualizations/useSparklineAreaOpacity';
|
|
3
|
+
import { useTheme } from '@coinbase/cds-web/hooks/useTheme';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export const SparklineAreaPattern = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
color,
|
|
8
|
+
id
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
activeColorScheme
|
|
12
|
+
} = useTheme();
|
|
13
|
+
const fillOpacity = useSparklineAreaOpacity(activeColorScheme);
|
|
14
|
+
return /*#__PURE__*/_jsx("pattern", {
|
|
15
|
+
height: "4",
|
|
16
|
+
id: id,
|
|
17
|
+
patternUnits: "userSpaceOnUse",
|
|
18
|
+
width: "4",
|
|
19
|
+
x: "0",
|
|
20
|
+
y: "0",
|
|
21
|
+
children: /*#__PURE__*/_jsxs("g", {
|
|
22
|
+
children: [/*#__PURE__*/_jsx("rect", {
|
|
23
|
+
fill: "transparent",
|
|
24
|
+
height: "4",
|
|
25
|
+
width: "4"
|
|
26
|
+
}), /*#__PURE__*/_jsx("circle", {
|
|
27
|
+
cx: "1",
|
|
28
|
+
cy: "1",
|
|
29
|
+
fill: color,
|
|
30
|
+
fillOpacity: fillOpacity,
|
|
31
|
+
r: "1"
|
|
32
|
+
})]
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import React, { forwardRef, memo, useId, useMemo, useRef } from 'react';
|
|
7
|
+
import { getAccessibleForegroundGradient } from '@coinbase/cds-common/color/getAccessibleForegroundGradient';
|
|
8
|
+
import { getAccessibleColor } from '@coinbase/cds-common/utils/getAccessibleColor';
|
|
9
|
+
import { getSparklineTransform } from '@coinbase/cds-common/visualizations/getSparklineTransform';
|
|
10
|
+
import { generateRandomId } from '@coinbase/cds-utils';
|
|
11
|
+
import { useTheme } from '@coinbase/cds-web/hooks/useTheme';
|
|
12
|
+
import { generateSparklineAreaWithId } from './generateSparklineWithId';
|
|
13
|
+
import { SparklineAreaPattern } from './SparklineAreaPattern';
|
|
14
|
+
import { SparklinePath } from './SparklinePath';
|
|
15
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
+
export const SparklineGradient = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
17
|
+
let {
|
|
18
|
+
background,
|
|
19
|
+
color,
|
|
20
|
+
path,
|
|
21
|
+
height,
|
|
22
|
+
width,
|
|
23
|
+
yAxisScalingFactor,
|
|
24
|
+
children
|
|
25
|
+
} = _ref;
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
const patternId = useRef(generateRandomId());
|
|
28
|
+
const gradient = getAccessibleForegroundGradient({
|
|
29
|
+
background: background !== null && background !== void 0 ? background : theme.color.bg,
|
|
30
|
+
color,
|
|
31
|
+
colorScheme: theme.activeColorScheme,
|
|
32
|
+
usage: 'graphic'
|
|
33
|
+
});
|
|
34
|
+
const areaColor = color !== 'auto' ? color : getAccessibleColor({
|
|
35
|
+
background: background !== null && background !== void 0 ? background : theme.color.bg,
|
|
36
|
+
foreground: 'auto',
|
|
37
|
+
usage: 'graphic'
|
|
38
|
+
});
|
|
39
|
+
const gradientId = useId();
|
|
40
|
+
const translateProps = getSparklineTransform(width, height, yAxisScalingFactor);
|
|
41
|
+
const hasChildren = !!children;
|
|
42
|
+
const linearGradient = useMemo(() => {
|
|
43
|
+
return /*#__PURE__*/_jsxs("defs", {
|
|
44
|
+
children: [/*#__PURE__*/_jsx("linearGradient", {
|
|
45
|
+
id: gradientId,
|
|
46
|
+
x1: "0%",
|
|
47
|
+
x2: "100%",
|
|
48
|
+
y1: "0%",
|
|
49
|
+
y2: "0%",
|
|
50
|
+
children: gradient.map((item, i) => /*#__PURE__*/_jsx("stop", {
|
|
51
|
+
offset: item.offset,
|
|
52
|
+
stopColor: item.color
|
|
53
|
+
}, "".concat(i, "_").concat(item)))
|
|
54
|
+
}), hasChildren && /*#__PURE__*/_jsx(SparklineAreaPattern, {
|
|
55
|
+
color: areaColor,
|
|
56
|
+
id: patternId.current
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
59
|
+
}, [gradientId, gradient, hasChildren, areaColor]);
|
|
60
|
+
return /*#__PURE__*/_jsxs("svg", {
|
|
61
|
+
height: height,
|
|
62
|
+
width: width,
|
|
63
|
+
children: [linearGradient, /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({}, translateProps), {}, {
|
|
64
|
+
children: [/*#__PURE__*/_jsx(SparklinePath, {
|
|
65
|
+
ref: forwardedRef,
|
|
66
|
+
path: path,
|
|
67
|
+
stroke: "url(#".concat(gradientId, ")")
|
|
68
|
+
}), generateSparklineAreaWithId(patternId.current, children)]
|
|
69
|
+
}))]
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
SparklineGradient.displayName = 'SparklineGradient';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { forwardRef, memo } from 'react';
|
|
2
|
+
import { borderWidth } from '@coinbase/cds-common/tokens/sparkline';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export const SparklinePath = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
5
|
+
let {
|
|
6
|
+
path,
|
|
7
|
+
stroke
|
|
8
|
+
} = _ref;
|
|
9
|
+
return /*#__PURE__*/_jsx("path", {
|
|
10
|
+
ref: forwardedRef,
|
|
11
|
+
d: path,
|
|
12
|
+
fill: "transparent",
|
|
13
|
+
stroke: stroke,
|
|
14
|
+
strokeLinecap: "round",
|
|
15
|
+
strokeLinejoin: "round",
|
|
16
|
+
strokeWidth: borderWidth
|
|
17
|
+
});
|
|
18
|
+
}));
|
|
19
|
+
SparklinePath.displayName = 'SparklinePath';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { figma } from '@figma/code-connect';
|
|
5
|
+
import { Sparkline } from '../Sparkline';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
figma.connect(Sparkline, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/✨-CDS-Components?node-id=320-15040&m=dev', {
|
|
8
|
+
imports: ["import { Sparkline } from '@coinbase/cds-web-visualization';", "import { useSparklinePath } from '@coinbase/cds-common/visualizations/useSparklinePath';"],
|
|
9
|
+
example: () => {
|
|
10
|
+
const data = [20, 30, 5, 45, 0];
|
|
11
|
+
// @ts-expect-error: useSparklinePath is not typed correctly
|
|
12
|
+
const path = useSparklinePath({
|
|
13
|
+
height: 200,
|
|
14
|
+
width: 200,
|
|
15
|
+
data
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/_jsx(Sparkline, {
|
|
18
|
+
color: "auto",
|
|
19
|
+
height: 200,
|
|
20
|
+
path: path,
|
|
21
|
+
width: 400
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
3
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export const InnerSparklineInteractiveProvider = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
width,
|
|
7
|
+
height,
|
|
8
|
+
children
|
|
9
|
+
} = _ref;
|
|
10
|
+
const {
|
|
11
|
+
setWidth,
|
|
12
|
+
setHeight
|
|
13
|
+
} = useSparklineInteractiveContext();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setWidth(width);
|
|
16
|
+
setHeight(height);
|
|
17
|
+
}, [width, height, setWidth, setHeight]);
|
|
18
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
19
|
+
children: children
|
|
20
|
+
});
|
|
21
|
+
};
|