@pradip1995/segment-animation-collections 0.1.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/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@pradip1995/segment-animation-collections",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "sideEffects": false,
9
+ "files": [
10
+ "src"
11
+ ],
12
+ "exports": {
13
+ ".": "./src/index.ts",
14
+ "./manifest": "./src/manifest.ts"
15
+ },
16
+ "peerDependencies": {
17
+ "@pradip1995/plugin-sdk": "^0.2.0",
18
+ "react": ">=19",
19
+ "react-dom": ">=19",
20
+ "next": ">=15"
21
+ },
22
+ "dependencies": {
23
+ "@pradip1995/commerce-core": "^4.0.2",
24
+ "@pradip1995/segment-primitives": "^0.4.0",
25
+ "@pradip1995/segment-tokens": "^0.3.7"
26
+ },
27
+ "devDependencies": {
28
+ "@pradip1995/plugin-sdk": "^0.2.0",
29
+ "@types/react": "^19",
30
+ "react": "19.0.3",
31
+ "typescript": "^5.7.2"
32
+ }
33
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./segment"
@@ -0,0 +1,11 @@
1
+ import type { SegmentManifest } from "@pradip1995/plugin-sdk"
2
+
3
+ const manifest: SegmentManifest = {
4
+ id: "animation-collections",
5
+ type: "segment",
6
+ version: "0.1.0",
7
+ compatibleFramework: ["^1.0.0"],
8
+ dataKey: "collections",
9
+ }
10
+
11
+ export default manifest
@@ -0,0 +1,117 @@
1
+ "use client"
2
+
3
+ import React from "react"
4
+ import Image from "next/image"
5
+ import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
6
+ import { motion } from "framer-motion"
7
+
8
+ export type CollectionItem = {
9
+ title: string
10
+ image: string
11
+ link: string
12
+ }
13
+
14
+ export default function AnimationCollections({
15
+ collections,
16
+ items,
17
+ title = "YOU MAY ALSO LIKE"
18
+ }: {
19
+ collections?: any[]
20
+ items?: CollectionItem[]
21
+ title?: string
22
+ }) {
23
+ // Try to use Medusa collections if available, otherwise fallback to static items
24
+ const fallbackItems: CollectionItem[] = [
25
+ { title: "NEW IN", image: "/images/cosmetics/hero-desktop.jpg?v=3", link: "/store" },
26
+ { title: "ACCESSORIES", image: "/images/cosmetics/promo-makeup.jpg?v=3", link: "/store" },
27
+ { title: "TRAIL", image: "/images/cosmetics/promo-skincare.jpg?v=3", link: "/store" },
28
+ { title: "HIKE", image: "/images/cosmetics/shop-banner.jpg?v=3", link: "/store" },
29
+ ]
30
+
31
+ let displayItems: CollectionItem[] = []
32
+
33
+ if (collections && collections.length > 0) {
34
+ displayItems = collections.slice(0, 4).map((c: any) => {
35
+ const metadata = c.metadata || {}
36
+ const imageUrl = metadata.collection_icon || metadata.collection_image || metadata.image || metadata.thumbnail || fallbackItems[0].image
37
+
38
+ return {
39
+ title: c.title || "Collection",
40
+ image: imageUrl.startsWith("http") || imageUrl.startsWith("/") ? imageUrl : `/${imageUrl}`,
41
+ link: `/store?collection=${c.handle || c.id}`
42
+ }
43
+ })
44
+ } else if (items && items.length > 0) {
45
+ displayItems = items
46
+ } else {
47
+ displayItems = fallbackItems
48
+ }
49
+
50
+ // Ensure we have exactly 4 items for the grid if possible
51
+ if (displayItems.length === 0) return null
52
+
53
+ const container = {
54
+ hidden: { opacity: 0 },
55
+ show: {
56
+ opacity: 1,
57
+ transition: { staggerChildren: 0.15 }
58
+ }
59
+ }
60
+
61
+ const itemAnim = {
62
+ hidden: { opacity: 0, y: 30 },
63
+ show: { opacity: 1, y: 0, transition: { duration: 0.6, ease: "easeOut" } }
64
+ }
65
+
66
+ return (
67
+ <section className="w-full bg-[#f4f4f4] py-16 md:py-24 font-sans border-t border-gray-200">
68
+ <div className="max-w-[1400px] mx-auto px-4 md:px-8">
69
+
70
+ <motion.h2
71
+ initial={{ opacity: 0, y: 20 }}
72
+ whileInView={{ opacity: 1, y: 0 }}
73
+ viewport={{ once: true, margin: "-50px" }}
74
+ transition={{ duration: 0.8 }}
75
+ className="text-center text-[16px] md:text-[20px] font-normal tracking-wide uppercase text-[#111] mb-12 md:mb-16"
76
+ >
77
+ {title}
78
+ </motion.h2>
79
+
80
+ <motion.div
81
+ variants={container}
82
+ initial="hidden"
83
+ whileInView="show"
84
+ viewport={{ once: true, margin: "-50px" }}
85
+ className="grid grid-cols-2 md:grid-cols-4 gap-4 md:gap-6"
86
+ >
87
+ {displayItems.map((item, idx) => (
88
+ <motion.div variants={itemAnim} key={idx}>
89
+ <LocalizedLink
90
+ href={item.link}
91
+ className="group relative block w-full aspect-square overflow-hidden bg-[#e9e9e9]"
92
+ >
93
+ <Image
94
+ src={item.image}
95
+ alt={item.title}
96
+ fill
97
+ className="object-cover transition-transform duration-700 ease-out group-hover:scale-105"
98
+ unoptimized
99
+ />
100
+ {/* Subtle dark gradient overlay for text readability */}
101
+ <div className="absolute inset-0 bg-gradient-to-t from-black/40 via-transparent to-transparent opacity-70 group-hover:opacity-90 transition-opacity duration-300" />
102
+
103
+ {/* Text overlay */}
104
+ <div className="absolute bottom-4 left-4 md:bottom-6 md:left-6 z-10">
105
+ <h3 className="text-white text-[12px] md:text-[14px] font-semibold tracking-wider uppercase inline-block border-b border-transparent group-hover:border-white pb-0.5 transition-all duration-300">
106
+ {item.title}
107
+ </h3>
108
+ </div>
109
+ </LocalizedLink>
110
+ </motion.div>
111
+ ))}
112
+ </motion.div>
113
+
114
+ </div>
115
+ </section>
116
+ )
117
+ }