alert.stories.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import styled from '@emotion/styled';
  2. import Alert from 'sentry/components/alert';
  3. import Button from 'sentry/components/button';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import space from 'sentry/styles/space';
  6. export default {
  7. title: 'Components/Alerts/Alert',
  8. component: Alert,
  9. parameters: {
  10. controls: {hideNoControlsWarning: true},
  11. },
  12. };
  13. export const Default = () => (
  14. <Grid>
  15. <Alert type="info">
  16. <ExternalLink href="#">Info message with a url</ExternalLink>
  17. </Alert>
  18. <Alert type="success">Success message without a url</Alert>
  19. <Alert type="warning">Warning message</Alert>
  20. <Alert type="error">
  21. Background workers haven't checked in recently. This can mean an issue with your
  22. configuration or a serious backlog in tasks.
  23. </Alert>
  24. </Grid>
  25. );
  26. Default.parameters = {
  27. docs: {
  28. description: {
  29. story: 'Inline alert messages',
  30. },
  31. },
  32. };
  33. export const WithIcons = () => (
  34. <Grid>
  35. <Alert type="info" showIcon>
  36. <ExternalLink href="#">Info message with a url</ExternalLink>
  37. </Alert>
  38. <Alert type="success" showIcon>
  39. Success message without a url
  40. </Alert>
  41. <Alert type="warning" showIcon>
  42. Warning message
  43. </Alert>
  44. <Alert type="error" showIcon>
  45. Background workers haven't checked in recently. This can mean an issue with your
  46. configuration or a serious backlog in tasks.
  47. </Alert>
  48. </Grid>
  49. );
  50. WithIcons.storyName = 'With Leading Icons';
  51. WithIcons.parameters = {
  52. docs: {
  53. description: {
  54. story: 'Optional leading icon via the `showIcon` prop',
  55. },
  56. },
  57. };
  58. export const WithTrailingItems = () => (
  59. <Grid>
  60. <Alert type="info" trailingItems={<Button size="xs">Trailing Button</Button>}>
  61. <ExternalLink href="#">Info message with a url</ExternalLink>
  62. </Alert>
  63. <Alert type="success" trailingItems={<Button size="xs">Trailing Button</Button>}>
  64. Success message without a url
  65. </Alert>
  66. <Alert type="warning" trailingItems={<Button size="xs">Trailing Button</Button>}>
  67. Warning message
  68. </Alert>
  69. <Alert type="error" trailingItems={<Button size="xs">Trailing Button</Button>}>
  70. Background workers haven't checked in recently. This can mean an issue with your
  71. configuration or a serious backlog in tasks.
  72. </Alert>
  73. </Grid>
  74. );
  75. WithTrailingItems.storyName = 'With Trailing Items';
  76. WithTrailingItems.parameters = {
  77. docs: {
  78. description: {
  79. story: 'Optional trailing items via the `trailingItems` prop',
  80. },
  81. },
  82. };
  83. export const System = () => (
  84. <Grid>
  85. <Alert type="info" system>
  86. <ExternalLink href="#">Info message with a url</ExternalLink>
  87. </Alert>
  88. <Alert type="success" system>
  89. Success message without a url
  90. </Alert>
  91. <Alert type="warning" system>
  92. Warning message
  93. </Alert>
  94. <Alert type="error" system>
  95. Background workers haven't checked in recently. This can mean an issue with your
  96. configuration or a serious backlog in tasks.
  97. </Alert>
  98. </Grid>
  99. );
  100. System.parameters = {
  101. docs: {
  102. description: {
  103. story:
  104. 'System-level alert messages that appear at the top of the viewport, or embedded in a panel',
  105. },
  106. },
  107. };
  108. export const Expandable = () => {
  109. return (
  110. <Grid>
  111. <Alert type="info" showIcon expand={[<div key="1">Here is some details</div>]}>
  112. Expandable Alert
  113. </Alert>
  114. </Grid>
  115. );
  116. };
  117. Expandable.storyName = 'Expandable';
  118. Expandable.parameters = {
  119. docs: {
  120. description: {
  121. story: 'Expand with details',
  122. },
  123. },
  124. };
  125. const Grid = styled('div')`
  126. display: grid;
  127. gap: ${space(1)};
  128. `;