@umituz/react-native-design-system 2.6.104 → 2.6.105
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/package.json +1 -1
- package/src/atoms/card/AtomicCard.tsx +183 -0
- package/src/atoms/card/configs/cardPaddingConfig.ts +19 -0
- package/src/atoms/card/index.ts +2 -0
- package/src/atoms/card/styles/cardStyles.ts +98 -0
- package/src/atoms/card/types.ts +77 -0
- package/src/atoms/index.ts +3 -4
- package/src/exports/molecules.ts +3 -11
- package/src/molecules/action-footer/types.ts +1 -1
- package/src/molecules/filter-group/FilterGroup.tsx +1 -1
- package/src/molecules/hero-section/types.ts +1 -1
- package/src/molecules/index.ts +3 -10
- package/src/molecules/info-grid/InfoGrid.tsx +2 -2
- package/src/theme/infrastructure/providers/DesignSystemProvider.tsx +0 -1
- package/src/atoms/AtomicCard.tsx +0 -104
- package/src/molecules/GlowingCard/GlowingCard.tsx +0 -81
- package/src/molecules/GlowingCard/README.md +0 -306
- package/src/molecules/GlowingCard/index.ts +0 -1
- package/src/molecules/info-card/InfoCard.tsx +0 -44
- package/src/molecules/info-card/index.ts +0 -3
- package/src/molecules/info-card/types.ts +0 -9
- package/src/molecules/media-card/MediaCard.tsx +0 -157
- package/src/molecules/media-card/README.md +0 -282
- package/src/molecules/media-card/index.ts +0 -2
- package/src/molecules/media-card/types.ts +0 -40
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
# MediaCard
|
|
2
|
-
|
|
3
|
-
MediaCard is an optimized card component for displaying images, videos, and media content with overlay text, badges, and selection state support.
|
|
4
|
-
|
|
5
|
-
## Import & Usage
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
import { MediaCard } from 'react-native-design-system/src/molecules/media-card';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
**Location:** `src/molecules/media-card/MediaCard.tsx`
|
|
12
|
-
|
|
13
|
-
## Basic Usage
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
<MediaCard
|
|
17
|
-
uri="https://example.com/image.jpg"
|
|
18
|
-
title="Media Title"
|
|
19
|
-
subtitle="Description"
|
|
20
|
-
/>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Strategy
|
|
24
|
-
|
|
25
|
-
**Purpose**: Provide a visually appealing and interactive card component optimized for media content display.
|
|
26
|
-
|
|
27
|
-
**When to Use**:
|
|
28
|
-
- Photo galleries and image grids
|
|
29
|
-
- Template/media selection interfaces
|
|
30
|
-
- Product cards with images
|
|
31
|
-
- Avatar/story selectors
|
|
32
|
-
- Background pickers
|
|
33
|
-
- Meme collections
|
|
34
|
-
|
|
35
|
-
**When NOT to Use**:
|
|
36
|
-
- For text-only content - use AtomicCard instead
|
|
37
|
-
- For complex layouts - use custom components
|
|
38
|
-
- For non-interactive displays - use Image component
|
|
39
|
-
|
|
40
|
-
## Rules
|
|
41
|
-
|
|
42
|
-
### Required
|
|
43
|
-
|
|
44
|
-
1. **ALWAYS** provide a `uri` prop with valid image URL
|
|
45
|
-
2. **MUST** have unique keys when rendering in lists
|
|
46
|
-
3. **NEVER** use invalid or broken image URLs
|
|
47
|
-
4. **ALWAYS** provide accessibility labels for screen readers
|
|
48
|
-
5. **MUST** handle loading and error states appropriately
|
|
49
|
-
|
|
50
|
-
### Content Guidelines
|
|
51
|
-
|
|
52
|
-
1. **ALWAYS** use appropriate size for context (sm/md/lg)
|
|
53
|
-
2. **MUST** maintain aspect ratio for images
|
|
54
|
-
3. **SHOULD** provide meaningful titles and subtitles
|
|
55
|
-
4. **NEVER** use text that overflows the card
|
|
56
|
-
|
|
57
|
-
### Selection State
|
|
58
|
-
|
|
59
|
-
1. **MUST** clearly indicate selected state
|
|
60
|
-
2. **ALWAYS** provide visual feedback for selection
|
|
61
|
-
3. **SHOULD** allow toggle behavior (select/deselect)
|
|
62
|
-
|
|
63
|
-
## Forbidden
|
|
64
|
-
|
|
65
|
-
❌ **NEVER** do these:
|
|
66
|
-
|
|
67
|
-
```tsx
|
|
68
|
-
// ❌ Missing URI
|
|
69
|
-
<MediaCard />
|
|
70
|
-
|
|
71
|
-
// ❌ Invalid URI
|
|
72
|
-
<MediaCard uri="not-a-url" />
|
|
73
|
-
|
|
74
|
-
// ❌ Text overflow
|
|
75
|
-
<MediaCard
|
|
76
|
-
uri="image.jpg"
|
|
77
|
-
title="This is an extremely long title that will overflow"
|
|
78
|
-
/>
|
|
79
|
-
|
|
80
|
-
// ❌ Wrong aspect ratio
|
|
81
|
-
<MediaCard
|
|
82
|
-
uri="portrait.jpg"
|
|
83
|
-
aspectRatio={2} // Too wide for portrait image
|
|
84
|
-
/>
|
|
85
|
-
|
|
86
|
-
// ❌ Inconsistent sizes in grid
|
|
87
|
-
<View>
|
|
88
|
-
<MediaCard size="sm" />
|
|
89
|
-
<MediaCard size="lg" /> {/* ❌ Inconsistent */}
|
|
90
|
-
</View>
|
|
91
|
-
|
|
92
|
-
// ❌ No accessibility
|
|
93
|
-
<MediaCard uri="image.jpg" /> {/* Missing accessibilityLabel */}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Best Practices
|
|
97
|
-
|
|
98
|
-
### Size Selection
|
|
99
|
-
|
|
100
|
-
✅ **DO**:
|
|
101
|
-
- Use `sm` for dense grids and galleries
|
|
102
|
-
- Use `md` for standard product cards
|
|
103
|
-
- Use `lg` for featured/hero items
|
|
104
|
-
- Keep sizes consistent within grids
|
|
105
|
-
|
|
106
|
-
❌ **DON'T**:
|
|
107
|
-
- Mix sizes arbitrarily in the same grid
|
|
108
|
-
- Use `lg` for small thumbnails
|
|
109
|
-
- Use `sm` for hero/featured content
|
|
110
|
-
|
|
111
|
-
### Aspect Ratio
|
|
112
|
-
|
|
113
|
-
✅ **DO**:
|
|
114
|
-
```tsx
|
|
115
|
-
// Square images
|
|
116
|
-
<MediaCard aspectRatio={1} />
|
|
117
|
-
|
|
118
|
-
// Portrait images
|
|
119
|
-
<MediaCard aspectRatio={0.8} />
|
|
120
|
-
|
|
121
|
-
// Landscape images
|
|
122
|
-
<MediaCard aspectRatio={1.2} />
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
❌ **DON'T**:
|
|
126
|
-
```tsx
|
|
127
|
-
// Don't distort images
|
|
128
|
-
<MediaCard aspectRatio={2} /> // For portrait image
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Overlay Usage
|
|
132
|
-
|
|
133
|
-
✅ **DO**:
|
|
134
|
-
```tsx
|
|
135
|
-
// Provide context
|
|
136
|
-
<MediaCard
|
|
137
|
-
title="Product Name"
|
|
138
|
-
subtitle="$29.99"
|
|
139
|
-
/>
|
|
140
|
-
|
|
141
|
-
// Clean display
|
|
142
|
-
<MediaCard showOverlay={false} />
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
❌ **DON'T**:
|
|
146
|
-
```tsx
|
|
147
|
-
// Don't show overlay for no reason
|
|
148
|
-
<MediaCard title="" subtitle="" />
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## AI Coding Guidelines
|
|
152
|
-
|
|
153
|
-
### For AI Agents
|
|
154
|
-
|
|
155
|
-
When generating MediaCard components, follow these rules:
|
|
156
|
-
|
|
157
|
-
1. **Always import from correct path**:
|
|
158
|
-
```typescript
|
|
159
|
-
import { MediaCard } from 'react-native-design-system/src/molecules/media-card';
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
2. **Always provide required props**:
|
|
163
|
-
```tsx
|
|
164
|
-
<MediaCard
|
|
165
|
-
uri="有效的图片URL"
|
|
166
|
-
title="简洁的标题"
|
|
167
|
-
size="根据上下文选择合适尺寸"
|
|
168
|
-
/>
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
3. **Always handle press events**:
|
|
172
|
-
```tsx
|
|
173
|
-
<MediaCard
|
|
174
|
-
uri="image.jpg"
|
|
175
|
-
onPress={() => navigation.navigate('Detail', { id })}
|
|
176
|
-
/>
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
4. **Always use appropriate sizes**:
|
|
180
|
-
```tsx
|
|
181
|
-
// Dense grid
|
|
182
|
-
<MediaCard size="sm" />
|
|
183
|
-
|
|
184
|
-
// Standard card
|
|
185
|
-
<MediaCard size="md" />
|
|
186
|
-
|
|
187
|
-
// Featured item
|
|
188
|
-
<MediaCard size="lg" />
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
5. **Never forget accessibility**:
|
|
192
|
-
```tsx
|
|
193
|
-
// ❌ Bad
|
|
194
|
-
<MediaCard uri="image.jpg" />
|
|
195
|
-
|
|
196
|
-
// ✅ Good
|
|
197
|
-
<MediaCard
|
|
198
|
-
uri="image.jpg"
|
|
199
|
-
accessibilityLabel="Product image"
|
|
200
|
-
title="Product Name"
|
|
201
|
-
/>
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
### Common Patterns
|
|
205
|
-
|
|
206
|
-
#### Photo Gallery
|
|
207
|
-
```tsx
|
|
208
|
-
<FlatList
|
|
209
|
-
numColumns={3}
|
|
210
|
-
data={photos}
|
|
211
|
-
renderItem={({ item }) => (
|
|
212
|
-
<MediaCard
|
|
213
|
-
uri={item.uri}
|
|
214
|
-
size="sm"
|
|
215
|
-
onPress={() => navigateToPhoto(item.id)}
|
|
216
|
-
/>
|
|
217
|
-
)}
|
|
218
|
-
/>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
#### Template Selector
|
|
222
|
-
```tsx
|
|
223
|
-
<MediaCard
|
|
224
|
-
uri={template.thumbnail}
|
|
225
|
-
title={template.name}
|
|
226
|
-
selected={selectedId === template.id}
|
|
227
|
-
onPress={() => setSelectedTemplate(template)}
|
|
228
|
-
/>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### Product Card
|
|
232
|
-
```tsx
|
|
233
|
-
<MediaCard
|
|
234
|
-
uri={product.image}
|
|
235
|
-
title={product.name}
|
|
236
|
-
subtitle={`$${product.price}`}
|
|
237
|
-
badge={product.isNew ? 'NEW' : ''}
|
|
238
|
-
onPress={() => navigateToProduct(product.id)}
|
|
239
|
-
/>
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
## Props Reference
|
|
243
|
-
|
|
244
|
-
| Prop | Type | Required | Default | Description |
|
|
245
|
-
|------|------|----------|---------|-------------|
|
|
246
|
-
| `uri` | `string` | Yes | - | Image URI |
|
|
247
|
-
| `title` | `string` | No | - | Overlay title |
|
|
248
|
-
| `subtitle` | `string` | No | - | Overlay subtitle |
|
|
249
|
-
| `badge` | `string \| number` | No | - | Badge content |
|
|
250
|
-
| `selected` | `boolean` | No | `false` | Selected state |
|
|
251
|
-
| `size` | `'sm' \| 'md' \| 'lg'` | No | `'md'` | Card size |
|
|
252
|
-
| `aspectRatio` | `number` | No | `0.8` | Aspect ratio |
|
|
253
|
-
| `overlayPosition` | `'top' \| 'bottom' \| 'center'` | No | `'bottom'` | Overlay position |
|
|
254
|
-
| `showOverlay` | `boolean` | No | `true` | Show overlay |
|
|
255
|
-
| `width` | `number` | No | - | Custom width |
|
|
256
|
-
| `onPress` | `() => void` | No | - | Press handler |
|
|
257
|
-
|
|
258
|
-
## Accessibility
|
|
259
|
-
|
|
260
|
-
- ✅ Screen reader announces title and subtitle
|
|
261
|
-
- ✅ Touch target size: minimum 44x44pt
|
|
262
|
-
- ✅ Selected state announced to screen readers
|
|
263
|
-
- ✅ Test ID support for testing
|
|
264
|
-
- ✅ Accessibility label support
|
|
265
|
-
|
|
266
|
-
## Performance
|
|
267
|
-
|
|
268
|
-
1. **Image optimization**: Use optimized image sizes
|
|
269
|
-
2. **Caching**: Enable image caching
|
|
270
|
-
3. **Lazy loading**: Use in long lists
|
|
271
|
-
4. **Memoization**: Memo press handlers
|
|
272
|
-
|
|
273
|
-
## Related Components
|
|
274
|
-
|
|
275
|
-
- [`AtomicCard`](../../atoms/AtomicCard/README.md) - Basic card component
|
|
276
|
-
- [`GlowingCard`](../GlowingCard/README.md) - Glowing effect card
|
|
277
|
-
- [`AtomicImage`](../../atoms/AtomicImage/README.md) - Image component
|
|
278
|
-
- [`Avatar`](../avatar/README.md) - User avatar component
|
|
279
|
-
|
|
280
|
-
## License
|
|
281
|
-
|
|
282
|
-
MIT
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type MediaCardSize = 'sm' | 'md' | 'lg';
|
|
2
|
-
export type MediaCardOverlayPosition = 'bottom' | 'center';
|
|
3
|
-
|
|
4
|
-
export interface MediaCardProps {
|
|
5
|
-
/** Image URI to display */
|
|
6
|
-
uri: string;
|
|
7
|
-
|
|
8
|
-
/** Optional title text */
|
|
9
|
-
title?: string;
|
|
10
|
-
|
|
11
|
-
/** Optional subtitle text (uses count, etc.) */
|
|
12
|
-
subtitle?: string;
|
|
13
|
-
|
|
14
|
-
/** Optional badge text (NEW, etc.) */
|
|
15
|
-
badge?: string;
|
|
16
|
-
|
|
17
|
-
/** Whether the card is selected */
|
|
18
|
-
selected?: boolean;
|
|
19
|
-
|
|
20
|
-
/** Card size */
|
|
21
|
-
size?: MediaCardSize;
|
|
22
|
-
|
|
23
|
-
/** Aspect ratio (width/height) */
|
|
24
|
-
aspectRatio?: number;
|
|
25
|
-
|
|
26
|
-
/** Overlay position */
|
|
27
|
-
overlayPosition?: MediaCardOverlayPosition;
|
|
28
|
-
|
|
29
|
-
/** Whether to show overlay */
|
|
30
|
-
showOverlay?: boolean;
|
|
31
|
-
|
|
32
|
-
/** Press handler */
|
|
33
|
-
onPress?: () => void;
|
|
34
|
-
|
|
35
|
-
/** Custom width */
|
|
36
|
-
width?: number;
|
|
37
|
-
|
|
38
|
-
/** Test ID */
|
|
39
|
-
testID?: string;
|
|
40
|
-
}
|