Permalink
Please sign in to comment.
Showing
with
411 additions
and 187 deletions.
- +5 −0 Dockerfile
- +3 −0 README.md
- +18 −0 components/loading.js
- +2 −2 components/navbuttons.js
- +89 −0 components/person-info.js
- +29 −20 components/thetest.js
- +1 −1 components/timer.js
- +4 −2 config/index.js
- +3 −4 lib/get-data.js
- +3 −1 lib/is-all-checked.js
- +8 −0 lib/post-data.js
- +2 −1 package.json
- +15 −0 pages/100.js
- +15 −0 pages/120.js
- +15 −0 pages/50.js
- +7 −1 pages/index.js
- +21 −0 pages/info.js
- +1 −0 static/loading.svg
- +170 −155 yarn.lock
| @@ -0,0 +1,18 @@ | ||
| +import React from 'react' | ||
| + | ||
| +export default ({loading}) => ( | ||
| + <span style={{display: loading ? 'block' : 'none'}} className='loading'> | ||
| + <p> | ||
| + <img src='static/loading.svg' style={{width: 100}} /> | ||
| + </p> | ||
| + <p> | ||
| + <big>LOADING ...</big></p> | ||
| + <style> | ||
| + {` | ||
| + .loading { | ||
| + text-align: center; | ||
| + } | ||
| + `} | ||
| + </style> | ||
| + </span> | ||
| +) |
| @@ -0,0 +1,89 @@ | ||
| +import React from 'react' | ||
| +const countries = require('country-list')() | ||
| + | ||
| +export default ({loading}) => ( | ||
| + <div> | ||
| + <form> | ||
| + <p className='question'>Information</p> | ||
| + By taking the test you are agreeing that the input you provide will be saved and used for statistics. | ||
| + <ul> | ||
| + <li className='infoText'> | ||
| + Answer honestly, even if you don't like the answer. | ||
| + </li> | ||
| + <li className='infoText'> | ||
| + Describe yourself as you generally are now, not as you wish to be in the future. | ||
| + </li> | ||
| + <li className='infoText'> | ||
| + Compare yourself in relation to other people of the same sex and roughly the same age. | ||
| + </li> | ||
| + <li className='infoText'> | ||
| + Your spontaneous answer is usually the most accurate. | ||
| + </li> | ||
| + </ul> | ||
| + <p className='question'>Age</p> | ||
| + <input name='age' className='age' type='text' placeholder='Age' pattern="\d*" maxLength='2' min='10' max='100' /> | ||
| + <p className='question'>Gender</p> | ||
| + <span className='choiseBox'> | ||
| + <i name='female' className='material-icons checked-female'>radio_button_checked</i> | ||
| + <span className='choiseText'>Female</span> | ||
| + <i name='male' className='material-icons checked-male'>radio_button_unchecked</i> | ||
| + <span className='choiseText'>Male</span> | ||
| + </span> | ||
| + <span className='choiseBox'> | ||
| + <p className='question'>Nationality</p> | ||
| + <select className='countries'> | ||
| + {countries.getData().map(country => { | ||
| + return ( | ||
| + <option key={country.code} value={country.code}>{country.name}</option> | ||
| + ) | ||
| + })} | ||
| + </select> | ||
| + </span> | ||
| + <span> | ||
| + <p style={{marginTop: '50px'}}> | ||
| + <button className='navButton' type='submit'> | ||
| + <i className='material-icons' style={{ fontSize: '40px' }}>navigate_next</i> | ||
| + </button> | ||
| + </p> | ||
| + </span> | ||
| + </form> | ||
| + <style> | ||
| + {` | ||
| + .age { | ||
| + font-size: 24px; | ||
| + background-color: #fff; | ||
| + color: #828282; | ||
| + width: 64px; | ||
| + } | ||
| + .countries { | ||
| + font-size: 24px; | ||
| + background-color: #fff; | ||
| + color: #828282; | ||
| + } | ||
| + .checked-female { | ||
| + color: #dfa7e8; | ||
| + } | ||
| + .checked-male { | ||
| + color: #a7cfe8; | ||
| + } | ||
| + .infoText { padding-bottom: 8px; } | ||
| + .navButton { | ||
| + background-color: #94d696; | ||
| + border-radius: 5px; | ||
| + border: transparent; | ||
| + color: white; | ||
| + margin-right: 10px; | ||
| + } | ||
| + .question { | ||
| + font-size: 28px; | ||
| + margin-bottom: 10px; | ||
| + } | ||
| + .choiseText { | ||
| + line-height: 24px; | ||
| + padding: 4px; | ||
| + vertical-align: top; | ||
| + } | ||
| + `} | ||
| + </style> | ||
| + </div> | ||
| +) |
| @@ -1,8 +1,10 @@ | ||
| 'use strict' | ||
| module.exports = { | ||
| - dataUrl: process.env.DATA_URL || 'https://micro-bigfive-questions-olegrjzdba.now.sh/getQuestions', | ||
| + dataUrl: process.env.DATA_URL || 'https://bigfive-questions.maccyber.io/getQuestions', | ||
| + generatorUrl: process.env.GENERATOR_URL || 'https://micro-bigfive-save-cmfdczkdwn.now.sh', | ||
| defaultLanguage: process.env.DEFAULT_LANG || 'en', | ||
| - defaultTest: process.env.DEFAULT_TEST || '50' | ||
| + defaultLimit: parseInt(process.env.DEFAULT_LIMIT) || 5, | ||
| + defaultTest: process.env.DEFAULT_TEST || 50 | ||
| } | ||
| @@ -1,9 +1,8 @@ | ||
| 'use strict' | ||
| -import fetch from 'isomorphic-fetch' | ||
| +import axios from 'axios' | ||
| module.exports = async (url) => { | ||
| - const dataResponse = await fetch(url) | ||
| - const data = await dataResponse.json() | ||
| - return data | ||
| + const res = await axios.get(url) | ||
| + return res.data | ||
| } |
| @@ -1,6 +1,8 @@ | ||
| 'use strict' | ||
| +import config from '../config' | ||
| + | ||
| module.exports = (radios, from, to) => { | ||
| const currentQuestions = radios.slice(from, to) | ||
| - return Object.keys(currentQuestions).length === 5 | ||
| + return Object.keys(currentQuestions).length === config.defaultLimit | ||
| } |
| @@ -0,0 +1,8 @@ | ||
| +'use strict' | ||
| + | ||
| +import axios from 'axios' | ||
| + | ||
| +module.exports = async (url, data) => { | ||
| + const res = await axios.post(url, data) | ||
| + return res.data | ||
| +} |
15
pages/100.js
| @@ -0,0 +1,15 @@ | ||
| +'use strict' | ||
| + | ||
| +import React from 'react' | ||
| +import TheTest from '../components/thetest' | ||
| +import Page from '../layouts' | ||
| + | ||
| +export default class Index extends React.Component { | ||
| + render () { | ||
| + return ( | ||
| + <Page pageTitle='BigFive Personality Test'> | ||
| + <TheTest test='100' /> | ||
| + </Page> | ||
| + ) | ||
| + } | ||
| +} |
15
pages/120.js
| @@ -0,0 +1,15 @@ | ||
| +'use strict' | ||
| + | ||
| +import React from 'react' | ||
| +import TheTest from '../components/thetest' | ||
| +import Page from '../layouts' | ||
| + | ||
| +export default class Index extends React.Component { | ||
| + render () { | ||
| + return ( | ||
| + <Page pageTitle='BigFive Personality Test'> | ||
| + <TheTest test='120' /> | ||
| + </Page> | ||
| + ) | ||
| + } | ||
| +} |
15
pages/50.js
| @@ -0,0 +1,15 @@ | ||
| +'use strict' | ||
| + | ||
| +import React from 'react' | ||
| +import TheTest from '../components/thetest' | ||
| +import Page from '../layouts' | ||
| + | ||
| +export default class Index extends React.Component { | ||
| + render () { | ||
| + return ( | ||
| + <Page pageTitle='BigFive Personality Test'> | ||
| + <TheTest test='50' /> | ||
| + </Page> | ||
| + ) | ||
| + } | ||
| +} |
Oops, something went wrong.
0 comments on commit
fe1e146