diff --git a/src/components/Expander/index.js b/src/components/Expander/index.js index de8f67b1..7e0d75be 100644 --- a/src/components/Expander/index.js +++ b/src/components/Expander/index.js @@ -3,27 +3,30 @@ import PropTypes from 'prop-types' import cx from 'classnames' import './style.scss' -const Expander = ({ onClick, preferences, style, show }) => ( -
- {preferences.expanderLogo && ( - - )} - {preferences.expanderTitle} +const Expander = ({ onClick, preferences, style, show }) => { + return ( +
+ {preferences.expanderLogo && ( + + )} - {preferences.onboardingMessage && ( -
{preferences.onboardingMessage}
- )} -
-) + {preferences.expanderTitle} + + {preferences.onboardingMessage && ( +
{preferences.onboardingMessage}
+ )} +
+ ) +} Expander.propTypes = { preferences: PropTypes.object, diff --git a/src/components/Expander/style.scss b/src/components/Expander/style.scss index 991c6398..e61ad3d5 100644 --- a/src/components/Expander/style.scss +++ b/src/components/Expander/style.scss @@ -12,6 +12,12 @@ box-shadow: 0 1px 6px lightgrey, 0 2px 32px lightgrey; transition: opacity 0.3s; + // preference sticky location bottom left + &.chatLocationStickyLeft { + left: 10px; + right: auto; + } + &.open { opacity: 1; } diff --git a/src/containers/App/index.js b/src/containers/App/index.js index 4b90ee25..310a097d 100644 --- a/src/containers/App/index.js +++ b/src/containers/App/index.js @@ -25,14 +25,20 @@ const NO_LOCALSTORAGE_MESSAGE }, ) class App extends Component { + state = { expanded: this.props.expanded || false, + chatLocationSticky: 'default', + chatDirectionOpen: 'default' } componentDidMount () { const { channelId, token, preferences, noCredentials, onRef } = this.props const credentials = getCredentialsFromCookie(channelId) const payload = { channelId, token } + preferences.chatLocationSticky = this.state.chatLocationSticky; + preferences.chatDirectionOpen = this.state.chatDirectionOpen; + this.forceUpdate(); if (onRef) { onRef(this) @@ -59,7 +65,6 @@ class App extends Component { componentWillReceiveProps (nextProps) { const { isReady, preferences, expanded } = nextProps - if (isReady !== this.props.isReady) { let expanded = null @@ -89,7 +94,7 @@ class App extends Component { } componentDidUpdate (prevState) { - const { onToggle } = this.props + const { onToggle, preferences } = this.props if (prevState.expanded !== this.state.expanded) { if (typeof window.localStorage !== 'undefined') { @@ -101,6 +106,9 @@ class App extends Component { console.log(NO_LOCALSTORAGE_MESSAGE) } } + + preferences.chatLocationSticky = this.state.chatLocationSticky; + preferences.chatDirectionOpen = this.state.chatDirectionOpen; } componentDidCatch (error, info) { @@ -120,6 +128,21 @@ class App extends Component { this.props.removeAllMessages() } + /*TODO remove for HACKTOBER DEMO purpose */ + handleChangeLocation = (event) => { + this.setState( + {chatLocationSticky: event.target.value}, () => { + this.forceUpdate(); + }); + } + + handleChangeDirection = (event) => { + this.setState( + {chatDirectionOpen: event.target.value}, () => { + this.forceUpdate(); + }); + } + render () { const { preferences, @@ -139,9 +162,66 @@ class App extends Component { defaultMessageDelay, } = this.props const { expanded } = this.state + const {chatDirectionOpen, chatLocationSticky } = this.state return (
+
+
+ LOCATION + + +
+
+ DIRECTION + + + +
+
{secondaryView ? ( diff --git a/src/containers/Chat/style.scss b/src/containers/Chat/style.scss index 293b16b8..5d191b7b 100644 --- a/src/containers/Chat/style.scss +++ b/src/containers/Chat/style.scss @@ -59,10 +59,48 @@ width: 370px; height: auto; box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16); - + &--slogan { margin-bottom: 0; } + + // preference sticky location bottom left + &.chatLocationStickyLeft { + left: 10px; + right: auto; + } + + &.chatDirectionLeftRight { + transform-origin: left; + + &.open { + transform: scaleX(1); + opacity: 1; + overflow: hidden; + } + + &.close { + transform: scaleX(0); + opacity: 0; + overflow: hidden; + } + } + + &.chatDirectionRightLeft { + transform-origin: right; + + &.open { + transform: scaleX(1); + opacity: 1; + overflow: hidden; + } + + &.close { + transform: scaleX(0); + opacity: 0; + overflow: hidden; + } + } } } @media only screen and (max-width: 420px) {