Skip to content
Snippets Groups Projects
Commit 28088af3 authored by nichexx's avatar nichexx :surfer:
Browse files

new css in Question page, add question counter

parent 2785af16
No related branches found
No related tags found
No related merge requests found
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import Likert from './likert.js'; import Likert from './likert.js';
import unisport_logo from './images/logo_unisport.png'; //import PropTypes from 'prop-types';
//import unisport_logo from './logo_unisport.png';
const likertOptions = { const likertOptions = {
question: "Ich würde am liebsten gemeinsam mit anderen trainieren. Teamgeist und Wir-Gefühl sind für mich beim Sport eine große Motivation.", question:
'Ich würde am liebsten gemeinsam mit anderen trainieren. Teamgeist und Wir-Gefühl sind für mich beim Sport eine große Motivation.',
responses: [ responses: [
{ value: 0, text: "Stimme nicht zu" }, { value: 0, text: 'Stimme nicht zu' },
{ value: 1, text: "Stimme eher nicht zu" }, { value: 1, text: 'Stimme eher nicht zu' },
{ value: 2, text: "Stimme eher zu"}, { value: 2, text: 'Stimme eher zu' },
{ value: 3, text: "Stimme zu" } { value: 3, text: 'Stimme zu' }
], ]
};
const counter = {
backgroundColor: '#F0F0F0',
color: '#8192A6',
padding: '10px',
width: '164px',
height: '50px',
borderRadius: '0.5em',
fontFamily: 'Roboto',
fontSize: '22px',
position: 'relativ',
display: 'block',
alignItems: 'center',
marginLeft: 'auto',
marginRight: 'auto',
textAlign: 'center'
}; };
export default function DemoQuestion() { export default function DemoInsteracion() {
let style = {
uniSportLogoStyle :
{
width : '163px',
height : '72px',
}
}
const refLikert = useRef(null); const refLikert = useRef(null);
const [chosen, setChosen] = useState(null); const [chosen, setChosen] = useState(null);
const onChange = (chosen) => {
const content = (
<span>
You chose:{" "}
<strong>
{chosen?.value}{chosen?.text}
</strong>
</span>
);
setChosen(content);
};
const getAlertMessage = () => { const getAlertMessage = () => {
const rect = refLikert.current.getBoundingClientRect(); const rect = refLikert.current.getBoundingClientRect();
return `This demonstrates how you can get access to the underlying DOM element. return `This demonstrates how you can get access to the underlying DOM element.
...@@ -46,27 +43,46 @@ and ${parseInt(rect.height)}px tall.`; ...@@ -46,27 +43,46 @@ and ${parseInt(rect.height)}px tall.`;
}; };
return ( return (
<> <div className='app'>
<question>Question </question> <h4 style={counter}> Frage 1/10 </h4>
<Likert <Likert
{...likertOptions} {...likertOptions}
onChange={onChange} id='q1'
onClick={() => {}}
//onChange={props.onAnswerSelected}
ref={refLikert} ref={refLikert}
className= 'withBorder' className='question_likert'
/> />
<p style={{ textAlign: 'center' }}> <p style={{ textAlign: 'center' }}>{chosen}</p>
{chosen} <style>
</p> {`
<style>{` .app {
.withBorder {
color: #003466; color: #003466;
padding: 2em; padding: 1em;
border: thin solid darkgray;
margin: 1.5em;
border-radius: 0.5em;
font-family: roboto-bold, sans-serif; font-family: roboto-bold, sans-serif;
font-size: 50px;
font-weight: 700; font-weight: 700;
height: 315px; align-items: center;
min-height: 420px; left: Thank 30%;
width: 702px; display: 'block',
`}</style> justify-content: center;
</> }
.likertText {
color: #6B9E1F;
display: inline-block;
font-family: roboto-normal, sans-serif;
font-size: 20px;
padding-top: 1em;
padding-left: 0.4em;
padding-right: 0.4em;
width: 100%;
box-sizing: border-box;
}
`}
</style>
</div>
); );
} }
import React from 'react';
import PropTypes from 'prop-types';
function QuestionCount(props) {
return (
<div className="questionCount">
Question <span>{props.counter}</span> of <span>{props.total}</span>
</div>
);
}
QuestionCount.propTypes = {
counter: PropTypes.number.isRequired,
total: PropTypes.number.isRequired
};
export default QuestionCount;
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500&display=swap');
.likertScale { .likertScale {
margin-bottom: 1em; margin-bottom: 1em;
border: none; border: none;
...@@ -18,10 +20,9 @@ ...@@ -18,10 +20,9 @@
flex-grow: 4; /* This can get overridden by the “flexible” prop. */ flex-grow: 4; /* This can get overridden by the “flexible” prop. */
flex-shrink: 0; flex-shrink: 0;
flex-basis: auto; flex-basis: auto;
display: flex; display: flex;
padding-top: 2em; padding-top: 1.5em;
padding-bottom: 1em; padding-bottom: 0.5em;
} }
.layout--stacked .likertBand { .layout--stacked .likertBand {
align-self: stretch; align-self: stretch;
...@@ -38,7 +39,7 @@ ...@@ -38,7 +39,7 @@
display: inline-block; display: inline-block;
width: 50%; width: 50%;
vertical-align: top; vertical-align: top;
margin-top: 1em; margin-top: 0.3em;
border-top: 2px solid #99cc01; border-top: 2px solid #99cc01;
} }
.likertResponse:first-child .likertLine:first-child { .likertResponse:first-child .likertLine:first-child {
...@@ -72,7 +73,9 @@ ...@@ -72,7 +73,9 @@
} }
.likertText { .likertText {
display: inline-block; display: inline-block;
padding-top: 2em; font-family: roboto-normal, sans-serif;
font-size: var(--font-size-m);
padding-top: 1em;
padding-left: 0.4em; padding-left: 0.4em;
padding-right: 0.4em; padding-right: 0.4em;
width: 100%; width: 100%;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment