replayPage.stories.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {useState} from 'react';
  2. import SelectControl from 'sentry/components/forms/controls/selectControl';
  3. import {Provider as ReplayContextProvider} from 'sentry/components/replays/replayContext';
  4. import ReplayController from 'sentry/components/replays/replayController';
  5. import ReplayPlayer from 'sentry/components/replays/replayPlayer';
  6. import rrwebEvents1 from './example_rrweb_events_1.json';
  7. import rrwebEvents2 from './example_rrweb_events_2.json';
  8. export default {
  9. title: 'Components/Replays/Replay Page',
  10. component: ReplayPlayer,
  11. };
  12. export const PlayerWithController = () => (
  13. <ReplayContextProvider events={rrwebEvents1}>
  14. <ReplayPlayer />
  15. <ReplayController speedOptions={[0.5, 1, 2, 8]} />
  16. </ReplayContextProvider>
  17. );
  18. export const CustomSpeedOptions = () => (
  19. <ReplayContextProvider events={rrwebEvents1}>
  20. <ReplayPlayer />
  21. <ReplayController speedOptions={[1, 8, 16]} />
  22. </ReplayContextProvider>
  23. );
  24. export const ChangeEventsInput = () => {
  25. const [selected, setSelected] = useState('example_1');
  26. const events = {
  27. example_1: rrwebEvents1,
  28. example_2: rrwebEvents2,
  29. };
  30. return (
  31. <ReplayContextProvider events={events[selected]}>
  32. <SelectControl
  33. label="Input"
  34. value={selected}
  35. onChange={opt => setSelected(opt.value)}
  36. options={[
  37. {value: 'example_1', label: 'Example 1'},
  38. {value: 'example_2', label: 'Example 2'},
  39. ]}
  40. />
  41. <ReplayPlayer />
  42. <ReplayController speedOptions={[1, 8, 16]} />
  43. </ReplayContextProvider>
  44. );
  45. };