react.sample.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <html>
  2. <head>
  3. <title>zuck.js</title>
  4. <link rel="icon" href="ICON.png">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0" />
  6. <!-- demo styles -->
  7. <link rel="stylesheet" href="demo/style.css">
  8. <!-- lib styles -->
  9. <link rel="stylesheet" href="dist/zuck.min.css">
  10. <!-- lib skins -->
  11. <link rel="stylesheet" href="dist/skins/snapgram.css">
  12. <link rel="stylesheet" href="dist/skins/vemdezap.css">
  13. <link rel="stylesheet" href="dist/skins/facesnap.css">
  14. <link rel="stylesheet" href="dist/skins/snapssenger.css">
  15. </head>
  16. <body>
  17. <div id="root"></div>
  18. <!-- Too much time needed to setup webpack and blablabla -->
  19. <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js"></script>
  20. <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js"></script>
  21. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.21.1/babel.min.js"></script>
  22. <script src="dist/zuck.min.js"></script>
  23. <script src="demo/script.js"></script>
  24. <script type="text/babel">
  25. class Demo extends React.Component {
  26. render() {
  27. return (
  28. <div>
  29. <h1 id="header">&nbsp;</h1>
  30. <a href="https://ramon.codes/projects/zuck.js" target="_blank" className="disclaimer">
  31. <img src="ICON.png" alt="zuck.js logo" />
  32. <p>This a demonstration of <strong>zuck.js</strong> javascript library.</p>
  33. <p>Not associated with Facebook, Instagram, WhatsApp or Snapchat.</p>
  34. </a>
  35. <Stories />
  36. <div className="skin">
  37. Choose your theme: <select id="skin" onChange={(event) => changeSkin(event.target.value)}>
  38. <option value="Snapgram">Snapgram (without fullscreen)</option>
  39. <option value="FaceSnap">FaceSnap (with fullscreen)</option>
  40. <option value="VemDeZAP">VemDeZAP (timeline + arrows)</option>
  41. <option value="Snapssenger">Snapssenger (with previews)</option>
  42. </select>
  43. </div>
  44. </div>
  45. );
  46. }
  47. }
  48. </script>
  49. <script type="text/babel">
  50. class Stories extends React.Component {
  51. constructor(props){
  52. super(props);
  53. // React ^16.3
  54. // this.storiesElement = React.createRef();
  55. this.storiesElement = null;
  56. this.storiesApi = null;
  57. this.state = {
  58. stories: [
  59. Zuck.buildTimelineItem(
  60. "ramon",
  61. "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/users/1.jpg",
  62. "Ramon",
  63. "https://ramon.codes",
  64. timestamp(),
  65. [
  66. ["ramon-1", "photo", 3, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/1.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/1.jpg", '', false, false, timestamp()],
  67. ["ramon-2", "video", 0, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/2.mp4", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/2.jpg", '', false, false, timestamp()],
  68. ["ramon-3", "photo", 3, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/3.png", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/3.png", 'https://ramon.codes', 'Visit my Portfolio', false, timestamp()]
  69. ]
  70. ),
  71. Zuck.buildTimelineItem(
  72. "gorillaz",
  73. "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/users/2.jpg",
  74. "Gorillaz",
  75. "",
  76. timestamp(),
  77. [
  78. ["gorillaz-1", "video", 0, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/4.mp4", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/4.jpg", '', false, false, timestamp()],
  79. ["gorillaz-2", "photo", 3, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/5.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/5.jpg", '', false, false, timestamp()],
  80. ]
  81. ),
  82. Zuck.buildTimelineItem(
  83. "ladygaga",
  84. "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/users/3.jpg",
  85. "Lady Gaga",
  86. "",
  87. timestamp(),
  88. [
  89. ["ladygaga-1", "photo", 5, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/6.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/6.jpg", '', false, false, timestamp()],
  90. ["ladygaga-2", "photo", 3, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/7.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/7.jpg", 'http://ladygaga.com', false, false, timestamp()],
  91. ]
  92. ),
  93. Zuck.buildTimelineItem(
  94. "starboy",
  95. "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/users/4.jpg",
  96. "The Weeknd",
  97. "",
  98. timestamp(),
  99. [
  100. ["starboy-1", "photo", 5, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/8.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/8.jpg", '', false, false, timestamp()]
  101. ]
  102. ),
  103. Zuck.buildTimelineItem(
  104. "riversquomo",
  105. "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/users/5.jpg",
  106. "Rivers Cuomo",
  107. "",
  108. timestamp(),
  109. [
  110. ["riverscuomo", "photo", 10, "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/9.jpg", "https://raw.githubusercontent.com/ramon82/assets/master/zuck.js/stories/9.jpg", '', false, false, timestamp()]
  111. ]
  112. )
  113. ]
  114. }
  115. }
  116. componentDidMount() {
  117. let currentSkin = getCurrentSkin(); // from demo
  118. this.storiesApi = new Zuck(this.storiesElement, {
  119. backNative: true,
  120. previousTap: true,
  121. skin: currentSkin['name'],
  122. autoFullScreen: currentSkin['params']['autoFullScreen'],
  123. avatars: currentSkin['params']['avatars'],
  124. paginationArrows: currentSkin['params']['paginationArrows'],
  125. list: currentSkin['params']['list'],
  126. cubeEffect: currentSkin['params']['cubeEffect'],
  127. localStorage: true,
  128. stories: this.state.stories,
  129. reactive: true,
  130. callbacks: {
  131. onDataUpdate: function (currentState, callback) {
  132. this.setState(state => {
  133. state.stories = currentState;
  134. return state;
  135. }, () => {
  136. callback();
  137. });
  138. }.bind(this)
  139. }
  140. });
  141. }
  142. render() {
  143. const timelineItems = []
  144. this.state.stories.forEach((story, storyId) => {
  145. const storyItems = [];
  146. story.items.forEach((storyItem) => {
  147. storyItems.push(
  148. <li key={storyItem.id} data-id={storyItem.id} data-time={storyItem.time} className={(storyItem.seen ? 'seen' : '')}>
  149. <a href={storyItem.src} data-type={storyItem.type} data-length={storyItem.length} data-link={storyItem.link} data-linkText={storyItem.linkText}>
  150. <img src={storyItem.preview} />
  151. </a>
  152. </li>
  153. );
  154. });
  155. let arrayFunc = story.seen ? 'push' : 'unshift';
  156. timelineItems[arrayFunc](
  157. <div className={(story.seen ? 'story seen' : 'story')} key={storyId} data-id={storyId} data-last-updated={story.lastUpdated} data-photo={story.photo}>
  158. <a className="item-link" href={story.link}>
  159. <span className="item-preview">
  160. <img src={story.photo} />
  161. </span>
  162. <span className="info" itemProp="author" itemScope="" itemType="http://schema.org/Person">
  163. <strong className="name" itemProp="name">{story.name}</strong>
  164. <span className="time">{story.lastUpdated}</span>
  165. </span>
  166. </a>
  167. <ul className="items">
  168. {storyItems}
  169. </ul>
  170. </div>
  171. );
  172. });
  173. return (
  174. <div>
  175. <div ref={node => this.storiesElement = node} id="stories-react" className="storiesWrapper">
  176. {timelineItems}
  177. </div>
  178. </div>
  179. );
  180. }
  181. }
  182. </script>
  183. <script type="text/babel">
  184. ReactDOM.render(
  185. <Demo />,
  186. document.getElementById('root')
  187. );
  188. </script>
  189. </body>
  190. </html>