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

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

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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
import type { Meta, StoryObj } from '@storybook/react';
import {
    Sheet,
    SheetClose,
    SheetContent,
    SheetDescription,
    SheetFooter,
    SheetHeader,
    SheetTitle,
    SheetTrigger,
} from '@/Components/ui/Sheet';
import { Button } from '@/Components/ui/Button';
import { Input } from '@/Components/ui/Input';
import { Label } from '@/Components/ui/Label';
import { useState } from 'react';
 
const meta = {
    title: 'UI/Sheet',
    component: Sheet,
    parameters: {
        layout: 'centered',
    },
    tags: ['autodocs'],
} satisfies Meta<typeof Sheet>;
 
export default meta;
type Story = StoryObj<typeof meta>;
 
export const Default: Story = {
    render: () => (
        <Sheet>
            <SheetTrigger asChild>
                <Button variant="outline">Open Sheet</Button>
            </SheetTrigger>
            <SheetContent>
                <SheetHeader>
                    <SheetTitle>Are you absolutely sure?</SheetTitle>
                    <SheetDescription>
                        This action cannot be undone. This will permanently delete your account
                        and remove your data from our servers.
                    </SheetDescription>
                </SheetHeader>
            </SheetContent>
        </Sheet>
    ),
};
 
export const WithForm: Story = {
    render: () => (
        <Sheet>
            <SheetTrigger asChild>
                <Button>Edit Profile</Button>
            </SheetTrigger>
            <SheetContent>
                <SheetHeader>
                    <SheetTitle>Edit profile</SheetTitle>
                    <SheetDescription>
                        Make changes to your profile here. Click save when you're done.
                    </SheetDescription>
                </SheetHeader>
                <div className="grid gap-4 py-4">
                    <div className="grid grid-cols-4 items-center gap-4">
                        <Label htmlFor="name" className="text-right">
                            Name
                        </Label>
                        <Input
                            id="name"
                            defaultValue="Pedro Duarte"
                            className="col-span-3"
                        />
                    </div>
                    <div className="grid grid-cols-4 items-center gap-4">
                        <Label htmlFor="username" className="text-right">
                            Username
                        </Label>
                        <Input
                            id="username"
                            defaultValue="@peduarte"
                            className="col-span-3"
                        />
                    </div>
                </div>
                <SheetFooter>
                    <SheetClose asChild>
                        <Button type="submit">Save changes</Button>
                    </SheetClose>
                </SheetFooter>
            </SheetContent>
        </Sheet>
    ),
};
 
export const Sides: Story = {
    render: () => {
        const SHEET_SIDES = ["top", "right", "bottom", "left"] as const;
        
        return (
            <div className="grid grid-cols-2 gap-2">
                {SHEET_SIDES.map((side) => (
                    <Sheet key={side}>
                        <SheetTrigger asChild>
                            <Button variant="outline" className="capitalize">
                                {side}
                            </Button>
                        </SheetTrigger>
                        <SheetContent side={side}>
                            <SheetHeader>
                                <SheetTitle>Sheet on {side}</SheetTitle>
                                <SheetDescription>
                                    This sheet slides in from the {side} side of the screen.
                                </SheetDescription>
                            </SheetHeader>
                        </SheetContent>
                    </Sheet>
                ))}
            </div>
        );
    },
};
 
export const Controlled: Story = {
    render: () => {
        const Component = () => {
            const [open, setOpen] = useState(false);
 
            return (
                <div className="flex flex-col items-center gap-4">
                    <Sheet open={open} onOpenChange={setOpen}>
                        <SheetTrigger asChild>
                            <Button>Open Sheet</Button>
                        </SheetTrigger>
                        <SheetContent>
                            <SheetHeader>
                                <SheetTitle>Controlled Sheet</SheetTitle>
                                <SheetDescription>
                                    This sheet's open state is controlled programmatically.
                                </SheetDescription>
                            </SheetHeader>
                            <div className="py-4">
                                <p className="text-sm text-muted-foreground">
                                    The sheet is currently: {open ? 'Open' : 'Closed'}
                                </p>
                            </div>
                        </SheetContent>
                    </Sheet>
                    <div className="flex gap-2">
                        <Button onClick={() => setOpen(true)} variant="outline">
                            Open Programmatically
                        </Button>
                        <Button onClick={() => setOpen(false)} variant="outline">
                            Close Programmatically
                        </Button>
                    </div>
                </div>
            );
        };
 
        return <Component />;
    },
};
 
export const LongContent: Story = {
    render: () => (
        <Sheet>
            <SheetTrigger asChild>
                <Button>View Terms</Button>
            </SheetTrigger>
            <SheetContent className="w-[400px] sm:w-[540px]">
                <SheetHeader>
                    <SheetTitle>Terms of Service</SheetTitle>
                    <SheetDescription>
                        Last updated: January 1, 2024
                    </SheetDescription>
                </SheetHeader>
                <div className="mt-6 space-y-4 pr-2">
                    <div>
                        <h3 className="font-medium">1. Acceptance of Terms</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            By accessing and using this service, you accept and agree to be bound by the terms and provision of this agreement. If you do not agree to abide by the above, please do not use this service.
                        </p>
                    </div>
                    <div>
                        <h3 className="font-medium">2. Use License</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            Permission is granted to temporarily download one copy of the materials (information or software) on our website for personal, non-commercial transitory viewing only. This is the grant of a license, not a transfer of title.
                        </p>
                    </div>
                    <div>
                        <h3 className="font-medium">3. Disclaimer</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            The materials on our website are provided on an 'as is' basis. We make no warranties, expressed or implied, and hereby disclaim and negate all other warranties including, without limitation, implied warranties or conditions of merchantability, fitness for a particular purpose, or non-infringement of intellectual property or other violation of rights.
                        </p>
                    </div>
                    <div>
                        <h3 className="font-medium">4. Limitations</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            In no event shall our company or its suppliers be liable for any damages (including, without limitation, damages for loss of data or profit, or due to business interruption) arising out of the use or inability to use the materials on our website, even if our company or an authorized representative has been notified orally or in writing of the possibility of such damage.
                        </p>
                    </div>
                    <div>
                        <h3 className="font-medium">5. Privacy Policy</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            Your privacy is important to us. Our Privacy Policy explains how we collect, use, and protect your information when you use our service. By using our service, you agree to the collection and use of information in accordance with our Privacy Policy.
                        </p>
                    </div>
                    <div>
                        <h3 className="font-medium">6. Revisions</h3>
                        <p className="mt-2 text-sm text-muted-foreground">
                            We may revise these terms of service at any time without notice. By using this website, you are agreeing to be bound by the then current version of these terms of service.
                        </p>
                    </div>
                </div>
                <SheetFooter className="mt-6">
                    <SheetClose asChild>
                        <Button variant="outline">Close</Button>
                    </SheetClose>
                    <Button>Accept Terms</Button>
                </SheetFooter>
            </SheetContent>
        </Sheet>
    ),
};
 
export const WithNavigation: Story = {
    render: () => (
        <Sheet>
            <SheetTrigger asChild>
                <Button variant="ghost" size="icon">
                    <svg
                        xmlns="http://www.w3.org/2000/svg"
                        width="24"
                        height="24"
                        viewBox="0 0 24 24"
                        fill="none"
                        stroke="currentColor"
                        strokeWidth="2"
                        strokeLinecap="round"
                        strokeLinejoin="round"
                    >
                        <line x1="3" y1="12" x2="21" y2="12" />
                        <line x1="3" y1="6" x2="21" y2="6" />
                        <line x1="3" y1="18" x2="21" y2="18" />
                    </svg>
                </Button>
            </SheetTrigger>
            <SheetContent side="left">
                <SheetHeader>
                    <SheetTitle>Navigation</SheetTitle>
                </SheetHeader>
                <nav className="mt-6 flex flex-col space-y-1">
                    <a
                        href="#"
                        className="flex items-center rounded-md px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground"
                    >
                        Home
                    </a>
                    <a
                        href="#"
                        className="flex items-center rounded-md px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground"
                    >
                        Products
                    </a>
                    <a
                        href="#"
                        className="flex items-center rounded-md px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground"
                    >
                        Services
                    </a>
                    <a
                        href="#"
                        className="flex items-center rounded-md px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground"
                    >
                        About
                    </a>
                    <a
                        href="#"
                        className="flex items-center rounded-md px-3 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground"
                    >
                        Contact
                    </a>
                </nav>
            </SheetContent>
        </Sheet>
    ),
};
 
export const WithTabs: Story = {
    render: () => (
        <Sheet>
            <SheetTrigger asChild>
                <Button>Account Settings</Button>
            </SheetTrigger>
            <SheetContent className="w-[400px] sm:w-[540px]">
                <SheetHeader>
                    <SheetTitle>Account Settings</SheetTitle>
                    <SheetDescription>
                        Manage your account settings and preferences.
                    </SheetDescription>
                </SheetHeader>
                <div className="mt-6">
                    <div className="flex space-x-1 border-b">
                        <button className="border-b-2 border-primary px-3 pb-2 text-sm font-medium">
                            General
                        </button>
                        <button className="px-3 pb-2 text-sm font-medium text-muted-foreground hover:text-foreground">
                            Security
                        </button>
                        <button className="px-3 pb-2 text-sm font-medium text-muted-foreground hover:text-foreground">
                            Notifications
                        </button>
                    </div>
                    <div className="mt-6 space-y-4">
                        <div>
                            <Label htmlFor="email">Email</Label>
                            <Input
                                id="email"
                                type="email"
                                defaultValue="user@example.com"
                                className="mt-1"
                            />
                        </div>
                        <div>
                            <Label htmlFor="name">Display Name</Label>
                            <Input
                                id="name"
                                defaultValue="John Doe"
                                className="mt-1"
                            />
                        </div>
                        <div>
                            <Label htmlFor="bio">Bio</Label>
                            <textarea
                                id="bio"
                                className="mt-1 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm"
                                placeholder="Tell us about yourself"
                            />
                        </div>
                    </div>
                </div>
                <SheetFooter className="mt-6">
                    <SheetClose asChild>
                        <Button variant="outline">Cancel</Button>
                    </SheetClose>
                    <Button>Save Changes</Button>
                </SheetFooter>
            </SheetContent>
        </Sheet>
    ),
};