@coinbase/cds-web 8.41.0 → 8.42.0
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 +7 -0
- package/dts/alpha/data-card/DataCard.d.ts +25 -0
- package/dts/alpha/data-card/DataCard.d.ts.map +1 -0
- package/dts/alpha/data-card/DataCardLayout.d.ts +44 -0
- package/dts/alpha/data-card/DataCardLayout.d.ts.map +1 -0
- package/dts/alpha/data-card/__figma__/DataCard.figma.d.ts +2 -0
- package/dts/alpha/data-card/__figma__/DataCard.figma.d.ts.map +1 -0
- package/dts/alpha/data-card/index.d.ts +3 -0
- package/dts/alpha/data-card/index.d.ts.map +1 -0
- package/dts/alpha/index.d.ts +1 -0
- package/dts/alpha/index.d.ts.map +1 -1
- package/dts/cards/AnnouncementCard.d.ts +1 -1
- package/dts/cards/AnnouncementCard.d.ts.map +1 -1
- package/dts/cards/CardRoot.d.ts +35 -0
- package/dts/cards/CardRoot.d.ts.map +1 -0
- package/dts/cards/ContainedAssetCard.d.ts +27 -0
- package/dts/cards/ContainedAssetCard.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCard.d.ts +3 -3
- package/dts/cards/ContentCard/ContentCard.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardBody.d.ts +58 -3
- package/dts/cards/ContentCard/ContentCardBody.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardFooter.d.ts +1 -1
- package/dts/cards/ContentCard/ContentCardFooter.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardHeader.d.ts +39 -5
- package/dts/cards/ContentCard/ContentCardHeader.d.ts.map +1 -1
- package/dts/cards/DataCard.d.ts +35 -0
- package/dts/cards/DataCard.d.ts.map +1 -1
- package/dts/cards/FeatureEntryCard.d.ts +2 -2
- package/dts/cards/FeatureEntryCard.d.ts.map +1 -1
- package/dts/cards/FloatingAssetCard.d.ts +25 -0
- package/dts/cards/FloatingAssetCard.d.ts.map +1 -1
- package/dts/cards/MediaCard/MediaCardLayout.d.ts +46 -0
- package/dts/cards/MediaCard/MediaCardLayout.d.ts.map +1 -0
- package/dts/cards/MediaCard/__figma__/MediaCard.figma.d.ts +2 -0
- package/dts/cards/MediaCard/__figma__/MediaCard.figma.d.ts.map +1 -0
- package/dts/cards/MediaCard/index.d.ts +26 -0
- package/dts/cards/MediaCard/index.d.ts.map +1 -0
- package/dts/cards/MessagingCard/MessagingCardLayout.d.ts +68 -0
- package/dts/cards/MessagingCard/MessagingCardLayout.d.ts.map +1 -0
- package/dts/cards/MessagingCard/__figma__/MessagingCard.figma.d.ts +2 -0
- package/dts/cards/MessagingCard/__figma__/MessagingCard.figma.d.ts.map +1 -0
- package/dts/cards/MessagingCard/index.d.ts +23 -0
- package/dts/cards/MessagingCard/index.d.ts.map +1 -0
- package/dts/cards/NudgeCard.d.ts +27 -0
- package/dts/cards/NudgeCard.d.ts.map +1 -1
- package/dts/cards/UpsellCard.d.ts +27 -0
- package/dts/cards/UpsellCard.d.ts.map +1 -1
- package/dts/cards/index.d.ts +3 -0
- package/dts/cards/index.d.ts.map +1 -1
- package/esm/alpha/data-card/DataCard.js +62 -0
- package/esm/alpha/data-card/DataCardLayout.js +83 -0
- package/esm/alpha/data-card/__figma__/DataCard.figma.js +29 -0
- package/esm/alpha/data-card/index.js +1 -0
- package/esm/alpha/index.js +1 -0
- package/esm/cards/AnnouncementCard.js +1 -1
- package/esm/cards/{CardRemoteImage.js → CardRoot.js} +31 -13
- package/esm/cards/ContainedAssetCard.js +28 -0
- package/esm/cards/ContentCard/ContentCard.js +8 -7
- package/esm/cards/ContentCard/ContentCardBody.js +77 -20
- package/esm/cards/ContentCard/ContentCardFooter.js +5 -6
- package/esm/cards/ContentCard/ContentCardHeader.js +65 -27
- package/esm/cards/DataCard.js +35 -0
- package/esm/cards/FeatureEntryCard.js +2 -2
- package/esm/cards/FloatingAssetCard.js +26 -0
- package/esm/cards/MediaCard/MediaCardLayout.js +77 -0
- package/esm/cards/MediaCard/__figma__/MediaCard.figma.js +46 -0
- package/esm/cards/MediaCard/index.js +61 -0
- package/esm/cards/MessagingCard/MessagingCardLayout.js +195 -0
- package/esm/cards/MessagingCard/__figma__/MessagingCard.figma.js +49 -0
- package/esm/cards/MessagingCard/index.js +70 -0
- package/esm/cards/NudgeCard.js +27 -0
- package/esm/cards/UpsellCard.js +27 -0
- package/esm/cards/index.js +6 -1
- package/package.json +6 -2
- package/dts/cards/CardRemoteImage.d.ts +0 -8
- package/dts/cards/CardRemoteImage.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["as", "body", "label", "media", "mediaPosition", "children", "gap", "testID"];
|
|
1
|
+
const _excluded = ["as", "body", "label", "media", "mediaPosition", "mediaPlacement", "title", "description", "children", "gap", "testID", "styles", "style", "classNames", "className"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -6,11 +6,18 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
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); }
|
|
7
7
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
-
import React, { forwardRef, memo } from 'react';
|
|
9
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
10
|
+
import { cx } from '../../cx';
|
|
10
11
|
import { Box, VStack } from '../../layout';
|
|
11
12
|
import { Text } from '../../typography/Text';
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
export const contentCardBodyDefaultElement = 'div';
|
|
15
|
+
const mapMediaPositionToMediaPlacement = {
|
|
16
|
+
top: 'top',
|
|
17
|
+
bottom: 'bottom',
|
|
18
|
+
right: 'end',
|
|
19
|
+
left: 'start'
|
|
20
|
+
};
|
|
14
21
|
export const ContentCardBody = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
22
|
let {
|
|
16
23
|
as,
|
|
@@ -18,42 +25,92 @@ export const ContentCardBody = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref,
|
|
|
18
25
|
label,
|
|
19
26
|
media,
|
|
20
27
|
mediaPosition = 'top',
|
|
28
|
+
mediaPlacement = mapMediaPositionToMediaPlacement[mediaPosition],
|
|
29
|
+
title,
|
|
30
|
+
description = body,
|
|
21
31
|
children,
|
|
22
32
|
gap = 1,
|
|
23
|
-
testID
|
|
33
|
+
testID,
|
|
34
|
+
styles,
|
|
35
|
+
style,
|
|
36
|
+
classNames,
|
|
37
|
+
className
|
|
24
38
|
} = _ref,
|
|
25
39
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
26
40
|
const Component = as !== null && as !== void 0 ? as : contentCardBodyDefaultElement;
|
|
27
|
-
const isHorizontal =
|
|
41
|
+
const isHorizontal = mediaPlacement === 'start' || mediaPlacement === 'end';
|
|
42
|
+
const isMediaFirst = !!media && (mediaPlacement === 'top' || mediaPlacement === 'start');
|
|
43
|
+
const isMediaLast = !!media && (mediaPlacement === 'bottom' || mediaPlacement === 'end');
|
|
44
|
+
const titleNode = useMemo(() => {
|
|
45
|
+
if (typeof title === 'string') {
|
|
46
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
47
|
+
as: "div",
|
|
48
|
+
font: "headline",
|
|
49
|
+
numberOfLines: 2,
|
|
50
|
+
children: title
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return title;
|
|
54
|
+
}, [title]);
|
|
55
|
+
const descriptionNode = useMemo(() => {
|
|
56
|
+
if (typeof description === 'string') {
|
|
57
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
58
|
+
as: "p",
|
|
59
|
+
color: "fgMuted",
|
|
60
|
+
font: "label2",
|
|
61
|
+
numberOfLines: 3,
|
|
62
|
+
children: description
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return description;
|
|
66
|
+
}, [description]);
|
|
67
|
+
const labelNode = useMemo(() => {
|
|
68
|
+
if (typeof label === 'string') {
|
|
69
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
70
|
+
as: "div",
|
|
71
|
+
font: "label2",
|
|
72
|
+
children: label
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return label;
|
|
76
|
+
}, [label]);
|
|
77
|
+
const textNode = useMemo(() => {
|
|
78
|
+
if (!titleNode && !descriptionNode && !labelNode) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
82
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.textContainer,
|
|
83
|
+
gap: isHorizontal ? 1 : 0,
|
|
84
|
+
style: styles === null || styles === void 0 ? void 0 : styles.textContainer,
|
|
85
|
+
children: [titleNode, descriptionNode, labelNode]
|
|
86
|
+
});
|
|
87
|
+
}, [classNames === null || classNames === void 0 ? void 0 : classNames.textContainer, isHorizontal, styles === null || styles === void 0 ? void 0 : styles.textContainer, titleNode, descriptionNode, labelNode]);
|
|
28
88
|
const mediaBox = isHorizontal ? /*#__PURE__*/_jsx(Box, {
|
|
89
|
+
borderRadius: 500,
|
|
29
90
|
flexShrink: 0,
|
|
30
91
|
height: 96,
|
|
92
|
+
overflow: "hidden",
|
|
31
93
|
width: 96,
|
|
32
94
|
children: media
|
|
33
|
-
}) :
|
|
95
|
+
}) : /*#__PURE__*/_jsx(Box, {
|
|
96
|
+
borderRadius: 500,
|
|
97
|
+
overflow: "hidden",
|
|
98
|
+
children: media
|
|
99
|
+
});
|
|
34
100
|
return /*#__PURE__*/_jsxs(VStack, _objectSpread(_objectSpread({
|
|
35
101
|
ref: ref,
|
|
36
102
|
as: Component,
|
|
103
|
+
className: cx(classNames === null || classNames === void 0 ? void 0 : classNames.root, className),
|
|
37
104
|
gap: gap,
|
|
105
|
+
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root),
|
|
38
106
|
testID: testID
|
|
39
107
|
}, props), {}, {
|
|
40
|
-
children: [/*#__PURE__*/_jsxs(Box, {
|
|
108
|
+
children: [(mediaBox || textNode) && /*#__PURE__*/_jsxs(Box, {
|
|
41
109
|
flexDirection: isHorizontal ? 'row' : 'column',
|
|
42
110
|
gap: isHorizontal ? 2 : 1,
|
|
43
|
-
justifyContent:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
maxWidth: "100%",
|
|
47
|
-
children: [typeof body === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
48
|
-
as: "p",
|
|
49
|
-
display: "block",
|
|
50
|
-
font: "body",
|
|
51
|
-
children: body
|
|
52
|
-
}) : body, typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
53
|
-
font: "label2",
|
|
54
|
-
children: label
|
|
55
|
-
}) : label]
|
|
56
|
-
}), (mediaPosition === 'bottom' || mediaPosition === 'right') && mediaBox]
|
|
111
|
+
justifyContent: mediaPlacement === 'end' ? 'space-between' : 'flex-start',
|
|
112
|
+
style: styles === null || styles === void 0 ? void 0 : styles.contentContainer,
|
|
113
|
+
children: [isMediaFirst && mediaBox, textNode, isMediaLast && mediaBox]
|
|
57
114
|
}), children]
|
|
58
115
|
}));
|
|
59
116
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["as", "
|
|
1
|
+
const _excluded = ["as", "children", "justifyContent"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -9,20 +9,19 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
|
|
|
9
9
|
import React, { forwardRef, memo } from 'react';
|
|
10
10
|
import { HStack } from '../../layout';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
export const contentCardFooterDefaultElement = '
|
|
12
|
+
export const contentCardFooterDefaultElement = 'footer';
|
|
13
13
|
export const ContentCardFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
14
|
let {
|
|
15
15
|
as,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
children,
|
|
17
|
+
justifyContent = 'space-between'
|
|
18
18
|
} = _ref,
|
|
19
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
const Component = as !== null && as !== void 0 ? as : contentCardFooterDefaultElement;
|
|
21
21
|
return /*#__PURE__*/_jsx(HStack, _objectSpread(_objectSpread({
|
|
22
22
|
ref: ref,
|
|
23
23
|
as: Component,
|
|
24
|
-
justifyContent:
|
|
25
|
-
testID: testID
|
|
24
|
+
justifyContent: justifyContent
|
|
26
25
|
}, props), {}, {
|
|
27
26
|
children: children
|
|
28
27
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["as", "avatar", "title", "meta", "end", "
|
|
1
|
+
const _excluded = ["as", "avatar", "title", "meta", "end", "subtitle", "actions", "thumbnail", "styles", "style", "classNames", "className", "gap"];
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
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; }
|
|
@@ -6,12 +6,13 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
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); }
|
|
7
7
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
-
import React, { forwardRef, memo } from 'react';
|
|
10
|
-
import {
|
|
9
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
10
|
+
import { cx } from '../../cx';
|
|
11
|
+
import { HStack, VStack } from '../../layout';
|
|
11
12
|
import { Avatar } from '../../media';
|
|
12
13
|
import { Text } from '../../typography/Text';
|
|
13
14
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
export const contentCardHeaderDefaultElement = '
|
|
15
|
+
export const contentCardHeaderDefaultElement = 'header';
|
|
15
16
|
export const ContentCardHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
16
17
|
let {
|
|
17
18
|
as,
|
|
@@ -19,39 +20,76 @@ export const ContentCardHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref
|
|
|
19
20
|
title,
|
|
20
21
|
meta,
|
|
21
22
|
end,
|
|
22
|
-
|
|
23
|
+
subtitle = meta,
|
|
24
|
+
actions = end,
|
|
25
|
+
thumbnail,
|
|
26
|
+
styles,
|
|
27
|
+
style,
|
|
28
|
+
classNames,
|
|
29
|
+
className,
|
|
30
|
+
gap = 1.5
|
|
23
31
|
} = _ref,
|
|
24
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
33
|
const Component = as !== null && as !== void 0 ? as : contentCardHeaderDefaultElement;
|
|
34
|
+
const titleNode = useMemo(() => {
|
|
35
|
+
if (typeof title === 'string') {
|
|
36
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
37
|
+
as: "div",
|
|
38
|
+
font: "label1",
|
|
39
|
+
numberOfLines: 1,
|
|
40
|
+
children: title
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return title;
|
|
44
|
+
}, [title]);
|
|
45
|
+
const subtitleNode = useMemo(() => {
|
|
46
|
+
if (typeof subtitle === 'string') {
|
|
47
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
48
|
+
as: "div",
|
|
49
|
+
color: "fgMuted",
|
|
50
|
+
font: "legal",
|
|
51
|
+
numberOfLines: 1,
|
|
52
|
+
children: subtitle
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return subtitle;
|
|
56
|
+
}, [subtitle]);
|
|
57
|
+
const thumbnailNode = useMemo(() => {
|
|
58
|
+
// Use new thumbnail prop if provided
|
|
59
|
+
if (thumbnail) return thumbnail;
|
|
60
|
+
// Fallback to deprecated avatar prop (supports string for backward compatibility)
|
|
61
|
+
if (typeof avatar === 'string') {
|
|
62
|
+
return /*#__PURE__*/_jsx(Avatar, {
|
|
63
|
+
alt: typeof title === 'string' ? title : undefined,
|
|
64
|
+
name: typeof title === 'string' ? title : undefined,
|
|
65
|
+
shape: "circle",
|
|
66
|
+
size: "l",
|
|
67
|
+
src: avatar
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return avatar;
|
|
71
|
+
}, [thumbnail, avatar, title]);
|
|
26
72
|
return /*#__PURE__*/_jsxs(HStack, _objectSpread(_objectSpread({
|
|
27
73
|
ref: ref,
|
|
28
74
|
alignItems: "center",
|
|
29
75
|
as: Component,
|
|
76
|
+
className: cx(classNames === null || classNames === void 0 ? void 0 : classNames.root, className),
|
|
77
|
+
gap: gap,
|
|
30
78
|
justifyContent: "space-between",
|
|
31
|
-
|
|
32
|
-
testID: testID
|
|
79
|
+
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
33
80
|
}, props), {}, {
|
|
34
81
|
children: [/*#__PURE__*/_jsxs(HStack, {
|
|
35
82
|
alignItems: "center",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
numberOfLines: 1,
|
|
48
|
-
children: title
|
|
49
|
-
}) : title, typeof meta === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
50
|
-
color: "fgMuted",
|
|
51
|
-
font: "label2",
|
|
52
|
-
numberOfLines: 1,
|
|
53
|
-
children: meta
|
|
54
|
-
}) : meta]
|
|
55
|
-
}), end]
|
|
83
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.contentContainer,
|
|
84
|
+
gap: 1.5,
|
|
85
|
+
style: styles === null || styles === void 0 ? void 0 : styles.contentContainer,
|
|
86
|
+
children: [thumbnailNode, /*#__PURE__*/_jsxs(VStack, {
|
|
87
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.textContainer,
|
|
88
|
+
flexGrow: 1,
|
|
89
|
+
justifyContent: "flex-start",
|
|
90
|
+
style: styles === null || styles === void 0 ? void 0 : styles.textContainer,
|
|
91
|
+
children: [titleNode, subtitleNode]
|
|
92
|
+
})]
|
|
93
|
+
}), actions]
|
|
56
94
|
}));
|
|
57
95
|
}));
|
package/esm/cards/DataCard.js
CHANGED
|
@@ -6,6 +6,41 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
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); }
|
|
7
7
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated This component is deprecated. Please use the alpha `DataCard` from `@coinbase/cds-web/alpha/data-card` instead.
|
|
11
|
+
*
|
|
12
|
+
* ### Migration Guide
|
|
13
|
+
*
|
|
14
|
+
* The new `DataCard` provides more flexibility with custom layouts and visualization components.
|
|
15
|
+
*
|
|
16
|
+
* **Before:**
|
|
17
|
+
* ```jsx
|
|
18
|
+
* <DataCard
|
|
19
|
+
* title="Progress"
|
|
20
|
+
* description="45% complete"
|
|
21
|
+
* progress={0.45}
|
|
22
|
+
* progressVariant="bar"
|
|
23
|
+
* startLabel="0"
|
|
24
|
+
* endLabel="45"
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* **After:**
|
|
29
|
+
* ```jsx
|
|
30
|
+
* import { DataCard } from '@coinbase/cds-web/alpha/data-card';
|
|
31
|
+
*
|
|
32
|
+
* <DataCard
|
|
33
|
+
* title="Progress"
|
|
34
|
+
* subtitle="45% complete"
|
|
35
|
+
* layout="vertical"
|
|
36
|
+
* thumbnail={<RemoteImage src={assetUrl} shape="circle" size="l" />}
|
|
37
|
+
* >
|
|
38
|
+
* <ProgressBarWithFixedLabels startLabel={0} endLabel={45} labelPlacement="below">
|
|
39
|
+
* <ProgressBar accessibilityLabel="45% complete" progress={0.45} weight="semiheavy" />
|
|
40
|
+
* </ProgressBarWithFixedLabels>
|
|
41
|
+
* </DataCard>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
9
44
|
import React, { memo, useMemo } from 'react';
|
|
10
45
|
import { defaultMediaSize } from '@coinbase/cds-common/tokens/card';
|
|
11
46
|
import { gutter } from '@coinbase/cds-common/tokens/sizing';
|
|
@@ -10,9 +10,9 @@ import React, { memo } from 'react';
|
|
|
10
10
|
import { Card } from './Card';
|
|
11
11
|
import { CardBody } from './CardBody';
|
|
12
12
|
|
|
13
|
-
/** @deprecated will be removed in
|
|
13
|
+
/** @deprecated Use MessagingCard instead. FeatureEntryCard will be removed in a future major release. */
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
/** @deprecated
|
|
15
|
+
/** @deprecated Use MessagingCard instead. FeatureEntryCard will be removed in a future major release. */
|
|
16
16
|
export const FeatureEntryCard = /*#__PURE__*/memo(function FeatureEntryCard(_ref) {
|
|
17
17
|
let {
|
|
18
18
|
onClick,
|
|
@@ -17,6 +17,32 @@ export const floatingAssetCardLargeWidth = 359;
|
|
|
17
17
|
export const floatingAssetCardSmallDimension = 156;
|
|
18
18
|
const pressCss = "pressCss-plkgnmc";
|
|
19
19
|
const focusRingCss = "focusRingCss-fqgx809";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use `MediaCard` instead. FloatingAssetCard will be removed in a future major release.
|
|
23
|
+
*
|
|
24
|
+
* Migration guide:
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Before
|
|
27
|
+
* <FloatingAssetCard
|
|
28
|
+
* title="Asset Title"
|
|
29
|
+
* subtitle="Subtitle"
|
|
30
|
+
* description="Description"
|
|
31
|
+
* media={<RemoteImage ... />}
|
|
32
|
+
* />
|
|
33
|
+
*
|
|
34
|
+
* // After
|
|
35
|
+
* <MediaCard
|
|
36
|
+
* title="Asset Title"
|
|
37
|
+
* subtitle="Subtitle"
|
|
38
|
+
* description="Description"
|
|
39
|
+
* thumbnail={<RemoteImage ... />}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Note: The floating variation (media outside the card container) is no longer supported.
|
|
44
|
+
* MediaCard provides a contained layout with media placement options (start/end).
|
|
45
|
+
*/
|
|
20
46
|
export const FloatingAssetCard = _ref => {
|
|
21
47
|
let {
|
|
22
48
|
className,
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { Box } from '../../layout';
|
|
3
|
+
import { HStack } from '../../layout/HStack';
|
|
4
|
+
import { VStack } from '../../layout/VStack';
|
|
5
|
+
import { Text } from '../../typography/Text';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
export const MediaCardLayout = /*#__PURE__*/memo(_ref => {
|
|
8
|
+
let {
|
|
9
|
+
title,
|
|
10
|
+
subtitle,
|
|
11
|
+
description,
|
|
12
|
+
thumbnail,
|
|
13
|
+
media,
|
|
14
|
+
mediaPlacement = 'end',
|
|
15
|
+
classNames = {},
|
|
16
|
+
styles = {}
|
|
17
|
+
} = _ref;
|
|
18
|
+
const titleNode = useMemo(() => {
|
|
19
|
+
if (typeof title === 'string') {
|
|
20
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
21
|
+
as: "div",
|
|
22
|
+
font: "headline",
|
|
23
|
+
numberOfLines: 2,
|
|
24
|
+
children: title
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return title;
|
|
28
|
+
}, [title]);
|
|
29
|
+
const subtitleNode = useMemo(() => typeof subtitle === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
30
|
+
as: "div",
|
|
31
|
+
color: "fgMuted",
|
|
32
|
+
font: "legal",
|
|
33
|
+
numberOfLines: 1,
|
|
34
|
+
children: subtitle
|
|
35
|
+
}) : subtitle, [subtitle]);
|
|
36
|
+
const headerNode = useMemo(() => /*#__PURE__*/_jsxs(VStack, {
|
|
37
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.headerContainer,
|
|
38
|
+
style: styles === null || styles === void 0 ? void 0 : styles.headerContainer,
|
|
39
|
+
children: [subtitleNode, titleNode]
|
|
40
|
+
}), [subtitleNode, titleNode, styles === null || styles === void 0 ? void 0 : styles.headerContainer, classNames === null || classNames === void 0 ? void 0 : classNames.headerContainer]);
|
|
41
|
+
const descriptionNode = useMemo(() => typeof description === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
42
|
+
as: "p",
|
|
43
|
+
color: "fgMuted",
|
|
44
|
+
font: "label2",
|
|
45
|
+
numberOfLines: 2,
|
|
46
|
+
children: description
|
|
47
|
+
}) : description, [description]);
|
|
48
|
+
const contentNode = useMemo(() => /*#__PURE__*/_jsxs(VStack, {
|
|
49
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.contentContainer,
|
|
50
|
+
flexBasis: "50%",
|
|
51
|
+
gap: 4,
|
|
52
|
+
justifyContent: "space-between",
|
|
53
|
+
padding: 2,
|
|
54
|
+
style: styles === null || styles === void 0 ? void 0 : styles.contentContainer,
|
|
55
|
+
children: [thumbnail, /*#__PURE__*/_jsxs(VStack, {
|
|
56
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.textContainer,
|
|
57
|
+
style: styles === null || styles === void 0 ? void 0 : styles.textContainer,
|
|
58
|
+
children: [headerNode, descriptionNode]
|
|
59
|
+
})]
|
|
60
|
+
}), [thumbnail, headerNode, descriptionNode, styles === null || styles === void 0 ? void 0 : styles.contentContainer, classNames === null || classNames === void 0 ? void 0 : classNames.contentContainer, classNames === null || classNames === void 0 ? void 0 : classNames.textContainer, styles === null || styles === void 0 ? void 0 : styles.textContainer]);
|
|
61
|
+
const mediaNode = useMemo(() => {
|
|
62
|
+
if (media) {
|
|
63
|
+
return /*#__PURE__*/_jsx(Box, {
|
|
64
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.mediaContainer,
|
|
65
|
+
flexBasis: "50%",
|
|
66
|
+
style: styles === null || styles === void 0 ? void 0 : styles.mediaContainer,
|
|
67
|
+
children: media
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}, [media, styles === null || styles === void 0 ? void 0 : styles.mediaContainer, classNames === null || classNames === void 0 ? void 0 : classNames.mediaContainer]);
|
|
71
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
72
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.layoutContainer,
|
|
73
|
+
flexGrow: 1,
|
|
74
|
+
style: styles === null || styles === void 0 ? void 0 : styles.layoutContainer,
|
|
75
|
+
children: [mediaPlacement === 'start' ? mediaNode : contentNode, mediaPlacement === 'end' ? mediaNode : contentNode]
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
7
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { figma } from '@figma/code-connect';
|
|
10
|
+
import { Avatar } from '../../../media';
|
|
11
|
+
import { MediaCard } from '../';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
figma.connect(MediaCard, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/%E2%9C%A8-CDS-Components?node-id=72941-18302&m=dev', {
|
|
14
|
+
imports: ["import { MediaCard } from '@coinbase/cds-web/cards/MediaCard'", "import { Avatar } from '@coinbase/cds-web/media/Avatar'"],
|
|
15
|
+
props: {
|
|
16
|
+
title: figma.string('title'),
|
|
17
|
+
subtitle: figma.boolean('show subtitle', {
|
|
18
|
+
true: figma.string('↳ subtitle'),
|
|
19
|
+
false: undefined
|
|
20
|
+
}),
|
|
21
|
+
description: figma.boolean('show subdetail', {
|
|
22
|
+
true: figma.instance('↳ subdetail'),
|
|
23
|
+
false: undefined
|
|
24
|
+
}),
|
|
25
|
+
media: figma.boolean('show media', {
|
|
26
|
+
true: figma.instance('↳ media'),
|
|
27
|
+
false: undefined
|
|
28
|
+
}),
|
|
29
|
+
mediaPlacement: figma.enum('media placement', {
|
|
30
|
+
left: 'start',
|
|
31
|
+
right: 'end',
|
|
32
|
+
none: undefined
|
|
33
|
+
})
|
|
34
|
+
},
|
|
35
|
+
example: _ref => {
|
|
36
|
+
let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
37
|
+
return /*#__PURE__*/_jsx(MediaCard, _objectSpread({
|
|
38
|
+
thumbnail: /*#__PURE__*/_jsx(Avatar, {
|
|
39
|
+
alt: "",
|
|
40
|
+
shape: "circle",
|
|
41
|
+
size: "l",
|
|
42
|
+
src: ""
|
|
43
|
+
})
|
|
44
|
+
}, props));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const _excluded = ["root"],
|
|
2
|
+
_excluded2 = ["root"],
|
|
3
|
+
_excluded3 = ["title", "subtitle", "description", "thumbnail", "media", "children", "mediaPlacement", "as", "classNames", "styles", "className", "style"];
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
8
|
+
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); }
|
|
9
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
+
import React, { forwardRef, memo } from 'react';
|
|
12
|
+
import { cx } from '../../cx';
|
|
13
|
+
import { CardRoot } from '../CardRoot';
|
|
14
|
+
import { MediaCardLayout } from './MediaCardLayout';
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
const mediaCardContainerProps = {
|
|
17
|
+
borderRadius: 500,
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
background: 'bgAlternate',
|
|
20
|
+
overflow: 'hidden'
|
|
21
|
+
};
|
|
22
|
+
export const MediaCard = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
23
|
+
let {
|
|
24
|
+
title,
|
|
25
|
+
subtitle,
|
|
26
|
+
description,
|
|
27
|
+
thumbnail,
|
|
28
|
+
media,
|
|
29
|
+
children,
|
|
30
|
+
mediaPlacement = 'end',
|
|
31
|
+
as,
|
|
32
|
+
classNames: {
|
|
33
|
+
root: rootClassName
|
|
34
|
+
} = {},
|
|
35
|
+
styles: {
|
|
36
|
+
root: rootStyle
|
|
37
|
+
} = {},
|
|
38
|
+
className,
|
|
39
|
+
style
|
|
40
|
+
} = _ref,
|
|
41
|
+
layoutClassNames = _objectWithoutProperties(_ref.classNames, _excluded),
|
|
42
|
+
layoutStyles = _objectWithoutProperties(_ref.styles, _excluded2),
|
|
43
|
+
props = _objectWithoutProperties(_ref, _excluded3);
|
|
44
|
+
return /*#__PURE__*/_jsx(CardRoot, _objectSpread(_objectSpread(_objectSpread({
|
|
45
|
+
ref: ref,
|
|
46
|
+
as: as,
|
|
47
|
+
className: cx(rootClassName, className),
|
|
48
|
+
style: _objectSpread(_objectSpread({}, rootStyle), style)
|
|
49
|
+
}, mediaCardContainerProps), props), {}, {
|
|
50
|
+
children: /*#__PURE__*/_jsx(MediaCardLayout, {
|
|
51
|
+
classNames: layoutClassNames,
|
|
52
|
+
description: description,
|
|
53
|
+
media: media,
|
|
54
|
+
mediaPlacement: mediaPlacement,
|
|
55
|
+
styles: layoutStyles,
|
|
56
|
+
subtitle: subtitle,
|
|
57
|
+
thumbnail: thumbnail,
|
|
58
|
+
title: title
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
61
|
+
}));
|