FollowerCollection.stories.tsx 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. import React from 'react';
  2. import { ComponentStory, ComponentMeta } from '@storybook/react';
  3. import { RecoilRoot } from 'recoil';
  4. import { action } from '@storybook/addon-actions';
  5. import { FollowerCollection } from './FollowerCollection';
  6. const mocks = {
  7. mocks: [
  8. {
  9. // The "matcher" determines if this
  10. // mock should respond to the current
  11. // call to fetch().
  12. matcher: {
  13. name: 'response',
  14. url: 'glob:/api/followers*',
  15. },
  16. // If the "matcher" matches the current
  17. // fetch() call, the fetch response is
  18. // built using this "response".
  19. response: {
  20. status: 200,
  21. body: {
  22. total: 100,
  23. results: [
  24. {
  25. link: 'https://sun.minuscule.space/users/mardijker',
  26. name: 'mardijker',
  27. username: 'mardijker@sun.minuscule.space',
  28. image:
  29. 'https://sun.minuscule.space/media/336af7ae5a2bcb508308eddb30b661ee2b2e15004a50795ee3ba0653ab190a93.jpg',
  30. timestamp: '2022-04-27T12:12:50Z',
  31. disabledAt: null,
  32. },
  33. {
  34. link: 'https://mastodon.online/users/Kallegro',
  35. name: '',
  36. username: 'Kallegro@mastodon.online',
  37. image: '',
  38. timestamp: '2022-04-26T15:24:09Z',
  39. disabledAt: null,
  40. },
  41. {
  42. link: 'https://mastodon.online/users/kerfuffle',
  43. name: 'Kerfuffle',
  44. username: 'kerfuffle@mastodon.online',
  45. image:
  46. 'https://files.mastodon.online/accounts/avatars/000/133/698/original/6aa73caa898b2d36.gif',
  47. timestamp: '2022-04-25T21:32:41Z',
  48. disabledAt: null,
  49. },
  50. {
  51. link: 'https://mastodon.uno/users/informapirata',
  52. name: 'informapirata :privacypride:',
  53. username: 'informapirata@mastodon.uno',
  54. image:
  55. 'https://cdn.masto.host/mastodonuno/accounts/avatars/000/060/227/original/da4c44c716a339b8.png',
  56. timestamp: '2022-04-25T11:38:23Z',
  57. disabledAt: null,
  58. },
  59. {
  60. link: 'https://gamethattune.club/users/Raeanus',
  61. name: 'Raeanus',
  62. username: 'Raeanus@gamethattune.club',
  63. image:
  64. 'https://gamethattune.club/media/a6e6ccea-34f8-4c2e-b9dc-ad8cca7fafd3/DD14E3BF-1358-4961-A900-42F3495F6BE2.jpeg',
  65. timestamp: '2022-04-23T00:46:56Z',
  66. disabledAt: null,
  67. },
  68. {
  69. link: 'https://mastodon.ml/users/latte',
  70. name: 'Даниил',
  71. username: 'latte@mastodon.ml',
  72. image:
  73. 'https://mastodon.ml/system/accounts/avatars/107/837/409/059/601/386/original/c45ec2676489e363.png',
  74. timestamp: '2022-04-19T13:06:09Z',
  75. disabledAt: null,
  76. },
  77. {
  78. link: 'https://wienermobile.rentals/users/jprjr',
  79. name: 'Johnny',
  80. username: 'jprjr@wienermobile.rentals',
  81. image: '',
  82. timestamp: '2022-04-14T14:48:11Z',
  83. disabledAt: null,
  84. },
  85. {
  86. link: 'https://gamethattune.club/users/johnny',
  87. name: 'John Regan',
  88. username: 'johnny@gamethattune.club',
  89. image:
  90. 'https://gamethattune.club/media/3c10cd89-866b-4604-ae40-39387fe17061/profile_large.jpg',
  91. timestamp: '2022-04-14T14:42:48Z',
  92. disabledAt: null,
  93. },
  94. {
  95. link: 'https://mastodon.social/users/MightyOwlbear',
  96. name: 'Haunted Owlbear',
  97. username: 'MightyOwlbear@mastodon.social',
  98. image:
  99. 'https://files.mastodon.social/accounts/avatars/107/246/961/007/605/352/original/a86fc3db97a6de04.jpg',
  100. timestamp: '2022-04-14T13:33:03Z',
  101. disabledAt: null,
  102. },
  103. {
  104. link: 'https://gamethattune.club/users/thelinkfloyd',
  105. name: 'thelinkfloyd',
  106. username: 'thelinkfloyd@gamethattune.club',
  107. image: '',
  108. timestamp: '2022-04-05T12:23:32Z',
  109. disabledAt: null,
  110. },
  111. {
  112. link: 'https://gamethattune.club/users/TheBaffler',
  113. name: 'TheBaffler',
  114. username: 'TheBaffler@gamethattune.club',
  115. image: '',
  116. timestamp: '2022-04-04T19:50:08Z',
  117. disabledAt: null,
  118. },
  119. {
  120. link: 'https://gamethattune.club/users/Gttjessie',
  121. name: 'Gttjessie',
  122. username: 'Gttjessie@gamethattune.club',
  123. image: '',
  124. timestamp: '2022-03-30T20:18:47Z',
  125. disabledAt: null,
  126. },
  127. {
  128. link: 'https://cybre.space/users/fractal',
  129. name: 'Le fractal',
  130. username: 'fractal@cybre.space',
  131. image:
  132. 'https://cybre.ams3.digitaloceanspaces.com/accounts/avatars/000/405/126/original/f1f2832a7bf1a967.png',
  133. timestamp: '2022-03-30T19:46:17Z',
  134. disabledAt: null,
  135. },
  136. {
  137. link: 'https://fosstodon.org/users/jumboshrimp',
  138. name: 'alex 👑🦐',
  139. username: 'jumboshrimp@fosstodon.org',
  140. image:
  141. 'https://cdn.fosstodon.org/accounts/avatars/000/320/316/original/de43cda8653ade7f.jpg',
  142. timestamp: '2022-03-30T18:09:54Z',
  143. disabledAt: null,
  144. },
  145. {
  146. link: 'https://gamethattune.club/users/nvrslep303',
  147. name: 'Tay',
  148. username: 'nvrslep303@gamethattune.club',
  149. image: 'https://gamethattune.club/media/5cf9bc27-8821-445a-86ce-8aa3704acf2d/pfp.jpg',
  150. timestamp: '2022-03-30T15:27:49Z',
  151. disabledAt: null,
  152. },
  153. {
  154. link: 'https://gamethattune.club/users/anKerrigan',
  155. name: 'anKerrigan',
  156. username: 'anKerrigan@gamethattune.club',
  157. image: '',
  158. timestamp: '2022-03-30T14:47:04Z',
  159. disabledAt: null,
  160. },
  161. {
  162. link: 'https://gamethattune.club/users/jgangsta187',
  163. name: 'jgangsta187',
  164. username: 'jgangsta187@gamethattune.club',
  165. image: '',
  166. timestamp: '2022-03-30T14:42:52Z',
  167. disabledAt: null,
  168. },
  169. {
  170. link: 'https://gamethattune.club/users/aekre',
  171. name: 'aekre',
  172. username: 'aekre@gamethattune.club',
  173. image: '',
  174. timestamp: '2022-03-30T14:41:32Z',
  175. disabledAt: null,
  176. },
  177. {
  178. link: 'https://fosstodon.org/users/owncast',
  179. name: 'Owncast',
  180. username: 'owncast@fosstodon.org',
  181. image:
  182. 'https://cdn.fosstodon.org/accounts/avatars/107/017/218/425/829/465/original/f98ba4cd61f483ab.png',
  183. timestamp: '2022-03-29T21:38:02Z',
  184. disabledAt: null,
  185. },
  186. {
  187. link: 'https://cybre.space/users/wklew',
  188. name: 'wally',
  189. username: 'wklew@cybre.space',
  190. image:
  191. 'https://cybre.ams3.digitaloceanspaces.com/accounts/avatars/000/308/727/original/7453e74f3e09b27b.jpg',
  192. timestamp: '2022-03-29T18:24:29Z',
  193. disabledAt: null,
  194. },
  195. {
  196. link: 'https://mastodon.social/users/nvrslep303',
  197. name: 'Tay',
  198. username: 'nvrslep303@mastodon.social',
  199. image:
  200. 'https://files.mastodon.social/accounts/avatars/108/041/196/166/285/851/original/fc444dd6096381af.jpg',
  201. timestamp: '2022-03-29T18:19:31Z',
  202. disabledAt: null,
  203. },
  204. {
  205. link: 'https://mastodon.social/users/morky',
  206. name: '',
  207. username: 'morky@mastodon.social',
  208. image: '',
  209. timestamp: '2022-03-29T18:17:59Z',
  210. disabledAt: null,
  211. },
  212. {
  213. link: 'https://mastodon.social/users/jgangsta187',
  214. name: 'John H.',
  215. username: 'jgangsta187@mastodon.social',
  216. image: '',
  217. timestamp: '2022-03-29T18:15:48Z',
  218. disabledAt: null,
  219. },
  220. {
  221. link: 'https://fosstodon.org/users/meisam',
  222. name: 'Meisam 🇪🇺:archlinux:',
  223. username: 'meisam@fosstodon.org',
  224. image:
  225. 'https://cdn.fosstodon.org/accounts/avatars/000/264/096/original/54b4e6db97206bda.jpg',
  226. timestamp: '2022-03-29T18:12:21Z',
  227. disabledAt: null,
  228. },
  229. ],
  230. },
  231. },
  232. },
  233. ],
  234. };
  235. const noFollowersMock = {
  236. mocks: [
  237. {
  238. // The "matcher" determines if this
  239. // mock should respond to the current
  240. // call to fetch().
  241. matcher: {
  242. name: 'response',
  243. url: 'glob:/api/followers*',
  244. },
  245. // If the "matcher" matches the current
  246. // fetch() call, the fetch response is
  247. // built using this "response".
  248. response: {
  249. status: 200,
  250. body: {
  251. total: 0,
  252. results: [],
  253. },
  254. },
  255. },
  256. ],
  257. };
  258. export default {
  259. title: 'owncast/Components/Followers/Followers collection',
  260. component: FollowerCollection,
  261. parameters: {
  262. chromatic: { diffThreshold: 0.86 },
  263. },
  264. } as ComponentMeta<typeof FollowerCollection>;
  265. const Template: ComponentStory<typeof FollowerCollection> = (args: object) => (
  266. <RecoilRoot>
  267. <FollowerCollection
  268. onFollowButtonClick={() => {
  269. action('Follow button clicked');
  270. }}
  271. name="Example stream name"
  272. {...args}
  273. />
  274. </RecoilRoot>
  275. );
  276. export const NoFollowers = Template.bind({});
  277. NoFollowers.parameters = {
  278. fetchMock: noFollowersMock,
  279. };
  280. export const Example = Template.bind({});
  281. Example.parameters = {
  282. fetchMock: mocks,
  283. };