diff --git a/demos/BookstoreApp.res b/demos/BookstoreApp.res index 8bb937c..6ca0a8c 100644 --- a/demos/BookstoreApp.res +++ b/demos/BookstoreApp.res @@ -338,7 +338,8 @@ let header = () => { } else { "hidden" } - }> + } + > {Component.textSignal(() => Int.toString(Signal.get(cartItemCount)))} , ], @@ -374,7 +375,8 @@ let homePage = () => {
+ class="bg-white dark:bg-stone-800 rounded-xl p-6 border-2 border-stone-200 dark:border-stone-700" + >
{Component.text("📖")}

{Component.text("12 Unique Titles")} @@ -384,7 +386,8 @@ let homePage = () => {

+ class="bg-white dark:bg-stone-800 rounded-xl p-6 border-2 border-stone-200 dark:border-stone-700" + >
{Component.text("🎨")}

{Component.text("Fictional Authors")} @@ -394,7 +397,8 @@ let homePage = () => {

+ class="bg-white dark:bg-stone-800 rounded-xl p-6 border-2 border-stone-200 dark:border-stone-700" + >
{Component.text("Æ‘")}

{Component.text("Functor Currency")} @@ -414,7 +418,8 @@ let aboutPage = () => { {Component.text("About Functional Bookstore")}

+ class="bg-white dark:bg-stone-800 rounded-xl p-8 border-2 border-stone-200 dark:border-stone-700 space-y-6" + >

{Component.text( "Welcome to the Functional Bookstore, your one-stop shop for the most absurd and delightful functional programming literature in the known universe.", @@ -461,49 +466,52 @@ let aboutPage = () => {

} -/* ProductCard Component using JSX */ -type productCardProps = {product: product} - -let productCard = (props: productCardProps) => { - let inCart = Computed.make(() => { - let item = getCartItem(props.product.id) - Option.isSome(item) - }) +module ProductCard = { + /* ProductCard Component using JSX */ + @jsx.component + let make = (~product: product) => { + let inCart = Computed.make(() => { + let item = getCartItem(product.id) + Option.isSome(item) + }) -
-
{Component.text(props.product.cover)}
-

- {Component.text(props.product.title)} -

-

- {Component.text("by " ++ props.product.author)} -

-

- {Component.text(props.product.description)} -

-
- - {Component.text(formatPrice(props.product.price))} - - +
+
{Component.text(product.cover)}
+

+ {Component.text(product.title)} +

+

+ {Component.text("by " ++ product.author)} +

+

+ {Component.text(product.description)} +

+
+ + {Component.text(formatPrice(product.price))} + + +
-
+ } } /* CatalogView Component using JSX */ @@ -513,7 +521,7 @@ let catalogView = () => { {Component.text("Available Books")}
- {Component.fragment(products->Array.map(product => productCard({product: product})))} + {products->Array.map(product => )->JSX.array}
} @@ -527,7 +535,8 @@ let cartItemRow = (props: cartItemRowProps) => { switch product { | Some(p) =>
+ class="bg-white dark:bg-stone-800 rounded-lg p-4 shadow border-2 border-stone-200 dark:border-stone-700" + >
{Component.text(p.cover)}
@@ -543,16 +552,19 @@ let cartItemRow = (props: cartItemRowProps) => {
+ class="px-4 py-1 bg-stone-100 dark:bg-stone-700 rounded font-semibold text-stone-900 dark:text-white" + > {Component.text(Int.toString(props.item.quantity))}
@@ -561,7 +573,8 @@ let cartItemRow = (props: cartItemRowProps) => {

@@ -585,7 +598,8 @@ let cartView = () => { "block" } else { "hidden" - }}> + }} + >

{Component.text("Your cart is empty")} @@ -609,12 +623,12 @@ let cartView = () => { "hidden" } else { "block" - }}> -

- {Component.list(cart, item => cartItemRow({item: item}))} -
+ }} + > +
{Component.list(cart, item => cartItemRow({item: item}))}
+ class="bg-stone-100 dark:bg-stone-800 rounded-lg p-6 border-2 border-stone-300 dark:border-stone-700" + >
{Component.text("Total:")} @@ -664,7 +678,8 @@ let checkoutView = () => { {Component.text("Checkout")}
+ class="bg-white dark:bg-stone-800 rounded-xl p-6 shadow-lg border-2 border-stone-200 dark:border-stone-700 mb-6" + >

{Component.text("Shipping Information")}

@@ -716,7 +731,8 @@ let checkoutView = () => {
+ class="bg-white dark:bg-stone-800 rounded-xl p-6 shadow-lg border-2 border-stone-200 dark:border-stone-700 mb-6" + >

{Component.text("Payment Information")}

@@ -733,7 +749,8 @@ let checkoutView = () => {
+ class="bg-stone-100 dark:bg-stone-800 rounded-lg p-6 border-2 border-stone-300 dark:border-stone-700 mb-6" + >
{Component.textSignal(() => "Items (" ++ Int.toString(Signal.get(cartItemCount)) ++ ")")} @@ -773,7 +790,8 @@ let checkoutView = () => { )}
@@ -784,7 +802,8 @@ let checkoutView = () => { let orderConfirmedView = () => {
+ class="bg-white dark:bg-stone-800 rounded-xl p-8 shadow-lg border-2 border-stone-300 dark:border-stone-700 text-center" + >
{Component.text("✅")}

{Component.text("Order Confirmed!")}