GithubHelp home page GithubHelp logo

lhj5924 / sendbird-uikit-react Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sendbird/sendbird-uikit-react

0.0 0.0 0.0 16.65 MB

Build chat in minutes with Sendbird UIKit open source code.

Home Page: https://sendbird.com/

License: MIT License

Shell 0.04% JavaScript 43.98% TypeScript 48.36% HTML 0.03% Handlebars 0.09% SCSS 7.50%

sendbird-uikit-react's Introduction

sendbird-uikit

Platform React Language TypeScript

React based UI kit based on sendbird javascript SDK

We are introducing a new version of the Sendbird Chat UIKit. Version 3 features a new modular architecture with more granular components that give you enhanced flexibility to customize your web and mobile apps. Check out our migration guides.

Installation

npm i @sendbird/uikit-react or if you're using yarn yarn add @sendbird/uikit-react

For typescript projects, add node_modules/@sendbird/uikit-react/index.d.ts to your include section in tsconfig file to get type definitions

Getting Started

With Sendbird UI Kit React, we export these components: (See src/index.jsx)

  • SendBirdProvider - The context provider for SDK component

  • useSendbirdStateContext - Hook to access SendBirdProvider context

  • sendBirdSelectors - A bunch of useful selectors that can be used along with useSendbirdStateContext

  • Channel - A UI Component where conversations happen

  • ChannelList - A ChannelList UI component

  • ChannelSettings - A component to handle the settings of a given channel

  • MessageSearch - To search for a message from a Channel

  • OpenChannel - A UI Component where open channel conversations happen

  • OpenChannelSettings - A component to handle the settings of a given channel And many more...

  • App - is a full fledged app(group channel) component made by combining the above components so that you dont have to combine all the above components by hand. Also it can be used as an example for composing components to build a chat UI

Note 1: Dont forget to import the stylesheet from the repo too Note 2: Name of some components are different from the directories they are in(example -> Channel component is from Conversation component). Please keep that in mind

Prerequisites

You need to install:

Caveats

  • We tried development on Mac OS / Linux systems. You might encounter problems in running npm run build or yarn run build in Windows machines
  • If you use node.js >= 17 and see ERR_OSSL_EVP_UNSUPPORTED error on any run cmd, try to set export NODE_OPTIONS=--openssl-legacy-provider in the terminal

Development

We use storybook for development and rollup for building the npm distribution(bundled JS file) Make sure you have nodejs and npm (or yarn) installed and run

Make a copy of .env.example and save it as .env Set your appId STORYBOOK_APP_ID

npm install
npm run storybook

or

yarn install
yarn storybook
  • By default, storybook opens in http://localhost:6006/
  • Smart Components such as ChannelList, Channel, ChannelSetting, App can be found under OTHERS
  • Dumb components such as inputs, buttons etc can be found under OTHERS/UI Components in storybook sidebar
  • Overridden storybook configs can be found in: ./storybook

Husky

We use Husky for githooks

To enable Husky in local, run: yarn husky install or npx husky install

Build

We use rollupJS for building the production bundle script that you want to use inside your applications.

We have both esm and commonjs output

npm run build

or

yarn run build

The bundled JS code can be found in ./release The CSS is in ./release/dist/index.css

Running the tests

We have implemented tests for dumb ui components only. Technologies used: Jest and testing-library

npm run test

or

yarn run test

Lint

npm run lint

or

yarn run lint
  • .eslintrc.json lints ts files and .eslintrc.js lints js files

Typescript

  • We are trying to progressively move our source code to typescript - which means older JS code and newly written TS code will coxist while we migrate older JS code to TS
  • .eslintrc.json lints ts files and .eslintrc.js lints js files
  • Type definition file can be src/index.d.ts which will be copied to /release directory

Webpack 5

Webpack 5 removes stream and buffer componets from default polyfill To enable these, install buffer and stream and then add the following to webpack.cofig.js

module.exports = {
  //...
  resolve: {
    fallback: {
      buffer: require.resolve('buffer'),
      stream: require.resolve('stream-browserify'),
    },
  },
};

To read more: https://webpack.js.org/configuration/resolve/#resolvefallback

Creating/Exporting New Components

  1. Define your component inside ./src.
  2. Add the following line to ./src/index.ts:
    export { default as NewComponent } from './src/location/of/NewComponent';
    
    • Will be imported as: import { NewComponent } from '@sendbird/uikit-react';
    • We don't do this anymore for new components; we prefer fine-grained exports (as in step 3).
  3. Add the following line to ./exports.js:
    NewComponent/SubComponent: 'location/of/NewComponent/SubComponent',
    
    • This component can be imported by the consumer as: import SubComponent from '@sendbird/uikit-react/NewComponent/SubComponent';
  4. Add type definitions to scripts/index_d_ts.

Scaffolding New Components

  1. Use yarn run generate-component to generate a UI component in src/ui. It uses Plop.js to generate the component.
  2. It can also be used to generate reducers.
  3. Plop templates are found in here.

Acknowledgments

LameJS

We use lamejs for converting audio formats It is a fast mp3 encoder written in JavaScript. The original repo is:

sendbird-uikit-react's People

Contributors

hoonbaek avatar sravan-s avatar ahyoungryu avatar chrischabot avatar tylerhammer avatar chrisallo avatar bang9 avatar kishorebanala avatar rahmatkurniawantiket avatar ruan20795 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.