1.0.2 • Published 3 years ago

weichat v1.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

react-mui-chat

React chat component, based on Material-UI framework

Features

  • 📱 Responsive styles
  • 3️⃣ Contact unread message counter
  • 🖥 Fullscreen and compatible modes
  • 🔥 Automatic scroll to first unread message
  • ⚡️ Automatic scroll to bottom, if contact hasn't unread messages

Requirements

  • React
  • ES6

Install

If you use NPM: npm i react-mui-chat

If you use Yarn: yarn add react-mui-chat

Usage

First of all - import component from library:

import React from 'react';
import MuiChat from 'react-mui-chat';

Then, add componnet to your code:

<section>
  <MuiChat>
</section>

That's all!

Props

NameTypeDescription
chatStylesobjectIn this param you will pass all the chat styles properties (see more information under the table).
contactsarrayArray of objects with contacts.
selectedContactobjectSelected contact object, with mandatory fields: index (integer), messages (array)
onContactClickfunctionOn contact click handler
onSendBtnClickfunctionOn send button click handler
showContactsFilterInputbooleanFlag for show/hide contacts filter input field
onContactsFilterChangefunctionHandler, that recieve value of contact filter input
contactsFilterFieldbooleanTurn on/off contacts filter textfield
msgDateFormatstringMoment date formatting string. See more on Moment docs

Styles

You need to pass 'chatStyles' prop (from the table above)

<section>
  <MuiChat chatStyles={{
    contactsColWidth: '350px',
    outcomingMsgColor: '#9b38ff',
  }}>
</section>
NameTypeDefaultDescription
incomingMsgColorstring#eeeIncoming message background color
outcomingMsgColorstring#2196f3Outcoming message background color
contactsColWidthstring300pxWidth of contacts column
selectedContactColorstring#2196f3Background color of selected contact

To do (MVP):

  1. Add contacts Search field ✅
  2. Add scroll to first unread message ✅
  3. Add dates between messages ✅
  4. Add additional content block for message
  5. Add hotkeys for sending messages
  6. Refactoring to npm-package
  7. Add examples of usage