From ec74b7e1d735094a436015b7e89e10ae9232711c Mon Sep 17 00:00:00 2001 From: Sravan S Date: Tue, 12 Apr 2022 13:57:50 +0900 Subject: [PATCH] Update sample for v3 --- samples/groupchannel/package-lock.json | 79 ++++++++-------- samples/groupchannel/package.json | 2 +- samples/groupchannel/src/App.js | 4 +- samples/groupchannel/src/CustomizedApp.js | 10 +- scripts/README.md | 103 +++++++++++++++++++++ scripts/package.template.json | 106 ++++++++++++++++++++++ 6 files changed, 253 insertions(+), 51 deletions(-) create mode 100644 scripts/README.md create mode 100644 scripts/package.template.json diff --git a/samples/groupchannel/package-lock.json b/samples/groupchannel/package-lock.json index d9fc59bcf..1166a79b5 100644 --- a/samples/groupchannel/package-lock.json +++ b/samples/groupchannel/package-lock.json @@ -8,11 +8,11 @@ "name": "1-2-customization-basic-format", "version": "1.0.0", "dependencies": { + "@sendbird/uikit-react": "3.0.0-beta", "prop-types": "^15.7.2", "react": "17.0.0", "react-dom": "17.0.0", - "react-scripts": "3.0.1", - "sendbird-uikit": "2.5.0" + "react-scripts": "3.0.1" }, "devDependencies": { "babel-eslint": "^10.0.1", @@ -2101,6 +2101,24 @@ "node": ">= 6" } }, + "node_modules/@sendbird/uikit-react": { + "version": "3.0.0-beta", + "resolved": "https://registry.npmjs.org/@sendbird/uikit-react/-/uikit-react-3.0.0-beta.tgz", + "integrity": "sha512-XA7Q3qRXVwmNVrwesqOlaYPNytWwjxEiErxXYRZZ07m/xXEcmfE3EyhTxVAjpIX+wFDHtSrtdriVeInL8cx0Kg==", + "dependencies": { + "css-vars-ponyfill": "^2.3.2", + "date-fns": "^2.16.1", + "prop-types": "^15.7.2", + "sendbird": "^3.1.4" + }, + "peerDependencies": { + "css-vars-ponyfill": "^2.3.2", + "date-fns": "^2.16.1", + "prop-types": "^15.7.2", + "react": "^16.8.6 || ^17.0.0", + "react-dom": "^16.8.6 || ^17.0.0" + } + }, "node_modules/@svgr/babel-plugin-add-jsx-attribute": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz", @@ -13425,9 +13443,9 @@ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" }, "node_modules/sendbird": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/sendbird/-/sendbird-3.1.2.tgz", - "integrity": "sha512-vwrbS0ublFgyvJLl0qUTevH/03VYH/0/c1qG8xHB0ofYvdF0ozqZESL0SM8LGkhVo5neogi2zb07+kd2uuaCJw==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/sendbird/-/sendbird-3.1.10.tgz", + "integrity": "sha512-CKfIpyc9u0rCpAZRVOi5ihOeFyujXH4v7Jo7dKBRjcm3HDa04Du1VQX9z1ykptC5CEB8EwZZpXxtwq52dYoprg==", "dependencies": { "agentkeepalive": "4.1.4", "axios": "^0.21.4", @@ -13435,27 +13453,6 @@ "ws": "^7.5.5" } }, - "node_modules/sendbird-uikit": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/sendbird-uikit/-/sendbird-uikit-2.5.0.tgz", - "integrity": "sha512-P7knRFX/XuoZY2EWX5iZLIz/y5PyWtAD0ksoS8Xr8Va1hJhD5EIF8GR99fmuspUDFlxj6sJ8fCu25RDNYIxzgA==", - "dependencies": { - "css-vars-ponyfill": "^2.3.2", - "date-fns": "^2.16.1", - "prop-types": "^15.7.2", - "react": "^16.8.6 || ^17.0.0", - "react-dom": "^16.8.6 || ^17.0.0", - "sendbird": "^3.0.160" - }, - "peerDependencies": { - "css-vars-ponyfill": "^2.3.2", - "date-fns": "^2.16.1", - "prop-types": "^15.7.2", - "react": "^16.8.6 || ^17.0.0", - "react-dom": "^16.8.6 || ^17.0.0", - "sendbird": "^3.0.160" - } - }, "node_modules/sendbird/node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -17700,6 +17697,17 @@ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz", "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==" }, + "@sendbird/uikit-react": { + "version": "3.0.0-beta", + "resolved": "https://registry.npmjs.org/@sendbird/uikit-react/-/uikit-react-3.0.0-beta.tgz", + "integrity": "sha512-XA7Q3qRXVwmNVrwesqOlaYPNytWwjxEiErxXYRZZ07m/xXEcmfE3EyhTxVAjpIX+wFDHtSrtdriVeInL8cx0Kg==", + "requires": { + "css-vars-ponyfill": "^2.3.2", + "date-fns": "^2.16.1", + "prop-types": "^15.7.2", + "sendbird": "^3.1.4" + } + }, "@svgr/babel-plugin-add-jsx-attribute": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz", @@ -26731,9 +26739,9 @@ } }, "sendbird": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/sendbird/-/sendbird-3.1.2.tgz", - "integrity": "sha512-vwrbS0ublFgyvJLl0qUTevH/03VYH/0/c1qG8xHB0ofYvdF0ozqZESL0SM8LGkhVo5neogi2zb07+kd2uuaCJw==", + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/sendbird/-/sendbird-3.1.10.tgz", + "integrity": "sha512-CKfIpyc9u0rCpAZRVOi5ihOeFyujXH4v7Jo7dKBRjcm3HDa04Du1VQX9z1ykptC5CEB8EwZZpXxtwq52dYoprg==", "requires": { "agentkeepalive": "4.1.4", "axios": "^0.21.4", @@ -26759,19 +26767,6 @@ } } }, - "sendbird-uikit": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/sendbird-uikit/-/sendbird-uikit-2.5.0.tgz", - "integrity": "sha512-P7knRFX/XuoZY2EWX5iZLIz/y5PyWtAD0ksoS8Xr8Va1hJhD5EIF8GR99fmuspUDFlxj6sJ8fCu25RDNYIxzgA==", - "requires": { - "css-vars-ponyfill": "^2.3.2", - "date-fns": "^2.16.1", - "prop-types": "^15.7.2", - "react": "^16.8.6 || ^17.0.0", - "react-dom": "^16.8.6 || ^17.0.0", - "sendbird": "^3.0.160" - } - }, "serialize-javascript": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.9.1.tgz", diff --git a/samples/groupchannel/package.json b/samples/groupchannel/package.json index 7c868469a..30ded5fc2 100644 --- a/samples/groupchannel/package.json +++ b/samples/groupchannel/package.json @@ -9,7 +9,7 @@ "react": "17.0.0", "react-dom": "17.0.0", "react-scripts": "3.0.1", - "sendbird-uikit": "2.5.0" + "@sendbird/uikit-react": "3.0.0-beta" }, "devDependencies": { "babel-eslint": "^10.0.1", diff --git a/samples/groupchannel/src/App.js b/samples/groupchannel/src/App.js index 8cdd80db2..175bb5363 100644 --- a/samples/groupchannel/src/App.js +++ b/samples/groupchannel/src/App.js @@ -1,6 +1,6 @@ import React from "react"; -import { SendBirdProvider as SBProvider } from "sendbird-uikit"; -import "sendbird-uikit/dist/index.css"; +import SBProvider from "@sendbird/uikit-react/SendbirdProvider"; +import "@sendbird/uikit-react/dist/index.css"; import CustomizedApp from "./CustomizedApp"; import "./styles.css"; diff --git a/samples/groupchannel/src/CustomizedApp.js b/samples/groupchannel/src/CustomizedApp.js index 597e4d6e3..eb465bebb 100644 --- a/samples/groupchannel/src/CustomizedApp.js +++ b/samples/groupchannel/src/CustomizedApp.js @@ -1,11 +1,9 @@ import React, { useState, useCallback } from "react"; -import { - Channel as SBConversation, - ChannelList as SBChannelList, - ChannelSettings as SBChannelSettings, - withSendBird -} from "sendbird-uikit"; +import SBConversation from '@sendbird/uikit-react/Channel'; +import SBChannelList from '@sendbird/uikit-react/ChannelList'; +import SBChannelSettings from '@sendbird/uikit-react/ChannelSettings' +import withSendBird from '@sendbird/uikit-react/withSendBird'; function CustomizedApp(props) { // default props diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 000000000..262e3a849 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,103 @@ +# sendbird-uikit + +Version 3 beta + +> 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](MIGRATION_v2-to-v3.md). + +## 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: +* nodejs 14 LTS https://nodejs.org/en/download/ +* npm 7 or above + +``` +npm 14 deprecated warnings for fsevents& chokidar@2.1.8 will be fixed when storybook is updated to webpack 5 +https://github.com/storybookjs/storybook/issues/12425#issuecomment-723043137 +``` + +We tried development on Mac OS / Linux systems. You might encounter problems in running `npm run build` in Windows machines + +### Development + +We use storybook for development and rollup for building the npm distribution(bundled JS file) +Make sure you have nodejs and npm 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 +``` +> `npm run generate-component` generates a UI component skeleton in `src/ui` + +* 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` + +### 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 +``` + +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, Enzyme and react-dom/test-utils + +``` +npm run test +``` + +### Lint + +``` +npm 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 + +### Creating/exporting new components + +1. Define your component inside './src' +2. Add the following line to './src/index.js' + `export NewComponent from './src/location/of/NewComponent';` +3. Add the following line to './exports.js' + `NewComponent: 'src/location/of/NewComponent',` diff --git a/scripts/package.template.json b/scripts/package.template.json new file mode 100644 index 000000000..2e1e6a937 --- /dev/null +++ b/scripts/package.template.json @@ -0,0 +1,106 @@ +{ + "name": "@sendbird/uikit-react", + "version": "{{ version }}", + "description": "React based UI kit for sendbird", + "main": "index.js", + "style": "dist/index.css", + "typings": "index.d.ts", + "module": "index.js", + "devEngines": { + "node": "14.x || 15.x || 16.x" + }, + "files": [ + "**/*" + ], + "scripts": { + }, + "repository": { + "type": "git", + "url": "git+git@github.com:sendbird/sendbird-uikit-react-sources.git" + }, + "author": "SendBird ", + "license": "SEE LICENSE IN LICENSE.md", + "peerDependencies": { + "css-vars-ponyfill": "^2.3.2", + "date-fns": "^2.16.1", + "prop-types": "^15.7.2", + "react": "^16.8.6 || ^17.0.0", + "react-dom": "^16.8.6 || ^17.0.0" + }, + "dependencies": { + "css-vars-ponyfill": "^2.3.2", + "date-fns": "^2.16.1", + "prop-types": "^15.7.2", + "sendbird": "^3.1.4" + }, + "bugs": { + "url": "https://community.sendbird.com" + }, + "homepage": "https://sendbird.com", + "devDependencies": { + "@babel/core": "^7.8.4", + "@babel/plugin-proposal-class-properties": "^7.8.3", + "@babel/plugin-proposal-export-default-from": "^7.8.3", + "@babel/preset-env": "^7.8.3", + "@babel/preset-react": "^7.8.3", + "@babel/preset-typescript": "^7.10.4", + "@rollup/plugin-babel": "^5.3.0", + "@rollup/plugin-commonjs": "^19.0.0", + "@rollup/plugin-eslint": "^8.0.1", + "@rollup/plugin-node-resolve": "^7.1.3", + "@rollup/plugin-replace": "^2.4.2", + "@rollup/plugin-typescript": "^8.2.1", + "@storybook/addon-actions": "^6.3.4", + "@storybook/addon-docs": "^6.3.4", + "@storybook/addon-links": "^6.3.4", + "@storybook/addons": "^6.3.4", + "@storybook/preset-scss": "^1.0.3", + "@storybook/react": "^6.3.4", + "@storybook/storybook-deployer": "^2.8.10", + "@svgr/rollup": "^5.5.0", + "@svgr/webpack": "^5.1.0", + "@typescript-eslint/eslint-plugin": "^3.6.0", + "@typescript-eslint/parser": "^3.6.0", + "@wojtekmaj/enzyme-adapter-react-17": "^0.6.2", + "autoprefixer": "^9.7.4", + "babel-eslint": "^10.0.3", + "babel-jest": "^25.1.0", + "babel-loader": "^8.0.6", + "browserslist": "^4.14.5", + "caniuse-lite": "^1.0.30001148", + "css-loader": "^3.4.2", + "dts-bundle-generator": "^6.5.0", + "enzyme": "^3.11.0", + "eslint": "^6.8.0", + "eslint-config-airbnb": "^18.0.1", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-jsx-a11y": "^6.2.3", + "eslint-plugin-react": "^7.18.0", + "eslint-plugin-react-hooks": "^1.7.0", + "jest": "^27.0.6", + "jsdom": "^16.1.0", + "node-sass": "^6.0.1", + "np": "^7.5.0", + "plop": "^2.5.3", + "postcss": "^8.3.5", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "react-test-renderer": "^17.0.2", + "rollup": "^2.53.1", + "rollup-plugin-copy": "^3.4.0", + "rollup-plugin-postcss": "^4.0.0", + "rollup-plugin-scss": "^3.0.0", + "rollup-plugin-size-snapshot": "^0.12.0", + "sass-loader": "^10.2.0", + "style-loader": "^1.1.3", + "stylelint": "^13.0.0", + "stylelint-config-sass-guidelines": "^7.0.0", + "ts-loader": "^7.0.5", + "tslib": "^2.0.0", + "typescript": "^4.3.5" + }, + "browserslist": [ + "defaults", + "IE 11" + ] +}