@pradip1995/layout-bnb 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 +44 -0
- package/src/cart-layout.tsx +27 -0
- package/src/checkout-layout.tsx +29 -0
- package/src/index.ts +2 -0
- package/src/layout.css +90 -0
- package/src/layout.tsx +18 -0
- package/src/manifest.ts +10 -0
- package/src/shell.tsx +60 -0
- package/src/store-layout.tsx +26 -0
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pradip1995/layout-bnb",
|
|
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
|
+
"./manifest": "./src/manifest.ts"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@medusajs/types": "^2.0.0",
|
|
23
|
+
"@pradip1995/plugin-sdk": "^0.2.0",
|
|
24
|
+
"react": ">=19"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@pradip1995/segment-footer": "0.2.6",
|
|
28
|
+
"@pradip1995/segment-nav": "0.2.8",
|
|
29
|
+
"@pradip1995/segment-promo-bar": "0.2.5",
|
|
30
|
+
"@pradip1995/segment-tokens": "0.3.2",
|
|
31
|
+
"@pradip1995/segment-primitives": "0.3.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@medusajs/types": "^2.0.0",
|
|
35
|
+
"@pradip1995/plugin-sdk": "^0.2.0",
|
|
36
|
+
"@types/react": "^19",
|
|
37
|
+
"react": "19.0.3",
|
|
38
|
+
"typescript": "^5.7.2"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"lint": "tsc --noEmit"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from "react"
|
|
2
|
+
import { Children } from "react"
|
|
3
|
+
import { BnbShell } from "./shell"
|
|
4
|
+
|
|
5
|
+
export default function LayoutBnbCart({
|
|
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
|
+
<BnbShell data={data} contained>
|
|
17
|
+
<div className="bnb-cart-layout" data-testid="cart-container">
|
|
18
|
+
<h1 className="section-heading mb-8">Your cart</h1>
|
|
19
|
+
<div className="bnb-cart-layout__grid">
|
|
20
|
+
<div className="bnb-cart-layout__items">{items}</div>
|
|
21
|
+
<div className="bnb-cart-layout__summary">{summary}</div>
|
|
22
|
+
</div>
|
|
23
|
+
{below.length > 0 ? <div className="mt-10 flex flex-col gap-8">{below}</div> : null}
|
|
24
|
+
</div>
|
|
25
|
+
</BnbShell>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ReactNode } from "react"
|
|
2
|
+
import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
|
|
3
|
+
import { BnbShell } from "./shell"
|
|
4
|
+
|
|
5
|
+
export default function LayoutBnbCheckout({
|
|
6
|
+
data,
|
|
7
|
+
children,
|
|
8
|
+
}: {
|
|
9
|
+
data: Record<string, unknown>
|
|
10
|
+
children: ReactNode
|
|
11
|
+
}) {
|
|
12
|
+
return (
|
|
13
|
+
<BnbShell data={data}>
|
|
14
|
+
<div className="bnb-checkout-layout" data-testid="checkout-container">
|
|
15
|
+
<div className="bnb-checkout-layout__bar">
|
|
16
|
+
<div className="bnb-checkout-layout__bar-inner">
|
|
17
|
+
<LocalizedLink href="/cart" className="bnb-checkout-layout__back">
|
|
18
|
+
<span aria-hidden>←</span>
|
|
19
|
+
<span>Back to shopping cart</span>
|
|
20
|
+
</LocalizedLink>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
<div className="bnb-checkout-layout__content">
|
|
24
|
+
<div className="bnb-checkout-layout__stack bnb-checkout-layout__stack--split">{children}</div>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</BnbShell>
|
|
28
|
+
)
|
|
29
|
+
}
|
package/src/index.ts
ADDED
package/src/layout.css
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
.bnb-layout__main {
|
|
2
|
+
background: var(--color-surface);
|
|
3
|
+
min-height: 100vh;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.bnb-main-layout,
|
|
8
|
+
.bnb-store-layout {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.bnb-store-layout__section + .bnb-store-layout__section {
|
|
15
|
+
margin-top: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.bnb-cart-layout {
|
|
19
|
+
padding: 2rem 0 3rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.bnb-cart-layout__grid {
|
|
23
|
+
display: grid;
|
|
24
|
+
grid-template-columns: 1fr;
|
|
25
|
+
gap: 2rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@media (min-width: 1024px) {
|
|
29
|
+
.bnb-cart-layout__grid {
|
|
30
|
+
grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
|
|
31
|
+
align-items: start;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.bnb-cart-layout__summary {
|
|
35
|
+
position: sticky;
|
|
36
|
+
top: calc(var(--header-height) + var(--promo-bar-height, 0px) + 20px);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.bnb-checkout-layout__bar {
|
|
41
|
+
border-bottom: 1px solid var(--color-border);
|
|
42
|
+
background: var(--color-surface);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.bnb-checkout-layout__bar-inner {
|
|
46
|
+
max-width: var(--container-max);
|
|
47
|
+
margin: 0 auto;
|
|
48
|
+
padding: 1rem 1.5rem;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.bnb-checkout-layout__back {
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: 0.5rem;
|
|
57
|
+
font-size: 0.875rem;
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
text-transform: uppercase;
|
|
60
|
+
letter-spacing: 0.04em;
|
|
61
|
+
color: var(--color-text-muted);
|
|
62
|
+
text-decoration: none;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.bnb-checkout-layout__back:hover {
|
|
66
|
+
color: var(--color-text-heading);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.bnb-checkout-layout__content {
|
|
70
|
+
max-width: var(--container-max);
|
|
71
|
+
margin: 0 auto;
|
|
72
|
+
padding: 2rem 1.5rem 3rem;
|
|
73
|
+
width: 100%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.bnb-checkout-layout__stack {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
gap: 2rem;
|
|
80
|
+
width: 100%;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@media (min-width: 1024px) {
|
|
84
|
+
.bnb-checkout-layout__stack--split {
|
|
85
|
+
display: grid;
|
|
86
|
+
grid-template-columns: minmax(0, 1.2fr) minmax(320px, 1fr);
|
|
87
|
+
gap: 2.5rem;
|
|
88
|
+
align-items: start;
|
|
89
|
+
}
|
|
90
|
+
}
|
package/src/layout.tsx
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react"
|
|
2
|
+
import { BnbShell } from "./shell"
|
|
3
|
+
|
|
4
|
+
export default function LayoutBnb({
|
|
5
|
+
data,
|
|
6
|
+
children,
|
|
7
|
+
}: {
|
|
8
|
+
data: Record<string, unknown>
|
|
9
|
+
children: ReactNode
|
|
10
|
+
}) {
|
|
11
|
+
return (
|
|
12
|
+
<BnbShell data={data}>
|
|
13
|
+
<div className="bnb-main-layout">{children}</div>
|
|
14
|
+
</BnbShell>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { BnbShell } from "./shell"
|
package/src/manifest.ts
ADDED
package/src/shell.tsx
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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 BnbShell({
|
|
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 className={`bnb-layout ${colorClasses.pageBg} min-h-screen flex flex-col font-sans antialiased ${className}`}>
|
|
38
|
+
{!hidePromo && promoBar && <PromoBar {...promoBar} />}
|
|
39
|
+
{nav && (
|
|
40
|
+
<Nav
|
|
41
|
+
{...nav}
|
|
42
|
+
categories={nav.categories}
|
|
43
|
+
collections={nav.collections}
|
|
44
|
+
wishlistCount={nav.wishlistCount}
|
|
45
|
+
cart={cart ?? null}
|
|
46
|
+
/>
|
|
47
|
+
)}
|
|
48
|
+
<main className="bnb-layout__main flex-1 w-full">
|
|
49
|
+
{contained ? (
|
|
50
|
+
<div className="mx-auto w-full px-4 sm:px-6" style={{ maxWidth: "var(--container-max)" }}>
|
|
51
|
+
{children}
|
|
52
|
+
</div>
|
|
53
|
+
) : (
|
|
54
|
+
children
|
|
55
|
+
)}
|
|
56
|
+
</main>
|
|
57
|
+
{!hideFooter && footer && <Footer {...footer} />}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from "react"
|
|
2
|
+
import { Children } from "react"
|
|
3
|
+
import { BnbShell } from "./shell"
|
|
4
|
+
|
|
5
|
+
/** Vertical stack for banner, shop-by nav, grid, FAQs, newsletter segments */
|
|
6
|
+
export default function LayoutBnbStore({
|
|
7
|
+
data,
|
|
8
|
+
children,
|
|
9
|
+
}: {
|
|
10
|
+
data: Record<string, unknown>
|
|
11
|
+
children: ReactNode
|
|
12
|
+
}) {
|
|
13
|
+
const sections = Children.toArray(children)
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<BnbShell data={data}>
|
|
17
|
+
<div className="bnb-store-layout" data-testid="store-container">
|
|
18
|
+
{sections.map((section, index) => (
|
|
19
|
+
<div key={index} className="bnb-store-layout__section">
|
|
20
|
+
{section}
|
|
21
|
+
</div>
|
|
22
|
+
))}
|
|
23
|
+
</div>
|
|
24
|
+
</BnbShell>
|
|
25
|
+
)
|
|
26
|
+
}
|