panels.stories.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import {Fragment} from 'react';
  2. import Button from 'sentry/components/button';
  3. import Field from 'sentry/components/forms/field';
  4. import {
  5. Panel,
  6. PanelAlert,
  7. PanelBody,
  8. PanelHeader,
  9. PanelItem,
  10. PanelTable,
  11. } from 'sentry/components/panels';
  12. import {IconTelescope} from 'sentry/icons';
  13. import {_BulkController} from './bulkController.stories';
  14. export default {
  15. title: 'Components/Tables/Panels',
  16. args: {
  17. dashedBorder: false,
  18. },
  19. };
  20. export const BasicPanel = ({...args}) => (
  21. <Panel {...args}>
  22. <PanelHeader>Panel Header</PanelHeader>
  23. <PanelBody>
  24. <PanelItem>Panel Item</PanelItem>
  25. <PanelItem>Panel Item</PanelItem>
  26. <PanelItem>Panel Item</PanelItem>
  27. </PanelBody>
  28. </Panel>
  29. );
  30. BasicPanel.parameters = {
  31. docs: {
  32. description: {
  33. story: 'Basic Panel component used in most settings',
  34. },
  35. },
  36. };
  37. export const PanelAlerts = ({...args}) => (
  38. <Panel {...args}>
  39. <PanelHeader>Panel Header</PanelHeader>
  40. <PanelBody>
  41. <PanelAlert type="info">Info Alert message</PanelAlert>
  42. <PanelAlert type="error">Error Alert message</PanelAlert>
  43. <PanelAlert type="warning">Warning Alert message</PanelAlert>
  44. <PanelAlert type="success">Success Alert message</PanelAlert>
  45. <PanelAlert type="info" icon={<IconTelescope size="md" />}>
  46. Custom Icon message
  47. </PanelAlert>
  48. <PanelItem>Panel Item</PanelItem>
  49. </PanelBody>
  50. </Panel>
  51. );
  52. PanelAlerts.parameters = {
  53. docs: {
  54. description: {
  55. story: 'Alert boxes inside a panel',
  56. },
  57. },
  58. };
  59. export const _PanelTable = () => (
  60. <Fragment>
  61. <PanelTable
  62. // eslint-disable-next-line react/jsx-key
  63. headers={[<div>Header #1</div>, 'Header #2', <div>Custom Header Wooooo</div>, '']}
  64. >
  65. <div>Panel Item with really long content</div>
  66. <div>Panel Item</div>
  67. <div>Panel Item</div>
  68. <div>Panel Item</div>
  69. <div>Panel Item</div>
  70. <div>Panel Item</div>
  71. <div>Panel Item</div>
  72. <div>Panel Item</div>
  73. <div>Panel Item</div>
  74. <div>Panel Item</div>
  75. <div>Panel Item</div>
  76. </PanelTable>
  77. <PanelTable headers={['Short', 'Longer heading name', '']}>
  78. <div>One Row</div>
  79. <div>One Row</div>
  80. <div>One Row</div>
  81. </PanelTable>
  82. <PanelTable
  83. isLoading
  84. // eslint-disable-next-line react/jsx-key
  85. headers={[<div>Header #1</div>, 'Header #2', <div>Custom Header Wooooo</div>]}
  86. >
  87. <div>Panel Item</div>
  88. <div>Panel Item</div>
  89. <div>Panel Item</div>
  90. </PanelTable>
  91. <PanelTable
  92. isEmpty
  93. // eslint-disable-next-line react/jsx-key
  94. headers={[<div>Header #1</div>, 'Header #2', <div>Custom Header Wooooo</div>]}
  95. >
  96. <div>Panel Item</div>
  97. <div>Panel Item</div>
  98. <div>Panel Item</div>
  99. </PanelTable>
  100. <_BulkController />
  101. </Fragment>
  102. );
  103. _PanelTable.parameters = {
  104. docs: {
  105. description: {
  106. story: 'A Panel for "tabular" data',
  107. },
  108. },
  109. };
  110. export const WithFields = ({...args}) => (
  111. <Panel {...args}>
  112. <PanelHeader>Panel Header</PanelHeader>
  113. <PanelBody>
  114. <Field label="Label" help="This is a helpful description for this form field">
  115. <Button priority="danger">Remove</Button>
  116. </Field>
  117. <Field
  118. label="Label"
  119. help="Control will fill up all available space, so wrap with a `<div>` to have it behave like an inline-block element."
  120. >
  121. <div>
  122. <Button priority="danger">Remove</Button>
  123. </div>
  124. </Field>
  125. </PanelBody>
  126. </Panel>
  127. );
  128. _PanelTable.parameters = {
  129. docs: {
  130. description: {
  131. story: 'Non-connected form field item',
  132. },
  133. },
  134. };