From 2666572936c48922be2e7c7e0a2ec98b258576a7 Mon Sep 17 00:00:00 2001 From: Mike Velko <44818580+mikevelko@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:49:46 +0200 Subject: [PATCH] modal measurements wip (#115) * modal measurements wip * underlined button * fixes * change naming --------- Co-authored-by: maksim hodasevich --- src/app/not-found.tsx | 2 +- src/app/product/[...productParams]/page.tsx | 21 ++++++++++-- src/components/cart/CartPopup.tsx | 2 +- .../global/Header/useMobileMenu.tsx | 12 +++---- src/components/layouts/CoreLayout.tsx | 10 +++--- .../product/MeasurementsModalContent.tsx | 33 +++++++++++++++++++ src/components/ui/Button/button.stories.ts | 11 +++++-- src/components/ui/Button/styles.tsx | 13 ++++++++ src/components/ui/Modal/index.tsx | 33 +++++++++++++++++++ 9 files changed, 119 insertions(+), 18 deletions(-) create mode 100644 src/components/product/MeasurementsModalContent.tsx create mode 100644 src/components/ui/Modal/index.tsx diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 01442de1..b4bdb597 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -17,7 +17,7 @@ export default function NotFound() { please go back to the homepage or contact us if the problem persists.

- + } + > + + +
+ {baseCurrencyPrice && product?.product?.slug && product?.sizes?.length && ( diff --git a/src/components/cart/CartPopup.tsx b/src/components/cart/CartPopup.tsx index de3f2a9e..e4657032 100644 --- a/src/components/cart/CartPopup.tsx +++ b/src/components/cart/CartPopup.tsx @@ -27,7 +27,7 @@ export default function CartPopup({
diff --git a/src/components/global/Header/useMobileMenu.tsx b/src/components/global/Header/useMobileMenu.tsx index 084a9fd5..1e9c8052 100644 --- a/src/components/global/Header/useMobileMenu.tsx +++ b/src/components/global/Header/useMobileMenu.tsx @@ -1,7 +1,7 @@ "use client"; -import { Dispatch, SetStateAction, useState } from "react"; import { useClickAway } from "@uidotdev/usehooks"; +import { Dispatch, SetStateAction, useState } from "react"; import Button from "@/components/ui/Button"; import { ButtonStyle } from "@/components/ui/Button/styles"; @@ -49,19 +49,19 @@ function MobileMenuDropdown({ {"[x]"} diff --git a/src/components/layouts/CoreLayout.tsx b/src/components/layouts/CoreLayout.tsx index f623b692..562e9b02 100644 --- a/src/components/layouts/CoreLayout.tsx +++ b/src/components/layouts/CoreLayout.tsx @@ -28,13 +28,13 @@ export default function CoreLayout({
@@ -64,10 +64,10 @@ export default function CoreLayout({
- - diff --git a/src/components/product/MeasurementsModalContent.tsx b/src/components/product/MeasurementsModalContent.tsx new file mode 100644 index 00000000..c73193f6 --- /dev/null +++ b/src/components/product/MeasurementsModalContent.tsx @@ -0,0 +1,33 @@ +"use client"; +import { useLockBodyScroll } from "@uidotdev/usehooks"; + +export default function MeasurementsModalContent() { + useLockBodyScroll(); + return ( +
+
Image placeholder
+
+
+
measurements
+
+
xs
+
s
+
...buttons here taken from dictionary
+
+
+
+
length
+
chest
+
shoulders
+
+
+
74cm
+
74cm
+
...values taken from dictionary
+
+
+
+
+
+ ); +} diff --git a/src/components/ui/Button/button.stories.ts b/src/components/ui/Button/button.stories.ts index 7885c51a..5152c0f0 100644 --- a/src/components/ui/Button/button.stories.ts +++ b/src/components/ui/Button/button.stories.ts @@ -1,6 +1,6 @@ -import type { Meta, StoryObj } from "@storybook/react"; -import { ButtonStyle } from "@/components/ui/Button/styles"; import Button from "@/components/ui/Button"; +import { ButtonStyle } from "@/components/ui/Button/styles"; +import type { Meta, StoryObj } from "@storybook/react"; const meta = { title: "UI/Button", @@ -37,6 +37,13 @@ export const UnderlinedButton: Story = { }, }; +export const UnderlinedHightlightButton: Story = { + args: { + style: ButtonStyle.underlinedHightlightButton, + children: "underlined hightlight button", + }, +}; + export const SimpleButton: Story = { args: { style: ButtonStyle.simpleButton, diff --git a/src/components/ui/Button/styles.tsx b/src/components/ui/Button/styles.tsx index 419a3901..ef219ece 100644 --- a/src/components/ui/Button/styles.tsx +++ b/src/components/ui/Button/styles.tsx @@ -2,6 +2,7 @@ export enum ButtonStyle { default = "default", bigButton = "bigButton", underlinedButton = "underlinedButton", + underlinedHightlightButton = "underlinedHightlightButton", simpleButton = "simpleButton", } @@ -14,6 +15,16 @@ function DefaultStyleComponent({ children }: StyleComponentType) { } function UnderlinedButtonStyleComponent({ children }: StyleComponentType) { + return ( + + {children} + + ); +} + +function UnderlinedHightlightButtonStyleComponent({ + children, +}: StyleComponentType) { return ( {children} @@ -39,6 +50,8 @@ function SimpleButtonStyleComponent({ children }: StyleComponentType) { const componentsStyleMap: Record = { [ButtonStyle.underlinedButton]: UnderlinedButtonStyleComponent, + [ButtonStyle.underlinedHightlightButton]: + UnderlinedHightlightButtonStyleComponent, [ButtonStyle.bigButton]: BigButtonStyleComponent, [ButtonStyle.default]: DefaultStyleComponent, [ButtonStyle.simpleButton]: SimpleButtonStyleComponent, diff --git a/src/components/ui/Modal/index.tsx b/src/components/ui/Modal/index.tsx new file mode 100644 index 00000000..df6144d9 --- /dev/null +++ b/src/components/ui/Modal/index.tsx @@ -0,0 +1,33 @@ +"use client"; + +import { useState } from "react"; + +export default function Modal({ + children, + openElement, +}: { + children: React.ReactNode; + openElement: React.ReactNode; +}) { + const [isModalOpen, setModalOpen] = useState(false); + + const openModal = () => setModalOpen(true); + const closeModal = () => setModalOpen(false); + + return ( +
+
{openElement}
+ {isModalOpen && ( +
+ + {children} +
+ )} +
+ ); +}