diff --git a/frontend/app/element/verticalnav.less b/frontend/app/element/collapsiblemenu.less similarity index 76% rename from frontend/app/element/verticalnav.less rename to frontend/app/element/collapsiblemenu.less index 72f9d9e14..0a37113f5 100644 --- a/frontend/app/element/verticalnav.less +++ b/frontend/app/element/collapsiblemenu.less @@ -3,35 +3,35 @@ @import "../mixins.less"; -.verticalnav { +.collapsible-menu { list-style: none; padding: 0; } -.verticalnav-item { +.collapsible-menu-item { padding: 10px; cursor: pointer; user-select: none; padding: 0; } -.verticalnav-item-button { +.collapsible-menu-item-button { display: flex; align-items: center; justify-content: space-between; width: 100%; } -.verticalnav-item-content { +.collapsible-menu-item-content { display: flex; align-items: center; } -.verticalnav-item-icon { +.collapsible-menu-item-icon { margin-right: 10px; /* Space between icon and text */ } -.verticalnav-item-text { +.collapsible-menu-item-text { .ellipsis(); text-decoration: none; } @@ -49,7 +49,7 @@ display: none; } -.verticalnav-item-button { +.collapsible-menu-item-button { padding: 10px; color: var(--main-text-color); @@ -59,6 +59,6 @@ } } -.verticalnav-item-button.clickable:hover { +.collapsible-menu-item-button.clickable:hover { background-color: #f0f0f0; } diff --git a/frontend/app/element/verticalnav.stories.tsx b/frontend/app/element/collapsiblemenu.stories.tsx similarity index 83% rename from frontend/app/element/verticalnav.stories.tsx rename to frontend/app/element/collapsiblemenu.stories.tsx index 7b6e5f08b..a8fb98656 100644 --- a/frontend/app/element/verticalnav.stories.tsx +++ b/frontend/app/element/collapsiblemenu.stories.tsx @@ -3,13 +3,11 @@ import { Meta, StoryObj } from "@storybook/react"; import { Avatar } from "./avatar"; -import { VerticalNav } from "./verticalnav"; // Updated import to use VerticalNav +import { CollapsibleMenu } from "./collapsiblemenu"; -import "./verticalnav.less"; // Updated stylesheet import - -const meta: Meta = { - title: "Elements/VerticalNav", // Updated title to reflect the component name change - component: VerticalNav, +const meta: Meta = { + title: "Elements/CollapsibleMenu", + component: CollapsibleMenu, argTypes: { items: { control: "object" }, renderItem: { control: false }, @@ -52,7 +50,6 @@ const nestedItems = [ icon: , onClick: () => console.log("Inbox clicked"), subItems: [ - // Updated `children` to `subItems` to match the new type { label: "Starred", icon: , @@ -80,7 +77,7 @@ const nestedItems = [ const customRenderItem = ( item: MenuItem, isOpen: boolean, - handleClick: (e: React.MouseEvent, item: MenuItem, itemKey: string) => void // Updated to pass the correct signature + handleClick: (e: React.MouseEvent, item: MenuItem, itemKey: string) => void ) => (
handleClick(e, item, `${item.label}`)}> @@ -99,7 +96,7 @@ export const Default: Story = { }, render: (args) => ( - + ), }; @@ -110,7 +107,7 @@ export const NestedList: Story = { }, render: (args) => ( - + ), }; @@ -122,7 +119,7 @@ export const CustomRender: Story = { }, render: (args) => ( - + ), }; @@ -133,7 +130,7 @@ export const WithClickHandlers: Story = { }, render: (args) => ( - + ), }; @@ -144,7 +141,7 @@ export const NestedWithClickHandlers: Story = { }, render: (args) => ( - + ), }; @@ -171,14 +168,3 @@ const avatarItems = [ onClick: () => console.log("Alice Lambert clicked"), }, ]; - -export const WithAvatars: Story = { - args: { - items: avatarItems, - }, - render: (args) => ( - - {/* Updated to use VerticalNav */} - - ), -}; diff --git a/frontend/app/element/verticalnav.tsx b/frontend/app/element/collapsiblemenu.tsx similarity index 75% rename from frontend/app/element/verticalnav.tsx rename to frontend/app/element/collapsiblemenu.tsx index 53ace202e..6dd3385ce 100644 --- a/frontend/app/element/verticalnav.tsx +++ b/frontend/app/element/collapsiblemenu.tsx @@ -3,7 +3,7 @@ import clsx from "clsx"; import React, { memo, useState } from "react"; -import "./verticalnav.less"; +import "./collapsiblemenu.less"; interface VerticalNavProps { items: MenuItem[]; @@ -15,7 +15,7 @@ interface VerticalNavProps { ) => React.ReactNode; } -const VerticalNav = memo(({ items, className, renderItem }: VerticalNavProps) => { +const CollapsibleMenu = memo(({ items, className, renderItem }: VerticalNavProps) => { const [open, setOpen] = useState<{ [key: string]: boolean }>({}); // Helper function to generate a unique key for each item based on its path in the hierarchy @@ -34,19 +34,19 @@ const VerticalNav = memo(({ items, className, renderItem }: VerticalNavProps) => const hasChildren = item.subItems && item.subItems.length > 0; return ( -
  • +
  • {renderItem ? ( renderItem(item, isOpen, (e) => handleClick(e, item, itemKey)) ) : ( -
    handleClick(e, item, itemKey)}> +
    handleClick(e, item, itemKey)}>
    - {item.icon &&
    {item.icon}
    } -
    {item.label}
    + {item.icon &&
    {item.icon}
    } +
    {item.label}
    {hasChildren && ( @@ -65,12 +65,12 @@ const VerticalNav = memo(({ items, className, renderItem }: VerticalNavProps) => }; return ( -
      +
        {items.map((item, index) => renderListItem(item, index, "root"))}
      ); }); -VerticalNav.displayName = "VerticalNav"; +CollapsibleMenu.displayName = "CollapsibleMenu"; -export { VerticalNav }; +export { CollapsibleMenu }; diff --git a/frontend/app/view/chat/channels.tsx b/frontend/app/view/chat/channels.tsx index dc9ef3459..52d55b0ea 100644 --- a/frontend/app/view/chat/channels.tsx +++ b/frontend/app/view/chat/channels.tsx @@ -1,10 +1,10 @@ // Copyright 2024, Command Line Inc. // SPDX-License-Identifier: Apache-2.0 -import { VerticalNav } from "@/app/element/verticalnav"; +import { CollapsibleMenu } from "@/app/element/collapsiblemenu"; import "./channels.less"; const Channels = ({ channels }: { channels: MenuItem[] }) => { - return ; + return ; }; export { Channels };