vue-badger-accordion icon indicating copy to clipboard operation
vue-badger-accordion copied to clipboard

Can't use other components inside BadgerAccordion

Open sayhicoelho opened this issue 4 years ago • 3 comments

Hi guys!

I need to create some themes for badger-accordion using my own components.

Example:

<badger-accordion>
  <my-custom-accordion-item>
    <template slot="header">Nice header</template>
    <template slot="content">Nice content</template>
  </my-custom-accordion-item>
</badger-accordion>

MyCustomAccordion.vue

<template>
  <badger-accordion-item>
    <template slot="header">
      <slot name="header" />
    </template>
    <template slot="content">
      <div class="custom-content-style">
        <slot name="content" />
      </div>
    </template>
  </badger-accordion-item>
</template>

<style scoped>
  .custom-content-style {
    background-color: red;
  }
</style>

<script>
...

When I try to click on the accordion item, nothing happens.

What is missing?

sayhicoelho avatar May 20 '20 15:05 sayhicoelho

Hi @sayhicoelho, I think you dont have to declare the <template name="xxx"></template> in your Component. Just insert the <slot name="xxx"></slot> wrapped with element of your choice.

<template>
  <badger-accordion-item>
    <div class="header">
      <slot name="header" />
    </div>
    <div>
      <div class="custom-content-style">
        <slot name="content" />
      </div>
    </div>
  </badger-accordion-item>
</template>

Please let me know, if that works.

vanderb avatar May 26 '20 12:05 vanderb

Thank you for the feedback @vanderb!

But still not working.

Using custom components as an accordion item would be nice.

sayhicoelho avatar May 30 '20 19:05 sayhicoelho

Hi @sayhicoelho you are totally right.

In the watcher-method this.$children be used to change states. This can not work, if $children is not the badger-accordion-item component.

I will take care about this Problem in next Release. But I am sorry I can not help you yet.

vanderb avatar Jun 02 '20 07:06 vanderb