From e758f3788353d6a3a893e57a7698cf4c3f219467 Mon Sep 17 00:00:00 2001 From: Paul O'Flaherty Date: Sun, 2 Apr 2017 11:29:11 +1000 Subject: [PATCH] Issue #11: Control height of Chat --- src/Chat.js | 17 +++++++++++------ src/Conversation.js | 8 +++++--- src/stories/chat.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/Chat.js b/src/Chat.js index db3ba30..023e258 100644 --- a/src/Chat.js +++ b/src/Chat.js @@ -9,13 +9,16 @@ const defaultStyle = { overflow: 'hidden', height: '340px', }, - inputDiv: { + conversation: { + height: '300px', + }, + textInputContainer: { height: '40px', width: '100%', backgroundColor: '#efefef', borderRadius: '5px', }, - input: { + textInput: { margin: '8px', width: 'calc(100% - 20px)', height: 'calc(100% - 20px)', @@ -49,12 +52,14 @@ class Chat extends React.Component { } } render() { - const style = StyleSheet.create(assignDeep({}, defaultStyle, this.props.styles || {})); + const chatStyles = assignDeep({}, defaultStyle, this.props.styles || {}); + const style = StyleSheet.create(chatStyles); + return (
- -
- + +
+
); diff --git a/src/Conversation.js b/src/Conversation.js index 5c82b2d..e25647e 100644 --- a/src/Conversation.js +++ b/src/Conversation.js @@ -126,16 +126,18 @@ class Conversation extends React.Component { const isInbound = isTyping && inbound; const isOutbound = isTyping && !inbound; - const style = StyleSheet.create(assignDeep({}, defaultStyle, { + const chatStyles = assignDeep({}, defaultStyle, { conversation: { height: this.props.height || defaultStyle.conversation.height, }, - }, this.props.styles || {})); + }, this.props.styles || {}); + const style = StyleSheet.create(chatStyles); + return (
- +
{isTyping && } diff --git a/src/stories/chat.js b/src/stories/chat.js index 503d408..beb4f59 100644 --- a/src/stories/chat.js +++ b/src/stories/chat.js @@ -24,4 +24,49 @@ storiesOf('Chat', module)
); +}) +.add('Chat configured styles and ends at the last message and allows the user to add messages', () => { + const messagesForConversation = [ + { + message: 'Press enter to write a message', + inbound: true, + backColor: 'white', + duration: 1000, + }, + ]; + const historicMessages = [ + { + message: 'Type in the input box below', + inbound: true, + backColor: 'white', + }, + ]; + const styles = { + chat: { + height: '480px', + }, + conversation: { + height: '400px', + }, + container: { + bottom: '1%', + }, + messages: { + height: '99%', + }, + noTyping: { + height: '2%', + }, + textInputContainer: { + height: '80px', + }, + textInput: { + fontSize: '2em', + }, + }; + return ( +
+ +
+ ); });