_activity.stories.js 3.5 KB

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