@coinbase/cds-mobile 8.40.2 → 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 +17 -0
- package/dts/alpha/combobox/Combobox.d.ts.map +1 -1
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts +1 -0
- package/dts/alpha/combobox/DefaultComboboxControl.d.ts.map +1 -1
- package/dts/alpha/data-card/DataCard.d.ts +27 -0
- package/dts/alpha/data-card/DataCard.d.ts.map +1 -0
- package/dts/alpha/data-card/DataCardLayout.d.ts +38 -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/alpha/select/DefaultSelectControl.d.ts +1 -0
- package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
- package/dts/alpha/select/Select.d.ts.map +1 -1
- package/dts/alpha/select/types.d.ts +6 -0
- package/dts/alpha/select/types.d.ts.map +1 -1
- package/dts/cards/AnnouncementCard.d.ts +2 -2
- package/dts/cards/AnnouncementCard.d.ts.map +1 -1
- package/dts/cards/CardMedia.d.ts +1 -2
- package/dts/cards/CardMedia.d.ts.map +1 -1
- package/dts/cards/CardRoot.d.ts +32 -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.map +1 -1
- package/dts/cards/ContentCard/ContentCardBody.d.ts +82 -10
- package/dts/cards/ContentCard/ContentCardBody.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardFooter.d.ts.map +1 -1
- package/dts/cards/ContentCard/ContentCardHeader.d.ts +50 -12
- package/dts/cards/ContentCard/ContentCardHeader.d.ts.map +1 -1
- 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/FeedCard.d.ts +3 -0
- package/dts/cards/FeedCard.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 +40 -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 +28 -0
- package/dts/cards/MediaCard/index.d.ts.map +1 -0
- package/dts/cards/MessagingCard/MessagingCardLayout.d.ts +62 -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 +21 -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 +4 -0
- package/dts/cards/index.d.ts.map +1 -1
- package/dts/examples/ExampleScreen.d.ts.map +1 -1
- package/esm/alpha/combobox/Combobox.js +5 -2
- package/esm/alpha/combobox/DefaultComboboxControl.js +7 -2
- package/esm/alpha/combobox/__stories__/Combobox.stories.js +123 -0
- package/esm/alpha/data-card/DataCard.js +44 -0
- package/esm/alpha/data-card/DataCardLayout.js +80 -0
- package/esm/alpha/data-card/__figma__/DataCard.figma.js +29 -0
- package/esm/alpha/data-card/__stories__/DataCard.stories.js +367 -0
- package/esm/alpha/data-card/index.js +1 -0
- package/esm/alpha/index.js +1 -0
- package/esm/alpha/select/DefaultSelectControl.js +20 -6
- package/esm/alpha/select/Select.js +3 -1
- package/esm/alpha/select/__stories__/AlphaSelect.stories.js +117 -0
- package/esm/cards/AnnouncementCard.js +2 -2
- package/esm/cards/CardMedia.js +5 -4
- package/esm/cards/CardRoot.js +27 -0
- package/esm/cards/ContainedAssetCard.js +27 -0
- package/esm/cards/ContentCard/ContentCard.js +7 -6
- package/esm/cards/ContentCard/ContentCardBody.js +74 -19
- package/esm/cards/ContentCard/ContentCardFooter.js +4 -5
- package/esm/cards/ContentCard/ContentCardHeader.js +60 -23
- package/esm/cards/ContentCard/__figma__/ContentCard.figma.js +9 -6
- package/esm/cards/DataCard.js +35 -0
- package/esm/cards/FeatureEntryCard.js +2 -2
- package/esm/cards/FeedCard.js +5 -0
- package/esm/cards/FloatingAssetCard.js +25 -0
- package/esm/cards/MediaCard/MediaCardLayout.js +68 -0
- package/esm/cards/MediaCard/__figma__/MediaCard.figma.js +41 -0
- package/esm/cards/MediaCard/index.js +45 -0
- package/esm/cards/MessagingCard/MessagingCardLayout.js +175 -0
- package/esm/cards/MessagingCard/__figma__/MessagingCard.figma.js +44 -0
- package/esm/cards/MessagingCard/index.js +58 -0
- package/esm/cards/NudgeCard.js +27 -0
- package/esm/cards/UpsellCard.js +27 -0
- package/esm/cards/__stories__/ContentCard.stories.js +375 -47
- package/esm/cards/__stories__/MediaCard.stories.js +189 -0
- package/esm/cards/__stories__/MessagingCard.stories.js +535 -0
- package/esm/cards/__stories__/NudgeCard.stories.js +2 -2
- package/esm/cards/__stories__/UpsellCard.stories.js +2 -2
- package/esm/cards/index.js +8 -1
- package/esm/controls/__stories__/TextInput.stories.js +1 -1
- package/esm/dates/__stories__/DateInput.stories.js +6 -4
- package/esm/dates/__stories__/DatePicker.stories.js +6 -4
- package/esm/examples/ExampleScreen.js +2 -2
- package/package.json +3 -3
- package/dts/cards/CardRemoteImage.d.ts +0 -5
- package/dts/cards/CardRemoteImage.d.ts.map +0 -1
- package/dts/cards/ContentCard/__figma__/ContentCardBody.figma.d.ts +0 -2
- package/dts/cards/ContentCard/__figma__/ContentCardBody.figma.d.ts.map +0 -1
- package/dts/cards/ContentCard/__figma__/ContentCardFooter.figma.d.ts +0 -2
- package/dts/cards/ContentCard/__figma__/ContentCardFooter.figma.d.ts.map +0 -1
- package/dts/cards/ContentCard/__figma__/ContentCardHeader.figma.d.ts +0 -2
- package/dts/cards/ContentCard/__figma__/ContentCardHeader.figma.d.ts.map +0 -1
- package/esm/cards/CardRemoteImage.js +0 -18
- package/esm/cards/ContentCard/__figma__/ContentCardBody.figma.js +0 -39
- package/esm/cards/ContentCard/__figma__/ContentCardFooter.figma.js +0 -142
- package/esm/cards/ContentCard/__figma__/ContentCardHeader.figma.js +0 -25
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { HStack } from '../../layout/HStack';
|
|
3
|
+
import { VStack } from '../../layout/VStack';
|
|
4
|
+
import { Text } from '../../typography/Text';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const MediaCardLayout = /*#__PURE__*/memo(_ref => {
|
|
7
|
+
let {
|
|
8
|
+
title,
|
|
9
|
+
subtitle,
|
|
10
|
+
description,
|
|
11
|
+
thumbnail,
|
|
12
|
+
media,
|
|
13
|
+
mediaPlacement = 'end',
|
|
14
|
+
styles = {}
|
|
15
|
+
} = _ref;
|
|
16
|
+
const titleNode = useMemo(() => {
|
|
17
|
+
if (typeof title === 'string') {
|
|
18
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
19
|
+
font: "headline",
|
|
20
|
+
numberOfLines: 2,
|
|
21
|
+
children: title
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return title;
|
|
25
|
+
}, [title]);
|
|
26
|
+
const subtitleNode = useMemo(() => typeof subtitle === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
27
|
+
color: "fgMuted",
|
|
28
|
+
font: "legal",
|
|
29
|
+
numberOfLines: 1,
|
|
30
|
+
children: subtitle
|
|
31
|
+
}) : subtitle, [subtitle]);
|
|
32
|
+
const headerNode = useMemo(() => /*#__PURE__*/_jsxs(VStack, {
|
|
33
|
+
style: styles == null ? void 0 : styles.headerContainer,
|
|
34
|
+
children: [subtitleNode, titleNode]
|
|
35
|
+
}), [subtitleNode, titleNode, styles == null ? void 0 : styles.headerContainer]);
|
|
36
|
+
const descriptionNode = useMemo(() => typeof description === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
37
|
+
color: "fgMuted",
|
|
38
|
+
font: "label2",
|
|
39
|
+
numberOfLines: 2,
|
|
40
|
+
children: description
|
|
41
|
+
}) : description, [description]);
|
|
42
|
+
const contentNode = useMemo(() => /*#__PURE__*/_jsxs(VStack, {
|
|
43
|
+
flexBasis: "50%",
|
|
44
|
+
gap: 4,
|
|
45
|
+
justifyContent: "space-between",
|
|
46
|
+
padding: 2,
|
|
47
|
+
style: styles == null ? void 0 : styles.contentContainer,
|
|
48
|
+
children: [thumbnail, /*#__PURE__*/_jsxs(VStack, {
|
|
49
|
+
style: styles == null ? void 0 : styles.textContainer,
|
|
50
|
+
children: [headerNode, descriptionNode]
|
|
51
|
+
})]
|
|
52
|
+
}), [styles == null ? void 0 : styles.contentContainer, styles == null ? void 0 : styles.textContainer, thumbnail, headerNode, descriptionNode]);
|
|
53
|
+
const mediaNode = useMemo(() => {
|
|
54
|
+
if (media) {
|
|
55
|
+
return /*#__PURE__*/_jsx(HStack, {
|
|
56
|
+
flexBasis: "50%",
|
|
57
|
+
style: styles == null ? void 0 : styles.mediaContainer,
|
|
58
|
+
children: media
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}, [media, styles == null ? void 0 : styles.mediaContainer]);
|
|
62
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
63
|
+
flexGrow: 1,
|
|
64
|
+
style: styles == null ? void 0 : styles.layoutContainer,
|
|
65
|
+
children: [mediaPlacement === 'start' ? mediaNode : contentNode, mediaPlacement === 'end' ? mediaNode : contentNode]
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
export { MediaCardLayout };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
2
|
+
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); }
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { figma } from '@figma/code-connect';
|
|
5
|
+
import { Avatar } from '../../../media';
|
|
6
|
+
import { MediaCard } from '../';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
figma.connect(MediaCard, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/%E2%9C%A8-CDS-Components?node-id=72941-18302&m=dev', {
|
|
9
|
+
imports: ["import { MediaCard } from '@coinbase/cds-mobile/cards/MediaCard'", "import { Avatar } from '@coinbase/cds-mobile/media/Avatar'"],
|
|
10
|
+
props: {
|
|
11
|
+
title: figma.string('title'),
|
|
12
|
+
subtitle: figma.boolean('show subtitle', {
|
|
13
|
+
true: figma.string('↳ subtitle'),
|
|
14
|
+
false: undefined
|
|
15
|
+
}),
|
|
16
|
+
description: figma.boolean('show subdetail', {
|
|
17
|
+
true: figma.instance('↳ subdetail'),
|
|
18
|
+
false: undefined
|
|
19
|
+
}),
|
|
20
|
+
media: figma.boolean('show media', {
|
|
21
|
+
true: figma.instance('↳ media'),
|
|
22
|
+
false: undefined
|
|
23
|
+
}),
|
|
24
|
+
mediaPlacement: figma.enum('media placement', {
|
|
25
|
+
left: 'start',
|
|
26
|
+
right: 'end',
|
|
27
|
+
none: undefined
|
|
28
|
+
})
|
|
29
|
+
},
|
|
30
|
+
example: _ref => {
|
|
31
|
+
let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
32
|
+
return /*#__PURE__*/_jsx(MediaCard, _extends({
|
|
33
|
+
thumbnail: /*#__PURE__*/_jsx(Avatar, {
|
|
34
|
+
accessibilityLabel: "",
|
|
35
|
+
shape: "circle",
|
|
36
|
+
size: "l",
|
|
37
|
+
src: ""
|
|
38
|
+
})
|
|
39
|
+
}, props));
|
|
40
|
+
}
|
|
41
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const _excluded = ["root"],
|
|
2
|
+
_excluded2 = ["title", "subtitle", "description", "thumbnail", "media", "mediaPlacement", "style", "styles"];
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
import { forwardRef, memo } from 'react';
|
|
6
|
+
import { CardRoot } from '../CardRoot';
|
|
7
|
+
import { MediaCardLayout } from './MediaCardLayout';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const mediaCardContainerProps = {
|
|
10
|
+
borderRadius: 500,
|
|
11
|
+
background: 'bgAlternate',
|
|
12
|
+
overflow: 'hidden'
|
|
13
|
+
};
|
|
14
|
+
export const MediaCard = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
title,
|
|
17
|
+
subtitle,
|
|
18
|
+
description,
|
|
19
|
+
thumbnail,
|
|
20
|
+
media,
|
|
21
|
+
mediaPlacement = 'end',
|
|
22
|
+
style,
|
|
23
|
+
styles: {
|
|
24
|
+
root: rootStyle
|
|
25
|
+
} = {}
|
|
26
|
+
} = _ref,
|
|
27
|
+
layoutStyles = _objectWithoutPropertiesLoose(_ref.styles, _excluded),
|
|
28
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
29
|
+
return /*#__PURE__*/_jsx(CardRoot, _extends({
|
|
30
|
+
ref: ref
|
|
31
|
+
}, mediaCardContainerProps, {
|
|
32
|
+
style: [style, rootStyle]
|
|
33
|
+
}, props, {
|
|
34
|
+
children: /*#__PURE__*/_jsx(MediaCardLayout, {
|
|
35
|
+
description: description,
|
|
36
|
+
media: media,
|
|
37
|
+
mediaPlacement: mediaPlacement,
|
|
38
|
+
styles: layoutStyles,
|
|
39
|
+
subtitle: subtitle,
|
|
40
|
+
thumbnail: thumbnail,
|
|
41
|
+
title: title
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
44
|
+
}));
|
|
45
|
+
MediaCard.displayName = 'MediaCard';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import React, { memo, useMemo } from 'react';
|
|
3
|
+
import { Button } from '../../buttons/Button';
|
|
4
|
+
import { IconButton } from '../../buttons/IconButton';
|
|
5
|
+
import { HStack } from '../../layout/HStack';
|
|
6
|
+
import { VStack } from '../../layout/VStack';
|
|
7
|
+
import { Pressable } from '../../system/Pressable';
|
|
8
|
+
import { Tag } from '../../tag/Tag';
|
|
9
|
+
import { Text } from '../../typography/Text';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
export const MessagingCardLayout = /*#__PURE__*/memo(_ref => {
|
|
12
|
+
let {
|
|
13
|
+
type,
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
tag,
|
|
17
|
+
action,
|
|
18
|
+
onActionButtonPress,
|
|
19
|
+
actionButtonAccessibilityLabel,
|
|
20
|
+
onDismissButtonPress,
|
|
21
|
+
dismissButtonAccessibilityLabel,
|
|
22
|
+
mediaPlacement = 'end',
|
|
23
|
+
media,
|
|
24
|
+
styles = {},
|
|
25
|
+
dismissButton
|
|
26
|
+
} = _ref;
|
|
27
|
+
const titleNode = useMemo(() => {
|
|
28
|
+
if (typeof title === 'string') {
|
|
29
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
30
|
+
color: type === 'upsell' ? 'fgInverse' : 'fg',
|
|
31
|
+
font: "headline",
|
|
32
|
+
numberOfLines: 2,
|
|
33
|
+
children: title
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return title;
|
|
37
|
+
}, [title, type]);
|
|
38
|
+
const descriptionNode = useMemo(() => {
|
|
39
|
+
if (typeof description === 'string') {
|
|
40
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
41
|
+
color: type === 'upsell' ? 'fgInverse' : 'fg',
|
|
42
|
+
font: "label2",
|
|
43
|
+
numberOfLines: 3,
|
|
44
|
+
children: description
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return description;
|
|
48
|
+
}, [description, type]);
|
|
49
|
+
const tagNode = useMemo(() => {
|
|
50
|
+
if (typeof tag === 'string') {
|
|
51
|
+
return /*#__PURE__*/_jsx(Tag, {
|
|
52
|
+
children: tag
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return tag;
|
|
56
|
+
}, [tag]);
|
|
57
|
+
const actionButtonNode = useMemo(() => {
|
|
58
|
+
if (!action) return null;
|
|
59
|
+
|
|
60
|
+
// If action is a string, render in a default button
|
|
61
|
+
if (typeof action === 'string') {
|
|
62
|
+
if (type === 'upsell') {
|
|
63
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
64
|
+
compact: true,
|
|
65
|
+
accessibilityLabel: actionButtonAccessibilityLabel != null ? actionButtonAccessibilityLabel : action,
|
|
66
|
+
onPress: onActionButtonPress,
|
|
67
|
+
variant: "secondary",
|
|
68
|
+
children: action
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
72
|
+
accessibilityLabel: actionButtonAccessibilityLabel != null ? actionButtonAccessibilityLabel : action,
|
|
73
|
+
onPress: onActionButtonPress,
|
|
74
|
+
paddingY: 1,
|
|
75
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
76
|
+
color: "fgPrimary",
|
|
77
|
+
font: "headline",
|
|
78
|
+
children: action
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Otherwise, render action as-is (custom React element)
|
|
84
|
+
return action;
|
|
85
|
+
}, [action, actionButtonAccessibilityLabel, onActionButtonPress, type]);
|
|
86
|
+
const computedDismissButtonAccessibilityLabel = useMemo(() => {
|
|
87
|
+
if (dismissButtonAccessibilityLabel) return dismissButtonAccessibilityLabel;
|
|
88
|
+
if (typeof title === 'string') return "Dismiss " + title;
|
|
89
|
+
return 'Dismiss card';
|
|
90
|
+
}, [dismissButtonAccessibilityLabel, title]);
|
|
91
|
+
const dismissButtonNode = useMemo(() => {
|
|
92
|
+
if (dismissButton) {
|
|
93
|
+
return dismissButton;
|
|
94
|
+
}
|
|
95
|
+
if (onDismissButtonPress) {
|
|
96
|
+
return /*#__PURE__*/_jsx(HStack, {
|
|
97
|
+
paddingEnd: 1,
|
|
98
|
+
paddingTop: 1,
|
|
99
|
+
position: "absolute",
|
|
100
|
+
right: 0,
|
|
101
|
+
style: styles == null ? void 0 : styles.dismissButtonContainer,
|
|
102
|
+
top: 0,
|
|
103
|
+
children: /*#__PURE__*/_jsx(IconButton, {
|
|
104
|
+
compact: true,
|
|
105
|
+
accessibilityLabel: computedDismissButtonAccessibilityLabel,
|
|
106
|
+
name: "close",
|
|
107
|
+
onPress: onDismissButtonPress,
|
|
108
|
+
variant: "secondary"
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}, [computedDismissButtonAccessibilityLabel, dismissButton, onDismissButtonPress, styles == null ? void 0 : styles.dismissButtonContainer]);
|
|
114
|
+
const contentContainerPaddingProps = useMemo(() => {
|
|
115
|
+
if (mediaPlacement === 'start' && dismissButtonNode) {
|
|
116
|
+
// needs to add additional padding to the end of the content area when media is placed at the start and there is a dismiss button
|
|
117
|
+
// this is to avoid dismiss button from overlapping with the content area
|
|
118
|
+
return {
|
|
119
|
+
paddingY: 2,
|
|
120
|
+
paddingStart: 2,
|
|
121
|
+
paddingEnd: 6
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
padding: 2
|
|
126
|
+
};
|
|
127
|
+
}, [dismissButtonNode, mediaPlacement]);
|
|
128
|
+
const mediaContainerPaddingProps = useMemo(() => {
|
|
129
|
+
if (type === 'upsell') return;
|
|
130
|
+
if (mediaPlacement === 'start') {
|
|
131
|
+
return {
|
|
132
|
+
paddingStart: 3,
|
|
133
|
+
paddingEnd: 1
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
// when media is placed at the end, we need to add additional padding to the end of the media container
|
|
137
|
+
// this is to avoid the dismiss button from overlapping with the media
|
|
138
|
+
return dismissButtonNode ? {
|
|
139
|
+
paddingStart: 1,
|
|
140
|
+
paddingEnd: 6
|
|
141
|
+
} : {
|
|
142
|
+
paddingStart: 1,
|
|
143
|
+
paddingEnd: 3
|
|
144
|
+
};
|
|
145
|
+
}, [dismissButtonNode, mediaPlacement, type]);
|
|
146
|
+
return /*#__PURE__*/_jsxs(HStack, {
|
|
147
|
+
flexDirection: mediaPlacement === 'start' ? 'row-reverse' : 'row',
|
|
148
|
+
flexGrow: 1,
|
|
149
|
+
position: "relative",
|
|
150
|
+
style: styles == null ? void 0 : styles.layoutContainer,
|
|
151
|
+
children: [/*#__PURE__*/_jsxs(VStack, _extends({
|
|
152
|
+
alignItems: "flex-start",
|
|
153
|
+
flexBasis: 0,
|
|
154
|
+
flexGrow: 1,
|
|
155
|
+
flexShrink: 1,
|
|
156
|
+
gap: 2,
|
|
157
|
+
justifyContent: "space-between"
|
|
158
|
+
}, contentContainerPaddingProps, {
|
|
159
|
+
style: styles == null ? void 0 : styles.contentContainer,
|
|
160
|
+
children: [/*#__PURE__*/_jsxs(VStack, {
|
|
161
|
+
alignItems: "flex-start",
|
|
162
|
+
gap: 0.5,
|
|
163
|
+
style: styles == null ? void 0 : styles.textContainer,
|
|
164
|
+
children: [tagNode, titleNode, descriptionNode]
|
|
165
|
+
}), actionButtonNode]
|
|
166
|
+
})), media && /*#__PURE__*/_jsx(HStack, _extends({
|
|
167
|
+
alignItems: "center",
|
|
168
|
+
flexShrink: 0,
|
|
169
|
+
style: styles == null ? void 0 : styles.mediaContainer
|
|
170
|
+
}, mediaContainerPaddingProps, {
|
|
171
|
+
children: media
|
|
172
|
+
})), dismissButtonNode]
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
MessagingCardLayout.displayName = 'MessagingCardLayout';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function _objectDestructuringEmpty(t) { if (null == t) throw new TypeError("Cannot destructure " + t); }
|
|
2
|
+
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); }
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { figma } from '@figma/code-connect';
|
|
5
|
+
import { MessagingCard } from '../';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
figma.connect(MessagingCard, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/%E2%9C%A8-CDS-Components?node-id=72941-20711&m=dev', {
|
|
8
|
+
imports: ["import { MessagingCard } from '@coinbase/cds-mobile/cards/MessagingCard'"],
|
|
9
|
+
props: {
|
|
10
|
+
type: figma.enum('type', {
|
|
11
|
+
upsell: 'upsell',
|
|
12
|
+
nudge: 'nudge'
|
|
13
|
+
}),
|
|
14
|
+
title: figma.boolean('show title', {
|
|
15
|
+
true: figma.string('↳ title'),
|
|
16
|
+
false: undefined
|
|
17
|
+
}),
|
|
18
|
+
description: figma.boolean('show subtitle', {
|
|
19
|
+
true: figma.string('↳ subtitle'),
|
|
20
|
+
false: undefined
|
|
21
|
+
}),
|
|
22
|
+
tag: figma.boolean('show tag', {
|
|
23
|
+
true: figma.instance('↳ tag'),
|
|
24
|
+
false: undefined
|
|
25
|
+
}),
|
|
26
|
+
action: figma.boolean('show cta', {
|
|
27
|
+
true: figma.instance('↳ cta'),
|
|
28
|
+
false: undefined
|
|
29
|
+
}),
|
|
30
|
+
media: figma.instance('media'),
|
|
31
|
+
mediaPlacement: figma.enum('media placement', {
|
|
32
|
+
left: 'start',
|
|
33
|
+
right: 'end'
|
|
34
|
+
}),
|
|
35
|
+
onDismissButtonPress: figma.boolean('show dismiss', {
|
|
36
|
+
true: () => {},
|
|
37
|
+
false: undefined
|
|
38
|
+
})
|
|
39
|
+
},
|
|
40
|
+
example: _ref => {
|
|
41
|
+
let props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
|
|
42
|
+
return /*#__PURE__*/_jsx(MessagingCard, _extends({}, props));
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
const _excluded = ["root"],
|
|
2
|
+
_excluded2 = ["type", "title", "description", "tag", "action", "onActionButtonPress", "actionButtonAccessibilityLabel", "dismissButton", "onDismissButtonPress", "dismissButtonAccessibilityLabel", "mediaPlacement", "media", "style", "styles"];
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
import { forwardRef, memo } from 'react';
|
|
6
|
+
import { CardRoot } from '../CardRoot';
|
|
7
|
+
import { MessagingCardLayout } from './MessagingCardLayout';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
const messagingCardContainerProps = {
|
|
10
|
+
borderRadius: 500,
|
|
11
|
+
overflow: 'hidden'
|
|
12
|
+
};
|
|
13
|
+
export const MessagingCard = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
14
|
+
let {
|
|
15
|
+
type,
|
|
16
|
+
title,
|
|
17
|
+
description,
|
|
18
|
+
tag,
|
|
19
|
+
action,
|
|
20
|
+
onActionButtonPress,
|
|
21
|
+
actionButtonAccessibilityLabel,
|
|
22
|
+
dismissButton,
|
|
23
|
+
onDismissButtonPress,
|
|
24
|
+
dismissButtonAccessibilityLabel,
|
|
25
|
+
mediaPlacement,
|
|
26
|
+
media,
|
|
27
|
+
style,
|
|
28
|
+
styles: {
|
|
29
|
+
root: rootStyle
|
|
30
|
+
} = {}
|
|
31
|
+
} = _ref,
|
|
32
|
+
layoutStyles = _objectWithoutPropertiesLoose(_ref.styles, _excluded),
|
|
33
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
34
|
+
const background = type === 'upsell' ? 'bgPrimary' : 'bgAlternate';
|
|
35
|
+
return /*#__PURE__*/_jsx(CardRoot, _extends({
|
|
36
|
+
ref: ref,
|
|
37
|
+
background: background,
|
|
38
|
+
borderWidth: 0,
|
|
39
|
+
style: [style, rootStyle]
|
|
40
|
+
}, messagingCardContainerProps, props, {
|
|
41
|
+
children: /*#__PURE__*/_jsx(MessagingCardLayout, {
|
|
42
|
+
action: action,
|
|
43
|
+
actionButtonAccessibilityLabel: actionButtonAccessibilityLabel,
|
|
44
|
+
description: description,
|
|
45
|
+
dismissButton: dismissButton,
|
|
46
|
+
dismissButtonAccessibilityLabel: dismissButtonAccessibilityLabel,
|
|
47
|
+
media: media,
|
|
48
|
+
mediaPlacement: mediaPlacement,
|
|
49
|
+
onActionButtonPress: onActionButtonPress,
|
|
50
|
+
onDismissButtonPress: onDismissButtonPress,
|
|
51
|
+
styles: layoutStyles,
|
|
52
|
+
tag: tag,
|
|
53
|
+
title: title,
|
|
54
|
+
type: type
|
|
55
|
+
})
|
|
56
|
+
}));
|
|
57
|
+
}));
|
|
58
|
+
MessagingCard.displayName = 'MessagingCard';
|
package/esm/cards/NudgeCard.js
CHANGED
|
@@ -9,6 +9,33 @@ import { Box, HStack, VStack } from '../layout';
|
|
|
9
9
|
import { Pressable } from '../system/Pressable';
|
|
10
10
|
import { Text } from '../typography/Text';
|
|
11
11
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Use `MessagingCard` with `type="nudge"` instead. NudgeCard will be removed in a future major release.
|
|
14
|
+
*
|
|
15
|
+
* Migration guide:
|
|
16
|
+
* ```tsx
|
|
17
|
+
* // Before
|
|
18
|
+
* <NudgeCard
|
|
19
|
+
* title="Title"
|
|
20
|
+
* description="Description"
|
|
21
|
+
* pictogram="addToWatchlist"
|
|
22
|
+
* action="Learn more"
|
|
23
|
+
* onActionPress={handleAction}
|
|
24
|
+
* onDismissPress={handleDismiss}
|
|
25
|
+
* />
|
|
26
|
+
*
|
|
27
|
+
* // After
|
|
28
|
+
* <MessagingCard
|
|
29
|
+
* type="nudge"
|
|
30
|
+
* title="Title"
|
|
31
|
+
* description="Description"
|
|
32
|
+
* media={<Pictogram dimension="48x48" name="addToWatchlist" />}
|
|
33
|
+
* actions={<Button compact variant="secondary">Learn more</Button>}
|
|
34
|
+
* onDismiss={handleDismiss}
|
|
35
|
+
* mediaPlacement="end"
|
|
36
|
+
* />
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
12
39
|
export const NudgeCard = /*#__PURE__*/memo(_ref => {
|
|
13
40
|
let {
|
|
14
41
|
title,
|
package/esm/cards/UpsellCard.js
CHANGED
|
@@ -5,6 +5,33 @@ import { HStack, VStack } from '../layout';
|
|
|
5
5
|
import { Pressable } from '../system/Pressable';
|
|
6
6
|
import { Text } from '../typography/Text';
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use `MessagingCard` with `type="upsell"` instead. UpsellCard will be removed in a future major release.
|
|
10
|
+
*
|
|
11
|
+
* Migration guide:
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // Before
|
|
14
|
+
* <UpsellCard
|
|
15
|
+
* title="Title"
|
|
16
|
+
* description="Description"
|
|
17
|
+
* media={<RemoteImage ... />}
|
|
18
|
+
* action="Get Started"
|
|
19
|
+
* onActionPress={handleAction}
|
|
20
|
+
* onDismissPress={handleDismiss}
|
|
21
|
+
* />
|
|
22
|
+
*
|
|
23
|
+
* // After
|
|
24
|
+
* <MessagingCard
|
|
25
|
+
* type="upsell"
|
|
26
|
+
* title="Title"
|
|
27
|
+
* description="Description"
|
|
28
|
+
* media={<RemoteImage ... />}
|
|
29
|
+
* actions={<Button compact variant="secondary">Get Started</Button>}
|
|
30
|
+
* onDismiss={handleDismiss}
|
|
31
|
+
* mediaPlacement="end"
|
|
32
|
+
* />
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
8
35
|
export const UpsellCard = /*#__PURE__*/memo(_ref => {
|
|
9
36
|
let {
|
|
10
37
|
title,
|