|
| 1 | +import React from 'react'; |
| 2 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 3 | +import { fn } from '@storybook/test'; |
| 4 | + |
| 5 | +import { Navbar } from '@concepta/react-material-ui'; |
| 6 | +import { Box, MenuItem } from '@mui/material'; |
| 7 | + |
| 8 | +const meta = { |
| 9 | + component: Navbar, |
| 10 | + tags: ['autodocs'], |
| 11 | + args: { |
| 12 | + text: 'John Doe', |
| 13 | + subText: 'Admin', |
| 14 | + }, |
| 15 | + argTypes: { |
| 16 | + drawerToggle: { |
| 17 | + type: 'function', |
| 18 | + description: 'Function to call when the drawer toggle button is clicked', |
| 19 | + }, |
| 20 | + showNotifications: { |
| 21 | + control: 'boolean', |
| 22 | + description: 'Whether to show the notifications icon', |
| 23 | + }, |
| 24 | + notificationsNumber: { |
| 25 | + control: 'number', |
| 26 | + description: 'Number of notifications to display', |
| 27 | + }, |
| 28 | + notificationsOnClick: { |
| 29 | + type: 'function', |
| 30 | + description: 'Function to call when the notifications icon is clicked', |
| 31 | + }, |
| 32 | + avatar: { control: 'text', description: 'URL of the user avatar' }, |
| 33 | + text: { |
| 34 | + control: 'text', |
| 35 | + description: 'Text to display next to the avatar', |
| 36 | + }, |
| 37 | + subText: { |
| 38 | + control: 'text', |
| 39 | + description: 'Subtext to display below the text', |
| 40 | + }, |
| 41 | + headerMenuOptions: { |
| 42 | + type: 'function', |
| 43 | + description: |
| 44 | + 'Function to render the dropdown menu options and handle the close action', |
| 45 | + }, |
| 46 | + }, |
| 47 | +} satisfies Meta<typeof Navbar>; |
| 48 | + |
| 49 | +export default meta; |
| 50 | + |
| 51 | +type Story = StoryObj<typeof meta>; |
| 52 | + |
| 53 | +export const Default: Story = { |
| 54 | + args: { |
| 55 | + showNotifications: true, |
| 56 | + notificationsNumber: 8, |
| 57 | + notificationsOnClick: fn(), |
| 58 | + avatar: 'https://picsum.photos/40/40', |
| 59 | + }, |
| 60 | +}; |
| 61 | + |
| 62 | +/** |
| 63 | + * Please preview it in a mobile viewPort to see the drawer toggle button. |
| 64 | + */ |
| 65 | +export const NavbarWithDrawerToggle: Story = { |
| 66 | + parameters: { viewport: { defaultViewport: 'mobile1' } }, |
| 67 | + args: { |
| 68 | + drawerToggle: fn(), |
| 69 | + }, |
| 70 | +}; |
| 71 | + |
| 72 | +export const NavbarWithNotifications: Story = { |
| 73 | + args: { |
| 74 | + showNotifications: true, |
| 75 | + notificationsNumber: 3, |
| 76 | + }, |
| 77 | +}; |
| 78 | + |
| 79 | +export const NavbarWithUserAccountInfo: Story = { |
| 80 | + args: { |
| 81 | + avatar: 'https://picsum.photos/40/40', |
| 82 | + text: 'John Doe', |
| 83 | + subText: 'Admin', |
| 84 | + }, |
| 85 | +}; |
| 86 | + |
| 87 | +export const NavbarWithCustomStyles: Story = { |
| 88 | + args: { |
| 89 | + sx: { |
| 90 | + backgroundColor: '#93d6ff', |
| 91 | + color: 'white', |
| 92 | + padding: '16px 32px', |
| 93 | + }, |
| 94 | + }, |
| 95 | +}; |
| 96 | + |
| 97 | +export const NavbarWithClickableNotifications: Story = { |
| 98 | + args: { |
| 99 | + showNotifications: true, |
| 100 | + notificationsNumber: 5, |
| 101 | + notificationsOnClick: fn(), |
| 102 | + }, |
| 103 | +}; |
| 104 | + |
| 105 | +export const NavbarWithDropdownMenu: Story = { |
| 106 | + args: { |
| 107 | + avatar: 'https://picsum.photos/40/40', |
| 108 | + text: 'John Doe', |
| 109 | + subText: 'Admin', |
| 110 | + headerMenuOptions: (handleClose) => ( |
| 111 | + <Box> |
| 112 | + <MenuItem onClick={handleClose}>Profile</MenuItem> |
| 113 | + <MenuItem onClick={handleClose}>My account</MenuItem> |
| 114 | + <MenuItem onClick={handleClose}>Logout</MenuItem> |
| 115 | + </Box> |
| 116 | + ), |
| 117 | + }, |
| 118 | +}; |
0 commit comments