From c21a137e1991af1331fe5768fc6bac15ea9230b1 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Wed, 25 Oct 2023 17:23:53 +0200
Subject: refactor(components): extract MainNav component from toolbar

---
 .../organisms/toolbar/main-nav.stories.tsx         | 34 ++++++++++------------
 1 file changed, 15 insertions(+), 19 deletions(-)

(limited to 'src/components/organisms/toolbar/main-nav.stories.tsx')

diff --git a/src/components/organisms/toolbar/main-nav.stories.tsx b/src/components/organisms/toolbar/main-nav.stories.tsx
index 57485d3..d79addf 100644
--- a/src/components/organisms/toolbar/main-nav.stories.tsx
+++ b/src/components/organisms/toolbar/main-nav.stories.tsx
@@ -1,13 +1,13 @@
-import { ComponentMeta, ComponentStory } from '@storybook/react';
-import { useState } from 'react';
-import { MainNav } from './main-nav';
+import type { ComponentMeta, ComponentStory } from '@storybook/react';
+import { useCallback, useState } from 'react';
+import { MainNavItem } from './main-nav';
 
 /**
- * MainNav - Storybook Meta
+ * MainNavItem - Storybook Meta
  */
 export default {
-  title: 'Organisms/Toolbar/MainNav',
-  component: MainNav,
+  title: 'Organisms/Toolbar/MainNavItem',
+  component: MainNavItem,
   argTypes: {
     className: {
       control: {
@@ -54,28 +54,24 @@ export default {
       },
     },
   },
-} as ComponentMeta<typeof MainNav>;
+} as ComponentMeta<typeof MainNavItem>;
 
-const Template: ComponentStory<typeof MainNav> = ({
+const Template: ComponentStory<typeof MainNavItem> = ({
   isActive = false,
   setIsActive: _setIsActive,
   ...args
 }) => {
   const [isOpen, setIsOpen] = useState<boolean>(isActive);
 
-  return (
-    <MainNav
-      isActive={isOpen}
-      setIsActive={() => {
-        setIsOpen(!isOpen);
-      }}
-      {...args}
-    />
-  );
+  const toggle = useCallback(() => {
+    setIsOpen((prevState) => !prevState);
+  }, []);
+
+  return <MainNavItem isActive={isOpen} setIsActive={toggle} {...args} />;
 };
 
 /**
- * MainNav Stories - Inactive
+ * MainNavItem Stories - Inactive
  */
 export const Inactive = Template.bind({});
 Inactive.args = {
@@ -87,7 +83,7 @@ Inactive.args = {
 };
 
 /**
- * MainNav Stories - Active
+ * MainNavItem Stories - Active
  */
 export const Active = Template.bind({});
 Active.args = {
-- 
cgit v1.2.3

