Skip to content

Commit c7bc434

Browse files
sravan-sSravan S
andauthored
chore: Update sample for v3 (#130)
Samples should point to v3 package, also modify imports to point to @sendbird/uikit-react Co-authored-by: Sravan S <[email protected]>
1 parent cd7fac6 commit c7bc434

File tree

6 files changed

+253
-51
lines changed

6 files changed

+253
-51
lines changed

samples/groupchannel/package-lock.json

Lines changed: 37 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/groupchannel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"react": "17.0.0",
1010
"react-dom": "17.0.0",
1111
"react-scripts": "3.0.1",
12-
"sendbird-uikit": "2.5.0"
12+
"@sendbird/uikit-react": "3.0.0-beta"
1313
},
1414
"devDependencies": {
1515
"babel-eslint": "^10.0.1",

samples/groupchannel/src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
2-
import { SendBirdProvider as SBProvider } from "sendbird-uikit";
3-
import "sendbird-uikit/dist/index.css";
2+
import SBProvider from "@sendbird/uikit-react/SendbirdProvider";
3+
import "@sendbird/uikit-react/dist/index.css";
44

55
import CustomizedApp from "./CustomizedApp";
66
import "./styles.css";

samples/groupchannel/src/CustomizedApp.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React, { useState, useCallback } from "react";
22

3-
import {
4-
Channel as SBConversation,
5-
ChannelList as SBChannelList,
6-
ChannelSettings as SBChannelSettings,
7-
withSendBird
8-
} from "sendbird-uikit";
3+
import SBConversation from '@sendbird/uikit-react/Channel';
4+
import SBChannelList from '@sendbird/uikit-react/ChannelList';
5+
import SBChannelSettings from '@sendbird/uikit-react/ChannelSettings'
6+
import withSendBird from '@sendbird/uikit-react/withSendBird';
97

108
function CustomizedApp(props) {
119
// default props

scripts/README.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# sendbird-uikit
2+
3+
<img alt="Version 3 beta" src="https://img.shields.io/badge/beta-v3-orange" />
4+
5+
> React based UI kit based on sendbird javascript SDK
6+
7+
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](MIGRATION_v2-to-v3.md).
8+
9+
## Getting Started
10+
11+
With Sendbird UI Kit React, we export these components:
12+
(See `src/index.jsx`)
13+
14+
* SendBirdProvider - The context provider for SDK component
15+
* useSendbirdStateContext - Hook to access SendBirdProvider context
16+
* sendBirdSelectors - A bunch of useful selectors that can be used along with *useSendbirdStateContext*
17+
18+
* Channel - A UI Component where conversations happen
19+
* ChannelList - A ChannelList UI component
20+
* ChannelSettings - A component to handle the settings of a given channel
21+
* MessageSearch - To search for a message from a Channel
22+
* OpenChannel - A UI Component where open channel conversations happen
23+
* OpenChannelSettings - A component to handle the settings of a given channel
24+
And many more...
25+
26+
* 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
27+
28+
> Note 1: Dont forget to import the stylesheet from the repo too
29+
> 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
30+
31+
### Prerequisites
32+
33+
You need to install:
34+
* nodejs 14 LTS https://nodejs.org/en/download/
35+
* npm 7 or above
36+
37+
```
38+
npm 14 deprecated warnings for fsevents& [email protected] will be fixed when storybook is updated to webpack 5
39+
https://github.com/storybookjs/storybook/issues/12425#issuecomment-723043137
40+
```
41+
42+
We tried development on Mac OS / Linux systems. You might encounter problems in running `npm run build` in Windows machines
43+
44+
### Development
45+
46+
We use storybook for development and rollup for building the npm distribution(bundled JS file)
47+
Make sure you have nodejs and npm installed and run
48+
49+
```
50+
Make a copy of env.example and save it as .env
51+
Set your appId STORYBOOK_APP_ID
52+
npm install
53+
npm run storybook
54+
```
55+
> `npm run generate-component` generates a UI component skeleton in `src/ui`
56+
57+
* By default, storybook opens in http://localhost:6006/
58+
* Smart Components such as ChannelList, Channel, ChannelSetting, App can be found under `OTHERS`
59+
* Dumb components such as inputs, buttons etc can be found under `OTHERS/UI Components` in storybook sidebar
60+
* Overridden storybook configs can be found in: `./storybook`
61+
62+
### Build
63+
64+
We use rollupJS for building the production bundle script that you want to use inside your applications.
65+
66+
We have both esm and commonjs output
67+
68+
```
69+
npm run build
70+
```
71+
72+
The bundled JS code can be found in `./release`
73+
The CSS is in `./release/dist/index.css`
74+
75+
## Running the tests
76+
77+
We have implemented tests for dumb ui components only. Technologies used: Jest, Enzyme and react-dom/test-utils
78+
79+
```
80+
npm run test
81+
```
82+
83+
### Lint
84+
85+
```
86+
npm run lint
87+
```
88+
* .eslintrc.json lints ts files and .eslintrc.js lints js files
89+
90+
91+
### Typescript
92+
93+
* 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
94+
* .eslintrc.json lints ts files and .eslintrc.js lints js files
95+
* Type definition file can be `src/index.d.ts` which will be copied to `/release` directory
96+
97+
### Creating/exporting new components
98+
99+
1. Define your component inside './src'
100+
2. Add the following line to './src/index.js'
101+
`export NewComponent from './src/location/of/NewComponent';`
102+
3. Add the following line to './exports.js'
103+
`NewComponent: 'src/location/of/NewComponent',`

scripts/package.template.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"name": "@sendbird/uikit-react",
3+
"version": "{{ version }}",
4+
"description": "React based UI kit for sendbird",
5+
"main": "index.js",
6+
"style": "dist/index.css",
7+
"typings": "index.d.ts",
8+
"module": "index.js",
9+
"devEngines": {
10+
"node": "14.x || 15.x || 16.x"
11+
},
12+
"files": [
13+
"**/*"
14+
],
15+
"scripts": {
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "[email protected]:sendbird/sendbird-uikit-react-sources.git"
20+
},
21+
"author": "SendBird <[email protected]>",
22+
"license": "SEE LICENSE IN LICENSE.md",
23+
"peerDependencies": {
24+
"css-vars-ponyfill": "^2.3.2",
25+
"date-fns": "^2.16.1",
26+
"prop-types": "^15.7.2",
27+
"react": "^16.8.6 || ^17.0.0",
28+
"react-dom": "^16.8.6 || ^17.0.0"
29+
},
30+
"dependencies": {
31+
"css-vars-ponyfill": "^2.3.2",
32+
"date-fns": "^2.16.1",
33+
"prop-types": "^15.7.2",
34+
"sendbird": "^3.1.4"
35+
},
36+
"bugs": {
37+
"url": "https://community.sendbird.com"
38+
},
39+
"homepage": "https://sendbird.com",
40+
"devDependencies": {
41+
"@babel/core": "^7.8.4",
42+
"@babel/plugin-proposal-class-properties": "^7.8.3",
43+
"@babel/plugin-proposal-export-default-from": "^7.8.3",
44+
"@babel/preset-env": "^7.8.3",
45+
"@babel/preset-react": "^7.8.3",
46+
"@babel/preset-typescript": "^7.10.4",
47+
"@rollup/plugin-babel": "^5.3.0",
48+
"@rollup/plugin-commonjs": "^19.0.0",
49+
"@rollup/plugin-eslint": "^8.0.1",
50+
"@rollup/plugin-node-resolve": "^7.1.3",
51+
"@rollup/plugin-replace": "^2.4.2",
52+
"@rollup/plugin-typescript": "^8.2.1",
53+
"@storybook/addon-actions": "^6.3.4",
54+
"@storybook/addon-docs": "^6.3.4",
55+
"@storybook/addon-links": "^6.3.4",
56+
"@storybook/addons": "^6.3.4",
57+
"@storybook/preset-scss": "^1.0.3",
58+
"@storybook/react": "^6.3.4",
59+
"@storybook/storybook-deployer": "^2.8.10",
60+
"@svgr/rollup": "^5.5.0",
61+
"@svgr/webpack": "^5.1.0",
62+
"@typescript-eslint/eslint-plugin": "^3.6.0",
63+
"@typescript-eslint/parser": "^3.6.0",
64+
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.2",
65+
"autoprefixer": "^9.7.4",
66+
"babel-eslint": "^10.0.3",
67+
"babel-jest": "^25.1.0",
68+
"babel-loader": "^8.0.6",
69+
"browserslist": "^4.14.5",
70+
"caniuse-lite": "^1.0.30001148",
71+
"css-loader": "^3.4.2",
72+
"dts-bundle-generator": "^6.5.0",
73+
"enzyme": "^3.11.0",
74+
"eslint": "^6.8.0",
75+
"eslint-config-airbnb": "^18.0.1",
76+
"eslint-plugin-import": "^2.20.0",
77+
"eslint-plugin-jsx-a11y": "^6.2.3",
78+
"eslint-plugin-react": "^7.18.0",
79+
"eslint-plugin-react-hooks": "^1.7.0",
80+
"jest": "^27.0.6",
81+
"jsdom": "^16.1.0",
82+
"node-sass": "^6.0.1",
83+
"np": "^7.5.0",
84+
"plop": "^2.5.3",
85+
"postcss": "^8.3.5",
86+
"react": "^17.0.2",
87+
"react-dom": "^17.0.2",
88+
"react-test-renderer": "^17.0.2",
89+
"rollup": "^2.53.1",
90+
"rollup-plugin-copy": "^3.4.0",
91+
"rollup-plugin-postcss": "^4.0.0",
92+
"rollup-plugin-scss": "^3.0.0",
93+
"rollup-plugin-size-snapshot": "^0.12.0",
94+
"sass-loader": "^10.2.0",
95+
"style-loader": "^1.1.3",
96+
"stylelint": "^13.0.0",
97+
"stylelint-config-sass-guidelines": "^7.0.0",
98+
"ts-loader": "^7.0.5",
99+
"tslib": "^2.0.0",
100+
"typescript": "^4.3.5"
101+
},
102+
"browserslist": [
103+
"defaults",
104+
"IE 11"
105+
]
106+
}

0 commit comments

Comments
 (0)