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

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

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                                                                                                                                                                                                                                                                                                                                                                                                                                               
import type { Meta, StoryObj } from '@storybook/react';
import { Alert, AlertTitle, AlertDescription } from './Alert';
import { AlertTriangle, CheckCircle, Info, XCircle, AlertCircle } from 'lucide-react';
 
const meta = {
  title: 'UI/Alert',
  component: Alert,
  parameters: {
    layout: 'centered',
  },
  tags: ['autodocs'],
  argTypes: {
    variant: {
      control: 'select',
      options: ['default', 'destructive', 'success', 'warning', 'error'],
    },
  },
} satisfies Meta<typeof Alert>;
 
export default meta;
type Story = StoryObj<typeof meta>;
 
export const Default: Story = {
  render: () => (
    <Alert className="w-[400px]">
      <Info className="h-4 w-4" />
      <AlertTitle>Heads up!</AlertTitle>
      <AlertDescription>
        You can add components to your app using the cli.
      </AlertDescription>
    </Alert>
  ),
};
 
export const Destructive: Story = {
  render: () => (
    <Alert variant="destructive" className="w-[400px]">
      <XCircle className="h-4 w-4" />
      <AlertTitle>Error</AlertTitle>
      <AlertDescription>
        Your session has expired. Please log in again.
      </AlertDescription>
    </Alert>
  ),
};
 
export const Success: Story = {
  render: () => (
    <Alert variant="success" className="w-[400px]">
      <CheckCircle className="h-4 w-4" />
      <AlertTitle>Success</AlertTitle>
      <AlertDescription>
        Your account has been created successfully.
      </AlertDescription>
    </Alert>
  ),
};
 
export const Warning: Story = {
  render: () => (
    <Alert variant="warning" className="w-[400px]">
      <AlertTriangle className="h-4 w-4" />
      <AlertTitle>Warning</AlertTitle>
      <AlertDescription>
        This action cannot be undone. Please proceed with caution.
      </AlertDescription>
    </Alert>
  ),
};
 
export const Error: Story = {
  render: () => (
    <Alert variant="error" className="w-[400px]">
      <AlertCircle className="h-4 w-4" />
      <AlertTitle>Error</AlertTitle>
      <AlertDescription>
        Failed to process your request. Please try again later.
      </AlertDescription>
    </Alert>
  ),
};
 
export const WithoutTitle: Story = {
  render: () => (
    <Alert className="w-[400px]">
      <Info className="h-4 w-4" />
      <AlertDescription>
        This is an alert without a title. It only contains a description.
      </AlertDescription>
    </Alert>
  ),
};
 
export const WithoutIcon: Story = {
  render: () => (
    <Alert className="w-[400px]">
      <AlertTitle>No Icon Alert</AlertTitle>
      <AlertDescription>
        This alert doesn't have an icon. It's still perfectly functional.
      </AlertDescription>
    </Alert>
  ),
};
 
export const LongContent: Story = {
  render: () => (
    <Alert className="w-[400px]">
      <Info className="h-4 w-4" />
      <AlertTitle>Long Content Alert</AlertTitle>
      <AlertDescription>
        This is an alert with a longer description to demonstrate how the component 
        handles multiple lines of text. The content wraps nicely and maintains proper 
        spacing and alignment with the icon. You can include multiple paragraphs or 
        even lists if needed.
      </AlertDescription>
    </Alert>
  ),
};
 
export const MinimalAlert: Story = {
  render: () => (
    <Alert className="w-[400px]">
      <AlertDescription>
        Minimal alert with just a description.
      </AlertDescription>
    </Alert>
  ),
};
 
export const AllVariants: Story = {
  render: () => (
    <div className="space-y-4 w-[400px]">
      <div className="text-lg font-semibold">Alert Variants</div>
      
      <Alert>
        <Info className="h-4 w-4" />
        <AlertTitle>Default</AlertTitle>
        <AlertDescription>
          This is a default alert variant.
        </AlertDescription>
      </Alert>
      
      <Alert variant="destructive">
        <XCircle className="h-4 w-4" />
        <AlertTitle>Destructive</AlertTitle>
        <AlertDescription>
          This is a destructive alert variant.
        </AlertDescription>
      </Alert>
      
      <Alert variant="success">
        <CheckCircle className="h-4 w-4" />
        <AlertTitle>Success</AlertTitle>
        <AlertDescription>
          This is a success alert variant.
        </AlertDescription>
      </Alert>
      
      <Alert variant="warning">
        <AlertTriangle className="h-4 w-4" />
        <AlertTitle>Warning</AlertTitle>
        <AlertDescription>
          This is a warning alert variant.
        </AlertDescription>
      </Alert>
      
      <Alert variant="error">
        <AlertCircle className="h-4 w-4" />
        <AlertTitle>Error</AlertTitle>
        <AlertDescription>
          This is an error alert variant.
        </AlertDescription>
      </Alert>
    </div>
  ),
};
 
export const UsageExamples: Story = {
  render: () => (
    <div className="space-y-4 w-[400px]">
      <div className="text-lg font-semibold">Usage Examples</div>
      
      <Alert variant="success">
        <CheckCircle className="h-4 w-4" />
        <AlertTitle>Payment Successful</AlertTitle>
        <AlertDescription>
          Your payment of $99.99 has been processed successfully.
        </AlertDescription>
      </Alert>
      
      <Alert variant="warning">
        <AlertTriangle className="h-4 w-4" />
        <AlertTitle>Storage Almost Full</AlertTitle>
        <AlertDescription>
          You've used 95% of your storage space. Consider upgrading your plan.
        </AlertDescription>
      </Alert>
      
      <Alert variant="error">
        <XCircle className="h-4 w-4" />
        <AlertTitle>Connection Failed</AlertTitle>
        <AlertDescription>
          Unable to connect to the server. Please check your internet connection.
        </AlertDescription>
      </Alert>
      
      <Alert>
        <Info className="h-4 w-4" />
        <AlertTitle>New Features Available</AlertTitle>
        <AlertDescription>
          We've added new features to enhance your experience. Check them out!
        </AlertDescription>
      </Alert>
    </div>
  ),
};