Advertisement
-adela1905

Exemple-1001-1

May 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. /**
  2. * Register Vue Components
  3. */
  4.  
  5. // register the grid component
  6. Vue.component('page-head', {
  7. template: '#page-head'
  8. })
  9.  
  10. Vue.component('grid', {
  11. template: '#grid',
  12. props: ['colors']
  13.  
  14. })
  15.  
  16.  
  17. ----------------------------------------------------------------------------------------------------------------
  18.  
  19.  
  20. /**
  21. * index.js
  22. * - All our useful JS goes here, awesome!
  23. */
  24.  
  25.  
  26. // Init Vue!
  27. var app = new Vue({
  28. el: '#demo',
  29. mounted: function () {
  30. window.addEventListener('scroll', this.onScroll);
  31. },
  32. methods: {
  33. onScroll: function(e) {
  34. if ((window.innerHeight + window.pageYOffset) >= document.body.offsetHeight) {
  35. this.addMoreColors();
  36. }
  37. },
  38. addMoreColors: function() {
  39. // Simple dummy function to add more data.
  40. this.colors = this.colors.concat([{ hex: "#f6d258"}, { hex: "#efcec5" }, { hex: "#d1af94" },{ hex: "#97d5e0" }, { hex: "#f6d258" }, { hex: "#efcec5" }]);
  41. }
  42. },
  43. data: function() {
  44. return {
  45. colors: [
  46. { hex: "#f6d258" },
  47. { hex: "#efcec5" },
  48. { hex: "#d1af94" },
  49. { hex: "#97d5e0" },
  50. { hex: "#f6d258" },
  51. { hex: "#efcec5" },
  52. { hex: "#97d5e0" },
  53. { hex: "#f6d258" },
  54. { hex: "#efcec5" },
  55. { hex: "#d1af94" },
  56. { hex: "#97d5e0" },
  57. ]
  58. }
  59. }
  60. })
  61.  
  62. ----------------------------------------------------------------------------------------------------------------
  63.  
  64. /**
  65. * index.scss
  66. * - Add any styles you want here!
  67. */
  68.  
  69. $background: #fff;
  70.  
  71. * {
  72. box-sizing: border-box;
  73. }
  74.  
  75. body {
  76. background: $background;
  77. }
  78.  
  79. header {
  80. font-family: 'Montserrat', sans-serif;
  81. text-transform: uppercase;
  82. letter-spacing: 2px;
  83. font-weight: normal;
  84. text-align: center;
  85. margin-top: 50px;
  86. margin-bottom: 50px;
  87. }
  88.  
  89. .grid {
  90. columns: 3 auto;
  91. column-gap: 20px;
  92. padding-left: 10px;
  93. padding-right: 10px;
  94. }
  95.  
  96. .color {
  97. display: inline-block;
  98. border-radius: 3px;
  99. width: 100%;
  100. height: 200px;
  101. margin-bottom: 20px;
  102. }
  103.  
  104. .pop-enter-active {
  105. transition: opacity 300ms ease-out, transform 300ms ease-out;
  106. }
  107.  
  108. .pop-enter {
  109. opacity: 0;
  110. transform: scale(0.9);
  111. }
  112.  
  113. .pop-enter-to {
  114. opacity: 1;
  115. transform: scale(1);
  116. }
  117.  
  118. ----------------------------------------------------------------------------------------------------------------
  119.  
  120. /**
  121. * index.scss
  122. * - Add any styles you want here!
  123. */
  124.  
  125. * {
  126. box-sizing: border-box;
  127. }
  128.  
  129. body {
  130. background: #fff;
  131. }
  132.  
  133. header {
  134. font-family: 'Montserrat', sans-serif;
  135. text-transform: uppercase;
  136. letter-spacing: 2px;
  137. font-weight: normal;
  138. text-align: center;
  139. margin-top: 50px;
  140. margin-bottom: 50px;
  141. }
  142.  
  143. .grid {
  144. columns: 3 auto;
  145. column-gap: 20px;
  146. padding-left: 10px;
  147. padding-right: 10px;
  148. }
  149.  
  150. .color {
  151. display: inline-block;
  152. border-radius: 3px;
  153. width: 100%;
  154. height: 200px;
  155. margin-bottom: 20px;
  156. }
  157.  
  158. .pop-enter-active {
  159. transition: opacity 300ms ease-out, transform 300ms ease-out;
  160. }
  161.  
  162. .pop-enter {
  163. opacity: 0;
  164. transform: scale(0.9);
  165. }
  166.  
  167. .pop-enter-to {
  168. opacity: 1;
  169. transform: scale(1);
  170. }
  171.  
  172. ----------------------------------------------------------------------------------------------------------------
  173.  
  174. <!DOCTYPE html>
  175. <html lang="en">
  176. <head>
  177.  
  178. <!-- Meta -->
  179. <meta charset="UTF-8" />
  180. <title>Vue.JS Grid</title>
  181.  
  182. <!-- Styles -->
  183. <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
  184. <link rel="stylesheet" href="styles/index.processed.css">
  185.  
  186. <!-- Scripts -->
  187. <script src="https://unpkg.com/vue@2.1.10/dist/vue.js"></script>
  188. </head>
  189. <body>
  190.  
  191. <script type="text/x-template" id="page-head">
  192. <header>
  193. <h1>Vue.JS Grid Template pour les Journées 1000 et 1</h1>
  194. </header>
  195. </script>
  196.  
  197. <script type="text/x-template" id="grid">
  198. <div class="grid">
  199. <transition-group name="pop">
  200. <div class="color" v-for="(color, index) in colors" v-bind:key="{index}" v-bind:style="{ backgroundColor: color.hex }"></div>
  201. </transition-group>
  202. </div>
  203. </script>
  204.  
  205. <div id="demo">
  206. <page-head></page-head>
  207. <grid :colors="colors"></grid>
  208. </div>
  209.  
  210. <!-- Scripts -->
  211. <script src="/scripts/components.js"></script>
  212. <script src="/scripts/index.js"></script>
  213. </body>
  214. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement