@pradip1995/segment-product-card 0.3.20 → 0.3.21
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 +6 -6
- package/src/product-card-actions.tsx +11 -2
- package/src/segment.css +34 -4
- package/src/shop-product-card.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pradip1995/segment-product-card",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,10 +17,6 @@
|
|
|
17
17
|
"./product-scroll": "./src/product-scroll.tsx",
|
|
18
18
|
"./product-rail-variants": "./src/product-rail-variants.tsx"
|
|
19
19
|
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"lint": "tsc --noEmit"
|
|
23
|
-
},
|
|
24
20
|
"peerDependencies": {
|
|
25
21
|
"@pradip1995/commerce-core": "^4.0.0",
|
|
26
22
|
"@pradip1995/plugin-sdk": "^0.2.0",
|
|
@@ -37,5 +33,9 @@
|
|
|
37
33
|
"@types/react": "^19",
|
|
38
34
|
"react": "19.0.3",
|
|
39
35
|
"typescript": "^5.7.2"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"lint": "tsc --noEmit"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "@pradip1995/commerce-core/client/actions/wishlist"
|
|
11
11
|
import type { HttpTypes } from "@medusajs/types"
|
|
12
12
|
import { isNextRedirect } from "@pradip1995/segment-primitives/is-next-redirect"
|
|
13
|
+
import LoginRequiredModal from "@pradip1995/segment-login-popup/required"
|
|
13
14
|
import QuickAddPanel from "./quick-add-panel"
|
|
14
15
|
|
|
15
16
|
type Props = {
|
|
@@ -46,6 +47,7 @@ export default function ProductCardActions({ product, countryCode, wishlistProdu
|
|
|
46
47
|
const [selectedOptions, setSelectedOptions] = useState<Record<string, string>>({})
|
|
47
48
|
const [quantity, setQuantity] = useState(1)
|
|
48
49
|
const [error, setError] = useState<string | null>(null)
|
|
50
|
+
const [loginRequired, setLoginRequired] = useState(false)
|
|
49
51
|
|
|
50
52
|
const variants = product.variants ?? []
|
|
51
53
|
const hasMultipleVariants = variants.length > 1
|
|
@@ -112,7 +114,7 @@ export default function ProductCardActions({ product, countryCode, wishlistProdu
|
|
|
112
114
|
}
|
|
113
115
|
|
|
114
116
|
if (result.error?.toLowerCase().includes("login")) {
|
|
115
|
-
|
|
117
|
+
setLoginRequired(true)
|
|
116
118
|
return
|
|
117
119
|
}
|
|
118
120
|
|
|
@@ -173,7 +175,7 @@ export default function ProductCardActions({ product, countryCode, wishlistProdu
|
|
|
173
175
|
|
|
174
176
|
return (
|
|
175
177
|
<>
|
|
176
|
-
<div className="product-card__actions" onClick={stopCardNav}>
|
|
178
|
+
<div className="product-card__actions absolute bottom-3.5 right-3.5 z-30 opacity-0 group-hover/media:opacity-100 transition-opacity duration-300 pointer-events-none group-hover/media:pointer-events-auto" onClick={stopCardNav}>
|
|
177
179
|
<button
|
|
178
180
|
type="button"
|
|
179
181
|
className={`product-card__wishlist-btn${wishlisted ? " product-card__wishlist-btn--active" : ""}${
|
|
@@ -231,6 +233,13 @@ export default function ProductCardActions({ product, countryCode, wishlistProdu
|
|
|
231
233
|
</div>
|
|
232
234
|
) : null}
|
|
233
235
|
|
|
236
|
+
<LoginRequiredModal
|
|
237
|
+
isOpen={loginRequired}
|
|
238
|
+
onClose={() => setLoginRequired(false)}
|
|
239
|
+
countryCode={countryCode}
|
|
240
|
+
message="Please log in to save items to your wishlist."
|
|
241
|
+
/>
|
|
242
|
+
|
|
234
243
|
{showQuickAdd ? (
|
|
235
244
|
<QuickAddPanel
|
|
236
245
|
product={product}
|
package/src/segment.css
CHANGED
|
@@ -53,8 +53,9 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.beauty-product-card .product-card__actions {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
bottom: 0.875rem;
|
|
57
|
+
top: auto;
|
|
58
|
+
right: 0.875rem;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
.beauty-product-card .product-card__wishlist-btn,
|
|
@@ -275,8 +276,9 @@
|
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
.jewelry-product-card .product-card__actions {
|
|
278
|
-
|
|
279
|
-
|
|
279
|
+
bottom: 0.875rem;
|
|
280
|
+
top: auto;
|
|
281
|
+
right: 0.875rem;
|
|
280
282
|
}
|
|
281
283
|
|
|
282
284
|
.jewelry-product-card .product-card__wishlist-btn {
|
|
@@ -406,3 +408,31 @@
|
|
|
406
408
|
pointer-events: auto;
|
|
407
409
|
}
|
|
408
410
|
}
|
|
411
|
+
|
|
412
|
+
/* Shop product card (Motion style) */
|
|
413
|
+
|
|
414
|
+
.shop-product-card .product-card__actions {
|
|
415
|
+
bottom: 0.875rem;
|
|
416
|
+
top: auto;
|
|
417
|
+
right: 0.875rem;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.shop-product-card .product-card__wishlist-btn {
|
|
421
|
+
width: 2.125rem;
|
|
422
|
+
height: 2.125rem;
|
|
423
|
+
border-radius: 999px;
|
|
424
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
425
|
+
background: rgba(255, 255, 255, 0.95);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.shop-product-card .product-card__wishlist-btn--active {
|
|
429
|
+
background: var(--color-brand-accent-muted, #f4eff8);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.shop-product-card .product-card__cart-btn {
|
|
433
|
+
display: none; /* Hide the cart icon since shop card uses the Quick View circle */
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.shop-product-card .product-card__quick-add-wrap {
|
|
437
|
+
display: none; /* Hide the quick add bar at the bottom, triggered by the blue circle instead */
|
|
438
|
+
}
|
|
@@ -44,14 +44,14 @@ export default function ShopProductCard({
|
|
|
44
44
|
)
|
|
45
45
|
const rawColorValues: string[] = colorOption?.values
|
|
46
46
|
?.map((v: OptionWithValue) => v.value)
|
|
47
|
-
.filter((val: string | undefined): val is string => Boolean(val)) || []
|
|
47
|
+
.filter((val: string | null | undefined): val is string => Boolean(val)) || []
|
|
48
48
|
|
|
49
49
|
// Fallback to variant options if no top-level color options exist
|
|
50
50
|
const variantColors: string[] = Array.from(
|
|
51
51
|
new Set(
|
|
52
52
|
(product.variants ?? [])
|
|
53
53
|
.flatMap((v: unknown) => (v as { options?: OptionWithValue[] }).options?.map((o: OptionWithValue) => o.value))
|
|
54
|
-
.filter((val: string | undefined): val is string => Boolean(val))
|
|
54
|
+
.filter((val: string | null | undefined): val is string => Boolean(val))
|
|
55
55
|
)
|
|
56
56
|
)
|
|
57
57
|
const colorValues: string[] = rawColorValues.length > 0 ? rawColorValues : variantColors
|
|
@@ -67,7 +67,7 @@ export default function ShopProductCard({
|
|
|
67
67
|
: 0
|
|
68
68
|
|
|
69
69
|
const isBestSelling = product.tags?.some(
|
|
70
|
-
(tag) => tag.value?.toLowerCase() === "best selling" || tag.value?.toLowerCase() === "bestseller"
|
|
70
|
+
(tag: any) => tag.value?.toLowerCase() === "best selling" || tag.value?.toLowerCase() === "bestseller"
|
|
71
71
|
)
|
|
72
72
|
|
|
73
73
|
return (
|