Giter Site home page Giter Site logo

gerasimvol / vue-faq-accordion Goto Github PK

View Code? Open in Web Editor NEW
84.0 3.0 16.0 2.3 MB

❓ Simple and smooth Vue.js accordion component. Perfect for your FAQ section

Home Page: https://www.npmjs.com/package/vue-faq-accordion

License: MIT License

Vue 84.67% JavaScript 15.33%
vue vuejs vue-component faq faq-accordion accordion

vue-faq-accordion's Introduction

vue-faq-accordion

npm npm

🗃 Simple and smooth vue accordion. Perfect for your FAQ section.

FAQ Section demo

🛠 Install

npm i vue-faq-accordion
yarn add vue-faq-accordion

🚀 Usage

<template>
  <VueFaqAccordion 
    :items="myItems"
  />
</template>

<script>
import VueFaqAccordion from 'vue-faq-accordion'

export default {
  components: {
    VueFaqAccordion
  },
  data () {
    return {
      myItems: [
          {
            title: 'How many time zones are there in all?',
            value: 'Given a 24-hour day and 360 degrees of longitude around the Earth',
            category: 'Tab-1'
          },
          {
            title: 'How long is a day and year on Venus?',
            value: 'Venus takes 224.7 Earth days to complete one orbit around the Sun.',
            category: 'Tab-2'
          },
          {
            title: 'What animal smells like popcorn?',
            value: 'Binturongs smell like popcorn.',
            category: 'Tab-2'
          }
        ]
    }
  }
}
</script>

⚙ Props

props: {

  /**
   * Array of items
   * Object style {questionProperty: string, answerProperty: string, tabName: string}
   * You can change object keys names using other props (questionProperty, answerProperty, tabName)
   */
  items: {
    type: Array,
    required: true
  },

  /**
   * Key name of object in items array for specifying title of question
   */
  questionProperty: {
    type: String,
    default: 'title'
  },
  
  /**
   * Key name of object in items array for specifying content text of open question
   */
  answerProperty: {
    type: String,
    default: 'value'
  },
  
  /**
   * Key name of object in items array for specifying navigation tab name
   */
  tabName: {
    type: String,
    default: 'category'
  },
  
 /**
  * Color for hover and active tab/question
  * possible format: 'red', '#F00', 'rgba(255, 0, 0, 1)'
  */
  activeColor: {
    type: String,
    default: '#D50000'
  },
  
  /**
   * Color for borders
   */
  borderColor: {
    type: String,
    default: '#9E9E9E'
  },
  
  /**
   * Color for fonts
   */
  fontColor: {
    type: String,
    default: '#000000'
  },

  /**
   * Opened by default tabName (category)
   */
  initialTab: {
    type: String,
    default: null
  },

  /**
   * Opened by default question
   * All closed by default
   */
  initialQuestionIndex: {
    type: Number,
    default: null
  }
  
}

🔥 Events

Event Payload Description
categorySelect { categoryIndex } Emitted on category change
itemSelect { itemIndex } Emitted on item open

📎 Slots

You can define own item markup via slots:

<VueFaqAccordion
  :items="myItems"
  v-slot="itemData"
>
  <img :src="itemData.imageSrc">
</VueFaqAccordion>
  • item data is available via scoped slot (v-slot="itemData")
  • don't add margins to this element (animation become choppy)

vue-faq-accordion's People

Contributors

adminxvii avatar dependabot[bot] avatar gerasimvol avatar jasonharriseis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vue-faq-accordion's Issues

Component props ??

Hi, thank you for this awesome vue-faq-accordion.

Is it possible to pass a list of components as properties?

Example:

export default { components: { VueFaqAccordion }, data () { return { myItems: [ { title: 'Title for a Component content', component: 'MyComponent1', category: 'Tab-1' }, { title: 'Title for a Component content', component: 'MyComponent2', category: 'Tab-1' }, { title: 'Title for a Component content', component: 'MyComponent3', category: 'Tab-2' }, { title: 'Title for a Component content', component: 'MyComponent4', category: 'Tab-2' } ] } } }

I think this component can be used for more things besides the frequently asked questions.

Please improve the module

You did a great job, i really like it!

But it's still sketchy as a npm module. There is no real implementation, no how-to. You will get way more attention by improving this stuff. ;)

Thanks for the good vue component!

Style Title and value

Awesome library here. I am currently using this library in an application I am working on, please is it possible to style the title and values? like font-size, font-weight e.t.c

Initial question index doesn't work when value is 0

First of all, thanks for this component, it's awesome!

I want to default open the first question in my tab. initialTab prop works fine, and initialQuestionIndex mostly works, EXCEPT when initialQuestionIndex = 0. In this case, nothing opens by default - expected behavior is the first question opens.

integrate medias / component

Hye gerasimvol,
Very nice lib with the system of navbar, thanks !
I noticed that the content filled into value, can only be stringed and are placed inside a paragraph element.
Is there a way to place a video as a content or another component to display in the accordion ?
Thanks for your help.

Netlify build fails

My Netlify build is failing bellow is the failed information, any idea what I am not doing wrong? looks like something with faq-accordion @gerasimvol

5:20:02 PM: Could not generate HTML for "/":
5:20:02 PM: ReferenceError: document is not defined
5:20:02 PM:     at addStyle (node_modules/vue-faq-accordion/dist/vue-faq-accordion.esm.js:262:0)
5:20:02 PM:     at assets/js/vendors~page--src--pages--index-vue.10463f7f.js:764:42
5:20:02 PM:     at a.__vue_inject_styles__ (node_modules/vue-faq-accordion/dist/vue-faq-accordion.esm.js:411:0)
5:20:02 PM:     at a.hook (node_modules/vue-faq-accordion/dist/vue-faq-accordion.esm.js:217:0)
5:20:02 PM:     at Rt (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:11201)
5:20:02 PM:     at Je (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:25232)
5:20:02 PM:     at a.e._init (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:32637)
5:20:02 PM:     at new a (/opt/build/repo/node_modules/vue/dist/vue.runtime.common.prod.js:6:30429)
5:20:02 PM:     at Wi (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:66558)
5:20:02 PM:     at oo (/opt/build/repo/node_modules/vue-server-renderer/build.prod.js:1:70788)
5:20:03 PM: error Command failed with exit code 1.
5:20:03 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
5:20:03 PM: ​
5:20:03 PM: ────────────────────────────────────────────────────────────────
5:20:03 PM:   "build.command" failed                                        
5:20:03 PM: ────────────────────────────────────────────────────────────────
5:20:03 PM: ​
5:20:03 PM:   Error message
5:20:03 PM:   Command failed with exit code 1: yarn build
5:20:03 PM: ​
5:20:03 PM:   Error location
5:20:03 PM:   In Build command from Netlify app:
5:20:03 PM:   yarn build
5:20:03 PM: ​
5:20:03 PM:   Resolved config
5:20:03 PM:   build:
5:20:03 PM:     command: yarn build
5:20:03 PM:     commandOrigin: ui
5:20:03 PM:     publish: /opt/build/repo/dist
5:20:03 PM:     publishOrigin: ui
5:20:03 PM: Caching artifacts
5:20:03 PM: Started saving node modules
5:20:03 PM: Finished saving node modules
5:20:03 PM: Started saving build plugins
5:20:03 PM: Finished saving build plugins
5:20:03 PM: Started saving yarn cache
5:20:07 PM: Finished saving yarn cache
5:20:07 PM: Started saving pip cache
5:20:07 PM: Finished saving pip cache
5:20:07 PM: Started saving emacs cask dependencies
5:20:07 PM: Finished saving emacs cask dependencies
5:20:07 PM: Started saving maven dependencies
5:20:07 PM: Finished saving maven dependencies
5:20:07 PM: Started saving boot dependencies
5:20:07 PM: Finished saving boot dependencies
5:20:07 PM: Started saving rust rustup cache
5:20:07 PM: Finished saving rust rustup cache
5:20:07 PM: Started saving go dependencies
5:20:07 PM: Finished saving go dependencies
5:20:09 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:20:09 PM: Creating deploy upload records
5:20:09 PM: Failing build: Failed to build site
5:20:09 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
5:20:09 PM: Finished processing build request in 1m26.615298958s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.