All files / laravel-saas/resources/js/stories/ui Tabs.stories.tsx

0% Statements 0/473
100% Branches 1/1
100% Functions 1/1
0% Lines 0/473

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
import type { Meta, StoryObj } from '@storybook/react';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/Components/ui/Tabs';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/Components/ui/Card';
import { Label } from '@/Components/ui/Label';
import { Input } from '@/Components/ui/Input';
import { Button } from '@/Components/ui/Button';
import { useState } from 'react';
 
const meta = {
    title: 'UI/Tabs',
    component: Tabs,
    parameters: {
        layout: 'centered',
    },
    tags: ['autodocs'],
    argTypes: {
        defaultValue: {
            control: 'text',
            description: 'The default active tab',
        },
        value: {
            control: 'text',
            description: 'The controlled active tab value',
        },
        orientation: {
            control: 'radio',
            options: ['horizontal', 'vertical'],
            description: 'The orientation of the tabs',
        },
    },
} satisfies Meta<typeof Tabs>;
 
export default meta;
type Story = StoryObj<typeof meta>;
 
export const Default: Story = {
    render: () => (
        <Tabs defaultValue="account" className="w-[400px]">
            <TabsList>
                <TabsTrigger value="account">Account</TabsTrigger>
                <TabsTrigger value="password">Password</TabsTrigger>
            </TabsList>
            <TabsContent value="account">
                <Card>
                    <CardHeader>
                        <CardTitle>Account</CardTitle>
                        <CardDescription>
                            Make changes to your account here. Click save when you're done.
                        </CardDescription>
                    </CardHeader>
                    <CardContent className="space-y-2">
                        <div className="space-y-1">
                            <Label htmlFor="name">Name</Label>
                            <Input id="name" defaultValue="Pedro Duarte" />
                        </div>
                        <div className="space-y-1">
                            <Label htmlFor="username">Username</Label>
                            <Input id="username" defaultValue="@peduarte" />
                        </div>
                    </CardContent>
                </Card>
            </TabsContent>
            <TabsContent value="password">
                <Card>
                    <CardHeader>
                        <CardTitle>Password</CardTitle>
                        <CardDescription>
                            Change your password here. After saving, you'll be logged out.
                        </CardDescription>
                    </CardHeader>
                    <CardContent className="space-y-2">
                        <div className="space-y-1">
                            <Label htmlFor="current">Current password</Label>
                            <Input id="current" type="password" />
                        </div>
                        <div className="space-y-1">
                            <Label htmlFor="new">New password</Label>
                            <Input id="new" type="password" />
                        </div>
                    </CardContent>
                </Card>
            </TabsContent>
        </Tabs>
    ),
};
 
export const WithIcons: Story = {
    render: () => (
        <Tabs defaultValue="dashboard" className="w-[500px]">
            <TabsList className="grid w-full grid-cols-4">
                <TabsTrigger value="dashboard" className="flex items-center gap-2">
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        width="16"
                        height="16"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                    >
                        <rect x="3" y="3" width="7" height="7" />
                        <rect x="14" y="3" width="7" height="7" />
                        <rect x="14" y="14" width="7" height="7" />
                        <rect x="3" y="14" width="7" height="7" />
                    </svg>
                    Dashboard
                </TabsTrigger>
                <TabsTrigger value="analytics" className="flex items-center gap-2">
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        width="16"
                        height="16"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                    >
                        <line x1="12" y1="20" x2="12" y2="10" />
                        <line x1="18" y1="20" x2="18" y2="4" />
                        <line x1="6" y1="20" x2="6" y2="16" />
                    </svg>
                    Analytics
                </TabsTrigger>
                <TabsTrigger value="reports" className="flex items-center gap-2">
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        width="16"
                        height="16"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                    >
                        <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
                        <polyline points="14 2 14 8 20 8" />
                        <line x1="16" y1="13" x2="8" y2="13" />
                        <line x1="16" y1="17" x2="8" y2="17" />
                        <polyline points="10 9 9 9 8 9" />
                    </svg>
                    Reports
                </TabsTrigger>
                <TabsTrigger value="settings" className="flex items-center gap-2">
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        width="16"
                        height="16"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                    >
                        <circle cx="12" cy="12" r="3" />
                        <path d="M12 1v6m0 6v6m4.22-10.22l4.24 4.24m-4.24 4.24l4.24 4.24M20 12h-6m-6 0H2m4.22-4.22L2 3.54m4.22 12.68L2 20.46" />
                    </svg>
                    Settings
                </TabsTrigger>
            </TabsList>
            <TabsContent value="dashboard" className="mt-4">
                <h3 className="text-lg font-medium">Dashboard</h3>
                <p className="text-sm text-muted-foreground">
                    View your dashboard metrics and KPIs.
                </p>
            </TabsContent>
            <TabsContent value="analytics" className="mt-4">
                <h3 className="text-lg font-medium">Analytics</h3>
                <p className="text-sm text-muted-foreground">
                    Analyze your data with detailed charts and insights.
                </p>
            </TabsContent>
            <TabsContent value="reports" className="mt-4">
                <h3 className="text-lg font-medium">Reports</h3>
                <p className="text-sm text-muted-foreground">
                    Generate and download comprehensive reports.
                </p>
            </TabsContent>
            <TabsContent value="settings" className="mt-4">
                <h3 className="text-lg font-medium">Settings</h3>
                <p className="text-sm text-muted-foreground">
                    Configure your application preferences.
                </p>
            </TabsContent>
        </Tabs>
    ),
};
 
export const Controlled: Story = {
    render: () => {
        const Component = () => {
            const [activeTab, setActiveTab] = useState("tab1");
 
            return (
                <div className="space-y-4">
                    <div className="flex gap-2">
                        <Button
                            variant="outline"
                            size="sm"
                            onClick={() => setActiveTab("tab1")}
                        >
                            Go to Tab 1
                        </Button>
                        <Button
                            variant="outline"
                            size="sm"
                            onClick={() => setActiveTab("tab2")}
                        >
                            Go to Tab 2
                        </Button>
                        <Button
                            variant="outline"
                            size="sm"
                            onClick={() => setActiveTab("tab3")}
                        >
                            Go to Tab 3
                        </Button>
                    </div>
                    <Tabs value={activeTab} onValueChange={setActiveTab} className="w-[400px]">
                        <TabsList className="grid w-full grid-cols-3">
                            <TabsTrigger value="tab1">Tab 1</TabsTrigger>
                            <TabsTrigger value="tab2">Tab 2</TabsTrigger>
                            <TabsTrigger value="tab3">Tab 3</TabsTrigger>
                        </TabsList>
                        <TabsContent value="tab1">
                            <Card>
                                <CardHeader>
                                    <CardTitle>Tab 1 Content</CardTitle>
                                </CardHeader>
                                <CardContent>
                                    <p>This is the content for Tab 1.</p>
                                </CardContent>
                            </Card>
                        </TabsContent>
                        <TabsContent value="tab2">
                            <Card>
                                <CardHeader>
                                    <CardTitle>Tab 2 Content</CardTitle>
                                </CardHeader>
                                <CardContent>
                                    <p>This is the content for Tab 2.</p>
                                </CardContent>
                            </Card>
                        </TabsContent>
                        <TabsContent value="tab3">
                            <Card>
                                <CardHeader>
                                    <CardTitle>Tab 3 Content</CardTitle>
                                </CardHeader>
                                <CardContent>
                                    <p>This is the content for Tab 3.</p>
                                </CardContent>
                            </Card>
                        </TabsContent>
                    </Tabs>
                    <p className="text-sm text-muted-foreground">
                        Active tab: {activeTab}
                    </p>
                </div>
            );
        };
 
        return <Component />;
    },
};
 
export const DisabledTab: Story = {
    render: () => (
        <Tabs defaultValue="general" className="w-[400px]">
            <TabsList className="grid w-full grid-cols-4">
                <TabsTrigger value="general">General</TabsTrigger>
                <TabsTrigger value="security">Security</TabsTrigger>
                <TabsTrigger value="integrations" disabled>
                    Integrations
                </TabsTrigger>
                <TabsTrigger value="advanced">Advanced</TabsTrigger>
            </TabsList>
            <TabsContent value="general">
                <Card>
                    <CardHeader>
                        <CardTitle>General Settings</CardTitle>
                    </CardHeader>
                    <CardContent>
                        <p>Configure general application settings.</p>
                    </CardContent>
                </Card>
            </TabsContent>
            <TabsContent value="security">
                <Card>
                    <CardHeader>
                        <CardTitle>Security Settings</CardTitle>
                    </CardHeader>
                    <CardContent>
                        <p>Manage your security preferences.</p>
                    </CardContent>
                </Card>
            </TabsContent>
            <TabsContent value="advanced">
                <Card>
                    <CardHeader>
                        <CardTitle>Advanced Settings</CardTitle>
                    </CardHeader>
                    <CardContent>
                        <p>Configure advanced features and options.</p>
                    </CardContent>
                </Card>
            </TabsContent>
        </Tabs>
    ),
};
 
export const ManyTabs: Story = {
    render: () => (
        <Tabs defaultValue="tab1" className="w-[600px]">
            <TabsList>
                {Array.from({ length: 8 }, (_, i) => (
                    <TabsTrigger key={i} value={`tab${i + 1}`}>
                        Tab {i + 1}
                    </TabsTrigger>
                ))}
            </TabsList>
            {Array.from({ length: 8 }, (_, i) => (
                <TabsContent key={i} value={`tab${i + 1}`}>
                    <Card>
                        <CardHeader>
                            <CardTitle>Tab {i + 1}</CardTitle>
                        </CardHeader>
                        <CardContent>
                            <p>This is the content for Tab {i + 1}.</p>
                        </CardContent>
                    </Card>
                </TabsContent>
            ))}
        </Tabs>
    ),
};
 
export const WithBadges: Story = {
    render: () => (
        <Tabs defaultValue="notifications" className="w-[500px]">
            <TabsList className="grid w-full grid-cols-3">
                <TabsTrigger value="notifications" className="relative">
                    Notifications
                    <span className="ml-2 rounded-full bg-primary px-2 py-0.5 text-xs text-primary-foreground">
                        12
                    </span>
                </TabsTrigger>
                <TabsTrigger value="messages" className="relative">
                    Messages
                    <span className="ml-2 rounded-full bg-destructive px-2 py-0.5 text-xs text-destructive-foreground">
                        3
                    </span>
                </TabsTrigger>
                <TabsTrigger value="activity">Activity</TabsTrigger>
            </TabsList>
            <TabsContent value="notifications">
                <Card>
                    <CardHeader>
                        <CardTitle>Notifications</CardTitle>
                        <CardDescription>You have 12 unread notifications.</CardDescription>
                    </CardHeader>
                    <CardContent>
                        <div className="space-y-2">
                            <div className="flex items-center space-x-2 rounded-md border p-3">
                                <div className="h-2 w-2 rounded-full bg-primary" />
                                <div className="flex-1">
                                    <p className="text-sm font-medium">New comment on your post</p>
                                    <p className="text-xs text-muted-foreground">2 minutes ago</p>
                                </div>
                            </div>
                            <div className="flex items-center space-x-2 rounded-md border p-3">
                                <div className="h-2 w-2 rounded-full bg-primary" />
                                <div className="flex-1">
                                    <p className="text-sm font-medium">New follower</p>
                                    <p className="text-xs text-muted-foreground">1 hour ago</p>
                                </div>
                            </div>
                        </div>
                    </CardContent>
                </Card>
            </TabsContent>
            <TabsContent value="messages">
                <Card>
                    <CardHeader>
                        <CardTitle>Messages</CardTitle>
                        <CardDescription>You have 3 unread messages.</CardDescription>
                    </CardHeader>
                    <CardContent>
                        <div className="space-y-2">
                            <div className="rounded-md border border-destructive/50 bg-destructive/10 p-3">
                                <p className="text-sm font-medium">Urgent: Project deadline tomorrow</p>
                                <p className="text-xs text-muted-foreground">From: John Doe</p>
                            </div>
                            <div className="rounded-md border p-3">
                                <p className="text-sm font-medium">Meeting rescheduled</p>
                                <p className="text-xs text-muted-foreground">From: Jane Smith</p>
                            </div>
                        </div>
                    </CardContent>
                </Card>
            </TabsContent>
            <TabsContent value="activity">
                <Card>
                    <CardHeader>
                        <CardTitle>Recent Activity</CardTitle>
                        <CardDescription>Your activity from the last 7 days.</CardDescription>
                    </CardHeader>
                    <CardContent>
                        <p>No recent activity to show.</p>
                    </CardContent>
                </Card>
            </TabsContent>
        </Tabs>
    ),
};
 
export const FullWidth: Story = {
    render: () => (
        <div className="w-full max-w-4xl">
            <Tabs defaultValue="overview" className="w-full">
                <TabsList className="grid w-full grid-cols-5">
                    <TabsTrigger value="overview">Overview</TabsTrigger>
                    <TabsTrigger value="analytics">Analytics</TabsTrigger>
                    <TabsTrigger value="reports">Reports</TabsTrigger>
                    <TabsTrigger value="notifications">Notifications</TabsTrigger>
                    <TabsTrigger value="settings">Settings</TabsTrigger>
                </TabsList>
                <TabsContent value="overview" className="mt-6">
                    <div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
                        <Card>
                            <CardHeader>
                                <CardTitle>Total Revenue</CardTitle>
                            </CardHeader>
                            <CardContent>
                                <p className="text-2xl font-bold">$45,231.89</p>
                                <p className="text-xs text-muted-foreground">+20.1% from last month</p>
                            </CardContent>
                        </Card>
                        <Card>
                            <CardHeader>
                                <CardTitle>Active Users</CardTitle>
                            </CardHeader>
                            <CardContent>
                                <p className="text-2xl font-bold">2,350</p>
                                <p className="text-xs text-muted-foreground">+180 from last month</p>
                            </CardContent>
                        </Card>
                        <Card>
                            <CardHeader>
                                <CardTitle>Sales</CardTitle>
                            </CardHeader>
                            <CardContent>
                                <p className="text-2xl font-bold">+12,234</p>
                                <p className="text-xs text-muted-foreground">+19% from last month</p>
                            </CardContent>
                        </Card>
                    </div>
                </TabsContent>
                <TabsContent value="analytics" className="mt-6">
                    <Card>
                        <CardHeader>
                            <CardTitle>Analytics Dashboard</CardTitle>
                            <CardDescription>
                                View detailed analytics and insights about your data.
                            </CardDescription>
                        </CardHeader>
                        <CardContent>
                            <p>Analytics content would go here.</p>
                        </CardContent>
                    </Card>
                </TabsContent>
                <TabsContent value="reports" className="mt-6">
                    <Card>
                        <CardHeader>
                            <CardTitle>Reports</CardTitle>
                            <CardDescription>
                                Generate and download various reports.
                            </CardDescription>
                        </CardHeader>
                        <CardContent>
                            <p>Reports content would go here.</p>
                        </CardContent>
                    </Card>
                </TabsContent>
                <TabsContent value="notifications" className="mt-6">
                    <Card>
                        <CardHeader>
                            <CardTitle>Notification Settings</CardTitle>
                            <CardDescription>
                                Configure how you receive notifications.
                            </CardDescription>
                        </CardHeader>
                        <CardContent>
                            <p>Notification settings would go here.</p>
                        </CardContent>
                    </Card>
                </TabsContent>
                <TabsContent value="settings" className="mt-6">
                    <Card>
                        <CardHeader>
                            <CardTitle>General Settings</CardTitle>
                            <CardDescription>
                                Manage your application settings.
                            </CardDescription>
                        </CardHeader>
                        <CardContent>
                            <p>Settings content would go here.</p>
                        </CardContent>
                    </Card>
                </TabsContent>
            </Tabs>
        </div>
    ),
};