feat: Add an extended bubble design for the widget (#1123)
* feat: Add a new design for chat bubble Signed-off-by: Pranav Raj Sreepuram <pranavrajs@gmail.com> * Add i18n * Fix stye issues * Set fixed font-size * Update docs for bubble
This commit is contained in:
parent
a04ca24def
commit
0adbc346df
16 changed files with 164 additions and 84 deletions
|
@ -1,5 +1,6 @@
|
|||
import { addClass, toggleClass, wootOn } from './DOMHelpers';
|
||||
import { IFrameHelper } from './IFrameHelper';
|
||||
import { BUBBLE_DESIGN } from './constants';
|
||||
|
||||
export const bubbleImg =
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAUVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////8IN+deAAAAGnRSTlMAAwgJEBk0TVheY2R5eo+ut8jb5OXs8fX2+cjRDTIAAADsSURBVHgBldZbkoMgFIThRgQv8SKKgGf/C51UnJqaRI30/9zfe+NQUQ3TvG7bOk9DVeCmshmj/CuOTYnrdBfkUOg0zlOtl9OWVuEk4+QyZ3DIevmSt/ioTvK1VH/s5bY3YdM9SBZ/mUUyWgx+U06ycgp7D8msxSvtc4HXL9BLdj2elSEfhBJAI0QNgJEBI1BEBsQClVBVGDgwYOLAhJkDM1YOrNg4sLFAsLJgZsHEgoEFFQt0JAFGFjQsKAMJ0LFAexKgZYFyJIDxJIBNJEDNAtSJBLCeBDCOBFAPzwFA94ED+zmhwDO9358r8ANtIsMXi7qVAwAAAABJRU5ErkJggg==';
|
||||
|
@ -10,14 +11,34 @@ export const widgetHolder = document.createElement('div');
|
|||
export const bubbleHolder = document.createElement('div');
|
||||
export const chatBubble = document.createElement('div');
|
||||
export const closeBubble = document.createElement('div');
|
||||
|
||||
export const notificationBubble = document.createElement('span');
|
||||
|
||||
export const getBubbleView = type =>
|
||||
BUBBLE_DESIGN.includes(type) ? type : BUBBLE_DESIGN[0];
|
||||
export const isExpandedView = type => getBubbleView(type) === BUBBLE_DESIGN[1];
|
||||
|
||||
export const setBubbleText = bubbleText => {
|
||||
if (isExpandedView(window.$chatwoot.type)) {
|
||||
const textNode = document.getElementById('woot-widget--expanded__text');
|
||||
textNode.innerHTML = bubbleText;
|
||||
}
|
||||
};
|
||||
|
||||
export const createBubbleIcon = ({ className, src, target }) => {
|
||||
target.className = `${className} woot-elements--${window.$chatwoot.position}`;
|
||||
let bubbleClassName = `${className} woot-elements--${window.$chatwoot.position}`;
|
||||
const bubbleIcon = document.createElement('img');
|
||||
bubbleIcon.src = src;
|
||||
target.appendChild(bubbleIcon);
|
||||
|
||||
if (isExpandedView(window.$chatwoot.type)) {
|
||||
const textNode = document.createElement('div');
|
||||
textNode.id = 'woot-widget--expanded__text';
|
||||
textNode.innerHTML = '';
|
||||
target.appendChild(textNode);
|
||||
bubbleClassName += ' woot-widget--expanded';
|
||||
}
|
||||
|
||||
target.className = bubbleClassName;
|
||||
return target;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue