0.1.6 • Published 1 year ago

react-video-quiz v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

📼 React Video Quiz 📼

NPM

import {VideoQuiz} from "react-video-quiz";

🧾 TODO

  • Continuous Delivery
  • Add prettier

  • Test in different browsers
  • Test with different video sources
  • Test in mobile and tablet
  • Add tests

  • Add more documentation
  • Add more examples

🖥️ Install

To install the library, please run the following code in your terminal:

npm install react-video-quiz

🧾 Props

<VideoQuiz> component:

PropertyTypeDefaultRequiredDescription
questionaryObjectnoneyesThe questionary object, see the questionary API below
widthstring number'300px'noPossible values for width can be 100% or 300px or 300
heightstring number'600px'noPossible values for width can be 100% or 600px or 600
configObjectnonenoThe configuration object, see the options API below

🧾 Questionary API

type Questionary = {

    id: number;

    video: string;

    text?: string;

    questions?: Questionary[];

}

🧾 Configuration API

 type VideoConfig = {
    
    onFinish?: (answers: number[]) => ( void | {} );
    
    containerStyle?: CSSProperties;
    
    videoStyle?: CSSProperties;
    
    videoClassName?: string;
    
    containerClassName?: string;
    
    orientation?: 'horizontal' | 'vertical';
    
    textContainerStyle?: CSSProperties;
    
    textContainerClassName?: string;
    
}

onFinish

Type: (answers: number[]) => ( void | {} )

Callback function that will be called when the user finishes the quiz.

orientation

Type: 'horizontal' | 'vertical'

Orientation of the component, can be horizontal or vertical.

containerStyle

Type: CSSProperties

Style object for the container of the component.

containerClassName

Type: string

Class name for the container of the component.

videoStyle

Type: CSSProperties

Style object for the video element.

videoClassName

Type: string

Class name for the video element.

textContainerStyle

Type: CSSProperties

Style object for the text container.

textContainerClassName

Type: string

Class name for the text container.

🧪 Example

import React from 'react';
import { VideoQuiz } from 'react-video-quiz';

export function MyApp() {
    const questionary = {
        id: 1,
        video: VideoShort,
        questions: [
            {
                id: 2,
                video: VideoShort,
                text: "opcion 2",
                questions: [
                    {
                        id: 4,
                        video: VideoShort,
                        text: "opcion 4",
                    },
                    {
                        id: 5,
                        video: VideoShort,
                        text: "opcion 5",
                    }
                ]
            },
            {
                id: 3,
                video: VideoShort,
                text: "opcion 3",
                questions: [
                    {
                        id: 6,
                        video: VideoShort,
                        text: "opcion 6",
                    },
                    {
                        id: 7,
                        video: VideoShort,
                        text: "opcion 7",
                    }
                ]
            }
        ]
    }
    
    return(
        <VideoQuiz
            questionary={questionary}
            width={300}
            height={600}
            config={{
                onFinish: (answers: number[]) => {
                    console.log('Quiz finished');
                }
            }}
        />
    )
}

🏛️ License

React Video Quiz is released under MIT license. You are free to use, modify and distribute this software, as long as the copyright header is left intact.

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago