@pradip1995/layout-chocomelon 0.2.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,45 @@
1
+ {
2
+ "name": "@pradip1995/layout-chocomelon",
3
+ "version": "0.2.0",
4
+ "license": "MIT",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "sideEffects": [
9
+ "src/layout.css"
10
+ ],
11
+ "files": [
12
+ "src"
13
+ ],
14
+ "exports": {
15
+ ".": "./src/index.ts",
16
+ "./store": "./src/store-layout.tsx",
17
+ "./cart": "./src/cart-layout.tsx",
18
+ "./checkout": "./src/checkout-layout.tsx",
19
+ "./account": "./src/account-layout.tsx",
20
+ "./manifest": "./src/manifest.ts"
21
+ },
22
+ "peerDependencies": {
23
+ "@medusajs/types": "^2.0.0",
24
+ "@pradip1995/plugin-sdk": "^0.2.0",
25
+ "react": ">=19"
26
+ },
27
+ "dependencies": {
28
+ "@pradip1995/segment-footer": "0.2.6",
29
+ "@pradip1995/segment-nav": "0.2.8",
30
+ "@pradip1995/segment-promo-bar": "0.2.5",
31
+ "@pradip1995/segment-primitives": "0.3.0",
32
+ "@pradip1995/segment-tokens": "0.3.2"
33
+ },
34
+ "devDependencies": {
35
+ "@medusajs/types": "^2.0.0",
36
+ "@pradip1995/plugin-sdk": "^0.2.0",
37
+ "@types/react": "^19",
38
+ "react": "19.0.3",
39
+ "typescript": "^5.7.2"
40
+ },
41
+ "scripts": {
42
+ "typecheck": "tsc --noEmit",
43
+ "lint": "tsc --noEmit"
44
+ }
45
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react"
2
+ import { ChocomelonShell } from "./shell"
3
+
4
+ export default function LayoutChocomelonAccount({
5
+ data,
6
+ children,
7
+ }: {
8
+ data: Record<string, unknown>
9
+ children: ReactNode
10
+ }) {
11
+ return (
12
+ <ChocomelonShell data={data}>
13
+ <div className="chocomelon-account-layout" data-testid="account-page">
14
+ <div className="chocomelon-account-layout__inner mx-auto px-4 sm:px-6">
15
+ <h1 className="section-heading chocomelon-account-layout__heading">My account</h1>
16
+ {children}
17
+ </div>
18
+ </div>
19
+ </ChocomelonShell>
20
+ )
21
+ }
@@ -0,0 +1,29 @@
1
+ import type { ReactNode } from "react"
2
+ import { Children } from "react"
3
+ import { ChocomelonShell } from "./shell"
4
+
5
+ export default function LayoutChocomelonCart({
6
+ data,
7
+ children,
8
+ }: {
9
+ data: Record<string, unknown>
10
+ children: ReactNode
11
+ }) {
12
+ const segments = Children.toArray(children)
13
+ const [items, summary, ...below] = segments
14
+
15
+ return (
16
+ <ChocomelonShell data={data} contained>
17
+ <div className="chocomelon-cart-layout" data-testid="cart-container">
18
+ <h1 className="section-heading chocomelon-cart-layout__heading">Your cart</h1>
19
+ <div className="chocomelon-cart-layout__grid">
20
+ <div className="chocomelon-cart-layout__items">{items}</div>
21
+ <div className="chocomelon-cart-layout__summary">{summary}</div>
22
+ </div>
23
+ {below.length > 0 ? (
24
+ <div className="chocomelon-cart-layout__below">{below}</div>
25
+ ) : null}
26
+ </div>
27
+ </ChocomelonShell>
28
+ )
29
+ }
@@ -0,0 +1,19 @@
1
+ import type { ReactNode } from "react"
2
+ import { ChocomelonShell } from "./shell"
3
+
4
+ export default function LayoutChocomelonCheckout({
5
+ data,
6
+ children,
7
+ }: {
8
+ data: Record<string, unknown>
9
+ children: ReactNode
10
+ }) {
11
+ return (
12
+ <ChocomelonShell data={data} contained>
13
+ <div className="chocomelon-checkout-layout" data-testid="checkout-container">
14
+ <h1 className="section-heading mb-8">Checkout</h1>
15
+ <div className="chocomelon-checkout-layout__grid">{children}</div>
16
+ </div>
17
+ </ChocomelonShell>
18
+ )
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default } from "./layout"
2
+ export { default as manifest } from "./manifest"
package/src/layout.css ADDED
@@ -0,0 +1,99 @@
1
+ .chocomelon-layout {
2
+ --chocomelon-page-bg: #fffafe;
3
+ }
4
+
5
+ .chocomelon-layout__main {
6
+ background: var(--chocomelon-page-bg);
7
+ min-height: 100vh;
8
+ width: 100%;
9
+ }
10
+
11
+ .chocomelon-main-layout {
12
+ display: flex;
13
+ flex-direction: column;
14
+ width: 100%;
15
+ }
16
+
17
+ .chocomelon-store-layout__grid {
18
+ display: flex;
19
+ flex-direction: column;
20
+ gap: 2rem;
21
+ padding: 2rem 1rem 3rem;
22
+ max-width: var(--container-max);
23
+ margin: 0 auto;
24
+ }
25
+
26
+ @media (min-width: 1024px) {
27
+ .chocomelon-store-layout__grid {
28
+ flex-direction: row;
29
+ align-items: flex-start;
30
+ gap: 3rem;
31
+ padding: 3rem 1.5rem;
32
+ }
33
+ }
34
+
35
+ .chocomelon-cart-layout {
36
+ padding: 1rem 0 3rem;
37
+ }
38
+
39
+ .chocomelon-cart-layout__heading {
40
+ margin-bottom: 2rem;
41
+ }
42
+
43
+ .chocomelon-cart-layout__grid {
44
+ display: grid;
45
+ grid-template-columns: 1fr;
46
+ gap: 1.5rem;
47
+ }
48
+
49
+ @media (min-width: 1024px) {
50
+ .chocomelon-cart-layout__grid {
51
+ grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
52
+ gap: 2.5rem;
53
+ align-items: start;
54
+ }
55
+
56
+ .chocomelon-cart-layout__summary {
57
+ position: sticky;
58
+ top: calc(var(--header-height) + var(--promo-bar-height, 0px) + 20px);
59
+ }
60
+ }
61
+
62
+ .chocomelon-cart-layout__below {
63
+ margin-top: 2.5rem;
64
+ display: flex;
65
+ flex-direction: column;
66
+ gap: 2rem;
67
+ }
68
+
69
+ .chocomelon-checkout-layout {
70
+ padding: 1.5rem 0 3rem;
71
+ }
72
+
73
+ .chocomelon-checkout-layout__grid {
74
+ display: grid;
75
+ grid-template-columns: 1fr;
76
+ gap: 2rem;
77
+ }
78
+
79
+ @media (min-width: 1024px) {
80
+ .chocomelon-checkout-layout__grid {
81
+ grid-template-columns: 1fr 1fr;
82
+ gap: 2.5rem;
83
+ }
84
+ }
85
+
86
+ .chocomelon-account-layout {
87
+ padding: 2rem 0 3rem;
88
+ }
89
+
90
+ .chocomelon-account-layout__inner {
91
+ max-width: 64rem;
92
+ margin: 0 auto;
93
+ width: 100%;
94
+ }
95
+
96
+ .chocomelon-account-layout__heading {
97
+ text-align: center;
98
+ margin-bottom: 1.5rem;
99
+ }
package/src/layout.tsx ADDED
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from "react"
2
+ import { ChocomelonShell } from "./shell"
3
+
4
+ export default function LayoutChocomelon({
5
+ data,
6
+ children,
7
+ }: {
8
+ data: Record<string, unknown>
9
+ children: ReactNode
10
+ }) {
11
+ return (
12
+ <ChocomelonShell data={data}>
13
+ <div className="chocomelon-main-layout">{children}</div>
14
+ </ChocomelonShell>
15
+ )
16
+ }
17
+
18
+ export { ChocomelonShell } from "./shell"
@@ -0,0 +1,10 @@
1
+ import type { LayoutManifest } from "@pradip1995/plugin-sdk"
2
+
3
+ const manifest: LayoutManifest = {
4
+ id: "layout-chocomelon",
5
+ type: "layout",
6
+ version: "0.1.0",
7
+ compatibleFramework: ["^1.0.0"],
8
+ }
9
+
10
+ export default manifest
package/src/shell.tsx ADDED
@@ -0,0 +1,62 @@
1
+ import type { ReactNode } from "react"
2
+ import type { HttpTypes } from "@medusajs/types"
3
+ import Nav from "@pradip1995/segment-nav"
4
+ import PromoBar from "@pradip1995/segment-promo-bar"
5
+ import Footer from "@pradip1995/segment-footer"
6
+ import type { FooterSlotData, NavSlotData, PromoBarSlotData } from "@pradip1995/plugin-sdk"
7
+ import { colorClasses } from "@pradip1995/segment-tokens"
8
+ import "./layout.css"
9
+
10
+ type ShellProps = {
11
+ data: Record<string, unknown>
12
+ children: ReactNode
13
+ hidePromo?: boolean
14
+ hideFooter?: boolean
15
+ contained?: boolean
16
+ className?: string
17
+ }
18
+
19
+ export function ChocomelonShell({
20
+ data,
21
+ children,
22
+ hidePromo = false,
23
+ hideFooter = false,
24
+ contained = false,
25
+ className = "",
26
+ }: ShellProps) {
27
+ const nav = data.nav as NavSlotData & {
28
+ categories?: unknown[]
29
+ collections?: unknown[]
30
+ wishlistCount?: number
31
+ }
32
+ const promoBar = data.promoBar as PromoBarSlotData
33
+ const footer = data.footer as FooterSlotData
34
+ const cart = data.cart as HttpTypes.StoreCart | null | undefined
35
+
36
+ return (
37
+ <div
38
+ className={`chocomelon-layout ${colorClasses.pageBg} min-h-screen flex flex-col font-sans antialiased ${className}`}
39
+ >
40
+ {!hidePromo && promoBar && <PromoBar {...promoBar} />}
41
+ {nav && (
42
+ <Nav
43
+ {...nav}
44
+ categories={nav.categories}
45
+ collections={nav.collections}
46
+ wishlistCount={nav.wishlistCount}
47
+ cart={cart ?? null}
48
+ />
49
+ )}
50
+ <main className="chocomelon-layout__main flex-1 w-full">
51
+ {contained ? (
52
+ <div className="mx-auto w-full px-4 sm:px-6" style={{ maxWidth: "var(--container-max)" }}>
53
+ {children}
54
+ </div>
55
+ ) : (
56
+ children
57
+ )}
58
+ </main>
59
+ {!hideFooter && footer && <Footer {...footer} />}
60
+ </div>
61
+ )
62
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react"
2
+ import { ChocomelonShell } from "./shell"
3
+
4
+ export default function LayoutChocomelonStore({
5
+ data,
6
+ children,
7
+ }: {
8
+ data: Record<string, unknown>
9
+ children: ReactNode
10
+ }) {
11
+ return (
12
+ <ChocomelonShell data={data}>
13
+ <div
14
+ className="chocomelon-store-layout__grid"
15
+ data-testid="store-container"
16
+ >
17
+ {children}
18
+ </div>
19
+ </ChocomelonShell>
20
+ )
21
+ }