-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
652 additions
and
645 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,35 @@ | ||
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items'; | ||
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart'; | ||
import { CartSummaryLineItem } from '@/vibes/soul/sections/cart/summary'; | ||
|
||
import { checkoutAction, lineItemAction } from './actions'; | ||
|
||
export default async function Preview() { | ||
// const products = await getLineItems('Electric') | ||
export default function Preview() { | ||
const lineItems = new Promise<CartLineItem[]>((res) => | ||
setTimeout(() => res(getLineItems('Electric')), 5000), | ||
setTimeout(() => res(getLineItems('Electric')), 1000), | ||
); | ||
const subtotal = await getSubtotal('Electric'); | ||
const summaryLineItems = getSubtotal('Electric').then((subtotal) => { | ||
return new Promise<CartSummaryLineItem[]>((res) => | ||
setTimeout( | ||
() => | ||
res([ | ||
{ label: 'Subtotal', value: subtotal }, | ||
{ label: 'Shipping', value: 'TBD' }, | ||
{ label: 'Tax', value: 'TBD' }, | ||
]), | ||
1000, | ||
), | ||
); | ||
}); | ||
const summaryTotal = new Promise<string>((res) => setTimeout(() => res('127.60'), 1000)); | ||
|
||
return ( | ||
<Cart | ||
checkoutAction={checkoutAction} | ||
emptyState={{ | ||
title: 'Your cart is empty', | ||
subtitle: 'Add some products to get started.', | ||
cta: { | ||
label: 'Continue shopping', | ||
href: '#', | ||
}, | ||
}} | ||
lineItemAction={lineItemAction} | ||
lineItems={lineItems} | ||
summary={{ | ||
title: 'Summary', | ||
subtotal: subtotal, | ||
caption: 'Shipping & taxes calculated at checkout', | ||
subtotalLabel: 'Subtotal', | ||
shippingLabel: 'Shipping', | ||
shipping: 'TBD', | ||
taxLabel: 'Tax', | ||
tax: 'TBD', | ||
// grandTotalLabel: 'Total', | ||
// grandTotal: '$127.60', | ||
ctaLabel: 'Checkout', | ||
}} | ||
title="Cart" | ||
summaryLineItems={summaryLineItems} | ||
summaryTotal={summaryTotal} | ||
/> | ||
); | ||
} |
44 changes: 18 additions & 26 deletions
44
apps/web/vibes/soul/examples/sections/cart/loading-electric.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items'; | ||
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart'; | ||
import { CartSummaryLineItem } from '@/vibes/soul/sections/cart/summary'; | ||
|
||
import { checkoutAction, lineItemAction } from './actions'; | ||
|
||
export default function Preview() { | ||
const lineItems = new Promise<CartLineItem[]>((res) => | ||
setTimeout(() => res(getLineItems('Electric')), 5000), | ||
); | ||
const subtotal = new Promise<string>((res) => | ||
setTimeout(() => res(getSubtotal('Electric')), 10000), | ||
setTimeout(() => res(getLineItems('Electric')), 1000), | ||
); | ||
const summaryLineItems = getSubtotal('Electric').then((subtotal) => { | ||
return new Promise<CartSummaryLineItem[]>((res) => | ||
setTimeout( | ||
() => | ||
res([ | ||
{ label: 'Subtotal', value: subtotal }, | ||
{ label: 'Shipping', value: 'TBD' }, | ||
{ label: 'Tax', value: 'TBD' }, | ||
]), | ||
1000, | ||
), | ||
); | ||
}); | ||
const summaryTotal = new Promise<string>((res) => setTimeout(() => res('127.60'), 1000)); | ||
|
||
return ( | ||
<Cart | ||
checkoutAction={checkoutAction} | ||
emptyState={{ | ||
title: 'Your cart is empty', | ||
subtitle: 'Add some products to get started.', | ||
cta: { | ||
label: 'Continue shopping', | ||
href: '#', | ||
}, | ||
}} | ||
lineItemAction={lineItemAction} | ||
lineItems={lineItems} | ||
summary={{ | ||
title: 'Summary', | ||
subtotal: subtotal, | ||
caption: 'Shipping & taxes calculated at checkout', | ||
subtotalLabel: 'Subtotal', | ||
shippingLabel: 'Shipping', | ||
shipping: 'TBD', | ||
taxLabel: 'Tax', | ||
tax: 'TBD', | ||
// grandTotalLabel: 'Total', | ||
// grandTotal: '$127.60', | ||
ctaLabel: 'Checkout', | ||
}} | ||
title="Cart" | ||
summaryLineItems={summaryLineItems} | ||
summaryTotal={summaryTotal} | ||
/> | ||
); | ||
} |
44 changes: 18 additions & 26 deletions
44
apps/web/vibes/soul/examples/sections/cart/loading-luxury.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,35 @@ | ||
import { getLineItems, getSubtotal } from '@/vibes/soul/data/line-items'; | ||
import { Cart, CartLineItem } from '@/vibes/soul/sections/cart'; | ||
import { CartSummaryLineItem } from '@/vibes/soul/sections/cart/summary'; | ||
|
||
import { checkoutAction, lineItemAction } from './actions'; | ||
|
||
export default function Preview() { | ||
const lineItems = new Promise<CartLineItem[]>((res) => | ||
setTimeout(() => res(getLineItems('Luxury')), 5000), | ||
); | ||
const subtotal = new Promise<string>((res) => | ||
setTimeout(() => res(getSubtotal('Luxury')), 10000), | ||
setTimeout(() => res(getLineItems('Luxury')), 1000), | ||
); | ||
const summaryLineItems = getSubtotal('Luxury').then((subtotal) => { | ||
return new Promise<CartSummaryLineItem[]>((res) => | ||
setTimeout( | ||
() => | ||
res([ | ||
{ label: 'Subtotal', value: subtotal }, | ||
{ label: 'Shipping', value: 'TBD' }, | ||
{ label: 'Tax', value: 'TBD' }, | ||
]), | ||
1000, | ||
), | ||
); | ||
}); | ||
const summaryTotal = new Promise<string>((res) => setTimeout(() => res('127.60'), 1000)); | ||
|
||
return ( | ||
<Cart | ||
checkoutAction={checkoutAction} | ||
emptyState={{ | ||
title: 'Your cart is empty', | ||
subtitle: 'Add some products to get started.', | ||
cta: { | ||
label: 'Continue shopping', | ||
href: '#', | ||
}, | ||
}} | ||
lineItemAction={lineItemAction} | ||
lineItems={lineItems} | ||
summary={{ | ||
title: 'Summary', | ||
subtotal: subtotal, | ||
caption: 'Shipping & taxes calculated at checkout', | ||
subtotalLabel: 'Subtotal', | ||
shippingLabel: 'Shipping', | ||
shipping: 'TBD', | ||
taxLabel: 'Tax', | ||
tax: 'TBD', | ||
// grandTotalLabel: 'Total', | ||
// grandTotal: '$127.60', | ||
ctaLabel: 'Checkout', | ||
}} | ||
title="Cart" | ||
summaryLineItems={summaryLineItems} | ||
summaryTotal={summaryTotal} | ||
/> | ||
); | ||
} |
Oops, something went wrong.