From fd0ef4b2d8be59bd0d180cd82163ddd149ca5de2 Mon Sep 17 00:00:00 2001 From: mama Date: Tue, 28 Nov 2017 18:08:21 +0100 Subject: [PATCH] Ajout de raccourcis clavier --- .../components/conversation/FormDecorator.js | 3 +- .../conversation/IgnoreStepButton.css | 17 ++----- .../conversation/IgnoreStepButton.js | 6 +-- source/components/conversation/Input.js | 46 ++++++++----------- source/components/conversation/SendButton.js | 35 ++++++++++++++ .../components/conversation/conversation.css | 19 ++++++++ 6 files changed, 82 insertions(+), 44 deletions(-) create mode 100644 source/components/conversation/SendButton.js diff --git a/source/components/conversation/FormDecorator.js b/source/components/conversation/FormDecorator.js index f20b926ba..57a73c2c8 100644 --- a/source/components/conversation/FormDecorator.js +++ b/source/components/conversation/FormDecorator.js @@ -24,8 +24,7 @@ export var FormDecorator = formType => RenderField => }), dispatch => ({ stepAction: (name, step) => dispatch(stepAction(name, step)), - setFormValue: (field, value) => console.log(field, value) || - dispatch(change('conversation', field, value)) + setFormValue: (field, value) => dispatch(change('conversation', field, value)) }) ) class extends Component { diff --git a/source/components/conversation/IgnoreStepButton.css b/source/components/conversation/IgnoreStepButton.css index 90963ea23..76873ae8a 100644 --- a/source/components/conversation/IgnoreStepButton.css +++ b/source/components/conversation/IgnoreStepButton.css @@ -1,5 +1,9 @@ -#ignore, #ignore:visited { +#ignore { + position: relative; +} + +#ignoreButton, #ignoreButton:visited { cursor: pointer; color: #444; font-weight: 200; @@ -9,14 +13,3 @@ line-height: 1.2em; font-style: italic; } - -#ignoreIcon { - font-size: 80%; - font-weight: bold; - background: #ddd; - color: white; - margin-right: .6em; - padding: .5em .4em; - border-radius: .2em; - transition: .2s opacity; -} diff --git a/source/components/conversation/IgnoreStepButton.js b/source/components/conversation/IgnoreStepButton.js index 36574b514..233a8cc56 100644 --- a/source/components/conversation/IgnoreStepButton.js +++ b/source/components/conversation/IgnoreStepButton.js @@ -19,11 +19,11 @@ export default class IgnoreStepButton extends Component { } render() { return ( -
- Échap - +
+ passer + Échap
) } diff --git a/source/components/conversation/Input.js b/source/components/conversation/Input.js index 3ae4149fe..6f73bef62 100644 --- a/source/components/conversation/Input.js +++ b/source/components/conversation/Input.js @@ -2,8 +2,8 @@ import React, { Component } from 'react' import { FormDecorator } from './FormDecorator' import classnames from 'classnames' import R from 'ramda' -import {Field} from 'redux-form' - +import { Field } from 'redux-form' +import SendButton from './SendButton' @FormDecorator('input') export default class Input extends Component { @@ -28,8 +28,8 @@ export default class Input extends Component {
{this.renderInversions()}
- { this.inputElement = el }} type="text" {...input} value={hoverSuggestion != null ? hoverSuggestion : input.value} @@ -46,6 +46,7 @@ export default class Input extends Component { key == 'Enter' && input.value && (!error ? submit() : input.onBlur()) + // blur will trigger the error } /> @@ -58,18 +59,9 @@ export default class Input extends Component { {answerSuffix} )} - +
{this.renderSuggestions(themeColours)} @@ -79,25 +71,27 @@ export default class Input extends Component { ) } - componentDidMount(){ - let { stepProps: { dottedName, inversion, setFormValue} } = this.props + componentDidMount() { + this.inputElement.focus() + + let { stepProps: { dottedName, inversion, setFormValue } } = this.props if (!inversion) return null // initialize the form field in renderinversions setFormValue(inversion.inversions[0].dottedName, 'inversions.' + dottedName) } renderInversions() { - let { stepProps: { dottedName, inversion} } = this.props + let { stepProps: { dottedName, inversion } } = this.props if (!inversion) return null - if (inversion.inversions.length === 1) return ( - {inversion.inversions[0].title || inversion.inversions[0].dottedName} - ) + if (inversion.inversions.length === 1) + return ( + + {inversion.inversions[0].title || inversion.inversions[0].dottedName} + + ) return ( - + {inversion.inversions.map(({ name, title, dottedName }) => (