0.1.1 • Published 3 years ago
react-tag-quiz v0.1.1
UI to create a series of questions with multiple choice answers that get fed into a simple function that outputs the results. BYO function.
Installation
npm install react-tag-quiz
import Quiz from 'react-tag-quiz
Sample Usage
<Quiz
formData={{questions[...]}}
introComponent={<div>{children}</div>}
getResultsFn={answers => {
// Fetch or generate answers
// Return answers object
}}
theme={{
section: {
color: '#fff',
},
color: {
background: 'tomato',
foreground: '#fff',
},
}}
/>
Required Props
Prop Name | Type | Example |
---|---|---|
formData | Object | {questions: [{label: 'What is your favourite colour?',options: { key: 'red', label: 'Red' },{ key: 'blue', label: 'Blue' },,},{...}],} |
introComponent | Component | <div><h1>Want to do the questionnaire? Click the button below to get started</h1>{children}</div> |
getResultsFn | Function | (selectedValues) => {} |
Optional Props
Prop Name | Type | Default |
---|---|---|
button | Component | ? |
startLabel | String | "Start" |
nextLabel | String | "Next" |
loadingMessage | String | "Loading your results..." |
finishLabel | String | "Get Results" |
height | String | "65vh" |
resultsComponent | Component | ? |
theme | Object | {} |
resetSelectionsOnRestart | Boolean | true |
Developing locally
- Create a symlink for this repo. From this directory
npm link
- To use it in another project, from that directory, run
npm link ../[path_to_this_repo]
- There will also likely be missing react/styled-component messages. If so,
npm link react
from this directory should fix - If there are subseuqne tmessages about invalid react hook calls, it is likely that the consuming project is seeing two versions of react. To fix this temporarily, from this directory
npm link ../[path_to_consumer_project]/node_modules/[react|react-dom|styled-components]
. See here.
0.1.1
3 years ago
0.0.18
3 years ago
0.0.14
3 years ago
0.0.15
3 years ago
0.0.16
3 years ago
0.0.17
3 years ago
0.0.13
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago
0.1.3
3 years ago