index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="demo-list-wrapper">
  3. <a href="https://github.com/jdf2e/nutui/" target="_blank" class="github-btn">Github</a>
  4. <h1 class="logo"></h1>
  5. <div class="version">NutUI 2.0</div>
  6. <p>一套京东风格的移动端Vue组件库</p>
  7. <div :class="['demo-list-box',{'unfold':foldStatus[item]}]" v-for="item in sorts" :key="item">
  8. <h4 @click="toggleFold(item)">
  9. {{oriSorts[item]}}
  10. <i></i>
  11. </h4>
  12. <ul>
  13. <template v-for="cpt in packages">
  14. <li v-if="cpt.showDemo !== false && cpt.sort == item" :key="cpt.name">
  15. <a :href="'./demo.html#/'+cpt.name">
  16. {{cpt.name}}
  17. <span>{{cpt.chnName}}</span>
  18. <nut-rate class="cpt-rec" v-if="cpt.star" :total="5" :value="cpt.star" :size="8" :spacing="3" :readOnly="true"></nut-rate>
  19. </a>
  20. </li>
  21. </template>
  22. </ul>
  23. </div>
  24. <div id="demo-footer">京东用户体验设计部(JDC) · 前端开发部</div>
  25. </div>
  26. </template>
  27. <script>
  28. import { packages, sorts } from "../../../src/config.json";
  29. export default {
  30. name: "index",
  31. data() {
  32. return {
  33. path: "",
  34. packages: {},
  35. sortedPackages: [],
  36. oriSorts: [],
  37. sorts: [1, 2, 0, 3, 4, 5],
  38. foldStatus: []
  39. };
  40. },
  41. methods: {
  42. toggleFold(idx) {
  43. this.foldStatus.splice(idx, 1, !this.foldStatus[idx]);
  44. sessionStorage.setItem("foldStatus", JSON.stringify(this.foldStatus));
  45. }
  46. },
  47. created() {
  48. this.packages = packages;
  49. this.oriSorts = sorts;
  50. this.foldStatus = Array(this.sorts.length)
  51. .join(",")
  52. .split(",")
  53. .map(function(key, index) {
  54. return 0;
  55. });
  56. },
  57. activated() {
  58. const seVal = sessionStorage.getItem("foldStatus");
  59. if (seVal && seVal !== "false") {
  60. this.foldStatus = JSON.parse(seVal);
  61. }
  62. }
  63. };
  64. </script>
  65. <style lang="scss" scoped>
  66. .demo-list-wrapper {
  67. #demo-footer{
  68. font-size:10px;
  69. color:#BBB;
  70. text-shadow:1px 1px #FFF;
  71. text-align: center;
  72. margin:10px 0;
  73. }
  74. position: relative;
  75. padding: 8px;
  76. box-sizing: border-box;
  77. .github-btn {
  78. position: absolute;
  79. top: -25px;
  80. right: 10px;
  81. height: 26px;
  82. width: 26px;
  83. font-size: 0;
  84. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 0 16 16' version='1.1' width='24' aria-hidden='true'%3E%3Cpath fill-rule='evenodd' fill='rgb(150,150,150)' d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z'%3E%3C/path%3E%3C/svg%3E")
  85. no-repeat;
  86. &:hover,
  87. &:active {
  88. opacity: 0.7;
  89. }
  90. }
  91. .logo {
  92. background: url(../asset/img/logo.png) no-repeat;
  93. background-size: contain;
  94. height: 100px;
  95. width: 100px;
  96. text-align: center;
  97. margin: 5px auto 15px;
  98. animation: swing 2.5s;
  99. }
  100. .version {
  101. text-align: center;
  102. font-size: 24px;
  103. }
  104. p {
  105. text-align: center;
  106. color: #848484;
  107. margin: 20px 0 30px;
  108. }
  109. }
  110. .demo-list-box {
  111. margin: 15px auto;
  112. width: 95%;
  113. background: #fff;
  114. border-radius: 5px;
  115. overflow: hidden;
  116. h4 {
  117. position: relative;
  118. margin: 0;
  119. height: 50px;
  120. font-weight: normal;
  121. line-height: 50px;
  122. padding: 0 15px;
  123. &:active {
  124. background-color: rgba(200, 200, 200, 0.1);
  125. }
  126. i {
  127. position: absolute;
  128. right: 15px;
  129. top: 50%;
  130. margin-top: -5px;
  131. height: 10px;
  132. width: 10px;
  133. transform: rotate(0deg);
  134. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='rgb(132,132,132)' viewBox='0 0 30 11'%3E%3Cpath d='M15 7.757L27.737.21a1.5 1.5 0 0 1 1.53 2.58c-4.5 2.668-9 5.334-13.5 8a1.503 1.503 0 0 1-1.53 0c-4.5-2.666-9-5.332-13.5-8A1.5 1.5 0 1 1 2.266.21C6.51 2.726 10.756 5.24 15 7.757' fill-rule='evenodd'/%3E%3C/svg%3E")
  135. no-repeat center;
  136. background-size: contain;
  137. transition: transform 0.3s;
  138. }
  139. }
  140. &.unfold {
  141. h4 i {
  142. transform: rotate(-180deg);
  143. }
  144. ul {
  145. display: block;
  146. }
  147. }
  148. ul {
  149. display: none;
  150. padding: 0 5px;
  151. }
  152. li {
  153. margin: 0 5px;
  154. overflow: hidden;
  155. border-top: 1px solid #edeef1;
  156. border-radius: 2px;
  157. background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 30'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cpath d='M-11 0h30v30h-30z'/%3E%3Cpath d='M7.757 15C5.241 10.755 2.727 6.51.21 2.266A1.5 1.5 0 0 1 2.79.736l8 13.499c.28.472.28 1.058 0 1.53l-8 13.5a1.499 1.499 0 1 1-2.58-1.53L7.757 15z' fill='rgb(132,132,132)' /%3E%3C/g%3E%3C/svg%3E")
  158. no-repeat right 10px center;
  159. background-size: 10px 10px;
  160. a {
  161. display: flex;
  162. align-items:center;
  163. height: 100%;
  164. padding: 20px 10px 20px 10px;
  165. text-decoration: none;
  166. color: #2e2d2d;
  167. }
  168. span {
  169. margin-left: 10px;
  170. font-size: 14px;
  171. color: #848484;
  172. }
  173. &:active {
  174. background-color: rgba(200, 200, 200, 0.1);
  175. }
  176. }
  177. }
  178. ul,
  179. li {
  180. list-style: none;
  181. margin: 0;
  182. padding: 0;
  183. }
  184. .cpt-rec{
  185. display:inline-flex;
  186. margin-left:5px;
  187. }
  188. @-webkit-keyframes swing {
  189. from {
  190. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  191. transform: perspective(400px) rotate3d(0, 1, 0, 90deg);
  192. -webkit-animation-timing-function: ease-in;
  193. animation-timing-function: ease-in;
  194. opacity: 0;
  195. }
  196. 40% {
  197. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -40deg);
  198. transform: perspective(400px) rotate3d(0, 1, 0, -40deg);
  199. -webkit-animation-timing-function: ease-in;
  200. animation-timing-function: ease-in;
  201. }
  202. 60% {
  203. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, 25deg);
  204. transform: perspective(400px) rotate3d(0, 1, 0, 25deg);
  205. opacity: 1;
  206. }
  207. 80% {
  208. -webkit-transform: perspective(400px) rotate3d(0, 1, 0, -10deg);
  209. transform: perspective(400px) rotate3d(0, 1, 0, -10deg);
  210. }
  211. to {
  212. -webkit-transform: perspective(400px);
  213. transform: perspective(400px);
  214. }
  215. }
  216. </style>