simm firebase chat - techbasejs/techbase GitHub Wiki

Install

npm install simm-firebase-chat

Usage

import firebaseChat from 'simm-firebase-chat';

const firebaseConfig = {};

firebaseChat.init(firebaseConfig)

firebaseChat.render('#my-container', {
   layout: 'basic', // basic or advanced, basic is simple layout, advanced is full-feature but it's complex layout.
   upload: {
     audio: true, // if false, button upload audio is hidden.
     video: true, // if false, button upload video is hidden.
   },
   hooks: {
     beforeSendMessage: () => {}, // hook before send message
     afterSendMessage: () => {}, // hook after send message
     beforeUpload: () => {}, // hook before upload
     afterUpload: () => {}, // hook after upload
   },
   customize: {
      // customize messageBox UI
      messageBox: ({ sendMessage, messageText }) => {
        const messageBoxElm = document.createElement('button');
        messageBoxElm.onClick = () => {
          sendMessage({ messageTextmessageText })
        };
        return messageBoxElm;
      },
      // customize button upload UI
      upload: ({ upload, type, file }) => {
        // type is audio or video
        const audioUploadElm = document.createElement('button');
        audioUploadElm.onClick = () => {
          upload(file);
        };
        return audioUploadElm;
      },
      // customize message item, if return null message item keep default UI.
      messageItem: ({ message, actions }) => {
        // actions.preview, actions.deleteMessage, actions.editMessage, ...
        const messageItem =  document.createElement('div');
        messageItem.innerHTML = message.body;
        return messageItem;
      },
      
   },
})