Make status flicker.

This commit is contained in:
Tomasz Rewak
2023-05-17 10:58:55 +02:00
parent a7b42a58a2
commit 558f1dd270
2 changed files with 30 additions and 13 deletions
+9 -3
View File
@@ -39,13 +39,19 @@ function getStatusColor(status) {
}
export default function Response(props) {
const { status } = props;
const { status, question_id, answer_id } = props;
const text = getStatusText(status);
const color = getStatusColor(status);
return React.createElement('div', { className: 'response', style: { color: color, borderColor: color } },
return React.createElement('div', { className: `response ${question_id !== answer_id ? 'flicker' : ''}`, style: { color: color, borderColor: color } },
[
React.createElement('div', { className: 'inner' }, [text])
]);
}
}
Response.defaultProps = {
status: 'info',
question_id: 0,
answer_id: 0
};
+21 -10
View File
@@ -162,25 +162,36 @@ def wise_man_answer(question: dict, personality: str, key: str):
@callback(
Output({'type': 'wise-man', 'name': MATCH}, 'question_id'),
Input('question', 'data'))
def question_id(question: dict):
def wise_man_question_id(question: dict):
return question['id']
@callback(
Output('response', 'question_id'),
Input('question', 'data'))
def response_question_id(question: dict):
return question['id']
@callback(
Output('response', 'status'),
Output('response', 'answer_id'),
Input({'type': 'wise-man', 'name': ALL}, 'answer'),
prevent_initial_call=True)
def response_status(answers: list):
answer_id = min([answer['id'] for answer in answers])
status = 'info'
if any([answer['status'] == 'error' for answer in answers]):
return 'error'
if any([answer['status'] == 'no' for answer in answers]):
return 'no'
if any([answer['status'] == 'conditional' for answer in answers]):
return 'conditional'
if all([answer['status'] == 'yes' for answer in answers]):
return 'yes'
return 'info'
status = 'error'
elif any([answer['status'] == 'no' for answer in answers]):
status = 'no'
elif any([answer['status'] == 'conditional' for answer in answers]):
status = 'conditional'
elif all([answer['status'] == 'yes' for answer in answers]):
status = 'yes'
return status, answer_id
@callback(