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-native-faq

v0.0.7

Published

React Native F.A.Q component

Downloads

22

Readme

Build Status

react-native-faq

React Native F.A.Q.

Installation

Run npm install react-native-faq or yarn add react-native-faq

See it in action!

react-native-faq SNACK example

COMPONENTS

FAQ

It renders and array of questions each question should be defined according the Question Component.

e.g.


//Define some questions
const questions = [{
  question: "How can I help you?",
       reply: "You have several options to choose:",
       bullets: bullets,
       actionText: "I'm ready to help!",
       onClick: action_example
}]

// Render a FAQ component

<FAQ questions=questions />

prop | type | default | description | ---- | :----: | :-------: | ----------- | containerStyle | object | "{}" | Style for the main View Component of the F.A.Q. This view contains the title and questions container | titleContainerStyle | object | "{}" | Style for the View component title container | titleStyle | object | "{ fontSize: 30, textAlign: 'center'}" | Style for the Text component containing the title | title | string | | A string for the title of the FAQ | questions | `array` | | An array containing the Questions to be rendered. | questionContainerStyle | object | "{}" | styles for the View component questions container. |

Question

Ideally to be render as an array inside the F.A.Q. component, but can be render alone just.

Here you have an example for the definition of a simple Question:

//First define some bullets
  const bullets = [
    "you could say hello",
    "Open an issue",
    "making a pull request",
    "or give me more ideas to improve this component"]
//Then definy an action (WebBroser is a method from ["expo"](https://docs.expo.io/versions/latest/))

const action_example = () => {
   WebBrowser.openBrowserAsync(
       "https://github.com/Olcina/react-native-faq"
   )};

//Wrap up everything in your quesstion props
const  props  = {
       question: "How can I help you?",
       reply: "You have several options to choose:",
       bullets: bullets,
       actionText: "I'm ready to help!",
       onClick: action_example}

//Finally render your question 

<Question  {...props} />
   

prop | type | default | description | ---- | :----: | :-------: | ----------- | bullets | array | "null" | An array of strings containing the aditional bullets for the Questions. | bulletStyle | object | "{ marginLeft: \"10%\"}" | Each bullet is made of a Text component, use this props to style all bullets. | actionText | string | `` | An string inside a Text component for the title. | containerStyle | object | "{ backgroundColor: \"lightgrey\", margin: 2, borderRadius: 5}" | Main Question View component style. | actionStyle | object | "{ backgroundColor: \"black\", borderRadius: 5, margin: 5}" | Question action button style container It's a Touchable Opacity component containing a Text component | actionTextStyle | object | "{ fontSize: 30, textAlign: \"center\"}" | Text component style for the Question title | replyStyle | object | "{ fontSize: 15}" | Question reply container style | titleStyle | object | "{ fontSize: 20}" | Question title container style | onClick | func | "null" | onClick prop: Can be any function you want to trigger. |

EXPO EXAMPLE

A working example for an expo project


import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants, WebBrowser } from 'expo';
import { FAQ, Question } from './components/Question'

// define some bullets
const bullets = [
    'you could say hello',
    'Open an issue',
    'making a pull request',
    'or give me more ideas to improve this component'
]
// define an action
const action_example = () => {
    WebBrowser.openBrowserAsync(
        'https://github.com/Olcina/react-native-faq'
    );
}

const goTo = (link) => {
    WebBrowser.openBrowserAsync(
        link
    );
}

const questions = [
    {
        question: "How can I help you?",
        reply: "You have several options to choose:",
        bullets: bullets,
        actionText: "I'm ready to help!",
        onClick: action_example
    },
    {
        question: "Don't you know how to start?",
        reply: "Open a GitHub account and chat whit me",
        actionText: "Sure! Take me there!",
        onClick: () => goTo('https://github.com/'),
    }
]

// or any pure javascript modules available in npm
import { Card } from 'react-native-paper';

export default class App extends React.Component {
    render() {
        return (
            <View style={styles.container}>

                <View>
                    <Text style={{ textAlign: 'center' }}>You can load a complete F.A.Q.</Text>

                    <FAQ
                        title='F.A.Q.'
                        questions={questions}
                    />

                </View>

                <View>
                    <Text style={{ textAlign: 'center' }}>Or add your questions one by one</Text>
                    <Question
                        question="Is it possible to add just one question?"
                        reply="Of course, here you have an example"
                        actionText="Sure! Take me there!"
                        onClick={() => goTo('https://github.com/')}
                    />
                </View>

            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'space-evenly',
        paddingTop: Constants.statusBarHeight,
        backgroundColor: '#ecf0f1',
        padding: 8,
    }
});