Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. import React from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import Provider, {initialState} from './util/provider';
  4. import LanguageProvider from '../src/App/hoc/language';
  5. import Game from '../src/App/game';
  6.  
  7. import * as GameActions from '../src/store/brisca/actions';
  8.  
  9. let GameWithLanguage = (props) => {
  10. return (<LanguageProvider><Game {...props} /></LanguageProvider>);
  11. }
  12.  
  13. export default () => {
  14. storiesOf('Game Page', module)
  15. .addDecorator((bundle) => {
  16. const {story, state = {}, action = null} = bundle();
  17. return <Provider story={story()}
  18. state={initialState()}
  19. onMount={(reduxStore) => {
  20. let store = reduxStore;
  21. setTimeout((function() {
  22. if (action) {
  23. this.store.dispatch(action);
  24. }
  25. }).bind({store}), 1000);
  26. }} />;
  27. })
  28. .add('loading', (props) => {
  29. return {
  30. story: () => <GameWithLanguage {...props} params={{gameId: "not loaded"}}/>
  31. }
  32. })
  33. .add('waiting', (props) => {
  34. return {
  35. story: () => <GameWithLanguage {...props} params={{gameId: "2"}} /> ,
  36. };
  37. })
  38. .add('waiting init', (props) => {
  39. return {
  40. story: () => <GameWithLanguage {...props} params={{gameId: "2"}} /> ,
  41. action: GameActions.gameReceive("2", (initialState()).briscas.games["first"])
  42. };
  43. })
  44. .add('game', (props) => {
  45. return {
  46. story: () => <GameWithLanguage {...props} params={{gameId: "play"}} />
  47. };
  48. })
  49. .add('game init', (props) => {
  50. return {
  51. story: () => <GameWithLanguage {...props} params={{gameId: "loading"}} /> ,
  52. action: GameActions.gameReceive("loading", (initialState()).briscas.games["first"])
  53. };
  54. })
  55. .add('game turn', (props) => {
  56. return {
  57. story: () => <GameWithLanguage {...props} params={{gameId: "first"}} /> ,
  58. action: GameActions.gameReceive("first", (initialState()).briscas.games["play"])
  59. };
  60. })
  61. .add('game opponent turn', (props) => {
  62. return {
  63. story: () => <GameWithLanguage {...props} params={{gameId: "play"}} /> ,
  64. action: GameActions.gameReceive("play", (initialState()).briscas.games["opponent"])
  65. };
  66. })
  67. .add('loading to opponent turn', (props) => {
  68. return {
  69. story: () => <GameWithLanguage {...props} params={{gameId: "loading"}} /> ,
  70. action: GameActions.gameReceive("loading", (initialState()).briscas.games["opponent"])
  71. };
  72. })
  73. .add('last deck card', (props) => {
  74. return {
  75. story: () => <GameWithLanguage {...props} params={{gameId: "lastDraw"}} /> ,
  76. action: GameActions.gameReceive("lastDraw", (initialState()).briscas.games["noDeck"])
  77. };
  78. })
  79. .add('last hand', (props) => {
  80. return {
  81. story: () => <GameWithLanguage {...props} params={{gameId: "lastHand"}} /> ,
  82. action: GameActions.gameReceive("lastHand", (initialState()).briscas.games["win"])
  83. };
  84. })
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement