From ba1d86a2fe0e94e7a6b9ccd2b362aade346e5921 Mon Sep 17 00:00:00 2001 From: Juunie Roh Date: Fri, 15 Dec 2023 16:10:18 +0900 Subject: [PATCH] feat: mobile menu open feature Added mobile menu feature, adjusted styles. Added storybook of component(next link box) --- package.json | 2 + src/components/NextLinkBox.stories.tsx | 23 ++++++++ src/templates/Main.stories.tsx | 2 +- src/templates/Main.tsx | 76 ++++++++++++++++++++++++-- tsconfig.json | 8 ++- yarn.lock | 14 ++++- 6 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 src/components/NextLinkBox.stories.tsx diff --git a/package.json b/package.json index 6223b74..538db33 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,8 @@ "storybook:build": "storybook build" }, "dependencies": { + "@headlessui/react": "^1.7.17", + "@heroicons/react": "^2.0.18", "@hookform/resolvers": "^3.3.2", "@t3-oss/env-nextjs": "^0.7.1", "next": "14.0.3", diff --git a/src/components/NextLinkBox.stories.tsx b/src/components/NextLinkBox.stories.tsx new file mode 100644 index 0000000..0266150 --- /dev/null +++ b/src/components/NextLinkBox.stories.tsx @@ -0,0 +1,23 @@ +import type { Meta, StoryObj } from '@storybook/react'; + +import { NextLinkBox } from './NextLinkBox'; + +const meta = { + title: 'Example/NextLinkBox', + component: NextLinkBox, + tags: ['autodocs'], + parameters: { + layout: 'fullscreen', + }, +} satisfies Meta; + +export default meta; +type Story = StoryObj; + +export const NextLinkBoxWithProps = { + args: { + href: '#', + title: 'Example Title', + description: 'Example Description', + }, +} satisfies Story; diff --git a/src/templates/Main.stories.tsx b/src/templates/Main.stories.tsx index 9678582..56b4383 100644 --- a/src/templates/Main.stories.tsx +++ b/src/templates/Main.stories.tsx @@ -33,7 +33,7 @@ export const MainWithString = { export const MainWithHomeLink: Story = { play: async ({ canvasElement }) => { const canvas = within(canvasElement); - const loginButton = await canvas.getByRole('link', { + const loginButton = canvas.getByRole('link', { name: /Juun/i, }); diff --git a/src/templates/Main.tsx b/src/templates/Main.tsx index 0ee3c94..d0bbb81 100644 --- a/src/templates/Main.tsx +++ b/src/templates/Main.tsx @@ -1,7 +1,9 @@ +import { Dialog } from '@headlessui/react'; +import { Bars3Icon, XMarkIcon } from '@heroicons/react/24/outline'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router'; -import { type ReactNode } from 'react'; +import { type ReactNode, useState } from 'react'; import { AppConfig } from '@/utils/AppConfig'; @@ -18,6 +20,7 @@ const menuData = [ const Main = (props: IMainProps) => { const router = useRouter(); + const [mobileMenuOpen, setMobileMenuOpen] = useState(false); return (
@@ -26,12 +29,12 @@ const Main = (props: IMainProps) => {
-

+

{AppConfig.title}

{ priority /> + + +
+ +
+

+ {AppConfig.title} +

+ +
+
+
+
+ {menuData.map((menu) => { + return ( + + {menu.name} + + ); + })} +
+
+
+ + By{' '} + Vercel Logo + +
+
+
{props.children} diff --git a/tsconfig.json b/tsconfig.json index 180a020..2bda05c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -46,5 +46,11 @@ } }, "exclude": ["./out/**/*", "./node_modules/**/*"], - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", ".storybook/*.ts"] + "include": [ + "next-env.d.ts", + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts", + ".storybook/*.ts" + ] } diff --git a/yarn.lock b/yarn.lock index 078ba1b..6544185 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1562,6 +1562,18 @@ resolved "https://registry.yarnpkg.com/@floating-ui/utils/-/utils-0.1.6.tgz#22958c042e10b67463997bd6ea7115fe28cbcaf9" integrity sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A== +"@headlessui/react@^1.7.17": + version "1.7.17" + resolved "https://registry.yarnpkg.com/@headlessui/react/-/react-1.7.17.tgz#a0ec23af21b527c030967245fd99776aa7352bc6" + integrity sha512-4am+tzvkqDSSgiwrsEpGWqgGo9dz8qU5M3znCkC4PgkpY4HcCZzEDEvozltGGGHIKl9jbXbZPSH5TWn4sWJdow== + dependencies: + client-only "^0.0.1" + +"@heroicons/react@^2.0.18": + version "2.0.18" + resolved "https://registry.yarnpkg.com/@heroicons/react/-/react-2.0.18.tgz#f80301907c243df03c7e9fd76c0286e95361f7c1" + integrity sha512-7TyMjRrZZMBPa+/5Y8lN0iyvUU/01PeMGX2+RE7cQWpEUIcb4QotzUObFkJDejj/HUH4qjP/eQ0gzzKs2f+6Yw== + "@hookform/resolvers@^3.3.2": version "3.3.2" resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-3.3.2.tgz#5c40f06fe8137390b071d961c66d27ee8f76f3bc" @@ -5599,7 +5611,7 @@ cli-width@^3.0.0: resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-3.0.0.tgz#a2f48437a2caa9a22436e794bf071ec9e61cedf6" integrity sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw== -client-only@0.0.1: +client-only@0.0.1, client-only@^0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1" integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==