Skip to content

Commit

Permalink
Merge pull request #2 from deco-sites/dev
Browse files Browse the repository at this point in the history
release 0.1.0!!!!!!
  • Loading branch information
vitormiura authored Nov 4, 2023
2 parents fb5ccc2 + 5ac222a commit c906f9f
Show file tree
Hide file tree
Showing 16 changed files with 1,509 additions and 3,431 deletions.
3,300 changes: 1 addition & 3,299 deletions .release.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/header/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Navbar({ items, searchbar, logo }: {
<Searchbar searchbar={searchbar} />
<a
class="btn btn-circle btn-sm btn-ghost"
href="/login"
href="/signin"
aria-label="Log in"
>
<Icon id="User" size={24} strokeWidth={0.4} />
Expand Down
114 changes: 61 additions & 53 deletions components/product/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ const relative = (url: string) => {
const WIDTH = 200;
const HEIGHT = 279;

function ProductCard(
{ product, preload, itemListName, layout, platform, index }: Props,
) {
const {
url,
productID,
name,
image: images,
offers,
isVariantOf,
} = product;
function ProductCard({
product,
preload,
itemListName,
layout,
platform,
index,
}: Props) {
const { url, productID, name, image: images, offers, isVariantOf } = product;
const id = `product-card-${productID}`;
const hasVariant = isVariantOf?.hasVariant ?? [];
const productGroupID = isVariantOf?.productGroupID;
Expand Down Expand Up @@ -112,9 +110,9 @@ function ProductCard(
align === "center" ? "text-center" : "text-start"
} ${l?.onMouseOver?.showCardShadow ? "lg:hover:card-bordered" : ""}
${
l?.onMouseOver?.card === "Move up" &&
"duration-500 transition-translate ease-in-out lg:hover:-translate-y-2"
}
l?.onMouseOver?.card === "Move up" &&
"duration-500 transition-translate ease-in-out lg:hover:-translate-y-2"
}
`}
data-deco="view-product"
>
Expand Down Expand Up @@ -219,7 +217,9 @@ function ProductCard(
{(!l?.elementsPositions?.skuSelector ||
l?.elementsPositions?.skuSelector === "Top") && (
<>
{l?.hide?.skuSelector ? "" : (
{l?.hide?.skuSelector ? (
""
) : (
<ul
class={`flex items-center gap-2 w-full overflow-auto p-3 ${
align === "center" ? "justify-center" : "justify-start"
Expand All @@ -231,25 +231,31 @@ function ProductCard(
</>
)}

{l?.hide?.productName && l?.hide?.productDescription
? ""
: (
<div class="flex flex-col gap-0">
{l?.hide?.productName ? "" : (
<h2
class="truncate text-base lg:text-lg text-base-content"
dangerouslySetInnerHTML={{ __html: name ?? "" }}
/>
)}
{l?.hide?.productDescription ? "" : (
<div
class="truncate text-sm lg:text-sm text-neutral"
dangerouslySetInnerHTML={{ __html: description ?? "" }}
/>
)}
</div>
)}
{l?.hide?.allPrices ? "" : (
{l?.hide?.productName && l?.hide?.productDescription ? (
""
) : (
<div class="flex flex-col gap-0">
{l?.hide?.productName ? (
""
) : (
<h2
class="truncate text-base lg:text-lg text-base-content"
dangerouslySetInnerHTML={{ __html: name ?? "" }}
/>
)}
{l?.hide?.productDescription ? (
""
) : (
<div
class="truncate text-sm lg:text-sm text-neutral"
dangerouslySetInnerHTML={{ __html: description ?? "" }}
/>
)}
</div>
)}
{l?.hide?.allPrices ? (
""
) : (
<div class="flex flex-col gap-2">
<div
class={`flex flex-col gap-0 ${
Expand All @@ -269,20 +275,22 @@ function ProductCard(
{formatPrice(price, offers?.priceCurrency)}
</div>
</div>
{l?.hide?.installments
? ""
: (
<div class="text-base-300 text-sm lg:text-base truncate">
ou {installments}
</div>
)}
{l?.hide?.installments ? (
""
) : (
<div class="text-base-300 text-sm lg:text-base truncate">
ou {installments}
</div>
)}
</div>
)}

{/* SKU Selector */}
{l?.elementsPositions?.skuSelector === "Bottom" && (
<>
{l?.hide?.skuSelector ? "" : (
{l?.hide?.skuSelector ? (
""
) : (
<ul
class={`flex items-center gap-2 w-full ${
align === "center" ? "justify-center" : "justify-start"
Expand All @@ -294,17 +302,17 @@ function ProductCard(
</>
)}

{!l?.hide?.cta
? (
<div
class={`flex-auto flex items-end ${
l?.onMouseOver?.showCta ? "lg:hidden" : ""
}`}
>
{cta}
</div>
)
: ""}
{!l?.hide?.cta ? (
<div
class={`flex-auto flex items-end ${
l?.onMouseOver?.showCta ? "lg:hidden" : ""
}`}
>
{cta}
</div>
) : (
""
)}
</div>
</div>
);
Expand Down
4 changes: 4 additions & 0 deletions components/product/ProductInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { usePlatform } from "$store/sdk/usePlatform.tsx";
import { ProductDetailsPage } from "apps/commerce/types.ts";
import { mapProductToAnalyticsItem } from "apps/commerce/utils/productToAnalyticsItem.ts";
import ProductSelector from "./ProductVariantSelector.tsx";
import Recommender from "$store/islands/Recommender.tsx";

interface Props {
page: ProductDetailsPage | null;
Expand Down Expand Up @@ -61,6 +62,9 @@ function ProductInfo({ page, layout }: Props) {
return (
<div class="flex flex-col">
{/* Breadcrumb */}
<Recommender
url={url}
/>
<Breadcrumb
itemListElement={breadcrumbList?.itemListElement.slice(0, -1)}
/>
Expand Down
22 changes: 14 additions & 8 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// This file is automatically updated during development when running `dev.ts`.

import * as $0 from "./routes/_app.tsx";
import * as $1 from "./routes/supabase/index.ts";
import * as $$0 from "./islands/AddToCartButton/linx.tsx";
import * as $$1 from "./islands/AddToCartButton/shopify.tsx";
import * as $$2 from "./islands/AddToCartButton/vnda.tsx";
Expand All @@ -19,14 +20,17 @@ import * as $$12 from "./islands/Header/Searchbar.tsx";
import * as $$13 from "./islands/Newsletter.tsx";
import * as $$14 from "./islands/OutOfStock.tsx";
import * as $$15 from "./islands/ProductImageZoom.tsx";
import * as $$16 from "./islands/SearchControls.tsx";
import * as $$17 from "./islands/ShippingSimulation.tsx";
import * as $$18 from "./islands/SliderJS.tsx";
import * as $$19 from "./islands/WishlistButton.tsx";
import * as $$16 from "./islands/Recommender.tsx";
import * as $$17 from "./islands/SearchControls.tsx";
import * as $$18 from "./islands/ShippingSimulation.tsx";
import * as $$19 from "./islands/SideModalIsland.tsx";
import * as $$20 from "./islands/SliderJS.tsx";
import * as $$21 from "./islands/WishlistButton.tsx";

const manifest = {
routes: {
"./routes/_app.tsx": $0,
"./routes/supabase/index.ts": $1,
},
islands: {
"./islands/AddToCartButton/linx.tsx": $$0,
Expand All @@ -45,10 +49,12 @@ const manifest = {
"./islands/Newsletter.tsx": $$13,
"./islands/OutOfStock.tsx": $$14,
"./islands/ProductImageZoom.tsx": $$15,
"./islands/SearchControls.tsx": $$16,
"./islands/ShippingSimulation.tsx": $$17,
"./islands/SliderJS.tsx": $$18,
"./islands/WishlistButton.tsx": $$19,
"./islands/Recommender.tsx": $$16,
"./islands/SearchControls.tsx": $$17,
"./islands/ShippingSimulation.tsx": $$18,
"./islands/SideModalIsland.tsx": $$19,
"./islands/SliderJS.tsx": $$20,
"./islands/WishlistButton.tsx": $$21,
},
baseUrl: import.meta.url,
};
Expand Down
27 changes: 27 additions & 0 deletions islands/Recommender.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { useEffect } from "preact/hooks";

export type Props ={
url: string | undefined
}

function Recommender({url}: Props) {
useEffect(() => {
(async () => {
const rawResponse = await fetch("http://localhost:8000/supabase", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({ url:url }),
});
const content = await rawResponse.text();

console.log(content);
})();
}, []);

return <></>;
}

export default Recommender;
59 changes: 59 additions & 0 deletions islands/SideModalIsland.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { useState } from "preact/hooks";
import type { ImageWidget } from "apps/admin/widgets.ts";

interface Props {
buttonTitle?: string;
title?: string;
section?: string;
section2?: string;
category?: string;
description?: string;
productName?: string;
discount?: string;
image?: ImageWidget;
}

export default function SideModalIsland({
buttonTitle = "Extra 10% OFF",
title = "BLACK FRIDAY",
section = "Best Offers",
section2 = "Exemple2",
category = "T-shirts",
description = "Best Products",
productName = "T-shirt Black",
discount = "10% OFF" ,
image = "https://images.unsplash.com/photo-https://d2vq4s943o8cb4.cloudfront.net/Custom/Content/Products/15/76/15767858_camiseta-lds-rocks-loja-do-suplemento-6994_l1_636459202348870883.png-1c9102c219da?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1770&q=80"
}: Props) {
const [isModalVisible, setIsModalVisible] = useState(false);

const handleClick = () => {
setIsModalVisible(!isModalVisible);
}

return (
<>
<div className={"fixed flex-row top-80 z-50 sm:flex h-72 modal-open transition-all duration-500 ease-in-out"} style={{right:isModalVisible ? "0" : "-380px"}}>
<button onClick={handleClick} className="bg-red-500 text-white inset-y-0 left-0 w-10 relative whitespace-nowrap flex items-center justify-center ">
<div className="-rotate-90 text-m underline font-bold uppercase">{buttonTitle}</div>
</button>
<div className={`bg-orange-200 p-4 transform translate-x-0 w-[380px]`}>
<div className="flex flex-col h-64 p-3 bg-white rounded-lg shadow-lg">
<div className="text-center text-black font-bold mb-4 text-xl" >{title}</div>
<div className="grid grid-cols-2 gap-8">
<div className="space-y-2">
<div className="uppercase font-semibold">{section}</div>
<div className="font-bold">{category}</div>
<div>{description}</div>
<div className="top-1 font-bold text-4xl text-red-600 right-0">{discount}</div>
</div>
<div>
<img src={image} alt={productName} className="w-54 h-32 object-cover rounded-md"/>
<p className="mt-2 text-center font-semibold">{productName}</p>
</div>
</div>
</div>
</div>
</div>
</>
);
}
Loading

0 comments on commit c906f9f

Please sign in to comment.