@coinbase/cds-mobile 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 +11 -0
- 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/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/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/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/examples/ExampleScreen.js +2 -2
- package/package.json +2 -2
- 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,367 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
import { Alert } from 'react-native';
|
|
3
|
+
import { ethBackground } from '@coinbase/cds-common/internal/data/assets';
|
|
4
|
+
import { NoopFn } from '@coinbase/cds-common/utils/mockUtils';
|
|
5
|
+
import { Example, ExampleScreen } from '../../../examples/ExampleScreen';
|
|
6
|
+
import { useTheme } from '../../../hooks/useTheme';
|
|
7
|
+
import { HStack } from '../../../layout';
|
|
8
|
+
import { Box } from '../../../layout/Box';
|
|
9
|
+
import { VStack } from '../../../layout/VStack';
|
|
10
|
+
import { RemoteImage } from '../../../media';
|
|
11
|
+
import { Text } from '../../../typography';
|
|
12
|
+
import { ProgressBar, ProgressBarWithFixedLabels, ProgressCircle } from '../../../visualizations';
|
|
13
|
+
import { DataCard } from '../DataCard';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const exampleThumbnail = /*#__PURE__*/_jsx(RemoteImage, {
|
|
16
|
+
accessibilityLabel: "Ethereum",
|
|
17
|
+
shape: "circle",
|
|
18
|
+
size: "l",
|
|
19
|
+
source: ethBackground,
|
|
20
|
+
testID: "thumbnail"
|
|
21
|
+
});
|
|
22
|
+
const renderProgressLabel = num => /*#__PURE__*/_jsxs(Text, {
|
|
23
|
+
color: "fgMuted",
|
|
24
|
+
font: "legal",
|
|
25
|
+
children: [num, "%"]
|
|
26
|
+
});
|
|
27
|
+
const DataCardScreen = () => {
|
|
28
|
+
const ref1 = useRef(null);
|
|
29
|
+
const ref2 = useRef(null);
|
|
30
|
+
const {
|
|
31
|
+
spectrum
|
|
32
|
+
} = useTheme();
|
|
33
|
+
return /*#__PURE__*/_jsxs(ExampleScreen, {
|
|
34
|
+
children: [/*#__PURE__*/_jsx(Example, {
|
|
35
|
+
title: "Basic Examples",
|
|
36
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
37
|
+
gap: 2,
|
|
38
|
+
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
39
|
+
layout: "vertical",
|
|
40
|
+
subtitle: "Progress indicator",
|
|
41
|
+
thumbnail: exampleThumbnail,
|
|
42
|
+
title: "Progress Bar Card",
|
|
43
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
44
|
+
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
45
|
+
font: "label1",
|
|
46
|
+
children: "\u2197 25.25%"
|
|
47
|
+
}),
|
|
48
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
49
|
+
paddingTop: 6,
|
|
50
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
51
|
+
labelPlacement: "below",
|
|
52
|
+
startLabel: {
|
|
53
|
+
value: 45,
|
|
54
|
+
render: renderProgressLabel
|
|
55
|
+
},
|
|
56
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
57
|
+
accessibilityLabel: "45% complete",
|
|
58
|
+
progress: 0.45,
|
|
59
|
+
weight: "semiheavy"
|
|
60
|
+
})
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
64
|
+
layout: "horizontal",
|
|
65
|
+
subtitle: "Circular progress",
|
|
66
|
+
thumbnail: exampleThumbnail,
|
|
67
|
+
title: "Progress Circle Card",
|
|
68
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
69
|
+
color: "fgNegative",
|
|
70
|
+
font: "label1",
|
|
71
|
+
children: "\u2198 3.12%"
|
|
72
|
+
}),
|
|
73
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
74
|
+
alignItems: "center",
|
|
75
|
+
height: "100%",
|
|
76
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
77
|
+
accessibilityLabel: "60% complete",
|
|
78
|
+
progress: 0.6,
|
|
79
|
+
size: 100,
|
|
80
|
+
weight: "heavy"
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
84
|
+
layout: "horizontal",
|
|
85
|
+
subtitle: "Circular progress",
|
|
86
|
+
thumbnail: exampleThumbnail,
|
|
87
|
+
title: "Progress Circle Card with very very very very very long title",
|
|
88
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
89
|
+
color: "fgNegative",
|
|
90
|
+
font: "label1",
|
|
91
|
+
children: "\u2198 1.8%"
|
|
92
|
+
}),
|
|
93
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
height: "100%",
|
|
96
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
97
|
+
accessibilityLabel: "60% complete",
|
|
98
|
+
progress: 0.6,
|
|
99
|
+
size: 100,
|
|
100
|
+
weight: "heavy"
|
|
101
|
+
})
|
|
102
|
+
})
|
|
103
|
+
})]
|
|
104
|
+
})
|
|
105
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
106
|
+
title: "Features",
|
|
107
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
108
|
+
gap: 2,
|
|
109
|
+
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
110
|
+
layout: "vertical",
|
|
111
|
+
subtitle: "High progress with tag",
|
|
112
|
+
thumbnail: exampleThumbnail,
|
|
113
|
+
title: "High Progress",
|
|
114
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
115
|
+
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
116
|
+
font: "label1",
|
|
117
|
+
children: "\u2197 25.25%"
|
|
118
|
+
}),
|
|
119
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
120
|
+
paddingTop: 6,
|
|
121
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
122
|
+
labelPlacement: "below",
|
|
123
|
+
startLabel: {
|
|
124
|
+
value: 90,
|
|
125
|
+
render: renderProgressLabel
|
|
126
|
+
},
|
|
127
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
128
|
+
accessibilityLabel: "90% complete",
|
|
129
|
+
color: "fgPositive",
|
|
130
|
+
progress: 0.9,
|
|
131
|
+
weight: "semiheavy"
|
|
132
|
+
})
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
136
|
+
layout: "horizontal",
|
|
137
|
+
subtitle: "Below target",
|
|
138
|
+
thumbnail: exampleThumbnail,
|
|
139
|
+
title: "Below Target",
|
|
140
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
141
|
+
color: "fgNegative",
|
|
142
|
+
font: "label1",
|
|
143
|
+
children: "\u2198 5.2%"
|
|
144
|
+
}),
|
|
145
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
146
|
+
alignItems: "center",
|
|
147
|
+
height: "100%",
|
|
148
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
149
|
+
accessibilityLabel: "95% complete",
|
|
150
|
+
color: "fgPositive",
|
|
151
|
+
progress: 0.95,
|
|
152
|
+
size: 100,
|
|
153
|
+
weight: "heavy"
|
|
154
|
+
})
|
|
155
|
+
})
|
|
156
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
157
|
+
layout: "horizontal",
|
|
158
|
+
subtitle: "Different size",
|
|
159
|
+
thumbnail: exampleThumbnail,
|
|
160
|
+
title: "Smaller Circle",
|
|
161
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
162
|
+
alignItems: "center",
|
|
163
|
+
height: "100%",
|
|
164
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
165
|
+
accessibilityLabel: "75% complete",
|
|
166
|
+
progress: 0.75,
|
|
167
|
+
size: 80,
|
|
168
|
+
weight: "heavy"
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
})]
|
|
172
|
+
})
|
|
173
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
174
|
+
title: "Interactive",
|
|
175
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
176
|
+
gap: 2,
|
|
177
|
+
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
178
|
+
ref: ref1,
|
|
179
|
+
renderAsPressable: true,
|
|
180
|
+
accessibilityLabel: "View progress bar details",
|
|
181
|
+
layout: "vertical",
|
|
182
|
+
onPress: () => Alert.alert('Progress bar card clicked!'),
|
|
183
|
+
subtitle: "Clickable progress card",
|
|
184
|
+
thumbnail: exampleThumbnail,
|
|
185
|
+
title: "Progress Bar with Button",
|
|
186
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
187
|
+
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
188
|
+
font: "label1",
|
|
189
|
+
children: "\u2197 8.5%"
|
|
190
|
+
}),
|
|
191
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
192
|
+
paddingTop: 6,
|
|
193
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
194
|
+
labelPlacement: "below",
|
|
195
|
+
startLabel: {
|
|
196
|
+
value: 75,
|
|
197
|
+
render: renderProgressLabel
|
|
198
|
+
},
|
|
199
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
200
|
+
accessibilityLabel: "75% complete",
|
|
201
|
+
progress: 0.75,
|
|
202
|
+
weight: "semiheavy"
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
207
|
+
ref: ref2,
|
|
208
|
+
renderAsPressable: true,
|
|
209
|
+
accessibilityLabel: "View progress circle details",
|
|
210
|
+
layout: "horizontal",
|
|
211
|
+
onPress: NoopFn,
|
|
212
|
+
subtitle: "Clickable progress circle card",
|
|
213
|
+
thumbnail: exampleThumbnail,
|
|
214
|
+
title: "Progress Circle with Button",
|
|
215
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
216
|
+
color: "fgNegative",
|
|
217
|
+
font: "label1",
|
|
218
|
+
children: "\u2198 8.5%"
|
|
219
|
+
}),
|
|
220
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
221
|
+
alignItems: "center",
|
|
222
|
+
height: "100%",
|
|
223
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
224
|
+
accessibilityLabel: "85% complete",
|
|
225
|
+
progress: 0.85,
|
|
226
|
+
size: 100,
|
|
227
|
+
weight: "heavy"
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
})]
|
|
231
|
+
})
|
|
232
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
233
|
+
title: "Style Overrides",
|
|
234
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
235
|
+
gap: 2,
|
|
236
|
+
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
237
|
+
layout: "vertical",
|
|
238
|
+
styles: {
|
|
239
|
+
root: {
|
|
240
|
+
borderWidth: 2,
|
|
241
|
+
borderColor: '#0066FF'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
subtitle: "Custom border",
|
|
245
|
+
thumbnail: exampleThumbnail,
|
|
246
|
+
title: "Custom Root Styles",
|
|
247
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
248
|
+
paddingTop: 6,
|
|
249
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
250
|
+
labelPlacement: "below",
|
|
251
|
+
startLabel: {
|
|
252
|
+
value: 50,
|
|
253
|
+
render: renderProgressLabel
|
|
254
|
+
},
|
|
255
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
256
|
+
accessibilityLabel: "50% complete",
|
|
257
|
+
progress: 0.5,
|
|
258
|
+
weight: "semiheavy"
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
263
|
+
layout: "horizontal",
|
|
264
|
+
styles: {
|
|
265
|
+
root: {
|
|
266
|
+
backgroundColor: '#F5F5F5'
|
|
267
|
+
},
|
|
268
|
+
headerContainer: {
|
|
269
|
+
paddingLeft: 16
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
subtitle: "Custom background and padding",
|
|
273
|
+
thumbnail: exampleThumbnail,
|
|
274
|
+
title: "Custom Layout Styles",
|
|
275
|
+
children: /*#__PURE__*/_jsx(HStack, {
|
|
276
|
+
alignItems: "center",
|
|
277
|
+
height: "100%",
|
|
278
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
279
|
+
accessibilityLabel: "70% complete",
|
|
280
|
+
progress: 0.7,
|
|
281
|
+
size: 100,
|
|
282
|
+
weight: "heavy"
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
286
|
+
layout: "vertical",
|
|
287
|
+
styles: {
|
|
288
|
+
root: {
|
|
289
|
+
minHeight: 200
|
|
290
|
+
},
|
|
291
|
+
layoutContainer: {
|
|
292
|
+
gap: 12
|
|
293
|
+
},
|
|
294
|
+
titleContainer: {
|
|
295
|
+
paddingBottom: 8
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
subtitle: "Custom spacing and height",
|
|
299
|
+
thumbnail: exampleThumbnail,
|
|
300
|
+
title: "Multiple Style Overrides",
|
|
301
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
302
|
+
paddingTop: 6,
|
|
303
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
304
|
+
labelPlacement: "below",
|
|
305
|
+
startLabel: {
|
|
306
|
+
value: 80,
|
|
307
|
+
render: renderProgressLabel
|
|
308
|
+
},
|
|
309
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
310
|
+
accessibilityLabel: "80% complete",
|
|
311
|
+
progress: 0.8,
|
|
312
|
+
weight: "semiheavy"
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
})
|
|
316
|
+
})]
|
|
317
|
+
})
|
|
318
|
+
}), /*#__PURE__*/_jsx(Example, {
|
|
319
|
+
title: "Multiple Cards",
|
|
320
|
+
children: /*#__PURE__*/_jsxs(VStack, {
|
|
321
|
+
gap: 2,
|
|
322
|
+
children: [/*#__PURE__*/_jsx(DataCard, {
|
|
323
|
+
layout: "vertical",
|
|
324
|
+
subtitle: "Progress tracking",
|
|
325
|
+
thumbnail: exampleThumbnail,
|
|
326
|
+
title: "Card 1",
|
|
327
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
328
|
+
paddingTop: 6,
|
|
329
|
+
children: /*#__PURE__*/_jsx(ProgressBarWithFixedLabels, {
|
|
330
|
+
labelPlacement: "below",
|
|
331
|
+
startLabel: {
|
|
332
|
+
value: 30,
|
|
333
|
+
render: renderProgressLabel
|
|
334
|
+
},
|
|
335
|
+
children: /*#__PURE__*/_jsx(ProgressBar, {
|
|
336
|
+
accessibilityLabel: "30% complete",
|
|
337
|
+
progress: 0.3,
|
|
338
|
+
weight: "semiheavy"
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
})
|
|
342
|
+
}), /*#__PURE__*/_jsx(DataCard, {
|
|
343
|
+
layout: "horizontal",
|
|
344
|
+
subtitle: "Completion status",
|
|
345
|
+
thumbnail: exampleThumbnail,
|
|
346
|
+
title: "Card 2",
|
|
347
|
+
titleAccessory: /*#__PURE__*/_jsx(Text, {
|
|
348
|
+
dangerouslySetColor: "rgb(" + spectrum.green70 + ")",
|
|
349
|
+
font: "label1",
|
|
350
|
+
children: "\u2197 25.25%"
|
|
351
|
+
}),
|
|
352
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
353
|
+
alignItems: "center",
|
|
354
|
+
height: "100%",
|
|
355
|
+
children: /*#__PURE__*/_jsx(ProgressCircle, {
|
|
356
|
+
accessibilityLabel: "95% complete",
|
|
357
|
+
progress: 0.95,
|
|
358
|
+
size: 120,
|
|
359
|
+
weight: "heavy"
|
|
360
|
+
})
|
|
361
|
+
})
|
|
362
|
+
})]
|
|
363
|
+
})
|
|
364
|
+
})]
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
export default DataCardScreen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataCard } from './DataCard';
|
package/esm/alpha/index.js
CHANGED
|
@@ -5,9 +5,9 @@ import React, { memo } from 'react';
|
|
|
5
5
|
import { Card } from './Card';
|
|
6
6
|
import { CardBody } from './CardBody';
|
|
7
7
|
|
|
8
|
-
/** @deprecated will be removed in
|
|
8
|
+
/** @deprecated Use MessagingCard instead. AnnouncementCard will be removed in a future major release. */
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
/** @deprecated
|
|
10
|
+
/** @deprecated Use MessagingCard instead. AnnouncementCard will be removed in a future major release. */
|
|
11
11
|
export const AnnouncementCard = /*#__PURE__*/memo(function AnnouncementCard(_ref) {
|
|
12
12
|
let {
|
|
13
13
|
onPress,
|
package/esm/cards/CardMedia.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const _excluded = ["placement"];
|
|
2
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
3
|
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; }
|
|
4
|
-
import
|
|
4
|
+
import { memo } from 'react';
|
|
5
5
|
import { defaultMediaDimension, defaultMediaSize, defaultPictogramMediaDimension } from '@coinbase/cds-common/tokens/card';
|
|
6
6
|
import { Pictogram, SpotSquare } from '../illustrations';
|
|
7
|
-
import {
|
|
7
|
+
import { getSource, RemoteImage } from '../media/RemoteImage';
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
const imageProps = {
|
|
10
10
|
start: {
|
|
@@ -37,9 +37,10 @@ export const CardMedia = /*#__PURE__*/memo(function CardMedia(_ref) {
|
|
|
37
37
|
testID: props.testID
|
|
38
38
|
}));
|
|
39
39
|
case 'image':
|
|
40
|
-
return /*#__PURE__*/_jsx(
|
|
40
|
+
return /*#__PURE__*/_jsx(RemoteImage, _extends({
|
|
41
41
|
alt: (_props$alt = props.alt) != null ? _props$alt : '',
|
|
42
|
-
|
|
42
|
+
resizeMode: "cover",
|
|
43
|
+
source: getSource(props.src),
|
|
43
44
|
testID: props.testID
|
|
44
45
|
}, imageProps[placement]));
|
|
45
46
|
default:
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const _excluded = ["children", "style", "renderAsPressable"];
|
|
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
|
+
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; }
|
|
4
|
+
import React, { forwardRef, memo } from 'react';
|
|
5
|
+
import { HStack } from '../layout/HStack';
|
|
6
|
+
import { Pressable } from '../system/Pressable';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
/**
|
|
9
|
+
* CardRoot is the foundational wrapper component for card layouts.
|
|
10
|
+
*
|
|
11
|
+
* By default, it renders as an HStack for horizontal layout.
|
|
12
|
+
* When `renderAsPressable` is true, it renders as a Pressable component.
|
|
13
|
+
*/
|
|
14
|
+
export const CardRoot = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
renderAsPressable
|
|
18
|
+
} = _ref,
|
|
19
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
|
+
const Component = renderAsPressable ? Pressable : HStack;
|
|
21
|
+
return /*#__PURE__*/_jsx(Component, _extends({
|
|
22
|
+
ref: ref
|
|
23
|
+
}, props, {
|
|
24
|
+
children: children
|
|
25
|
+
}));
|
|
26
|
+
}));
|
|
27
|
+
CardRoot.displayName = 'CardRoot';
|
|
@@ -4,6 +4,33 @@ import { HStack, VStack } from '../layout';
|
|
|
4
4
|
import { Pressable } from '../system';
|
|
5
5
|
import { Text } from '../typography/Text';
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `MediaCard` instead. ContainedAssetCard will be removed in a future major release.
|
|
9
|
+
*
|
|
10
|
+
* Migration guide:
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // Before
|
|
13
|
+
* <ContainedAssetCard
|
|
14
|
+
* header={<Avatar ... />}
|
|
15
|
+
* title="Asset Title"
|
|
16
|
+
* subtitle="Subtitle"
|
|
17
|
+
* description="Description"
|
|
18
|
+
* size="l"
|
|
19
|
+
* >
|
|
20
|
+
* <RemoteImage ... />
|
|
21
|
+
* </ContainedAssetCard>
|
|
22
|
+
*
|
|
23
|
+
* // After
|
|
24
|
+
* <MediaCard
|
|
25
|
+
* thumbnail={<Avatar ... />}
|
|
26
|
+
* title="Asset Title"
|
|
27
|
+
* subtitle="Subtitle"
|
|
28
|
+
* description="Description"
|
|
29
|
+
* media={<RemoteImage ... />}
|
|
30
|
+
* mediaPlacement="end"
|
|
31
|
+
* />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
7
34
|
export const ContainedAssetCard = /*#__PURE__*/memo(_ref => {
|
|
8
35
|
let {
|
|
9
36
|
title,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["testID", "children", "maxWidth", "minWidth", "
|
|
1
|
+
const _excluded = ["testID", "children", "maxWidth", "minWidth", "borderRadius", "padding", "gap"];
|
|
2
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
3
|
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; }
|
|
4
4
|
import React, { forwardRef, memo } from 'react';
|
|
@@ -11,17 +11,18 @@ export const ContentCard = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function Co
|
|
|
11
11
|
children,
|
|
12
12
|
maxWidth = contentCardMaxWidth,
|
|
13
13
|
minWidth = contentCardMinWidth,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
borderRadius = 500,
|
|
15
|
+
padding = 2,
|
|
16
|
+
gap = 2
|
|
16
17
|
} = _ref,
|
|
17
18
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
19
|
return /*#__PURE__*/_jsx(VStack, _extends({
|
|
19
20
|
ref: ref,
|
|
20
|
-
|
|
21
|
+
borderRadius: borderRadius,
|
|
22
|
+
gap: gap,
|
|
21
23
|
maxWidth: maxWidth,
|
|
22
24
|
minWidth: minWidth,
|
|
23
|
-
|
|
24
|
-
paddingY: paddingY,
|
|
25
|
+
padding: padding,
|
|
25
26
|
testID: testID
|
|
26
27
|
}, props, {
|
|
27
28
|
children: children
|
|
@@ -1,47 +1,102 @@
|
|
|
1
|
-
const _excluded = ["body", "label", "media", "mediaPosition", "children", "testID"];
|
|
1
|
+
const _excluded = ["body", "label", "media", "mediaPosition", "mediaPlacement", "title", "description", "children", "gap", "testID", "style", "styles"];
|
|
2
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
3
|
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; }
|
|
4
|
-
import React, { forwardRef, memo } from 'react';
|
|
4
|
+
import React, { forwardRef, memo, useMemo } from 'react';
|
|
5
5
|
import { Box, VStack } from '../../layout';
|
|
6
6
|
import { Text } from '../../typography/Text';
|
|
7
7
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const mapMediaPositionToMediaPlacement = {
|
|
9
|
+
top: 'top',
|
|
10
|
+
bottom: 'bottom',
|
|
11
|
+
right: 'end',
|
|
12
|
+
left: 'start'
|
|
13
|
+
};
|
|
8
14
|
export const ContentCardBody = /*#__PURE__*/memo(/*#__PURE__*/forwardRef(function ContentCardBody(_ref, ref) {
|
|
9
15
|
let {
|
|
10
16
|
body,
|
|
11
17
|
label,
|
|
12
18
|
media,
|
|
13
19
|
mediaPosition = 'top',
|
|
20
|
+
mediaPlacement = mapMediaPositionToMediaPlacement[mediaPosition],
|
|
21
|
+
title,
|
|
22
|
+
description = body,
|
|
14
23
|
children,
|
|
15
|
-
|
|
24
|
+
gap = 1,
|
|
25
|
+
testID,
|
|
26
|
+
style,
|
|
27
|
+
styles
|
|
16
28
|
} = _ref,
|
|
17
29
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
|
-
const
|
|
30
|
+
const hasMedia = !!media;
|
|
31
|
+
const isHorizontal = mediaPlacement === 'start' || mediaPlacement === 'end';
|
|
32
|
+
const isMediaFirst = hasMedia && (mediaPlacement === 'top' || mediaPlacement === 'start');
|
|
33
|
+
const isMediaLast = hasMedia && (mediaPlacement === 'bottom' || mediaPlacement === 'end');
|
|
34
|
+
const titleNode = useMemo(() => {
|
|
35
|
+
if (typeof title === 'string') {
|
|
36
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
37
|
+
font: "headline",
|
|
38
|
+
numberOfLines: 2,
|
|
39
|
+
children: title
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return title;
|
|
43
|
+
}, [title]);
|
|
44
|
+
const descriptionNode = useMemo(() => {
|
|
45
|
+
if (typeof description === 'string') {
|
|
46
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
47
|
+
color: "fgMuted",
|
|
48
|
+
font: "label2",
|
|
49
|
+
numberOfLines: 3,
|
|
50
|
+
children: description
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return description;
|
|
54
|
+
}, [description]);
|
|
55
|
+
const labelNode = useMemo(() => {
|
|
56
|
+
if (typeof label === 'string') {
|
|
57
|
+
return /*#__PURE__*/_jsx(Text, {
|
|
58
|
+
font: "label2",
|
|
59
|
+
children: label
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return label;
|
|
63
|
+
}, [label]);
|
|
64
|
+
const textNode = useMemo(() => {
|
|
65
|
+
if (!titleNode && !descriptionNode && !labelNode) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/_jsxs(VStack, {
|
|
69
|
+
flexShrink: 1,
|
|
70
|
+
gap: isHorizontal ? 1 : 0,
|
|
71
|
+
style: styles == null ? void 0 : styles.textContainer,
|
|
72
|
+
children: [titleNode, descriptionNode, labelNode]
|
|
73
|
+
});
|
|
74
|
+
}, [titleNode, descriptionNode, labelNode, isHorizontal, styles == null ? void 0 : styles.textContainer]);
|
|
19
75
|
const mediaBox = isHorizontal ? /*#__PURE__*/_jsx(Box, {
|
|
76
|
+
borderRadius: 500,
|
|
20
77
|
flexShrink: 0,
|
|
21
78
|
height: 96,
|
|
79
|
+
overflow: "hidden",
|
|
80
|
+
style: styles == null ? void 0 : styles.mediaContainer,
|
|
22
81
|
width: 96,
|
|
23
82
|
children: media
|
|
24
|
-
}) :
|
|
83
|
+
}) : /*#__PURE__*/_jsx(Box, {
|
|
84
|
+
borderRadius: 500,
|
|
85
|
+
overflow: "hidden",
|
|
86
|
+
children: media
|
|
87
|
+
});
|
|
25
88
|
return /*#__PURE__*/_jsxs(VStack, _extends({
|
|
26
89
|
ref: ref,
|
|
27
|
-
gap:
|
|
90
|
+
gap: gap,
|
|
91
|
+
style: [styles == null ? void 0 : styles.root, style],
|
|
28
92
|
testID: testID
|
|
29
93
|
}, props, {
|
|
30
|
-
children: [/*#__PURE__*/_jsxs(Box, {
|
|
94
|
+
children: [(mediaBox || textNode) && /*#__PURE__*/_jsxs(Box, {
|
|
31
95
|
flexDirection: isHorizontal ? 'row' : 'column',
|
|
32
96
|
gap: isHorizontal ? 2 : 1,
|
|
33
|
-
justifyContent:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
maxWidth: isHorizontal ? '70%' : '100%',
|
|
37
|
-
children: [typeof body === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
38
|
-
font: "body",
|
|
39
|
-
children: body
|
|
40
|
-
}) : body, typeof label === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
41
|
-
font: "label2",
|
|
42
|
-
children: label
|
|
43
|
-
}) : label]
|
|
44
|
-
}), (mediaPosition === 'bottom' || mediaPosition === 'right') && mediaBox]
|
|
97
|
+
justifyContent: mediaPlacement === 'end' ? 'space-between' : 'flex-start',
|
|
98
|
+
style: styles == null ? void 0 : styles.contentContainer,
|
|
99
|
+
children: [isMediaFirst && mediaBox, textNode, isMediaLast && mediaBox]
|
|
45
100
|
}), children]
|
|
46
101
|
}));
|
|
47
102
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["
|
|
1
|
+
const _excluded = ["children", "justifyContent"];
|
|
2
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
3
|
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; }
|
|
4
4
|
import React, { forwardRef, memo } from 'react';
|
|
@@ -6,14 +6,13 @@ import { HStack } from '../../layout';
|
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
export const ContentCardFooter = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
8
8
|
let {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
children,
|
|
10
|
+
justifyContent = 'space-between'
|
|
11
11
|
} = _ref,
|
|
12
12
|
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
13
13
|
return /*#__PURE__*/_jsx(HStack, _extends({
|
|
14
14
|
ref: ref,
|
|
15
|
-
justifyContent:
|
|
16
|
-
testID: testID
|
|
15
|
+
justifyContent: justifyContent
|
|
17
16
|
}, props, {
|
|
18
17
|
children: children
|
|
19
18
|
}));
|