File size: 9,927 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
  "name": "alert",
  "file": "compositions/ui/alert",
  "snippet": "import { Alert as ChakraAlert } from \"@chakra-ui/react\"\nimport * as React from \"react\"\n\nexport interface AlertProps extends Omit<ChakraAlert.RootProps, \"title\"> {\n  startElement?: React.ReactNode\n  endElement?: React.ReactNode\n  title?: React.ReactNode\n  icon?: React.ReactElement\n}\n\nexport const Alert = React.forwardRef<HTMLDivElement, AlertProps>(\n  function Alert(props, ref) {\n    const { title, children, icon, startElement, endElement, ...rest } = props\n    return (\n      <ChakraAlert.Root ref={ref} {...rest}>\n        {startElement || <ChakraAlert.Indicator>{icon}</ChakraAlert.Indicator>}\n        {children ? (\n          <ChakraAlert.Content>\n            <ChakraAlert.Title>{title}</ChakraAlert.Title>\n            <ChakraAlert.Description>{children}</ChakraAlert.Description>\n          </ChakraAlert.Content>\n        ) : (\n          <ChakraAlert.Title flex=\"1\">{title}</ChakraAlert.Title>\n        )}\n        {endElement}\n      </ChakraAlert.Root>\n    )\n  },\n)\n",
  "examples": [
    {
      "name": "alert-basic",
      "content": "export const AlertBasic = () => {\n  return (\n    <Alert.Root status=\"info\" title=\"This is the alert title\">\n      <Alert.Indicator />\n      <Alert.Title>This is the alert title</Alert.Title>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-closed-component",
      "content": "export interface AlertProps extends Omit<ChakraAlert.RootProps, \"title\"> {\n  startElement?: React.ReactNode\n  endElement?: React.ReactNode\n  title?: React.ReactNode\n  icon?: React.ReactElement\n}\n\nexport const AlertClosedComponent = React.forwardRef<\n  HTMLDivElement,\n  AlertProps\n>(function Alert(props, ref) {\n  const { title, children, icon, startElement, endElement, ...rest } = props\n  return (\n    <ChakraAlert.Root ref={ref} {...rest}>\n      {startElement || <ChakraAlert.Indicator>{icon}</ChakraAlert.Indicator>}\n      {children ? (\n        <ChakraAlert.Content>\n          <ChakraAlert.Title>{title}</ChakraAlert.Title>\n          <ChakraAlert.Description>{children}</ChakraAlert.Description>\n        </ChakraAlert.Content>\n      ) : (\n        <ChakraAlert.Title flex=\"1\">{title}</ChakraAlert.Title>\n      )}\n      {endElement}\n    </ChakraAlert.Root>\n  )\n})\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert as ChakraAlert } from \"@chakra-ui/react\"",
        "import * as React from \"react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-buttons",
      "content": "export const AlertWithButtons = () => {\n  return (\n    <Alert.Root>\n      <Alert.Indicator />\n      <Alert.Content>\n        <Alert.Title>This is the alert title</Alert.Title>\n        <Alert.Description>This is the alert description</Alert.Description>\n      </Alert.Content>\n      <Button size=\"sm\" alignSelf=\"center\">\n        Action\n      </Button>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, Button } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-close-button",
      "content": "export const AlertWithCloseButton = () => {\n  return (\n    <Alert.Root>\n      <Alert.Indicator />\n      <Alert.Content>\n        <Alert.Title>Success!</Alert.Title>\n        <Alert.Description>\n          Your application has been received. We will review your application\n          and respond within the next 48 hours.\n        </Alert.Description>\n      </Alert.Content>\n      <CloseButton pos=\"relative\" top=\"-2\" insetEnd=\"-2\" />\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, CloseButton } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-color-palette-override",
      "content": "export const AlertWithColorPaletteOverride = () => {\n  return (\n    <Alert.Root status=\"info\" colorPalette=\"teal\">\n      <Alert.Indicator />\n      <Alert.Title>This is an info alert but shown as teal</Alert.Title>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-custom-icon",
      "content": "export const AlertWithCustomIcon = () => {\n  return (\n    <Alert.Root status=\"warning\">\n      <Alert.Indicator>\n        <LuAlarmClockPlus />\n      </Alert.Indicator>\n      <Alert.Title>Submitting this form will delete your account</Alert.Title>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert } from \"@chakra-ui/react\"",
        "import { LuAlarmClockPlus } from \"react-icons/lu\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\"",
      "npmDependencies": [
        "react-icons"
      ]
    },
    {
      "name": "alert-with-customization",
      "content": "export const AlertWithCustomization = () => {\n  return (\n    <Stack gap=\"4\">\n      <Alert.Root title=\"Success\" status=\"success\">\n        <Alert.Indicator>\n          <LuPercent />\n        </Alert.Indicator>\n        <Alert.Content color=\"fg\">\n          <Alert.Title>Black Friday Sale (20% off)</Alert.Title>\n          <Alert.Description>\n            Upgrade your plan to get access to the sale.\n          </Alert.Description>\n        </Alert.Content>\n        <Link alignSelf=\"center\" fontWeight=\"medium\">\n          Upgrade\n        </Link>\n      </Alert.Root>\n\n      <Alert.Root\n        size=\"sm\"\n        borderStartWidth=\"3px\"\n        borderStartColor=\"colorPalette.solid\"\n        alignItems=\"center\"\n        title=\"Success\"\n        status=\"success\"\n      >\n        <LuPercent />\n        <Alert.Title textStyle=\"sm\">\n          Heads up: Black Friday Sale (20% off)\n        </Alert.Title>\n      </Alert.Root>\n    </Stack>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, Link, Stack } from \"@chakra-ui/react\"",
        "import { LuPercent } from \"react-icons/lu\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\"",
      "npmDependencies": [
        "react-icons"
      ]
    },
    {
      "name": "alert-with-description",
      "content": "export const AlertWithDescription = () => {\n  return (\n    <Alert.Root status=\"error\">\n      <Alert.Indicator />\n      <Alert.Content>\n        <Alert.Title>Invalid Fields</Alert.Title>\n        <Alert.Description>\n          Your form has some errors. Please fix them and try again.\n        </Alert.Description>\n      </Alert.Content>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-spinner",
      "content": "export const AlertWithSpinner = () => {\n  return (\n    <Alert.Root\n      borderStartWidth=\"3px\"\n      borderStartColor=\"colorPalette.600\"\n      title=\"We are loading something\"\n    >\n      <Alert.Indicator>\n        <Spinner size=\"sm\" />\n      </Alert.Indicator>\n      <Alert.Title>We are loading something</Alert.Title>\n    </Alert.Root>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, Spinner } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-status",
      "content": "export const AlertWithStatus = () => {\n  return (\n    <Stack gap=\"4\" width=\"full\">\n      <Alert.Root status=\"error\">\n        <Alert.Indicator />\n        <Alert.Title>There was an error processing your request</Alert.Title>\n      </Alert.Root>\n\n      <Alert.Root status=\"info\">\n        <Alert.Indicator />\n        <Alert.Title>\n          Chakra is going live on August 30th. Get ready!\n        </Alert.Title>\n      </Alert.Root>\n\n      <Alert.Root status=\"warning\">\n        <Alert.Indicator />\n        <Alert.Title>\n          Seems your account is about expire, upgrade now\n        </Alert.Title>\n      </Alert.Root>\n\n      <Alert.Root status=\"success\">\n        <Alert.Indicator />\n        <Alert.Title>Data uploaded to the server. Fire on!</Alert.Title>\n      </Alert.Root>\n    </Stack>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, Stack } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    },
    {
      "name": "alert-with-variants",
      "content": "export const AlertWithVariants = () => {\n  return (\n    <Stack gap=\"4\">\n      <Alert.Root status=\"success\" variant=\"subtle\">\n        <Alert.Indicator />\n        <Alert.Title>Data uploaded to the server. Fire on!</Alert.Title>\n      </Alert.Root>\n\n      <Alert.Root status=\"success\" variant=\"solid\">\n        <Alert.Indicator />\n        <Alert.Title>Data uploaded to the server. Fire on!</Alert.Title>\n      </Alert.Root>\n\n      <Alert.Root status=\"success\" variant=\"surface\">\n        <Alert.Indicator />\n        <Alert.Title>Data uploaded to the server. Fire on!</Alert.Title>\n      </Alert.Root>\n    </Stack>\n  )\n}\n",
      "hasSnippet": false,
      "importPaths": [
        "import { Alert, Stack } from \"@chakra-ui/react\""
      ],
      "importPath": "import { Alert } from \"@chakra-ui/react\""
    }
  ]
}