Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. //the vue file
  2. <template class="bg-white">
  3. <ul class="ul-special bg-white-400">
  4. <li v-for="(item, index) in items" class="li-special bg-white" :key="index">
  5. <div @click="select(index)" class="bg-white flex justify-between items-center py-5 border-t border-gray-dark">
  6. <button class="bg-white">
  7. <h4 v-html="item.title">
  8. </h4>
  9. </button>
  10. <button class="plus-rotate" v-bind:class="[selectedIndex === index ? 'plus-x' : '']">
  11. <icon icon="plus-sign"></icon>
  12. </button>
  13. </div>
  14.  
  15. <transition
  16. v-on:before-enter="beforeEnter" v-on:enter="enter"
  17. v-on:before-leave="beforeLeave" v-on:leave="leave">
  18. <article v-show="selectedIndex === index" class="transition-all overflow-hidden max-w-xs sm:max-w-md md:max-w-lg lg:max-w-xl xl:max-w-3xl">
  19. <div v-html="item.copy" class="pt-5 pb-8">
  20. </div>
  21. </article>
  22. </transition>
  23. </li>
  24. </ul>
  25. </template>
  26.  
  27. <script>
  28.  
  29. import Icon from 'laravel-mix-vue-svgicon/IconComponent.vue';
  30.  
  31. export default {
  32. props: {
  33. items: {
  34. default: () => ([]),
  35. },
  36. },
  37.  
  38. data: () => ({
  39.  
  40. selectedIndex: null,
  41. }),
  42.  
  43. methods: {
  44. select(index) {
  45. if (this.selectedIndex === index) {
  46. this.selectedIndex = null;
  47. } else {
  48. this.selectedIndex = index;
  49. }
  50. },
  51.  
  52. beforeEnter: function(el) {
  53. el.style.height = '0';
  54. },
  55. enter: function(el) {
  56. el.style.height = el.scrollHeight + 'px';
  57. },
  58. beforeLeave: function(el) {
  59. el.style.height = el.scrollHeight + 'px';
  60. },
  61. leave: function(el) {
  62. el.style.height = '0';
  63. },
  64. },
  65. }
  66. </script>
  67.  
  68.  
  69. //the blade file
  70. <section class="text-gray-dark py-24 max-w-4xl mx-auto px-5 sm:px-12 md:px-24">
  71. <h2 class="mb-5 border-grey-200 pb-5">
  72. {!! $block['headline'] !!}
  73. </h2>
  74. <accordion :items="{{ json_encode( $block['list']) }}">
  75.  
  76. </accordion>
  77. </section>
  78.  
  79. //fields file
  80. <?php
  81.  
  82. namespace App\Fields\Blocks;
  83.  
  84. use Carbon_Fields\Field;
  85.  
  86. class Accordion extends AbstractBlock {
  87.  
  88. public $template = 'accordion';
  89. public $name = 'Accordion List';
  90.  
  91. public function fields() {
  92. return array(
  93.  
  94. Field::make( 'text', 'headline', __( 'List Headline' ) ),
  95.  
  96. Field::make( 'complex', 'list', __( 'Accordion List' ) )
  97. ->set_layout( 'tabbed-horizontal' )
  98. ->set_min(1)
  99. ->add_fields( array(
  100. Field::make( 'text', 'title', __( 'Title or Question' ) ),
  101. Field::make( 'rich_text', 'copy', __( 'Description or Answer' ) ),
  102. ) )
  103. );
  104. }
  105.  
  106. public function category() {
  107. return array('lists', __( 'Custom List Modules' ), 'editor-ol');
  108. }
  109.  
  110. }
  111.  
  112. //the css classes
  113. .ul-special .li-special:last-child {
  114. @apply border-b border-gray-dark
  115. }
  116.  
  117. .plus-rotate {
  118. transform: rotate(0deg);
  119. transition: all .3s ease-in-out;
  120.  
  121. &:hover {
  122. transform: rotate(45deg);
  123. transition: all .3s ease-in-out;
  124.  
  125. }
  126. }
  127.  
  128. .plus-x {
  129. @apply text-red;
  130. transform: rotate(45deg);
  131. transition: all .3s ease-in-out;
  132. }
  133.  
  134. .transition-all {
  135. transition: all .3s ease-in-out;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement