From f7f7a6b9c7f653019df8aa55c57025d4e9f10e7d Mon Sep 17 00:00:00 2001 From: Nithin David Thomas Date: Fri, 17 Jan 2020 13:36:05 +0530 Subject: [PATCH] Feature: Widget design update (#426) --- .../assets/scss/widgets/_woot-tables.scss | 2 +- app/javascript/packs/sdk.js | 30 +++++---- app/javascript/widget/App.vue | 13 +--- .../widget/assets/scss/_mixins.scss | 64 +++++++++++++++++-- .../widget/assets/scss/_variables.scss | 13 +++- app/javascript/widget/assets/scss/sdk.js | 21 ++---- .../widget/components/AgentMessage.vue | 8 +-- app/javascript/widget/components/Branding.vue | 2 +- .../widget/components/ChatFooter.vue | 4 +- .../widget/components/ChatHeader.vue | 54 +++++++++++++--- .../widget/components/ChatHeaderExpanded.vue | 6 +- .../widget/components/UserMessage.vue | 1 + .../widget/components/UserMessageBubble.vue | 2 +- .../widget/components/template/EmailInput.vue | 2 +- app/javascript/widget/helpers/utils.js | 10 +++ app/javascript/widget/views/Home.vue | 15 +++++ app/views/widget_tests/index.html.erb | 2 + package.json | 3 +- 18 files changed, 186 insertions(+), 66 deletions(-) diff --git a/app/javascript/dashboard/assets/scss/widgets/_woot-tables.scss b/app/javascript/dashboard/assets/scss/widgets/_woot-tables.scss index a51d38e83..d229c0738 100644 --- a/app/javascript/dashboard/assets/scss/widgets/_woot-tables.scss +++ b/app/javascript/dashboard/assets/scss/widgets/_woot-tables.scss @@ -21,7 +21,7 @@ table { tr { .show-if-hover { opacity: 0; - transition: all .2s $ease-in-out-cubic; + transition: all 0.2s $ease-in-out-cubic; } &:hover { diff --git a/app/javascript/packs/sdk.js b/app/javascript/packs/sdk.js index 1917aa83e..8f2295ff2 100755 --- a/app/javascript/packs/sdk.js +++ b/app/javascript/packs/sdk.js @@ -140,19 +140,21 @@ const IFrameHelper = { '*' ); }, + events: { + loaded: message => { + Cookies.set('cw_conversation', message.config.authToken); + IFrameHelper.sendMessage('config-set', {}); + IFrameHelper.onLoad(message.config.channelConfig); + IFrameHelper.setCurrentUrl(); + }, + set_auth_token: message => { + Cookies.set('cw_conversation', message.authToken); + }, + toggleBubble: () => { + bubbleClickCallback(); + }, + }, initPostMessageCommunication: () => { - const events = { - loaded: message => { - Cookies.set('cw_conversation', message.config.authToken); - IFrameHelper.sendMessage('config-set', {}); - IFrameHelper.onLoad(message.config.channelConfig); - IFrameHelper.setCurrentUrl(); - }, - set_auth_token: message => { - Cookies.set('cw_conversation', message.authToken); - }, - }; - window.onmessage = e => { if ( typeof e.data !== 'string' || @@ -161,8 +163,8 @@ const IFrameHelper = { return; } const message = JSON.parse(e.data.replace('chatwoot-widget:', '')); - if (typeof events[message.event] === 'function') { - events[message.event](message); + if (typeof IFrameHelper.events[message.event] === 'function') { + IFrameHelper.events[message.event](message); } }; }, diff --git a/app/javascript/widget/App.vue b/app/javascript/widget/App.vue index 86b86d459..890233796 100755 --- a/app/javascript/widget/App.vue +++ b/app/javascript/widget/App.vue @@ -6,17 +6,8 @@ diff --git a/app/javascript/widget/components/ChatHeaderExpanded.vue b/app/javascript/widget/components/ChatHeaderExpanded.vue index 7178c7556..d2f020ac6 100755 --- a/app/javascript/widget/components/ChatHeaderExpanded.vue +++ b/app/javascript/widget/components/ChatHeaderExpanded.vue @@ -41,15 +41,15 @@ export default {