import {VideoQuiz} from "react-video-quiz";
-
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
To install the library, please run the following code in your terminal:
npm install react-video-quiz
<VideoQuiz>
component:
Property | Type | Default | Required | Description |
---|---|---|---|---|
questionary | Object |
none | yes | The questionary object, see the questionary API below |
width | string number |
'300px' | no | Possible values for width can be 100% or 300px or 300 |
height | string number |
'600px' | no | Possible values for width can be 100% or 600px or 600 |
config | Object |
none | no | The configuration object, see the options API below |
type Questionary = {
id: number;
video: string;
text?: string;
questions?: Questionary[];
}
type VideoConfig = {
onFinish?: (answers: number[]) => ( void | {} );
containerStyle?: CSSProperties;
videoStyle?: CSSProperties;
videoClassName?: string;
containerClassName?: string;
orientation?: 'horizontal' | 'vertical';
textContainerStyle?: CSSProperties;
textContainerClassName?: string;
}
Type: (answers: number[]) => ( void | {} )
Callback function that will be called when the user finishes the quiz.
Type: 'horizontal' | 'vertical'
Orientation of the component, can be horizontal or vertical.
Type: CSSProperties
Style object for the container of the component.
Type: string
Class name for the container of the component.
Type: CSSProperties
Style object for the video element.
Type: string
Class name for the video element.
Type: CSSProperties
Style object for the text container.
Type: string
Class name for the text container.
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');
}
}}
/>
)
}
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.