Skip to content

Commit

Permalink
Merge branch 'Weaverse:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hta218 authored Oct 16, 2024
2 parents 17b8af8 + 7acaccc commit 100e200
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 210 deletions.
1 change: 1 addition & 0 deletions app/lib/judgeme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type JudgemeProductData = {
type JudgemeReviewType = {
id: string;
title: string;
created_at: string;
body: string;
rating: number;
reviewer: {
Expand Down
14 changes: 5 additions & 9 deletions app/modules/product-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Image, flattenConnection } from "@shopify/hydrogen";
import type { MoneyV2, Product } from "@shopify/hydrogen/storefront-api-types";
import type { MoneyV2 } from "@shopify/hydrogen/storefront-api-types";
import clsx from "clsx";
import type { ProductCardFragment } from "storefrontapi.generated";
import { Link } from "~/components/link";
import { ProductTag } from "~/components/product-tag";
import { VariantPrices } from "~/components/variant-prices";
import { getProductPlaceholder } from "~/lib/placeholders";
import { isDiscounted, isNewArrival } from "~/lib/utils";
import { QuickViewTrigger } from "./quick-view";

Expand All @@ -18,18 +17,15 @@ export function ProductCard({
className?: string;
loading?: HTMLImageElement["loading"];
}) {
let cardLabel = "";
let cardProduct: Product = product?.variants
? (product as Product)
: getProductPlaceholder();
if (!cardProduct?.variants?.nodes?.length) return null;
if (!product?.variants?.nodes?.length) return null;

let variants = flattenConnection(cardProduct.variants);
let variants = flattenConnection(product.variants);
let firstVariant = variants[0];

if (!firstVariant) return null;
let { image, price, compareAtPrice } = firstVariant;

let { image, price, compareAtPrice } = firstVariant;
let cardLabel = "";
if (isDiscounted(price as MoneyV2, compareAtPrice as MoneyV2)) {
cardLabel = "Sale";
} else if (isNewArrival(product.publishedAt)) {
Expand Down
32 changes: 16 additions & 16 deletions app/sections/judgeme-reviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import type {
HydrogenComponentSchema
} from "@weaverse/hydrogen";
import { forwardRef } from "react";
import { backgroundInputs } from "~/components/background-image";
import { Section, layoutInputs } from "~/components/section";

let JudgemeReviewSection = forwardRef<HTMLElement, any>((props, ref) => {
let { children, loaderData, ...rest } = props;
return (
<Section ref={ref} {...rest} overflow="unset">
<div className="max-w-4xl mx-auto py-6 px-8 bg-white rounded shadow">
{children}
</div>
</Section>
);
});
Expand All @@ -22,21 +19,24 @@ export let schema: HydrogenComponentSchema = {
type: "judgeme-reviews",
title: "Judgeme Reviews",
inspector: [
// {
// group: "Layout",
// inputs: layoutInputs.filter((inp) => inp.name !== "borderRadius"),
// },
// {
// group: "Background",
// inputs: backgroundInputs.filter((inp) => inp.name === "backgroundColor"),
// },
{
group: "Layout",
inputs: layoutInputs.filter((inp) => inp.name !== "borderRadius"),
},
],
childTypes: [
"heading",
"subheading",
"paragraph",
"button",
"judgeme-review--form",
"judgeme-review--list",
"judgeme-review--index",
],
presets: {
children: [
{
type: "heading",
Content: "Reviews",
},
{
type: "judgeme-review--index",
},
],
},
};
Loading

0 comments on commit 100e200

Please sign in to comment.