import type { Meta, StoryObj } from '@storybook/nextjs-vite';
import { useState } from 'react';
import { fn } from 'storybook/test';
import {
BracketCurlyIcon,
ChartDonutIcon,
IdCardIcon,
MonitorIcon,
Settings02Icon
} from '../components/icons-v2-generated';
import { NavigationSidebar } from '../components/navigation/navigation-sidebar';
import { NavigationSidebarConfig } from '../types/navigation';
// Mock navigation items
const defaultNavigationItems: NavigationSidebarConfig['items'] = [
{
id: 'dashboard',
label: 'Dashboard',
icon: ,
path: '/dashboard',
isActive: true,
},
{
id: 'organizations',
label: 'Organizations',
icon: ,
path: '/organizations',
},
{
id: 'devices',
label: 'Devices',
icon: ,
path: '/devices',
},
{
id: 'scripts',
label: 'Scripts',
icon: ,
path: '/scripts',
},
];
const secondaryNavigationItems: NavigationSidebarConfig['items'] = [
{
id: 'settings',
label: 'Settings',
icon: ,
path: '/settings',
section: 'secondary',
},
];
const allNavigationItems: NavigationSidebarConfig['items'] = [
...defaultNavigationItems,
...secondaryNavigationItems,
];
const meta = {
title: 'Navigation/NavigationSidebar',
component: NavigationSidebar,
parameters: {
layout: 'fullscreen',
docs: {
description: {
component: 'A responsive navigation sidebar component with collapsible functionality, mobile overlay support, and customizable navigation items.',
},
},
},
tags: ['autodocs'],
decorators: [
(Story) => (
Main Content Area
This is where your main content would go. The sidebar will remain fixed on the left.
),
],
args: {
config: {
items: allNavigationItems,
onNavigate: fn(),
onToggleMinimized: fn(),
},
},
} satisfies Meta;
export default meta;
type Story = StoryObj;
/**
* Default expanded sidebar with primary and secondary navigation sections.
*/
export const Default: Story = {
render: (args) => {
const [items, setItems] = useState(args.config.items);
const handleNavigate = (path: string) => {
fn()(path);
setItems(prevItems =>
prevItems.map(item => ({
...item,
isActive: item.path === path,
}))
);
};
return (
);
},
args: {
config: {
items: allNavigationItems,
onNavigate: fn(),
onToggleMinimized: fn(),
},
},
};