From 0964dc52c81cd82c546f0e1ba1041498fabe4d4e Mon Sep 17 00:00:00 2001 From: hta218 Date: Tue, 17 Dec 2024 09:50:40 +0700 Subject: [PATCH 1/2] Remove unused input component --- app/modules/input.tsx | 107 ------------------------------------------ 1 file changed, 107 deletions(-) delete mode 100644 app/modules/input.tsx diff --git a/app/modules/input.tsx b/app/modules/input.tsx deleted file mode 100644 index 9a8051c6..00000000 --- a/app/modules/input.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import { X } from "@phosphor-icons/react"; -import { type VariantProps, cva } from "class-variance-authority"; -import clsx from "clsx"; -import type React from "react"; -import { forwardRef, useState } from "react"; - -interface InputProps - extends VariantProps, - React.InputHTMLAttributes { - variant?: "default" | "search" | "minisearch" | "error"; - suffix?: React.ReactNode; - prefixElement?: React.ReactNode; - onClear?: (event: React.ChangeEvent) => void; -} - -let variants = cva( - "w-full focus-visible:outline-none !shadow-none focus:ring-0", - { - variants: { - variant: { - default: "leading-tight", - search: - "px-0 py-2 text-2xl w-full focus:ring-0 border-x-0 border-t-0 transition border-b-2 border-line focus:border-line-subtle", - minisearch: - "hidden md:inline-block text-left lg:text-right border-b transition border-transparent -mb-px border-x-0 border-t-0 appearance-none px-0 py-1 focus:ring-transparent placeholder:opacity-20 placeholder:text-inherit focus:border-line-subtle", - error: "border-red-500", - }, - }, - }, -); - -/** - * @deprecated - * No need an `Input` component since we only have a few inputs in the theme. - * Just implement where needed. - */ -export let Input = forwardRef( - ( - { - className = "", - type, - variant = "default", - prefixElement, - prefix, - suffix, - onFocus, - onBlur, - onClear, - ...rest - }, - ref, - ) => { - let [focused, setFocused] = useState(false); - let commonClasses = clsx( - "w-full border px-3 py-3", - // focused ? "border-line" : "border-line", - className, - ); - - let handleClear = (e: any) => { - e.preventDefault(); - e.stopPropagation(); - if (e.currentTarget?.previousSibling) { - e.currentTarget.previousSibling.value = ""; - } - if (onClear) onClear(e); - }; - if (type === "search") { - suffix = ; - } - let hasChild = Boolean(prefixElement || suffix); - - let rawInput = ( - { - setFocused(true); - if (onFocus) onFocus(e); - }} - onBlur={(e) => { - setFocused(false); - if (onBlur) onBlur(e); - }} - {...rest} - /> - ); - - return hasChild ? ( -
- {prefixElement} - {rawInput} - {suffix} -
- ) : ( - rawInput - ); - }, -); From 26e777740ecce67365fd8c9f296887ee6451df6a Mon Sep 17 00:00:00 2001 From: hta218 Date: Tue, 17 Dec 2024 09:51:05 +0700 Subject: [PATCH 2/2] Make footer newsletter form work --- app/components/layout/footer.tsx | 79 ++++++++++++++++++++-------- app/routes/($locale).api.customer.ts | 8 +-- 2 files changed, 61 insertions(+), 26 deletions(-) diff --git a/app/components/layout/footer.tsx b/app/components/layout/footer.tsx index 8b8f33a1..a86c587e 100644 --- a/app/components/layout/footer.tsx +++ b/app/components/layout/footer.tsx @@ -6,7 +6,7 @@ import { XLogo, } from "@phosphor-icons/react"; import * as Accordion from "@radix-ui/react-accordion"; -import { Link } from "@remix-run/react"; +import { Link, useFetcher } from "@remix-run/react"; import { Image } from "@shopify/hydrogen"; import { useThemeSettings } from "@weaverse/hydrogen"; import { cva } from "class-variance-authority"; @@ -15,7 +15,7 @@ import { Button } from "~/components/button"; import { useShopMenu } from "~/hooks/use-shop-menu"; import { cn } from "~/lib/cn"; import type { SingleMenuItem } from "~/lib/type"; -import { Input } from "~/modules/input"; +import type { CustomerApiPlayLoad } from "~/routes/($locale).api.customer"; import { CountrySelector } from "./country-selector"; let variants = cva("", { @@ -48,10 +48,6 @@ export function Footer() { addressTitle, storeAddress, storeEmail, - newsletterTitle, - newsletterDescription, - newsletterPlaceholder, - newsletterButtonText, } = useThemeSettings(); let socialItems = [ @@ -81,18 +77,19 @@ export function Footer() {