diff --git a/src/commonStyles.module.css b/src/commonStyles.module.css new file mode 100644 index 0000000..839a2b2 --- /dev/null +++ b/src/commonStyles.module.css @@ -0,0 +1,52 @@ +.actions { + display: flex; + justify-content: space-around; +} + +.actions > div { + cursor: pointer; + padding: 5px 20px; + + color: #eee; + border: 1px solid #555; + border-radius: 3px; + user-select: none; +} + +.actions > div:hover { + background-color: #444; + color: white; +} + +.infoContainer { + display: flex; + flex-direction: column; + align-items: center; +} + +.infoContainer > div { + margin: 2px; + text-align: center; +} + +.infoContainer li { + margin: 5px 0px; +} + +.infoHeader { + color: white; + font-size: 38px; + font-weight: bold; +} + +.infoReadButton { + cursor: pointer; + padding: 10px 30px; + + border: 1px solid #444; + border-radius: 3px; +} + +.infoReadButton:hover { + background-color: #444; +} diff --git a/src/components/LoadingIndicator.js b/src/components/LoadingIndicator.js index 1212c1c..d197376 100644 --- a/src/components/LoadingIndicator.js +++ b/src/components/LoadingIndicator.js @@ -1,13 +1,11 @@ -import React, { PureComponent } from 'react' +import React from 'react' -class LoadingIndicator extends PureComponent { - render () { - return ( -
- Loading... -
- ) - } +import styles from './LoadingIndicator.module.css' + +export default function LoadingIndicator() { + return ( +
+
+
+ ) } - -export default LoadingIndicator diff --git a/src/components/LoadingIndicator.module.css b/src/components/LoadingIndicator.module.css new file mode 100644 index 0000000..4638be8 --- /dev/null +++ b/src/components/LoadingIndicator.module.css @@ -0,0 +1,24 @@ +.load { + border: 4px solid #f3f3f3; + border-top: 4px solid #99f; + border-radius: 50%; + width: 20px; + height: 20px; + animation: spin 2s linear infinite; + + margin: 10px; +} + +@keyframes spin { + 0% { + transform: rotate(0deg); + } + 100% { + transform: rotate(360deg); + } +} + +.loadContainer { + display: flex; + justify-content: center; +} diff --git a/src/components/Question.js b/src/components/Question.js index 242c8e8..00984ab 100644 --- a/src/components/Question.js +++ b/src/components/Question.js @@ -1,78 +1,121 @@ -import React, { PureComponent } from 'react' +import React from 'react' import styles from './question.module.css' -class Question extends PureComponent { - render () { - const { subjInd, question, onChange, deleteQuestion } = this.props +const overflowLength = 140 - let qdata = question.data - if (typeof qdata === 'object' && qdata.type === 'simple') { - qdata = '' - } - if (qdata) { - try { - qdata = JSON.stringify(qdata) - } catch (e) {} - } +export default function Question({ question, onChange, index }) { + // FIXME: focus change when input changes to textarea + const possibleAnswers = + question.possibleAnswers || question.data.possibleAnswers - const qChange = (e) => { - onChange(subjInd, question.ind, { - ...question, - [e.target.name]: e.target.value - }) - } - - const qDataChange = (e) => { - try { - let newData = JSON.parse(e.target.value) - onChange(subjInd, question.ind, { - ...question, - data: newData - }) - } catch (e) { - console.log('invalid JSON') - } - } - - return ( -
-
- -
-
- -
-
- - { deleteQuestion(subjInd, question.ind) }} - > - Delete question - -
-
- ) - } + return ( +
+ {question.Q && question.Q.length > overflowLength ? ( +