npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-faq-component-yfx

v0.0.3

Published

React package to render collapsible faq sections

Downloads

5

Readme

react-faq-component

release open issues license Build Status

An accessible React package to render FAQ section. view demo

Install

npm install --save react-faq-component

Usage

import React, { Component } from "react";
import Faq from "react-faq-component";

const data = {
    title: "FAQ (How it works)",
    rows: [
        {
            title: "Lorem ipsum dolor sit amet,",
            content: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sed tempor sem. Aenean vel turpis feugiat,
              ultricies metus at, consequat velit. Curabitur est nibh, varius in tellus nec, mattis pulvinar metus.
              In maximus cursus lorem, nec laoreet velit eleifend vel. Ut aliquet mauris tortor, sed egestas libero interdum vitae.
              Fusce sed commodo purus, at tempus turpis.`,
        },
        {
            title: "Nunc maximus, magna at ultricies elementum",
            content:
                "Nunc maximus, magna at ultricies elementum, risus turpis vulputate quam, vitae convallis ex tortor sed dolor.",
        },
        {
            title: "Curabitur laoreet, mauris vel blandit fringilla",
            content: `Curabitur laoreet, mauris vel blandit fringilla, leo elit rhoncus nunc, ac sagittis leo elit vel lorem.
            Fusce tempor lacus ut libero posuere viverra. Nunc velit dolor, tincidunt at varius vel, laoreet vel quam.
            Sed dolor urna, lobortis in arcu auctor, tincidunt mattis ante. Vivamus venenatis ultricies nibh in volutpat.
            Cras eu metus quis leo vestibulum feugiat nec sagittis lacus.Mauris vulputate arcu sed massa euismod dignissim. `,
        },
        {
            title: "What is the package version",
            content: <p>current version is 1.2.1</p>,
        },
    ],
};

const styles = {
    // bgColor: 'white',
    titleTextColor: "blue",
    rowTitleColor: "blue",
    // rowContentColor: 'grey',
    // arrowColor: "red",
};

const config = {
    // animate: true,
    // arrowIcon: "V",
    // tabFocus: true
};

export default class App extends Component {
    render() {
        return (
            <div>
                <Faq data={data} styles={styles} config={config} />
            </div>
        );
    }
}

data props

The data passed to react-faq-component is an object having below keys(mentioned in the table).

| attribute | type | optional | details | | --------- | :----: | :------: | :---------------------------------------------------- | | title | String | true | Text displayed as the title/header of the FAQ section | | rows | Array | true | Array of obj containing title and content of each row | | styles | Object | true | Object that updates default text/bg color |

config props (optional)

const config = {
    animate: true,
    arrowIcon: "V",
};

The config passed to react-faq-component is an object having below keys(mentioned in the table).

| attribute | type | optional | details | | --------- | :--------: | :------: | :------------------------------------------------------------------------------------------------------------------------------------------- | | animate | Boolean | true | Whether to enable the (row) content animation (default val : true) | | arrowIcon | JSX/string | true | Custom component to display instead of default arrow | | tabFocus | Boolean | true | Whether to add outline on tab focus (default val : false). Focus outline is added when keyboard tab is used to navigate through the contents |

styles props format

styles attribute in data is optional and can be used to change text/bg color in FAQ component. e.g:

const data = {
  title: ...,
  rows: [...],
  styles: {
    // bgColor: 'white',
    titleTextColor: 'blue',
    rowTitleColor: 'blue',
    // rowTitleTextSize: 'medium',
    // rowContentColor: 'grey',
    rowContentTextSize: '16px',
    // rowContentPaddingTop: '10px',
    rowContentPaddingBottom: '10px',
    rowContentPaddingLeft: '50px',
    // rowContentPaddingRight: '150px',
    // arrowColor: "red",
    //transitionDuration: "1s",
    // timingFunc: "ease"
  }
}

| attribute | type | optional | default value | details | | ----------------------- | :----: | :------: | :-----------: | :------------------------------------------------- | | bgColor | String | true | white | background color of faq-component | | titleTextColor | String | true | black | text color of FAQ title/header text | | rowTitleColor | String | true | black | text color of title text of rowItems | | rowTitleTextSize | String | true | large | size of title text in rowItems | | rowContentColor | String | true | black | text color of row content in rowItems | | rowContentTextSize | String | true | medium | size of row content in rowItems | | arrowColor | String | true | black | color of row arrow | | rowContentPaddingTop | String | true | 0 | value of padding-top of row content in rowItems | | rowContentPaddingBottom | String | true | 0 | value of padding-bottom of row content in rowItems | | rowContentPaddingLeft | String | true | 0 | value of padding-left of row content in rowItems | | rowContentPaddingRight | String | true | 0 | value of padding-right of row content in rowItems | | transitionDuration | String | true | 0.3s | transition duration for expanding row content | | timingFunc | String | true | ease | transition function for expanding row content |

If the above style options are not enough, you can write you own custom css to apply styles on the elements.

.faq-row-wrapper {
    .faq-title {
    }

    .faq-body {
        .faq-row {
            .row-title {
            }

            .row-content {
                .row-content-text {
                }
            }
        }
    }
}

These classnames are applied to the elements and do not contain any styles.

Screenshot

Screenshot 1


Screenshot 2

License

MIT © binodswain