diff --git a/public/index.html b/public/index.html index 0d60cf1..a7b2c13 100644 --- a/public/index.html +++ b/public/index.html @@ -23,6 +23,8 @@ exitMessage: 'The chat is closed. You may close this window.', chatUnavailableMessage: 'The chat service is not available right now. Please try again later.', anonymousDisplayName: 'Anonymous', + position: 'bottom right', + size: 'large', } EmbeddableChatbox.mount(config); diff --git a/src/components/_chat.scss b/src/components/_chat.scss index a7b6558..84bf8d9 100644 --- a/src/components/_chat.scss +++ b/src/components/_chat.scss @@ -26,14 +26,56 @@ } } + +@keyframes slideInDown { + from { + transform: translate3d(0, -100%, 0); + display: inherit; + visibility: visible; + } + + to { + transform: translate3d(0, 0, 0); + } +} + +@keyframes slideOutUp { + from { + transform: translate3d(0, 0, 0); + } + + to { + display: none; + visibility: hidden; + transform: translate3d(0, -100%, 0); + } +} + .docked-widget { position: fixed; - bottom: 10px; - right: 10px; z-index: 9999; - width: 400px; max-width: 100vw; font-size: $base-font-size; + + &.size-large { + width: 400px; + + .dock { + width: 400px; + } + } + + &.size-small { + #open-chatbox-label { + display: flex; + align-items: center; + + .icon { + margin-left: 0.5em; + font-size: 1.2em; + } + } + } } .dock { @@ -41,7 +83,6 @@ display: flex; align-items: center; justify-content: space-between; - width: 400px; max-width: calc(100vw - 10px); color: $white; font-family: $theme-font; @@ -53,6 +94,7 @@ background-color: transparent; padding: 5px; + #open-chatbox-label { background: $theme-color; padding: 0.75em; @@ -105,6 +147,10 @@ &-entering { animation-name: slideInUp; + + &.position-top { + animation-name: slideInDown; + } } &-entered { display: inherit; @@ -112,6 +158,10 @@ } &-exiting { animation-name: slideOutDown; + + &.position-top { + animation-name: slideOutUp; + } } &-exited { display: none; diff --git a/src/components/chatbox.jsx b/src/components/chatbox.jsx index a725a80..7952548 100644 --- a/src/components/chatbox.jsx +++ b/src/components/chatbox.jsx @@ -40,6 +40,8 @@ const DEFAULT_CHAT_UNAVAILABLE_MESSAGE = "The chat service is not available righ const DEFAULT_CHAT_OFFLINE_MESSAGE = "All of the chat facilitators are currently offline." const DEFAULT_WAIT_MESSAGE = "Please be patient, our online facilitators are currently responding to other support requests." const DEFAULT_ENCRYPTION_DISABLED = false +const DEFAULT_POSITION = 'bottom right' +const DEFAULT_SIZE = 'large' class ChatBox extends React.Component { @@ -638,14 +640,15 @@ class ChatBox extends React.Component { const { ready, messages, messagesInFlight, inputValue, userId, roomId, typingStatus, opened, showDock, emojiSelectorOpen, isMobile, decryptionErrors } = this.state; const orderedMessages = Object.values(messages).sort((a,b) => a.timestamp - b.timestamp) const inputLabel = 'Send a message...' + const [positionY, positionX] = this.props.position.split(' ') return (
-
+
{(status) => { return ( -
+
@@ -736,7 +739,7 @@ class ChatBox extends React.Component { )} } - {showDock && !roomId && } + {showDock && !roomId && } {showDock && roomId &&
}
@@ -758,6 +761,8 @@ ChatBox.propTypes = { waitMessage: PropTypes.string, chatOfflineMessage: PropTypes.string, isEncryptionDisabled: PropTypes.bool, + position: PropTypes.oneOf(['top left', 'top right', 'bottom left', 'bottom right']), + size: PropTypes.oneOf(['small', 'large']) } ChatBox.defaultProps = { @@ -773,7 +778,9 @@ ChatBox.defaultProps = { chatUnavailableMessage: DEFAULT_CHAT_UNAVAILABLE_MESSAGE, waitMessage: DEFAULT_WAIT_MESSAGE, chatOfflineMessage: DEFAULT_CHAT_OFFLINE_MESSAGE, - isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED + isEncryptionDisabled: DEFAULT_ENCRYPTION_DISABLED, + position: DEFAULT_POSITION, + size: DEFAULT_SIZE, } export default ChatBox; diff --git a/src/components/dock.jsx b/src/components/dock.jsx index 091da38..2f9f6ae 100644 --- a/src/components/dock.jsx +++ b/src/components/dock.jsx @@ -1,8 +1,7 @@ -import React from "react" +import React, { Fragment } from "react" import PropTypes from "prop-types" -const Dock = ({ handleToggleOpen }) => { - +const Dock = ({ handleToggleOpen, size }) => { return( ) }