activity.stories.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. import ActivityItem from 'sentry/components/activity/item';
  2. import ActivityAvatar from 'sentry/components/activity/item/avatar';
  3. import ActivityBubble from 'sentry/components/activity/item/bubble';
  4. const user = {
  5. username: 'billy@sentry.io',
  6. identities: [],
  7. id: '1',
  8. name: 'billy@sentry.io',
  9. dateJoined: '2019-03-09T06:52:42.836Z',
  10. avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
  11. email: 'billy@sentry.io',
  12. };
  13. export default {
  14. title: 'Views/Activity/Activity Item',
  15. };
  16. export const DefaultActivityItem = ({hideDate}) => (
  17. <ActivityItem
  18. author={{type: 'user', user}}
  19. item={{id: '123'}}
  20. date={new Date()}
  21. header={<div>{user.email}</div>}
  22. hideDate={hideDate}
  23. >
  24. Activity Item
  25. </ActivityItem>
  26. );
  27. DefaultActivityItem.storyName = 'Default';
  28. DefaultActivityItem.args = {
  29. hideDate: false,
  30. };
  31. DefaultActivityItem.parameters = {
  32. docs: {
  33. description: {
  34. story:
  35. 'An Activity Item is composed of: an author, header, body, and additionally timestamp and a status.',
  36. },
  37. },
  38. };
  39. export const WithCustomHeader = ({hideDate}) => (
  40. <ActivityItem
  41. author={{type: 'user', user}}
  42. item={{id: '123'}}
  43. date={new Date()}
  44. header={() => (
  45. <div style={{backgroundColor: '#ccc'}}>Custom header (no timestamp)</div>
  46. )}
  47. hideDate={hideDate}
  48. >
  49. Activity Item
  50. </ActivityItem>
  51. );
  52. WithCustomHeader.storyName = 'with custom Header';
  53. WithCustomHeader.args = {
  54. hideDate: false,
  55. };
  56. WithCustomHeader.parameters = {
  57. docs: {
  58. description: {
  59. story: 'Activity Item with a custom header',
  60. },
  61. },
  62. };
  63. export const WithFooter = ({hideDate}) => (
  64. <ActivityItem
  65. author={{type: 'user', user}}
  66. item={{id: '123'}}
  67. date={new Date()}
  68. header={<div>{user.email}</div>}
  69. footer={<div>Footer</div>}
  70. hideDate={hideDate}
  71. >
  72. Activity Item
  73. </ActivityItem>
  74. );
  75. WithFooter.storyName = 'with footer';
  76. WithFooter.args = {
  77. hideDate: false,
  78. };
  79. WithFooter.parameters = {
  80. docs: {
  81. description: {
  82. story: 'Activity Item with a footer',
  83. },
  84. },
  85. };
  86. export const SystemActivity = ({hideDate}) => (
  87. <ActivityItem
  88. author={{type: 'system'}}
  89. item={{id: '123'}}
  90. date={new Date()}
  91. header={<div>Sentry detected something</div>}
  92. hideDate={hideDate}
  93. >
  94. Sentry did something
  95. </ActivityItem>
  96. );
  97. SystemActivity.storyName = 'system activity';
  98. SystemActivity.args = {
  99. hideDate: false,
  100. };
  101. SystemActivity.parameters = {
  102. docs: {
  103. description: {
  104. story: 'An ActivityItem generated by Sentry',
  105. },
  106. },
  107. };
  108. export const Bubble = ({...args}) => (
  109. <ActivityBubble {...args}>
  110. <div>Activity Bubble</div>
  111. <div>Activity Bubble</div>
  112. <div>Activity Bubble</div>
  113. <div>Activity Bubble</div>
  114. <div>Activity Bubble</div>
  115. </ActivityBubble>
  116. );
  117. Bubble.component = ActivityBubble;
  118. Bubble.args = {
  119. backgroundColor: '#fff',
  120. borderColor: 'red',
  121. };
  122. Bubble.argTypes = {
  123. backgroundColor: {control: 'color'},
  124. borderColor: {control: 'color'},
  125. };
  126. Bubble.parameters = {
  127. docs: {
  128. description: {
  129. story:
  130. 'Activity bubble with arrow at the top-left. This should probably not be used directly unless creating a new component.',
  131. },
  132. },
  133. };
  134. export const Avatar = () => (
  135. <div>
  136. <h3>User</h3>
  137. <ActivityAvatar type="user" user={user} size={48} />
  138. <h3>System</h3>
  139. <ActivityAvatar type="system" size={48} />
  140. </div>
  141. );
  142. Avatar.parameters = {
  143. docs: {
  144. description: {
  145. story: 'Avatar based on the author type.',
  146. },
  147. },
  148. };