crew-recommendation-ui 0.1.2 → 0.1.4
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/dls/components/Card.tsx +1 -0
- package/src/dls/components/index.ts +1 -0
- package/src/dls/index.ts +1 -0
- package/src/dls/tokens/colors.ts +1 -0
- package/src/dls/tokens/index.ts +1 -0
- package/src/dls/tokens/spacing.ts +1 -0
- package/src/dls/tokens/typography.ts +1 -0
- package/src/index.ts +1 -0
- package/src/recommendation-listing/components/BadgeGroup.tsx +1 -0
- package/src/recommendation-listing/components/RecommendationCard.tsx +75 -8
- package/src/recommendation-listing/components/RecommendationList.tsx +7 -1
- package/src/recommendation-listing/components/index.ts +1 -0
- package/src/recommendation-listing/index.ts +1 -0
- package/src/recommendation-listing/types.ts +6 -0
- package/vite.config.ts +1 -0
- package/BUILD_AND_PUBLISH.md +0 -191
package/package.json
CHANGED
package/src/dls/index.ts
CHANGED
package/src/dls/tokens/colors.ts
CHANGED
package/src/dls/tokens/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -15,9 +15,11 @@ import type { RecommendationCardProps } from '../types';
|
|
|
15
15
|
export function RecommendationCard({
|
|
16
16
|
itemData,
|
|
17
17
|
onPress,
|
|
18
|
+
onSelect,
|
|
18
19
|
isSelected = false,
|
|
19
20
|
showBadge = true,
|
|
20
21
|
showPrice = true,
|
|
22
|
+
showSelectButton = false,
|
|
21
23
|
imageHeight = 200,
|
|
22
24
|
testID,
|
|
23
25
|
}: RecommendationCardProps) {
|
|
@@ -25,6 +27,11 @@ export function RecommendationCard({
|
|
|
25
27
|
onPress?.(itemData);
|
|
26
28
|
}, [onPress, itemData]);
|
|
27
29
|
|
|
30
|
+
const handleSelectPress = useCallback((event: any) => {
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
onSelect?.(itemData);
|
|
33
|
+
}, [onSelect, itemData]);
|
|
34
|
+
|
|
28
35
|
const imageUrl = itemData.image_signed_urls?.[0];
|
|
29
36
|
|
|
30
37
|
return (
|
|
@@ -100,14 +107,38 @@ export function RecommendationCard({
|
|
|
100
107
|
</View>
|
|
101
108
|
)}
|
|
102
109
|
|
|
103
|
-
{/* Price */}
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
{/* Price Section with Select Button */}
|
|
111
|
+
<View style={styles.priceSection}>
|
|
112
|
+
{showPrice && (
|
|
113
|
+
<PriceDisplay
|
|
114
|
+
price={itemData.price}
|
|
115
|
+
originalPrice={itemData.originalPrice}
|
|
116
|
+
isPriceExclusive={itemData.isPriceExclusive}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{/* Select Button */}
|
|
121
|
+
{showSelectButton && !isSelected && (
|
|
122
|
+
<TouchableOpacity
|
|
123
|
+
style={styles.selectButton}
|
|
124
|
+
onPress={handleSelectPress}
|
|
125
|
+
activeOpacity={0.7}
|
|
126
|
+
accessibilityRole="button"
|
|
127
|
+
accessibilityLabel="Select this option"
|
|
128
|
+
>
|
|
129
|
+
<Text style={styles.selectButtonText}>
|
|
130
|
+
{isSelected ? "Selected" : "Select"}
|
|
131
|
+
</Text>
|
|
132
|
+
</TouchableOpacity>
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{/* Selected Checkmark */}
|
|
136
|
+
{showSelectButton && isSelected && (
|
|
137
|
+
<View style={styles.selectedBadge}>
|
|
138
|
+
<Text style={styles.selectedBadgeText}>✓ Selected</Text>
|
|
139
|
+
</View>
|
|
140
|
+
)}
|
|
141
|
+
</View>
|
|
111
142
|
</View>
|
|
112
143
|
</TouchableOpacity>
|
|
113
144
|
);
|
|
@@ -173,5 +204,41 @@ const styles = StyleSheet.create({
|
|
|
173
204
|
...textStyles.caption,
|
|
174
205
|
color: colors.neutral[300],
|
|
175
206
|
},
|
|
207
|
+
priceSection: {
|
|
208
|
+
flexDirection: 'row',
|
|
209
|
+
justifyContent: 'space-between',
|
|
210
|
+
alignItems: 'center',
|
|
211
|
+
marginTop: spacing[2],
|
|
212
|
+
},
|
|
213
|
+
selectButton: {
|
|
214
|
+
backgroundColor: colors.primary[600],
|
|
215
|
+
paddingHorizontal: spacing[4],
|
|
216
|
+
paddingVertical: spacing[2],
|
|
217
|
+
borderRadius: borderRadius.full,
|
|
218
|
+
minWidth: 80,
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
justifyContent: 'center',
|
|
221
|
+
},
|
|
222
|
+
selectButtonText: {
|
|
223
|
+
...textStyles.body,
|
|
224
|
+
color: colors.white,
|
|
225
|
+
fontWeight: '600',
|
|
226
|
+
fontSize: 14,
|
|
227
|
+
},
|
|
228
|
+
selectedBadge: {
|
|
229
|
+
backgroundColor: colors.success[500],
|
|
230
|
+
paddingHorizontal: spacing[4],
|
|
231
|
+
paddingVertical: spacing[2],
|
|
232
|
+
borderRadius: borderRadius.full,
|
|
233
|
+
minWidth: 80,
|
|
234
|
+
alignItems: 'center',
|
|
235
|
+
justifyContent: 'center',
|
|
236
|
+
},
|
|
237
|
+
selectedBadgeText: {
|
|
238
|
+
...textStyles.body,
|
|
239
|
+
color: colors.white,
|
|
240
|
+
fontWeight: '600',
|
|
241
|
+
fontSize: 14,
|
|
242
|
+
},
|
|
176
243
|
});
|
|
177
244
|
|
|
@@ -14,6 +14,9 @@ import type { RecommendationListProps, RecommendationItemData } from '../types';
|
|
|
14
14
|
export function RecommendationList({
|
|
15
15
|
items,
|
|
16
16
|
onItemPress,
|
|
17
|
+
onItemSelect,
|
|
18
|
+
selectedItemId,
|
|
19
|
+
showSelectButton = false,
|
|
17
20
|
renderItem: customRenderItem,
|
|
18
21
|
ListHeaderComponent,
|
|
19
22
|
ListEmptyComponent,
|
|
@@ -35,11 +38,14 @@ export function RecommendationList({
|
|
|
35
38
|
<RecommendationCard
|
|
36
39
|
itemData={item}
|
|
37
40
|
onPress={onItemPress}
|
|
41
|
+
onSelect={onItemSelect}
|
|
42
|
+
isSelected={selectedItemId === item.id}
|
|
43
|
+
showSelectButton={showSelectButton}
|
|
38
44
|
testID={`recommendation-card-${item.id}`}
|
|
39
45
|
/>
|
|
40
46
|
);
|
|
41
47
|
},
|
|
42
|
-
[customRenderItem, onItemPress],
|
|
48
|
+
[customRenderItem, onItemPress, onItemSelect, selectedItemId, showSelectButton],
|
|
43
49
|
);
|
|
44
50
|
|
|
45
51
|
return (
|
|
@@ -18,9 +18,11 @@ export interface RecommendationItemData {
|
|
|
18
18
|
export interface RecommendationCardProps {
|
|
19
19
|
itemData: RecommendationItemData;
|
|
20
20
|
onPress?: (item: RecommendationItemData) => void;
|
|
21
|
+
onSelect?: (item: RecommendationItemData) => void;
|
|
21
22
|
isSelected?: boolean;
|
|
22
23
|
showBadge?: boolean;
|
|
23
24
|
showPrice?: boolean;
|
|
25
|
+
showSelectButton?: boolean;
|
|
24
26
|
imageHeight?: number;
|
|
25
27
|
testID?: string;
|
|
26
28
|
}
|
|
@@ -28,6 +30,9 @@ export interface RecommendationCardProps {
|
|
|
28
30
|
export interface RecommendationListProps {
|
|
29
31
|
items: RecommendationItemData[];
|
|
30
32
|
onItemPress?: (item: RecommendationItemData) => void;
|
|
33
|
+
onItemSelect?: (item: RecommendationItemData) => void;
|
|
34
|
+
selectedItemId?: string | null;
|
|
35
|
+
showSelectButton?: boolean;
|
|
31
36
|
onBackPress?: () => void;
|
|
32
37
|
onSharePress?: () => void;
|
|
33
38
|
renderItem?: (item: RecommendationItemData, index: number) => React.ReactElement;
|
|
@@ -56,3 +61,4 @@ export interface PriceDisplayProps {
|
|
|
56
61
|
isPriceExclusive?: boolean;
|
|
57
62
|
}
|
|
58
63
|
|
|
64
|
+
|
package/vite.config.ts
CHANGED
package/BUILD_AND_PUBLISH.md
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# Build & Publish Guide
|
|
2
|
-
|
|
3
|
-
## 🎯 Option 1: Use as Local Workspace Package (RECOMMENDED)
|
|
4
|
-
|
|
5
|
-
This is the **best approach for monorepo projects**. No npm publishing needed!
|
|
6
|
-
|
|
7
|
-
### ✅ Advantages:
|
|
8
|
-
- No npm account or tokens needed
|
|
9
|
-
- Instant changes without publishing
|
|
10
|
-
- Better for development workflow
|
|
11
|
-
- Automatic linking via Yarn workspaces
|
|
12
|
-
|
|
13
|
-
### 📦 Setup (Already Done!):
|
|
14
|
-
|
|
15
|
-
1. **Library is already in the monorepo:**
|
|
16
|
-
```
|
|
17
|
-
crew-dashboards/libs/recommendation-ui/
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
2. **crew-website already configured:**
|
|
21
|
-
```json
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"crew-recommendation-ui": "*"
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
3. **Build the library:**
|
|
28
|
-
```bash
|
|
29
|
-
cd /Users/gurkawalbir.singh/Downloads/Workspace/crew-dashboards/libs/recommendation-ui
|
|
30
|
-
yarn build
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
4. **Use in crew-website:**
|
|
34
|
-
```tsx
|
|
35
|
-
// Instead of:
|
|
36
|
-
import { colors } from 'crew-recommendation-ui/dls';
|
|
37
|
-
|
|
38
|
-
// Use:
|
|
39
|
-
import { colors } from '@crew-dashboards/recommendation-ui/dls';
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 🔄 Development Workflow:
|
|
43
|
-
|
|
44
|
-
1. **Make changes to the library:**
|
|
45
|
-
```bash
|
|
46
|
-
cd libs/recommendation-ui
|
|
47
|
-
# Edit files in src/
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
2. **Rebuild the library:**
|
|
51
|
-
```bash
|
|
52
|
-
yarn build
|
|
53
|
-
# Or use watch mode for auto-rebuild:
|
|
54
|
-
yarn dev
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
3. **Changes are immediately available in crew-website** (restart dev server if needed)
|
|
58
|
-
|
|
59
|
-
### 🚀 For Production:
|
|
60
|
-
|
|
61
|
-
Build the library before deploying crew-website:
|
|
62
|
-
```bash
|
|
63
|
-
# From project root
|
|
64
|
-
cd libs/recommendation-ui && yarn build
|
|
65
|
-
cd ../../apps/crew-website && yarn build
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
---
|
|
69
|
-
|
|
70
|
-
## 📤 Option 2: Publish to npm (If Needed)
|
|
71
|
-
|
|
72
|
-
Only use this if you need to share the library **outside** the monorepo (e.g., with crew-frontend-monorepo).
|
|
73
|
-
|
|
74
|
-
### Prerequisites:
|
|
75
|
-
- npm account
|
|
76
|
-
- Logged in: `npm login`
|
|
77
|
-
- Automation token (to bypass 2FA)
|
|
78
|
-
|
|
79
|
-
### Steps:
|
|
80
|
-
|
|
81
|
-
1. **Build the library:**
|
|
82
|
-
```bash
|
|
83
|
-
cd /Users/gurkawalbir.singh/Downloads/Workspace/crew-dashboards/libs/recommendation-ui
|
|
84
|
-
yarn build
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
2. **Update version in package.json:**
|
|
88
|
-
```json
|
|
89
|
-
{
|
|
90
|
-
"version": "0.2.0" // Increment version
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
3. **Publish to npm:**
|
|
95
|
-
```bash
|
|
96
|
-
npm publish
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
4. **Consume from npm:**
|
|
100
|
-
```json
|
|
101
|
-
// In any package.json
|
|
102
|
-
{
|
|
103
|
-
"dependencies": {
|
|
104
|
-
"@crew-dashboards/recommendation-ui": "^0.2.0"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Publishing Script (Optional):
|
|
110
|
-
|
|
111
|
-
Add to `libs/recommendation-ui/package.json`:
|
|
112
|
-
```json
|
|
113
|
-
{
|
|
114
|
-
"scripts": {
|
|
115
|
-
"prepublishOnly": "yarn build",
|
|
116
|
-
"publish:patch": "npm version patch && npm publish",
|
|
117
|
-
"publish:minor": "npm version minor && npm publish",
|
|
118
|
-
"publish:major": "npm version major && npm publish"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Then use:
|
|
124
|
-
```bash
|
|
125
|
-
yarn publish:patch # 0.1.0 -> 0.1.1
|
|
126
|
-
yarn publish:minor # 0.1.0 -> 0.2.0
|
|
127
|
-
yarn publish:major # 0.1.0 -> 1.0.0
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
---
|
|
131
|
-
|
|
132
|
-
## 🔍 Verify the Setup
|
|
133
|
-
|
|
134
|
-
### Check if library is linked:
|
|
135
|
-
```bash
|
|
136
|
-
cd /Users/gurkawalbir.singh/Downloads/Workspace/crew-dashboards/apps/crew-website
|
|
137
|
-
ls -la node_modules/@crew-dashboards/recommendation-ui
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Should show a symlink to `../../libs/recommendation-ui`
|
|
141
|
-
|
|
142
|
-
### Test import:
|
|
143
|
-
```tsx
|
|
144
|
-
// In crew-website/src/test.tsx
|
|
145
|
-
import { colors, spacing } from '@crew-dashboards/recommendation-ui/dls';
|
|
146
|
-
import { RecommendationCard } from '@crew-dashboards/recommendation-ui/recommendation-listing';
|
|
147
|
-
|
|
148
|
-
console.log(colors.primary[500]); // Should work!
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
---
|
|
152
|
-
|
|
153
|
-
## 📝 Common Commands
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
# Build library
|
|
157
|
-
cd libs/recommendation-ui && yarn build
|
|
158
|
-
|
|
159
|
-
# Watch mode (auto-rebuild on changes)
|
|
160
|
-
cd libs/recommendation-ui && yarn dev
|
|
161
|
-
|
|
162
|
-
# Clean build artifacts
|
|
163
|
-
cd libs/recommendation-ui && yarn clean
|
|
164
|
-
|
|
165
|
-
# Reinstall dependencies (if needed)
|
|
166
|
-
cd crew-dashboards && yarn install
|
|
167
|
-
|
|
168
|
-
# Start crew-website with the library
|
|
169
|
-
cd apps/crew-website && yarn dev
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## 🎯 Recommended Approach for Your Project
|
|
175
|
-
|
|
176
|
-
Since you have everything in the **crew-dashboards monorepo**, use **Option 1 (Local Workspace Package)**:
|
|
177
|
-
|
|
178
|
-
1. ✅ Library is already set up in `libs/recommendation-ui/`
|
|
179
|
-
2. ✅ crew-website is already configured to use it
|
|
180
|
-
3. ✅ Just build and import!
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
# Build once
|
|
184
|
-
cd libs/recommendation-ui && yarn build
|
|
185
|
-
|
|
186
|
-
# Use in crew-website
|
|
187
|
-
# Update imports from 'crew-recommendation-ui' to '@crew-dashboards/recommendation-ui'
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
This gives you the **best developer experience** without the overhead of npm publishing! 🚀
|
|
191
|
-
|