activity.stories.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import React from 'react';
  2. import {boolean, color} from '@storybook/addon-knobs';
  3. import {storiesOf} from '@storybook/react';
  4. import {withInfo} from '@storybook/addon-info';
  5. import ActivityAvatar from 'app/components/activity/item/avatar';
  6. import ActivityBubble from 'app/components/activity/item/bubble';
  7. import ActivityItem from 'app/components/activity/item';
  8. const user = {
  9. username: 'billy@sentry.io',
  10. identities: [],
  11. id: '1',
  12. name: 'billy@sentry.io',
  13. dateJoined: '2019-03-09T06:52:42.836Z',
  14. avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
  15. email: 'billy@sentry.io',
  16. };
  17. storiesOf('UI|Activity/Item', module)
  18. .add(
  19. 'default ActivityItem',
  20. withInfo(
  21. 'An Activity Item is composed of: an author, header, body, and additionally timestamp and a status.'
  22. )(() => (
  23. <ActivityItem
  24. author={{type: 'user', user}}
  25. item={{id: '123'}}
  26. date={new Date()}
  27. header={<div>{user.email}</div>}
  28. hideDate={boolean('Hide Date', false)}
  29. >
  30. Activity Item
  31. </ActivityItem>
  32. ))
  33. )
  34. .add(
  35. 'with custom Header',
  36. withInfo('Activity Item with a custom header')(() => (
  37. <ActivityItem
  38. author={{type: 'user', user}}
  39. item={{id: '123'}}
  40. date={new Date()}
  41. header={() => (
  42. <div style={{backgroundColor: '#ccc'}}>Custom header (no timestamp)</div>
  43. )}
  44. >
  45. Activity Item
  46. </ActivityItem>
  47. ))
  48. )
  49. .add(
  50. 'with footer',
  51. withInfo('Activity Item with a footer')(() => (
  52. <ActivityItem
  53. author={{type: 'user', user}}
  54. item={{id: '123'}}
  55. date={new Date()}
  56. hideDate={boolean('Hide Date', false)}
  57. header={<div>{user.email}</div>}
  58. footer={<div>Footer</div>}
  59. >
  60. Activity Item
  61. </ActivityItem>
  62. ))
  63. )
  64. .add(
  65. 'system activity',
  66. withInfo('An ActivityItem generated by Sentry')(() => (
  67. <ActivityItem
  68. author={{type: 'system'}}
  69. item={{id: '123'}}
  70. date={new Date()}
  71. header={<div>Sentry detected something</div>}
  72. hideDate={boolean('Hide Date', false)}
  73. >
  74. Sentry did something
  75. </ActivityItem>
  76. ))
  77. );
  78. storiesOf('UI|Activity/Item/Components', module)
  79. .add(
  80. 'Bubble',
  81. withInfo(
  82. 'Activity bubble with arrow at the top-left. This should probably not be used directly unless creating a new component.'
  83. )(() => (
  84. <ActivityBubble
  85. backgroundColor={color('Background', '#fff')}
  86. borderColor={color('Border', 'red')}
  87. >
  88. <div>Activity Bubble</div>
  89. <div>Activity Bubble</div>
  90. <div>Activity Bubble</div>
  91. <div>Activity Bubble</div>
  92. <div>Activity Bubble</div>
  93. </ActivityBubble>
  94. ))
  95. )
  96. .add(
  97. 'Avatar',
  98. withInfo('Avatar based on the author type.')(() => (
  99. <div>
  100. <h3>User</h3>
  101. <ActivityAvatar type="user" user={user} size={48} />
  102. <h3>System</h3>
  103. <ActivityAvatar type="system" size={48} />
  104. </div>
  105. ))
  106. );