diff --git a/components/cart/inline-add-to-cart.tsx b/components/cart/inline-add-to-cart.tsx
new file mode 100644
index 000000000..573e68c67
--- /dev/null
+++ b/components/cart/inline-add-to-cart.tsx
@@ -0,0 +1,75 @@
+'use client';
+
+import clsx from 'clsx';
+import { addItem } from 'components/cart/actions';
+import LoadingDots from 'components/loading-dots';
+import { ProductVariant } from 'lib/shopify/types';
+import { useTranslations } from 'next-intl';
+import { useRouter, useSearchParams } from 'next/navigation';
+import { useTransition } from 'react';
+
+export function InlineAddToCart({
+ variants,
+ availableForSale
+}: {
+ variants: ProductVariant[];
+ availableForSale: boolean;
+}) {
+ const router = useRouter();
+ const searchParams = useSearchParams();
+ const t = useTranslations('Index');
+
+ const [isPending, startTransition] = useTransition();
+ const defaultVariantId = variants.length === 1 ? variants[0]?.id : undefined;
+ const variant = variants.find((variant: ProductVariant) =>
+ variant.selectedOptions.every(
+ (option) => option.value === searchParams.get(option.name.toLowerCase())
+ )
+ );
+ const selectedVariantId = variant?.id || defaultVariantId;
+ const title = !availableForSale
+ ? 'Out of stock'
+ : !selectedVariantId
+ ? 'Please select options'
+ : undefined;
+
+ return (
+
+ );
+}
diff --git a/components/grid/three-items.tsx b/components/grid/homepage-products.tsx
similarity index 68%
rename from components/grid/three-items.tsx
rename to components/grid/homepage-products.tsx
index 02671f646..84391b945 100644
--- a/components/grid/three-items.tsx
+++ b/components/grid/homepage-products.tsx
@@ -1,4 +1,5 @@
import clsx from 'clsx';
+import { InlineAddToCart } from 'components/cart/inline-add-to-cart';
import { SupportedLocale } from 'components/layout/navbar/language-control';
import { getCollectionProducts } from 'lib/shopify';
import type { Product } from 'lib/shopify/types';
@@ -6,13 +7,17 @@ import Link from 'next/link';
import Label from '../label';
import { GridTileImage } from './tile';
-function ThreeItemGridItem({ item, priority }: { item: Product; priority?: boolean }) {
+function HomepageProductsItem({ item, priority }: { item: Product; priority?: boolean }) {
const size = item?.variants?.[0]?.selectedOptions?.find((option) => option.name === 'Size');
const image = item?.variants?.[0]?.image;
return !!image ? (
-
) : null;
}
-export async function ThreeItemGrid({ lang }: { lang?: SupportedLocale }) {
+export async function HomepageProducts({ lang }: { lang?: SupportedLocale }) {
// Collections that start with `hidden-*` are hidden from the search page.
const homepageItems = await getCollectionProducts({
collection: 'hidden-homepage-featured-items',
@@ -50,14 +56,14 @@ export async function ThreeItemGrid({ lang }: { lang?: SupportedLocale }) {
return (
);
}
diff --git a/components/label.tsx b/components/label.tsx
index 3fbcf3c33..e5af536cd 100644
--- a/components/label.tsx
+++ b/components/label.tsx
@@ -15,7 +15,9 @@ const Label = ({
return (
-
{title}
+
+ {title}
+
+
shop list
-
- {t('shops.subtitle')}
-
+ {t('shops.subtitle')}