├── .gitignore ├── public ├── robots.txt ├── favicon.ico ├── favicon.png ├── faviconR.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── assets │ ├── badge.png │ ├── list.png │ ├── theme.png │ ├── avatar.png │ ├── receipt.png │ ├── sample.mp3 │ ├── sidebar.png │ ├── status.png │ ├── composer.png │ ├── localize.png │ ├── power-off.png │ ├── Image-518@1x.png │ ├── conversation.png │ ├── listwrapper.png │ ├── loading_icon.gif │ ├── right-arrow.png │ ├── sound-small.png │ ├── switch-mode.png │ ├── cometchat_logo.png │ ├── cyclops_avatar.png │ ├── ironman_avatar.png │ ├── spiderman_avatar.png │ ├── wolverine_avatar.png │ ├── captainamerica_avatar.png │ ├── add-members.svg │ ├── password-group.svg │ ├── file-bubble.svg │ ├── ban-members.svg │ ├── image-bubble.svg │ ├── card-bubble.svg │ ├── audio-bubble.svg │ ├── contacts.svg │ ├── info.svg │ ├── details.svg │ ├── form-bubble.svg │ ├── create-group.svg │ ├── call-logs.svg │ ├── text-bubble.svg │ ├── call-log-history.svg │ ├── video-bubble.svg │ ├── call-log-participants.svg │ ├── call-log-recordings.svg │ ├── transfer-ownership-icon.svg │ └── group-member.svg ├── index.css ├── IsMobileViewContext.ts ├── components │ ├── CardList │ │ ├── Shared │ │ │ ├── Bubbles │ │ │ │ ├── assets │ │ │ │ │ ├── close2x.png │ │ │ │ │ ├── sample.jpeg │ │ │ │ │ ├── button-opc.png │ │ │ │ │ ├── File Bubble.pdf │ │ │ │ │ └── sampleVideo.mp4 │ │ │ │ ├── FileBubble │ │ │ │ │ ├── sample.pdf │ │ │ │ │ └── index.tsx │ │ │ │ ├── ImageBubble │ │ │ │ │ ├── astro.png │ │ │ │ │ ├── sample.jpeg │ │ │ │ │ ├── style.ts │ │ │ │ │ └── index.tsx │ │ │ │ ├── AudioBubble │ │ │ │ │ ├── sample.mp3 │ │ │ │ │ └── index.tsx │ │ │ │ ├── VideoBubble │ │ │ │ │ ├── aurora.mp4 │ │ │ │ │ └── index.tsx │ │ │ │ ├── StatusIndicator │ │ │ │ │ ├── style.ts │ │ │ │ │ └── index.tsx │ │ │ │ ├── Avatar │ │ │ │ │ ├── style.ts │ │ │ │ │ └── index.tsx │ │ │ │ ├── Receipt │ │ │ │ │ ├── style.ts │ │ │ │ │ └── index.tsx │ │ │ │ ├── Badge │ │ │ │ │ ├── style.ts │ │ │ │ │ └── index.tsx │ │ │ │ ├── TextBubble │ │ │ │ │ └── index.tsx │ │ │ │ ├── Localize │ │ │ │ │ └── index.tsx │ │ │ │ ├── Theme │ │ │ │ │ └── index.tsx │ │ │ │ └── SoundManager │ │ │ │ │ └── index.tsx │ │ │ ├── style.ts │ │ │ └── index.tsx │ │ └── index.tsx │ ├── Home │ │ └── style.ts │ ├── CallButtonsWrapper │ │ ├── style.ts │ │ └── index.tsx │ ├── Button │ │ ├── effects.ts │ │ └── index.tsx │ ├── App │ │ ├── effects.ts │ │ └── style.ts │ ├── TextInput │ │ ├── style.ts │ │ └── index.tsx │ ├── MessageListWrapper │ │ └── index.tsx │ ├── JoinGroupWrapper │ │ ├── index.tsx │ │ └── style.ts │ ├── MessagesWrapper │ │ └── index.tsx │ ├── UserDetails │ │ └── index.tsx │ ├── ContactsWrapper │ │ └── index.tsx │ ├── GroupDetails │ │ └── index.tsx │ ├── MessageHeaderWrapper │ │ └── index.tsx │ ├── ChatsCardList │ │ └── index.tsx │ ├── TransferOwnershipWrapper │ │ └── index.tsx │ ├── AddMembersWrapper │ │ └── index.tsx │ ├── UsersCardList │ │ └── index.tsx │ ├── GroupMembersWrapper │ │ └── index.tsx │ ├── BannedMembersWrapper │ │ └── index.tsx │ ├── SharedCardList │ │ └── index.tsx │ ├── Signup │ │ ├── style.ts │ │ └── index.tsx │ ├── CallLogsWrapper │ │ └── index.tsx │ ├── CallLogsWithDetailsWrapper │ │ └── index.tsx │ ├── ComposerWrapper │ │ └── index.tsx │ ├── CreateGroupWrapper │ │ ├── index.tsx │ │ └── style.ts │ ├── ResourcesCardList │ │ └── index.tsx │ ├── Card │ │ ├── style.ts │ │ └── index.tsx │ ├── ConversationsWithMessagesWrapper │ │ └── index.tsx │ ├── MessagesCardList │ │ └── index.tsx │ ├── CallsCardList │ │ └── index.tsx │ ├── LoginSignup │ │ ├── index.tsx │ │ └── style.ts │ ├── GroupsCardList │ │ └── index.tsx │ ├── Login │ │ └── style.ts │ ├── MessageInformationWrapper │ │ └── index.tsx │ ├── CallLogRecordingsWrapper │ │ └── index.tsx │ ├── CallLogHistoryWrapper │ │ └── index.tsx │ ├── CallLogDetailsWrapper │ │ └── index.tsx │ └── CallLogParticipantsWrapper │ │ └── index.tsx ├── metaInfo.ts ├── react-app-env.d.ts ├── AppConstants.ts ├── index.tsx ├── sampleApp │ └── sampledata.js └── custom-hooks.ts ├── LICENSE.md ├── SUPPORT.md ├── Screenshots └── overview_cometchat_screens.png ├── tsconfig.json ├── SECURITY.md ├── package.json ├── README.md └── CONTRIBUTING.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | package-lock.json 3 | .DS_Store 4 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/public/favicon.png -------------------------------------------------------------------------------- /public/faviconR.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/public/faviconR.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/assets/badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/badge.png -------------------------------------------------------------------------------- /src/assets/list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/list.png -------------------------------------------------------------------------------- /src/assets/theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/theme.png -------------------------------------------------------------------------------- /src/assets/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/avatar.png -------------------------------------------------------------------------------- /src/assets/receipt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/receipt.png -------------------------------------------------------------------------------- /src/assets/sample.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/sample.mp3 -------------------------------------------------------------------------------- /src/assets/sidebar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/sidebar.png -------------------------------------------------------------------------------- /src/assets/status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/status.png -------------------------------------------------------------------------------- /src/assets/composer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/composer.png -------------------------------------------------------------------------------- /src/assets/localize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/localize.png -------------------------------------------------------------------------------- /src/assets/power-off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/power-off.png -------------------------------------------------------------------------------- /src/assets/Image-518@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/Image-518@1x.png -------------------------------------------------------------------------------- /src/assets/conversation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/conversation.png -------------------------------------------------------------------------------- /src/assets/listwrapper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/listwrapper.png -------------------------------------------------------------------------------- /src/assets/loading_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/loading_icon.gif -------------------------------------------------------------------------------- /src/assets/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/right-arrow.png -------------------------------------------------------------------------------- /src/assets/sound-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/sound-small.png -------------------------------------------------------------------------------- /src/assets/switch-mode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/switch-mode.png -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2023 CometChat Inc. 2 | 3 | License agreement: https://www.cometchat.com/legal-terms-of-service -------------------------------------------------------------------------------- /src/assets/cometchat_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/cometchat_logo.png -------------------------------------------------------------------------------- /src/assets/cyclops_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/cyclops_avatar.png -------------------------------------------------------------------------------- /src/assets/ironman_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/ironman_avatar.png -------------------------------------------------------------------------------- /SUPPORT.md: -------------------------------------------------------------------------------- 1 | # Getting Support 2 | 3 | The quickest way to get support is to contact us via your CometChat Pro Dashboard. 4 | -------------------------------------------------------------------------------- /src/assets/spiderman_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/spiderman_avatar.png -------------------------------------------------------------------------------- /src/assets/wolverine_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/wolverine_avatar.png -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | html, body, #root { 2 | height: 100%; 3 | } 4 | 5 | body { 6 | margin: 0; 7 | font-family: sans-serif; 8 | } 9 | -------------------------------------------------------------------------------- /src/IsMobileViewContext.ts: -------------------------------------------------------------------------------- 1 | import { createContext } from "react"; 2 | 3 | export const IsMobileViewContext = createContext(false); 4 | -------------------------------------------------------------------------------- /src/assets/captainamerica_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/assets/captainamerica_avatar.png -------------------------------------------------------------------------------- /Screenshots/overview_cometchat_screens.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/Screenshots/overview_cometchat_screens.png -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/assets/close2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/assets/close2x.png -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/assets/sample.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/assets/sample.jpeg -------------------------------------------------------------------------------- /src/metaInfo.ts: -------------------------------------------------------------------------------- 1 | export const metaInfo = { 2 | name: "cometchat-chat-sample-app-react", 3 | version: "4.3.8", 4 | type: "sample", 5 | platform: "React" 6 | } 7 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module '*.mp3'; 3 | declare module '*.mp4'; 4 | declare module '*.pdf'; 5 | declare module '*.png'; 6 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/FileBubble/sample.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/FileBubble/sample.pdf -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/ImageBubble/astro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/ImageBubble/astro.png -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/assets/button-opc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/assets/button-opc.png -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/AudioBubble/sample.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/AudioBubble/sample.mp3 -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/ImageBubble/sample.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/ImageBubble/sample.jpeg -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/VideoBubble/aurora.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/VideoBubble/aurora.mp4 -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/assets/File Bubble.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/assets/File Bubble.pdf -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/assets/sampleVideo.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/creative2113/react-chat-app/HEAD/src/components/CardList/Shared/Bubbles/assets/sampleVideo.mp4 -------------------------------------------------------------------------------- /src/AppConstants.ts: -------------------------------------------------------------------------------- 1 | // Head over to the Credentials section in your app on CometChat Dashboard and where you can find your unique App ID, Region and Auth Key. 😊 2 | 3 | export const AppConstants = { 4 | APP_ID: "APP_ID", 5 | REGION: "REGION", 6 | AUTH_KEY: "AUTH_KEY", 7 | }; 8 | -------------------------------------------------------------------------------- /src/assets/add-members.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/password-group.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/file-bubble.svg: -------------------------------------------------------------------------------- 1 | folder, file, archive, document, office -------------------------------------------------------------------------------- /src/components/Home/style.ts: -------------------------------------------------------------------------------- 1 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 2 | import { ListStyle } from "@cometchat/uikit-shared"; 3 | 4 | export function listStyle(theme : CometChatTheme) : ListStyle { 5 | return { 6 | background: theme.palette.getBackground(), 7 | titleTextFont: fontHelper(theme.typography.heading), 8 | titleTextColor: theme.palette.getAccent() 9 | }; 10 | } 11 | -------------------------------------------------------------------------------- /src/assets/ban-members.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/assets/image-bubble.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/StatusIndicator/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | 3 | export function statusIndicatorStyle() : CSSProperties { 4 | return { 5 | height:"18px", 6 | width:"18px", 7 | borderRadius:"50%", 8 | border: "none" 9 | }; 10 | } 11 | export function statusIndicatorWrapperStyle() : CSSProperties { 12 | return { 13 | display: "flex",justifyContent: "center",alignItems: "center",position: "relative",margin: "0 auto",height:"30px" 14 | }; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } -------------------------------------------------------------------------------- /src/components/CallButtonsWrapper/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme } from "@cometchat/uikit-resources"; 3 | import { CallButtonsStyle } from "@cometchat/uikit-shared"; 4 | 5 | export function callButtonsWrapperStyle(theme : CometChatTheme) : CSSProperties { 6 | return { 7 | width: "100%", 8 | height: "100%", 9 | background: theme.palette.getBackground(), 10 | display: "flex", 11 | justifyContent: "center", 12 | alignItems: "center" 13 | }; 14 | } 15 | 16 | export function callButtonsStyle() : CallButtonsStyle { 17 | return { 18 | width: "fit-content", 19 | height: "fit-content" 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Avatar/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | export const avatarWrapperStyle:any = { 3 | flexDirection: "column", 4 | alignItems: "center", 5 | display: "flex", 6 | marginTop:"15px" 7 | } 8 | 9 | export function inputStyle(themeMode: string) : CSSProperties { 10 | return { 11 | height: "21px", 12 | width: "93%", 13 | outline: "none", 14 | padding: "8px", 15 | borderRadius: "12px", 16 | background: "transparent", 17 | font: "400 13px Inter, sans-serif", 18 | border: "1px solid", 19 | marginTop:"15px", 20 | borderColor: themeMode === "dark" ? "#bbb" : "rgba(20, 20, 20, 0.08)", 21 | color: themeMode === "dark" ? "#bbb" : "rgba(20, 20, 20, 0.58)", 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | This document outlines the Responsible Disclosure Program for CometChat Pro 4 | 5 | ## Responsible Disclosure Policy 6 | 7 | At CometChat we take security seriously and consider it a top priority. Since a 8 | public disclosure of a security vulnerability could put the entire 9 | community at risk, we require that potential vulnerabilities are kept 10 | confidential until they are confirmed and fixed. We appreciate your efforts in 11 | keeping CometChat Pro and its users safe by responsibly disclosing any security 12 | vulnerability. Rest assured we will make every effort to acknowledge your 13 | contributions. 14 | 15 | ## Reporting a vulnerability 16 | 17 | To report any security related issues, please communicate with the CometChat Pro security team by sending an email to security@cometchat.com 18 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/ImageBubble/style.ts: -------------------------------------------------------------------------------- 1 | import {CometChatThemeContext, fontHelper} from "@cometchat/chat-uikit-react" 2 | 3 | import { useContext } from "react"; 4 | export function senderBubbleStyle() { 5 | const { theme } = useContext(CometChatThemeContext); 6 | return { 7 | borderRadius:"8px", 8 | background:theme.palette.getPrimary(), 9 | textFont: fontHelper(theme.typography.text2), 10 | textColor: theme.palette.getAccent("dark"), 11 | }; 12 | } 13 | 14 | export function receiverBubbleStyle() { 15 | const { theme } = useContext(CometChatThemeContext); 16 | return { 17 | borderRadius:"8px", 18 | background:theme.palette.getAccent200(), 19 | textFont: fontHelper(theme.typography.text2), 20 | textColor: theme.palette.getAccent(), 21 | }; 22 | } -------------------------------------------------------------------------------- /src/assets/card-bubble.svg: -------------------------------------------------------------------------------- 1 | navigation-menu-4 -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Receipt/style.ts: -------------------------------------------------------------------------------- 1 | 2 | import { CSSProperties } from "react"; 3 | export function componentDetailsModalStyle(themeMode: string) : CSSProperties { 4 | return { 5 | height: "auto", 6 | width: "100%", 7 | maxWidth: "600px", 8 | minHeight: "150px", 9 | transform: "translate(-50%, -50%)", 10 | left: "50%", 11 | top:"50%", 12 | position: "absolute", 13 | zIndex: "10", 14 | padding: "12px 16px", 15 | borderRadius: "12px", 16 | display: "flex", 17 | flexDirection: "column", 18 | justifyContent: "space-between", 19 | backgroundColor: themeMode === "dark" ? "black" : "white", 20 | color: themeMode === "dark" ? "white" : "black", 21 | boxShadow: "rgba(20, 20, 20, 0.33) 0px 0px 3px" 22 | } 23 | }; 24 | -------------------------------------------------------------------------------- /src/components/Button/effects.ts: -------------------------------------------------------------------------------- 1 | import { useEffect } from "react"; 2 | 3 | interface IEffectsProps { 4 | ref : React.MutableRefObject, 5 | onClickPropRef : React.MutableRefObject<((customEvent: CustomEvent<{event: PointerEvent}>) => void) | undefined> 6 | }; 7 | 8 | export function Effects(props : IEffectsProps) { 9 | const { 10 | ref, 11 | onClickPropRef 12 | } = props; 13 | 14 | useEffect(() => { 15 | const buttonElement = ref.current; 16 | const eventName = "cc-button-clicked"; 17 | const handleEvent = (e : CustomEvent<{event : PointerEvent}>) => onClickPropRef.current?.(e); 18 | buttonElement.addEventListener(eventName, handleEvent); 19 | return () => { 20 | buttonElement.removeEventListener(eventName, handleEvent); 21 | }; 22 | }, [onClickPropRef, ref]); // Refs are in the dependency array to satisfy ESlint 23 | } 24 | -------------------------------------------------------------------------------- /src/assets/audio-bubble.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/components/App/effects.ts: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect } from "react"; 3 | 4 | interface IEffectsProps { 5 | setLoggedInUser: React.Dispatch< 6 | React.SetStateAction 7 | >; 8 | setIsMobileView: React.Dispatch>; 9 | } 10 | 11 | export function Effects(props: IEffectsProps) { 12 | const { setLoggedInUser, setIsMobileView } = props; 13 | 14 | useEffect(() => { 15 | (async () => { 16 | try { 17 | setLoggedInUser(await CometChat.getLoggedinUser()); 18 | } catch (error) { 19 | console.log(error); 20 | } 21 | })(); 22 | }, [setLoggedInUser]); 23 | 24 | useEffect(() => { 25 | function handleResize() { 26 | if (window.innerWidth <= 768) setIsMobileView(true); 27 | else setIsMobileView(false); 28 | } 29 | window.addEventListener("resize", handleResize); 30 | }, [setIsMobileView]); 31 | } 32 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Badge/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | 3 | export function inputStyle(themeMode: string) : CSSProperties { 4 | return { 5 | height: "21px", 6 | width: "93%", 7 | outline: "none", 8 | padding: "8px", 9 | borderRadius: "12px", 10 | background: "transparent", 11 | font: "400 13px Inter, sans-serif", 12 | borderColor: themeMode === "dark" ? "#bbb" : "rgba(20, 20, 20, 0.08)", 13 | color: themeMode === "dark" ? "#bbb" : "rgba(20, 20, 20, 0.58)", 14 | border: "1px solid", 15 | marginTop:"15px" 16 | } 17 | } 18 | export const badgeDemoStyle:any = { 19 | flexDirection: "column", 20 | alignItems: "center", 21 | display: "flex", 22 | marginTop:"15px" 23 | } 24 | export const colorButtonStyle:any = { 25 | border: "none", 26 | padding:"10px", 27 | borderRight: "1px solid white", 28 | color: "#ffff", 29 | borderRadius: "5px", 30 | height: "30px", 31 | width: "30px", 32 | fontSize: "12px" 33 | } -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import "./index.css"; 2 | import "@cometchat/uikit-elements"; 3 | 4 | import { App } from "./components/App"; 5 | import { AppConstants } from "./AppConstants"; 6 | import {CometChat} from '@cometchat/chat-sdk-javascript' 7 | import { CometChatUIKit } from "@cometchat/chat-uikit-react"; 8 | import ReactDOM from "react-dom/client"; 9 | import { UIKitSettingsBuilder } from '@cometchat/uikit-shared'; 10 | import { metaInfo } from "./metaInfo"; 11 | 12 | (async () => { 13 | const uiKitSettings = new UIKitSettingsBuilder() 14 | .setAppId(AppConstants.APP_ID) 15 | .setRegion(AppConstants.REGION) 16 | .setAuthKey(AppConstants.AUTH_KEY) 17 | .subscribePresenceForAllUsers() 18 | .build(); 19 | try { 20 | await CometChatUIKit.init(uiKitSettings); 21 | try{CometChat.setDemoMetaInfo(metaInfo)}catch(err){} 22 | console.log("Initialization completed successfully"); 23 | const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement); 24 | root.render(); 25 | } 26 | catch(error) { 27 | console.log("Initialization failed with error:", error); 28 | } 29 | })(); 30 | -------------------------------------------------------------------------------- /src/sampleApp/sampledata.js: -------------------------------------------------------------------------------- 1 | import CaptainAmericaAvatar from "../assets/captainamerica_avatar.png"; 2 | import CyclopsAvatar from "../assets/cyclops_avatar.png"; 3 | import IronManAvatar from "../assets/ironman_avatar.png"; 4 | import SpidermanAvatar from "../assets/spiderman_avatar.png"; 5 | import WolverineAvatar from "../assets/wolverine_avatar.png"; 6 | 7 | export const users = { 8 | "users":[ 9 | { 10 | "uid": "superhero1", 11 | "name": "Iron Man", 12 | "avatar": IronManAvatar 13 | }, 14 | { 15 | "uid": "superhero2", 16 | "name": "Captain America", 17 | "avatar": CaptainAmericaAvatar 18 | }, 19 | { 20 | "uid": "superhero3", 21 | "name": "Spiderman", 22 | "avatar": SpidermanAvatar 23 | }, 24 | { 25 | "uid": "superhero4", 26 | "name": "Wolverine", 27 | "avatar": WolverineAvatar 28 | }, 29 | { 30 | "uid": "superhero5", 31 | "name": "Cyclops", 32 | "avatar": CyclopsAvatar 33 | } 34 | ] 35 | } -------------------------------------------------------------------------------- /src/components/TextInput/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 3 | 4 | export function labelStyle() : CSSProperties { 5 | return { 6 | display: "flex", 7 | flexDirection: "column", 8 | rowGap: "4px" 9 | }; 10 | } 11 | 12 | export function labelTextStyle(theme : CometChatTheme) : CSSProperties { 13 | return { 14 | font: fontHelper(theme.typography.subtitle2), 15 | color: theme.palette.getAccent600("light") 16 | }; 17 | } 18 | 19 | export function inputStyle(theme : CometChatTheme) : CSSProperties { 20 | return { 21 | padding: "8px", 22 | border: `1px solid ${theme.palette.getAccent100("light")}`, 23 | borderRadius: "8px", 24 | font: fontHelper(theme.typography.subtitle2) 25 | }; 26 | } 27 | 28 | export function requiredSymbolStyle() : CSSProperties { 29 | return { 30 | color: "red" 31 | }; 32 | } 33 | 34 | export function labelContainerStyle() : CSSProperties { 35 | return { 36 | display: "flex", 37 | columnGap: "1px" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/assets/contacts.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icons/24/Contacts 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/components/MessageListWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | 3 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 4 | import { CometChatMessageList } from "@cometchat/chat-uikit-react"; 5 | 6 | type MessageListWrapperProps = { setSomeInterestingOpStarted : React.Dispatch> }; 7 | 8 | export function MessageListWrapper(props : MessageListWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const [render, setRender] = useState(false); 11 | const { setSomeInterestingOpStarted, ...otherProps } = props; 12 | 13 | useEffect( () => { 14 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 15 | groupsRequest.fetchNext().then((fetchedGroup)=>{ 16 | setGroup(fetchedGroup[0]); 17 | }).then(()=>{ 18 | setTimeout(() => { 19 | setRender(true); 20 | }, 1000); 21 | }); 22 | }, [render]); 23 | 24 | return ( 25 | group ? 26 | : (<>) 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /src/assets/info.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icons/24/Info 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/assets/details.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/components/JoinGroupWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { useContext, useEffect, useRef } from "react"; 2 | 3 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 4 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 5 | import { joinGroupStyle } from "./style"; 6 | import { useNavigate } from "react-router-dom"; 7 | 8 | export function JoinGroupWrapper() { 9 | const joinGroupRef = useRef(null); 10 | const navigate = useNavigate(); 11 | const { theme } = useContext(CometChatThemeContext); 12 | 13 | useEffect(() => { 14 | const joinGroupElement = joinGroupRef.current; 15 | if (!joinGroupElement) { 16 | return; 17 | } 18 | const handleEvent = (group : CometChat.Group | undefined, password : string) => { 19 | console.log("Group:", group); 20 | console.log("Entered password:", password); 21 | navigate("/home/groups-module"); 22 | }; 23 | joinGroupElement.joinClick = handleEvent; 24 | return () => { 25 | joinGroupElement.joinClick = null; 26 | }; 27 | }, [navigate]); 28 | 29 | return ( 30 | 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /src/components/JoinGroupWrapper/style.ts: -------------------------------------------------------------------------------- 1 | import { JoinGroupStyle } from "@cometchat/uikit-elements"; 2 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 3 | 4 | export function joinGroupStyle(theme : CometChatTheme) : JoinGroupStyle { 5 | return { 6 | boxShadow: `${theme.palette.getAccent100()} 0px 16px 32px 0px`, 7 | titleTextFont: fontHelper(theme.typography.title1), 8 | titleTextColor: theme.palette.getAccent(), 9 | passwordInputPlaceholderTextFont: fontHelper(theme.typography.subtitle1), 10 | passwordInputPlaceholderTextColor: theme.palette.getAccent600(), 11 | passwordInputBackground: theme.palette.getAccent100(), 12 | passwordInputBorder: "none", 13 | passwordInputBorderRadius: "8px", 14 | passwordInputBoxShadow: `${theme.palette.getAccent100()} 0 0 0 1px`, 15 | passwordInputTextFont: fontHelper(theme.typography.subtitle1), 16 | passwordInputTextColor: theme.palette.getAccent(), 17 | height: "100%", 18 | width: "100%", 19 | joinButtonTextFont: fontHelper(theme.typography.subtitle1), 20 | joinButtonTextColor: theme.palette.getAccent(), 21 | joinButtonBackground: theme.palette.getPrimary(), 22 | joinButtonBorderRadius: "8px", 23 | joinButtonBorder: "none", 24 | background: theme.palette.getBackground() 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /src/components/MessagesWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { CometChatMessages } from "@cometchat/chat-uikit-react"; 4 | 5 | type MessagesWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 6 | 7 | export function MessagesWrapper(props : MessagesWrapperProps) { 8 | const [group, setGroup] = useState(); 9 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 10 | 11 | useEffect(() => { 12 | (async () => { 13 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 14 | try { 15 | setSomeInterestingAsyncOpStarted(true); 16 | const [fetchGroup] = await groupsRequest.fetchNext(); 17 | setGroup(fetchGroup); 18 | } 19 | catch(error) { 20 | console.log(error); 21 | } 22 | finally { 23 | setSomeInterestingAsyncOpStarted(false); 24 | } 25 | })(); 26 | }, [setSomeInterestingAsyncOpStarted]); 27 | 28 | if (!group) { 29 | return null; 30 | } 31 | 32 | return ( 33 | 37 | ); 38 | } 39 | -------------------------------------------------------------------------------- /src/components/UserDetails/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatDetails } from "@cometchat/chat-uikit-react"; 5 | 6 | type UserDetailsProps = { setInterestingAsyncOpStarted: React.Dispatch>} 7 | 8 | export function UserDetails(props : UserDetailsProps) { 9 | const [user, setUser] = useState(); 10 | const navigate = useNavigate(); 11 | const { setInterestingAsyncOpStarted } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const usersRequest = new CometChat.UsersRequestBuilder().setLimit(1).build(); 16 | try { 17 | setInterestingAsyncOpStarted(true); 18 | const [fetchdUser] = await usersRequest.fetchNext(); 19 | setUser(fetchdUser); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setInterestingAsyncOpStarted]); 29 | 30 | return ( 31 | navigate("/home/users-module")} 34 | {...props} 35 | /> 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /src/components/ContactsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | CometChatContacts, 3 | CometChatPalette, 4 | CometChatTheme, 5 | CometChatThemeContext, 6 | } from "@cometchat/chat-uikit-react"; 7 | import { useContext, useMemo } from "react"; 8 | 9 | import { useLocation } from "react-router-dom"; 10 | 11 | export function ContactsWrapper() { 12 | const { state } = useLocation(); 13 | const changeThemeToCustom = state?.changeThemeToCustom; 14 | const { theme } = useContext(CometChatThemeContext); 15 | 16 | const themeContext = useMemo(() => { 17 | let res = theme; 18 | if (changeThemeToCustom) { 19 | res = new CometChatTheme({ 20 | palette: new CometChatPalette({ 21 | mode: theme.palette.mode, 22 | primary: { 23 | light: "#D422C2", 24 | dark: "#D422C2", 25 | }, 26 | accent: { 27 | light: "#07E676", 28 | dark: "#B6F0D3", 29 | }, 30 | accent50: { 31 | light: "#39f", 32 | dark: "#141414", 33 | }, 34 | accent900: { 35 | light: "white", 36 | dark: "black", 37 | }, 38 | }), 39 | }); 40 | } 41 | return { theme: res }; 42 | }, [theme, changeThemeToCustom]); 43 | 44 | return ( 45 | 46 | 47 | 48 | ); 49 | } 50 | -------------------------------------------------------------------------------- /src/components/GroupDetails/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatDetails } from "@cometchat/chat-uikit-react"; 5 | 6 | type GroupDetailsProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function GroupDetails(props : GroupDetailsProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOpStarted]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 | navigate("/home/groups-module")} 38 | {...otherProps} 39 | /> 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /src/assets/form-bubble.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/MessageHeaderWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatMessageHeader } from "@cometchat/chat-uikit-react"; 5 | 6 | type MessageHeaderWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function MessageHeaderWrapper(props : MessageHeaderWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } catch(error) { 21 | console.log(error); 22 | } 23 | finally { 24 | setSomeInterestingAsyncOpStarted(false); 25 | } 26 | })(); 27 | }, [setSomeInterestingAsyncOpStarted]); 28 | 29 | if (!group) { 30 | return null; 31 | } 32 | 33 | return ( 34 | navigate(-1)} 37 | {...otherProps} 38 | /> 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /src/components/ChatsCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { ICardProps } from "../Card"; 2 | import Sidebar from "../../assets/sidebar.png"; 3 | import ListWrapper from "../../assets/listwrapper.png"; 4 | import ContactIcon from "../../assets/contacts.svg" 5 | import { CardList } from "../CardList"; 6 | 7 | const cardDataList : Omit[] = [ 8 | { 9 | title: "conversations with messages", 10 | description: "CometChatConversationsWithMessages is an independent component used to set up a screen that shows the recent conversations and allows you to send a message to the user or group from the list.", 11 | imageInfo: { 12 | url: Sidebar, 13 | altText: "chat screen" 14 | } 15 | }, 16 | { 17 | title: "conversations", 18 | description: "CometChatConversations is an independent component used to set up a screen that shows the recent conversations alone.", 19 | imageInfo: { 20 | url: ListWrapper, 21 | altText: "list wrapper" 22 | } 23 | }, 24 | { 25 | title: "contacts", 26 | description: "CometChatContacts is an independent component used to set up a screen that shows the users and groups list.", 27 | imageInfo: { 28 | url: ContactIcon, 29 | altText: "Contacts" 30 | } 31 | } 32 | ]; 33 | 34 | export function ChatsCardList() { 35 | return ( 36 | 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /src/components/TransferOwnershipWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatTransferOwnership } from "@cometchat/chat-uikit-react"; 5 | 6 | type TransferOwnershipWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function TransferOnwershipWrapper(props : TransferOwnershipWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOpStarted]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 | navigate("/home/groups-module")} 38 | {...otherProps} 39 | /> 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /src/components/AddMembersWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatAddMembers } from "@cometchat/chat-uikit-react"; 5 | 6 | type AddMembersWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function AddMembersWrapper(props : AddMembersWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOpStarted]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 | navigate(-1)} 38 | onClose = {() => navigate("/home/groups-module")} 39 | {...otherProps} 40 | /> 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /src/components/UsersCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { ICardProps } from "../Card"; 2 | import Sidebar from "../../assets/sidebar.png"; 3 | import ListWrapper from "../../assets/listwrapper.png"; 4 | import Details from "../../assets/details.svg"; 5 | import { CardList } from "../CardList"; 6 | 7 | const cardDataList : Omit[] = [ 8 | { 9 | title: "users with messages", 10 | description: "CometChatUsersWithMessages is an independent component used to set up a screen that shows the list of users available in your app and gives you the ability to search for a specific user and to start a conversation.", 11 | imageInfo: { 12 | url: Sidebar, 13 | altText: "chat screen" 14 | } 15 | }, 16 | { 17 | title: "users", 18 | description: "CometChatUsers is an independent component used to set up a screen and display a scrollable list of users available in your app and gives you the ability to search for a specific user.", 19 | imageInfo: { 20 | url: ListWrapper, 21 | altText: "list wrapper" 22 | } 23 | }, 24 | { 25 | title: "user details", 26 | description: "CometChatDetails component for a user. To learn more about this component tap click on this card.", 27 | imageInfo: { 28 | url: Details, 29 | altText: "details" 30 | } 31 | } 32 | ]; 33 | 34 | export function UsersCardList() { 35 | return ( 36 | 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /src/components/GroupMembersWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatGroupMembers } from "@cometchat/chat-uikit-react"; 5 | 6 | type GroupMembersWrapperProps = { setSomeInterestingAsyncOperation : React.Dispatch>}; 7 | 8 | export function GroupMembersWrapper(props : GroupMembersWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOperation, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOperation(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOperation(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOperation]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 | navigate(-1)} 38 | onClose = {() => navigate("/home/groups-module")} 39 | {...otherProps} 40 | /> 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /src/components/BannedMembersWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useEffect, useState } from "react"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { CometChatBannedMembers } from "@cometchat/chat-uikit-react"; 5 | 6 | type BannedMembersWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function BannedMembersWrapper(props : BannedMembersWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const navigate = useNavigate(); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 16 | try { 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOpStarted]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 | navigate(-1)} 38 | {...otherProps} 39 | onClose = {() => navigate("/home/groups-module")} 40 | /> 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /src/components/SharedCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { ResourcesCardList } from "../ResourcesCardList"; 3 | import { ViewsCardList } from "../ViewsCardList"; 4 | import { fontHelper } from "@cometchat/uikit-resources"; 5 | import { useContext } from "react"; 6 | 7 | export function SharedCardList() { 8 | const { theme } = useContext(CometChatThemeContext); 9 | 10 | return ( 11 |
21 |
29 | Shared 30 |
31 |
39 |
40 | 41 |
42 |
43 | 44 |
45 |
46 |
47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /src/components/Signup/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 3 | 4 | export function formStyle() : CSSProperties { 5 | return { 6 | display: "flex", 7 | flexDirection: "column", 8 | rowGap: "16px" 9 | }; 10 | } 11 | 12 | export function generateUidCheckboxStyle() : CSSProperties { 13 | return { 14 | width: "24px", 15 | height: "24px", 16 | cursor: "pointer" 17 | }; 18 | } 19 | 20 | export function generateUidStyle() : CSSProperties { 21 | return { 22 | display: "flex", 23 | columnGap: "4px", 24 | alignItems: "center", 25 | marginBottom: "16px" 26 | }; 27 | } 28 | 29 | export function checkboxTextStyle(theme : CometChatTheme) : CSSProperties { 30 | return { 31 | font: fontHelper(theme.typography.subtitle2), 32 | color: theme.palette.getAccent600("light") 33 | }; 34 | } 35 | 36 | export function submitBtnStyle(theme : CometChatTheme) : CSSProperties { 37 | return { 38 | font: fontHelper(theme.typography.subtitle1), 39 | color: theme.palette.getAccent900("light"), 40 | backgroundColor: theme.palette.getPrimary(), 41 | padding: "8px 4px", 42 | borderRadius: "8px", 43 | border: `1px solid ${theme.palette.getAccent100("light")}`, 44 | cursor: "pointer" 45 | }; 46 | } 47 | 48 | export function errorMessageStyle(theme : CometChatTheme) : CSSProperties { 49 | return { 50 | font: fontHelper(theme.typography.subtitle2), 51 | color: theme.palette.getError(), 52 | height: "48px", 53 | overflowY: "auto" 54 | }; 55 | } 56 | -------------------------------------------------------------------------------- /src/components/Button/index.tsx: -------------------------------------------------------------------------------- 1 | import { CSSProperties, useRef } from "react"; 2 | import { useRefSync } from "../../custom-hooks"; 3 | import { Effects } from "./effects"; 4 | 5 | export type ButtonStyle = { 6 | buttonTextFont? : string, 7 | buttonTextColor? : string, 8 | buttonIconTint? : string 9 | } & CSSProperties; 10 | 11 | interface IButtonProps { 12 | text? : string, 13 | hoverText? : string, 14 | iconURL? : string, 15 | disabled? : boolean, 16 | buttonStyle? : ButtonStyle, 17 | onClick? : (customEvent : CustomEvent<{event : PointerEvent}>) => void 18 | }; 19 | 20 | export function Button(props : IButtonProps) { 21 | const { 22 | text, 23 | hoverText, 24 | iconURL, 25 | disabled, 26 | buttonStyle, 27 | onClick 28 | } = props; 29 | 30 | const ref = useRef(); 31 | const onClickPropRef = useRefSync(onClick); 32 | 33 | function getDisabledPropSpreadObject() : {disabled? : true} { 34 | return disabled ? {disabled} : {}; 35 | } 36 | 37 | function getStylePropSpreadObject(styleObject : T1, stylePropName : T2) : {T2?: string} { 38 | return styleObject ? {[stylePropName] : JSON.stringify(styleObject)} : {}; 39 | } 40 | 41 | Effects({ 42 | ref, 43 | onClickPropRef 44 | }); 45 | 46 | return ( 47 | 55 | ); 56 | } 57 | -------------------------------------------------------------------------------- /src/components/CallLogsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatCallLogs, CometChatIncomingCall, CometChatPalette, CometChatTheme, CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { useContext, useMemo } from "react"; 3 | 4 | import { useLocation } from "react-router-dom"; 5 | 6 | export function CallLogsWrapper({ isMobileView } : {isMobileView : boolean}) { 7 | const { state } = useLocation(); 8 | const changeThemeToCustom = state?.changeThemeToCustom; 9 | const { theme } = useContext(CometChatThemeContext); 10 | 11 | const themeContext = useMemo(() => { 12 | let res = theme; 13 | if (changeThemeToCustom) { 14 | res = new CometChatTheme({ 15 | palette: new CometChatPalette({ 16 | mode: theme.palette.mode, 17 | primary: { 18 | light: "#D422C2", 19 | dark: "#D422C2", 20 | }, 21 | accent: { 22 | light: "#07E676", 23 | dark: "#B6F0D3", 24 | }, 25 | accent50: { 26 | light: "#39f", 27 | dark: "#141414", 28 | }, 29 | accent900: { 30 | light: "white", 31 | dark: "black", 32 | } 33 | }), 34 | }) 35 | } 36 | return {theme: res}; 37 | }, [theme, changeThemeToCustom]); 38 | 39 | return ( 40 | 41 | 42 | 43 | 44 | ); 45 | } 46 | -------------------------------------------------------------------------------- /src/assets/create-group.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | group_add 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/assets/call-logs.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/components/CallLogsWithDetailsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatCallLogsWithDetails, CometChatIncomingCall, CometChatPalette, CometChatTheme, CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { useContext, useMemo } from "react"; 3 | 4 | import { useLocation } from "react-router-dom"; 5 | 6 | export function CallLogsWithDetailsWrapper({ isMobileView } : {isMobileView : boolean}) { 7 | const { state } = useLocation(); 8 | const changeThemeToCustom = state?.changeThemeToCustom; 9 | const { theme } = useContext(CometChatThemeContext); 10 | 11 | const themeContext = useMemo(() => { 12 | let res = theme; 13 | if (changeThemeToCustom) { 14 | res = new CometChatTheme({ 15 | palette: new CometChatPalette({ 16 | mode: theme.palette.mode, 17 | primary: { 18 | light: "#D422C2", 19 | dark: "#D422C2", 20 | }, 21 | accent: { 22 | light: "#07E676", 23 | dark: "#B6F0D3", 24 | }, 25 | accent50: { 26 | light: "#39f", 27 | dark: "#141414", 28 | }, 29 | accent900: { 30 | light: "white", 31 | dark: "black", 32 | } 33 | }), 34 | }) 35 | } 36 | return {theme: res}; 37 | }, [theme, changeThemeToCustom]); 38 | 39 | return ( 40 | 41 | 44 | 45 | 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /src/components/ComposerWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatMessageComposer, CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { useContext, useEffect, useState } from "react"; 3 | 4 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 5 | 6 | type ComposerWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 7 | 8 | export function ComposerWrapper(props : ComposerWrapperProps) { 9 | const [group, setGroup] = useState(); 10 | const { theme } = useContext(CometChatThemeContext); 11 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 12 | 13 | useEffect(() => { 14 | (async () => { 15 | try { 16 | const groupsRequest = new CometChat.GroupsRequestBuilder().setLimit(1).build(); 17 | setSomeInterestingAsyncOpStarted(true); 18 | const [fetchedGroup] = await groupsRequest.fetchNext(); 19 | setGroup(fetchedGroup); 20 | } 21 | catch(error) { 22 | console.log(error); 23 | } 24 | finally { 25 | setSomeInterestingAsyncOpStarted(false); 26 | } 27 | })(); 28 | }, [setSomeInterestingAsyncOpStarted]); 29 | 30 | if (!group) { 31 | return null; 32 | } 33 | 34 | return ( 35 |
43 | 50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /src/components/CreateGroupWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { createGroupStyle, createGroupWrapperStyle } from "./style"; 2 | import { useContext, useEffect, useRef } from "react"; 3 | 4 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 5 | import { useNavigate } from "react-router-dom"; 6 | 7 | type CreateGroupWrapperProps = { isMobileView : boolean }; 8 | 9 | export function CreateGroupWrapper({ isMobileView } : CreateGroupWrapperProps) { 10 | const createGroupRef = useRef(null); 11 | const navigate = useNavigate(); 12 | const { theme } = useContext(CometChatThemeContext); 13 | 14 | useEffect(() => { 15 | const createGroupElement = createGroupRef.current; 16 | if (!createGroupElement) { 17 | return; 18 | } 19 | // const createGroupEventName = "cc-creategroup-created"; 20 | const closeClickedEventName = "cc-creategroup-close-clicked"; 21 | const handleCreateGroup = (e : CustomEvent) => { 22 | console.log("Group details:", e); 23 | }; 24 | const handleCloseClicked = () => navigate("/home/groups-module"); 25 | createGroupElement.createClick = handleCreateGroup; 26 | createGroupElement.addEventListener(closeClickedEventName, handleCloseClicked); 27 | return () => { 28 | createGroupElement.createClick = null; 29 | createGroupElement.removeEventListener(closeClickedEventName, handleCloseClicked); 30 | }; 31 | }, [navigate]); 32 | 33 | return ( 34 |
37 | 41 |
42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /src/components/ResourcesCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { CardList } from "../CardList"; 2 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 3 | import { ICardProps } from "../Card"; 4 | import Localize from "../../assets/localize.png"; 5 | import SoundSmall from "../../assets/sound-small.png"; 6 | import Theme from "../../assets/theme.png"; 7 | import { fontHelper } from "@cometchat/uikit-resources"; 8 | import { useContext } from "react"; 9 | 10 | const cardDataList : Omit[] = [ 11 | { 12 | title: "sound manager", 13 | description: "CometChatSoundManager allows you to play different types of audio which is required for incoming and outgoing events in the UI kit.", 14 | imageInfo: { 15 | url: SoundSmall, 16 | altText: "sound" 17 | } 18 | }, 19 | { 20 | title: "theme", 21 | description: "CometChatTheme is a style applied to every component and every view in the activity or component in the UI kit.", 22 | imageInfo: { 23 | url: Theme, 24 | altText: "theme" 25 | } 26 | }, 27 | { 28 | title: "localize", 29 | description: "CometChatLocalize allows you to detect the language of your users based on their browser or device settings and set the language accordingly.", 30 | imageInfo: { 31 | url: Localize, 32 | altText: "language" 33 | } 34 | } 35 | ]; 36 | 37 | export function ResourcesCardList() { 38 | const { theme } = useContext(CometChatThemeContext); 39 | 40 | return ( 41 | 49 | ); 50 | } 51 | -------------------------------------------------------------------------------- /src/components/Card/style.ts: -------------------------------------------------------------------------------- 1 | import { IconStyle } from "@cometchat/uikit-elements"; 2 | import { CSSProperties } from "react"; 3 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 4 | 5 | export function cardStyle(cardContainerStyle : CSSProperties | undefined, theme : CometChatTheme) : CSSProperties { 6 | return { 7 | padding: "16px", 8 | borderRadius: "8px", 9 | boxShadow: `0px 0px 8px ${theme.palette.getAccent300()}`, 10 | display: "flex", 11 | columnGap: "12px", 12 | border: `1px solid ${theme.palette.getAccent300()}`, 13 | backgroundColor: theme.palette.getBackground(), 14 | cursor: "pointer", 15 | ...cardContainerStyle 16 | }; 17 | } 18 | 19 | export function iconStyle(theme : CometChatTheme) : IconStyle { 20 | return { 21 | width: "28px", 22 | height: "28px", 23 | iconTint: theme.palette.getAccent() 24 | }; 25 | } 26 | 27 | export function titleStyle(theme : CometChatTheme) : CSSProperties { 28 | return { 29 | font: fontHelper(theme.typography.title2), 30 | color: theme.palette.getAccent(), 31 | textTransform: "capitalize" 32 | }; 33 | } 34 | 35 | export function descriptionStyle(theme : CometChatTheme) : CSSProperties { 36 | return { 37 | font: fontHelper(theme.typography.subtitle1), 38 | color: theme.palette.getAccent600(), 39 | wordBreak: "break-word" 40 | }; 41 | } 42 | 43 | export function arrowImageStyle() : CSSProperties { 44 | return { 45 | width: "12px", 46 | height: "12px", 47 | flexShrink: "0" 48 | }; 49 | } 50 | 51 | export function textContentContainerStyle() : CSSProperties { 52 | return { 53 | textAlign: "left", 54 | display: "flex", 55 | flexDirection: "column", 56 | rowGap: "8px", 57 | flexGrow: "1" 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /src/components/ConversationsWithMessagesWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatConversationsWithMessages, CometChatIncomingCall, CometChatPalette, CometChatTheme, CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { useContext, useMemo } from "react"; 3 | 4 | import { useLocation } from "react-router-dom"; 5 | 6 | export function ConversationsWithMessagesWrapper({ isMobileView } : {isMobileView : boolean}) { 7 | const { state } = useLocation(); 8 | const changeThemeToCustom = state?.changeThemeToCustom; 9 | const { theme } = useContext(CometChatThemeContext); 10 | 11 | const themeContext = useMemo(() => { 12 | let res = theme; 13 | if (changeThemeToCustom) { 14 | res = new CometChatTheme({ 15 | palette: new CometChatPalette({ 16 | mode: theme.palette.mode, 17 | primary: { 18 | light: "#D422C2", 19 | dark: "#D422C2", 20 | }, 21 | accent: { 22 | light: "#07E676", 23 | dark: "#B6F0D3", 24 | }, 25 | accent50: { 26 | light: "#39f", 27 | dark: "#141414", 28 | }, 29 | accent900: { 30 | light: "white", 31 | dark: "black", 32 | } 33 | }), 34 | }) 35 | } 36 | return {theme: res}; 37 | }, [theme, changeThemeToCustom]); 38 | 39 | return ( 40 | 41 | 44 | 45 | 46 | ); 47 | } 48 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | CometChat React Sample App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cometchat-chat-sample-app-react", 3 | "version": "4.3.8", 4 | "private": true, 5 | "dependencies": { 6 | "@cometchat/calls-sdk-javascript": "^4.0.7", 7 | "@cometchat/chat-sdk-javascript": "^4.0.5", 8 | "@cometchat/chat-uikit-react": "^4.3.7", 9 | "@cometchat/uikit-elements": "^4.3.7", 10 | "@cometchat/uikit-resources": "^4.3.7", 11 | "@cometchat/uikit-shared": "^4.3.8", 12 | "@lit-labs/react": "^1.1.1", 13 | "@testing-library/jest-dom": "^5.16.5", 14 | "@testing-library/react": "^13.4.0", 15 | "@testing-library/user-event": "^13.5.0", 16 | "@types/jest": "^27.5.2", 17 | "@types/node": "^16.18.32", 18 | "@types/react": "^18.2.7", 19 | "@types/react-dom": "^18.2.4", 20 | "react": "^18.2.0", 21 | "react-dom": "^18.2.0", 22 | "react-router-dom": "^6.11.2", 23 | "react-scripts": "^5.0.1", 24 | "react-switch": "^7.0.0", 25 | "typescript": "^4.9.5", 26 | "web-vitals": "^2.1.4" 27 | }, 28 | "devDependencies": { 29 | "@babel/plugin-transform-private-property-in-object": "^7.24.1" 30 | }, 31 | "scripts": { 32 | "start": "react-scripts start", 33 | "build": "react-scripts build", 34 | "test": "react-scripts test", 35 | "eject": "react-scripts eject" 36 | }, 37 | "eslintConfig": { 38 | "extends": [ 39 | "react-app", 40 | "react-app/jest" 41 | ] 42 | }, 43 | "browserslist": { 44 | "production": [ 45 | ">0.2%", 46 | "not dead", 47 | "not op_mini all" 48 | ], 49 | "development": [ 50 | "last 1 chrome version", 51 | "last 1 firefox version", 52 | "last 1 safari version" 53 | ] 54 | }, 55 | "description": "This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).", 56 | "main": "index.js", 57 | "author": "CometChat Team", 58 | "license": "SEE LICENSE IN LICENSE.md" 59 | } 60 | -------------------------------------------------------------------------------- /src/components/TextInput/index.tsx: -------------------------------------------------------------------------------- 1 | import { inputStyle, labelContainerStyle, labelStyle, labelTextStyle, requiredSymbolStyle } from "./style"; 2 | 3 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 4 | import { useContext } from "react"; 5 | 6 | interface ITextInputProps { 7 | labelText : string, 8 | placeholderText : string, 9 | value : string, 10 | onValueChange : (newValue : string) => void 11 | required? : boolean 12 | }; 13 | 14 | export function TextInput(props : ITextInputProps) { 15 | const { 16 | labelText, 17 | placeholderText, 18 | value, 19 | onValueChange, 20 | required = false 21 | } = props; 22 | 23 | const { theme } = useContext(CometChatThemeContext); 24 | 25 | function getLabel() { 26 | let labelJSX = ( 27 | 30 | {labelText} 31 | 32 | ); 33 | if (required) { 34 | labelJSX = ( 35 | 38 | {labelJSX} 39 | 42 | * 43 | 44 | 45 | ); 46 | } 47 | return labelJSX; 48 | } 49 | 50 | return ( 51 | 64 | ); 65 | } 66 | -------------------------------------------------------------------------------- /src/assets/text-bubble.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/components/CallButtonsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CometChatCallButtons, CometChatThemeContext } from "@cometchat/chat-uikit-react"; 2 | import { callButtonsStyle, callButtonsWrapperStyle } from "./style"; 3 | import { useContext, useEffect, useState } from "react"; 4 | 5 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 6 | import { useNavigate } from "react-router-dom"; 7 | 8 | type CallButtonsWrapperProps = { setSomeInterestingAsyncOpStarted : React.Dispatch> }; 9 | 10 | export function CallButtonsWrapper(props : CallButtonsWrapperProps) { 11 | const [loggedInUser, setLoggedInUser] = useState(null); 12 | const navigate = useNavigate(); 13 | const { theme } = useContext(CometChatThemeContext); 14 | const { setSomeInterestingAsyncOpStarted, ...otherProps } = props; 15 | 16 | function handleClick(message : string) { 17 | console.log(message); 18 | navigate("/home/calls-module"); 19 | } 20 | 21 | useEffect(() => { 22 | (async () => { 23 | try { 24 | setSomeInterestingAsyncOpStarted(true); 25 | setLoggedInUser(await CometChat.getLoggedinUser()); 26 | } 27 | catch(error) { 28 | console.log(error); 29 | } 30 | finally { 31 | setSomeInterestingAsyncOpStarted(false); 32 | } 33 | })(); 34 | }, [setSomeInterestingAsyncOpStarted]); 35 | 36 | return ( 37 |
40 | handleClick("Voice call button clicked")} 43 | onVideoCallClick = {() => handleClick("Video call button clicked")} 44 | callButtonsStyle = {callButtonsStyle()} 45 | {...otherProps} 46 | /> 47 |
48 | ); 49 | } -------------------------------------------------------------------------------- /src/assets/call-log-history.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | CometChat 3 |

4 | 5 | 6 | # React Sample App by CometChat 7 | 8 | This is a reference application showcasing the integration of [CometChat's React UI Kit](https://www.cometchat.com/docs/v4/react-uikit/overview) within a React framework. It provides developers with examples of implementing real-time messaging and voice and video calling features in their own React-based applications. 9 | 10 |
14 | 15 |
16 | 17 | ## Prerequisites 18 | 19 | - Ensure that you have Node.js and npm installed: 20 | 21 | ```sh 22 | npm install npm@latest -g 23 | ``` 24 | 25 | - Sign up for a [CometChat](https://app.cometchat.com/) account to get your app credentials: _`App ID`_, _`Region`_, and _`Auth Key`_ 26 | 27 | 28 | ## Installation 29 | 1. Clone the repository: 30 | ```sh 31 | git clone https://github.com/cometchat/cometchat-sample-app-react.git 32 | ``` 33 | 2. Navigate to the cloned directory: 34 | ```sh 35 | cd cometchat-sample-app-react 36 | ``` 37 | 3. Install dependencies: 38 | ```sh 39 | npm install 40 | ``` 41 | 4. Enter your CometChat _`App ID`_, _`Region`_, and _`Auth Key`_ in the [src/AppConstants.ts](https://github.com/cometchat/cometchat-sample-app-react/blob/v4/src/AppConstants.ts) file: 42 | https://github.com/cometchat/cometchat-sample-app-react/blob/ce2a0d3460cabd9f0500f499c008ca930111f842/src/AppConstants.ts#L1-L7 43 | 5. Run the project locally to see all CometChat features in action: 44 | ``` 45 | npm run start 46 | ``` 47 | 48 | 49 | 50 | ## Help and Support 51 | For issues running the project or integrating with our UI Kits, consult our [documentation](https://www.cometchat.com/docs/react-uikit/integration) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](http://app.cometchat.com/). 52 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/AudioBubble/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 5 | import SampleAudio from "./sample.mp3" 6 | import { useContext } from "react"; 7 | 8 | const AudioBubble = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "audio-bubble" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | const { theme } = useContext(CometChatThemeContext); 19 | const themeMode = theme.palette.mode 20 | return ( 21 | 22 |
25 |
28 |
29 |
Audio Bubble
30 |
closeIcon
31 |
32 |
33 | CometChatAudioBubble displays a media message containing an audio" "To learn more about this component tap here. 34 |
35 |
36 | 37 |
38 |
39 |
) 40 | 41 | } 42 | export { AudioBubble }; -------------------------------------------------------------------------------- /src/components/MessagesCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { ICardProps } from "../Card"; 2 | import Sidebar from "../../assets/sidebar.png"; 3 | import ListWrapper from "../../assets/listwrapper.png"; 4 | import List from "../../assets/list.png"; 5 | import Composer from "../../assets/composer.png"; 6 | import InfoIcon from "../../assets/info.svg" 7 | import { CardList } from "../CardList"; 8 | 9 | const cardDataList : Omit[] = [ 10 | { 11 | title: "messages", 12 | description: "CometChatMessages is an independent component that is used to handle messages for users and groups.", 13 | imageInfo: { 14 | url: Sidebar, 15 | altText: "chat screen" 16 | } 17 | }, 18 | { 19 | title: "message header", 20 | description: "CometChatMessageHeader is an independent component that displays the user or group information using SDK's user or group object.", 21 | imageInfo: { 22 | url: ListWrapper, 23 | altText: "list wrapper" 24 | } 25 | }, 26 | { 27 | title: "message list", 28 | description: "CometChatMessageList displays a list of messages and handles real-time operations.", 29 | imageInfo: { 30 | url: List, 31 | altText: "list" 32 | } 33 | }, 34 | { 35 | title: "message composer", 36 | description: "CometChatMessageComposer is an independent and a critical component that allows users to compose and send various types of messages such as text, image, video and custom messages.", 37 | imageInfo: { 38 | url: Composer, 39 | altText: "composer" 40 | } 41 | }, 42 | { 43 | title: "message information", 44 | description: "CometChatMessageInformation displays read receipts for the selected message for user and group chat.", 45 | imageInfo: { 46 | url: InfoIcon, 47 | altText: "message information" 48 | } 49 | } 50 | ]; 51 | 52 | export function MessagesCardList() { 53 | return ( 54 | 58 | ); 59 | } 60 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/ImageBubble/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 5 | import SampleImg from "./astro.png" 6 | import { useContext } from "react"; 7 | 8 | const ImageBubble = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "image-bubble" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | 19 | const imageStyle = {height:"auto",maxHeight:"300px", width:"100%",borderRadius:"8px",margin: "auto", display: "block"} 20 | const { theme } = useContext(CometChatThemeContext); 21 | const themeMode = theme.palette.mode 22 | return ( 23 | 24 |
27 |
30 |
31 |
Image Bubble
32 |
closeIcon
33 |
34 |
35 | CometChatImageBubble displays a media message containing an image. 36 |
37 |
38 | 39 |
40 |
41 |
) 42 | 43 | } 44 | export { ImageBubble }; -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/VideoBubble/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 5 | import SampleVideo from "./aurora.mp4" 6 | import { useContext } from "react"; 7 | 8 | const VideoBubble = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "video-bubble" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | const videoStyle = {background: "#e4e1e1",borderRadius:"8px",margin: "auto", display: "block"} 19 | const { theme } = useContext(CometChatThemeContext); 20 | const themeMode = theme.palette.mode 21 | return ( 22 | 23 |
26 |
29 |
30 |
Video Bubble
31 |
closeIcon
32 |
33 |
34 | CometChatVideoBubble component displays a media message containing a video which is downloadable. 35 |
36 |
37 | 38 |
39 |
40 |
) 41 | 42 | } 43 | export { VideoBubble }; -------------------------------------------------------------------------------- /src/components/CardList/Shared/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | export function loadingComponentModalStyle(showModal : boolean) : CSSProperties { 3 | return { 4 | height: "100%", 5 | width: "100%", 6 | background: "#a1a1a1e6", 7 | position: "absolute", 8 | top: "50%", 9 | left: "50%", 10 | transform: "translate(-50%, -50%)", 11 | display: showModal ? "flex" : "none", 12 | zIndex: 1 13 | }; 14 | } 15 | 16 | export function componentDetailsModalStyle(themeMode: string) : CSSProperties { 17 | return { 18 | height: "auto", 19 | width: "100%", 20 | maxWidth: "300px", 21 | minHeight: "150px", 22 | transform: "translate(-50%, -50%)", 23 | left: "50%", 24 | top:"50%", 25 | position: "absolute", 26 | zIndex: "10", 27 | padding: "12px 16px", 28 | borderRadius: "12px", 29 | display: "flex", 30 | flexDirection: "column", 31 | justifyContent: "space-between", 32 | backgroundColor: themeMode === "dark" ? "black" : "white", 33 | color: themeMode === "dark" ? "white" : "black", 34 | boxShadow: "rgba(20, 20, 20, 0.33) 0px 0px 3px", 35 | maxHeight:"70%", 36 | overflow:"auto", 37 | WebkitScrollSnapType:"none" 38 | } 39 | }; 40 | 41 | export const componentDetailsModalHeaderStyle = { 42 | textAlign: "left" as "left", 43 | fontWeight: "700", 44 | fontSize: "15px", 45 | display: "flex", 46 | width: '100%', 47 | justifyContent: 'space-between', 48 | color: "inherit" 49 | } 50 | 51 | export const componentDetailsModalTitleStyle = { 52 | display: "flex", 53 | alignItems: "center", 54 | justifyContent: "center" 55 | } 56 | 57 | export const componentDetailsModalCloseIconWrapperStyle = { 58 | height: "30px", 59 | width: "30px", 60 | cursor: "pointer", 61 | } 62 | 63 | export const componentDetailsModalDescriptionStyle = { 64 | marginTop: "10px", 65 | textAlign: "left" as "left", 66 | fontWeight: "400", 67 | fontSize: "13px", 68 | color: "#777777", 69 | lineHeight:"17px" 70 | } 71 | 72 | export const componentDetailModalCloseIconStyle = { 73 | width: "24px" 74 | } 75 | 76 | export const tabListStyle = { 77 | width: "24px" 78 | } -------------------------------------------------------------------------------- /src/custom-hooks.ts: -------------------------------------------------------------------------------- 1 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 2 | import { useCallback, useRef, useState } from "react"; 3 | 4 | /** 5 | * Sets the created ref to the `value` passed 6 | * 7 | * @remarks 8 | * After the initial call of this hook, the internal ref is set to the `value` passed to this hook after the component has rendered completely. 9 | * So the returned ref will not have the updated value while the component renders 10 | */ 11 | export function useRefSync(value : T) : React.MutableRefObject { 12 | const res = useRef(value); 13 | res.current = value; 14 | return res; 15 | } 16 | 17 | /** 18 | * Custom hook to make refs stateful 19 | * 20 | * @remarks 21 | * Making refs stateful opens up the possibility of using the element the ref is pointing to as a dependency for a `useEffect` call 22 | * 23 | * @example 24 | * Here's a simple example 25 | * ```ts 26 | * // At the top most level of the functional component 27 | * const [inputElement, setInputRef] = useStateRef(null); 28 | * 29 | * // Inside the JSX 30 | * 31 | * ``` 32 | */ 33 | export function useStateRef(initialValue : T) : [T, (node : T) => void] { 34 | const [state, setState] = useState(initialValue); 35 | const setRef = useCallback((node : T) => { 36 | setState(node); 37 | }, []); 38 | return [state, setRef]; 39 | } 40 | 41 | export function useCometChatErrorHandler(onError : ((error : CometChat.CometChatException) => void) | undefined) : (error : unknown) => void { 42 | const onErrorRef = useRefSync(onError); 43 | const errorHandler = useCallback(function fn(error : unknown) : void { 44 | if (typeof error === "object" && error) { 45 | if (error instanceof CometChat.CometChatException) { 46 | const onError = onErrorRef.current; 47 | if (onError) { 48 | return onError(error); 49 | } 50 | } 51 | else if (error instanceof Error) { 52 | return fn(new CometChat.CometChatException({ 53 | code: "ERROR", 54 | name: error.name, 55 | message: error.message 56 | })); 57 | } 58 | } 59 | console.log(error); 60 | }, [onErrorRef]); 61 | return errorHandler; 62 | } 63 | -------------------------------------------------------------------------------- /src/assets/video-bubble.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/assets/call-log-participants.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/components/Card/index.tsx: -------------------------------------------------------------------------------- 1 | import { CSSProperties, useContext } from "react"; 2 | import { arrowImageStyle, cardStyle, descriptionStyle, iconStyle, textContentContainerStyle, titleStyle } from "./style"; 3 | 4 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 5 | import RightArrow from "../../assets/right-arrow.png"; 6 | 7 | export interface ICardProps { 8 | title : string, 9 | description : string, 10 | onClick : () => void, 11 | imageInfo? : {url : string, altText : string}, 12 | cardContainerStyle? : CSSProperties 13 | }; 14 | 15 | export function Card(props : ICardProps) { 16 | const { 17 | title, 18 | description, 19 | onClick, 20 | imageInfo, 21 | cardContainerStyle 22 | } = props; 23 | 24 | const { theme } = useContext(CometChatThemeContext); 25 | 26 | function getImage() { 27 | if (!imageInfo) { 28 | return null; 29 | } 30 | return ( 31 | 36 | 40 | 41 | ); 42 | } 43 | 44 | function getTextContent() { 45 | return ( 46 |
49 |
52 | {title} 53 |
54 |
57 | {description} 58 |
59 |
60 | ); 61 | } 62 | 63 | function getArrow() { 64 | if (imageInfo) { 65 | return null; 66 | } 67 | return ( 68 | Right arrow 73 | ); 74 | } 75 | 76 | return ( 77 | 85 | ); 86 | } 87 | -------------------------------------------------------------------------------- /src/components/App/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme } from "@cometchat/uikit-resources"; 3 | 4 | const LOGGED_IN_USER_INFO_CONTAINER_HEIGHT = "48px"; 5 | const FOOTER_HEIGHT = "48px"; 6 | 7 | export function appStyle(theme : CometChatTheme) : CSSProperties { 8 | return { 9 | height: "100%", 10 | boxSizing: "border-box", 11 | backgroundColor: theme.palette.getBackground(), 12 | position: "relative", 13 | overflowX: "hidden" 14 | }; 15 | } 16 | 17 | export function footerStyle() : CSSProperties { 18 | return { 19 | display: "flex", 20 | justifyContent: "center", 21 | alignItems: "center", 22 | height: FOOTER_HEIGHT 23 | }; 24 | } 25 | 26 | export function messageStyle(isError : boolean) : CSSProperties { 27 | return { 28 | padding: "16px", 29 | color: "white", 30 | textAlign: "center", 31 | backgroundColor: isError ? "red" : "green", 32 | borderRadius: "8px", 33 | width: "300px", 34 | boxSizing: "border-box", 35 | position: "fixed", 36 | top: "32px", 37 | left: "50%", 38 | transform: "translateX(-50%)" 39 | }; 40 | } 41 | 42 | export function loggedInUserInfoContainerStyle() : CSSProperties { 43 | return { 44 | height: LOGGED_IN_USER_INFO_CONTAINER_HEIGHT, 45 | display: "flex", 46 | justifyContent: "flex-end", 47 | alignItems: "center", 48 | columnGap: "8px", 49 | padding: "0 16px" 50 | }; 51 | } 52 | 53 | export function uidStyle() : CSSProperties { 54 | return { 55 | fontWeight: "600" 56 | }; 57 | } 58 | 59 | export function logoutBtnStyle() : CSSProperties { 60 | return { 61 | cursor: "pointer", 62 | backgroundColor: "transparent", 63 | border: "none" 64 | }; 65 | } 66 | 67 | export function logoutImgStyle() : CSSProperties { 68 | return { 69 | width: "24px", 70 | height: "24px" 71 | }; 72 | } 73 | 74 | export function loadingModalStyle(showModal : boolean) : CSSProperties { 75 | return { 76 | display: showModal ? "flex" : "none", 77 | width: "100vw", 78 | height: "100vh", 79 | backgroundColor: "#393b39", 80 | position: "fixed", 81 | top: "0", 82 | left: "0", 83 | justifyContent: "center", 84 | alignItems: "center" 85 | }; 86 | } 87 | 88 | export function imageStyle() : CSSProperties { 89 | return { 90 | backgroundSize: "cover" 91 | }; 92 | } -------------------------------------------------------------------------------- /src/assets/call-log-recordings.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/FileBubble/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 5 | import SamplePDF from "./sample.pdf" 6 | import { fontHelper } from "@cometchat/uikit-resources"; 7 | import { useContext } from "react"; 8 | 9 | const FileBubble = (props:any) => { 10 | const { 11 | activeComponent, 12 | handleCloseComponentModal, 13 | showComponentModal, 14 | } = props; 15 | let showModal = false; 16 | const bubbleSlug = "file-bubble" 17 | if(showComponentModal && activeComponent === bubbleSlug) 18 | showModal = true 19 | const { theme } = useContext(CometChatThemeContext); 20 | const fileStyle = { 21 | borderRadius:"8px", 22 | height:"fit-content", 23 | width:"220px", 24 | background:theme.palette.getAccent200(), 25 | titleFont: fontHelper(theme.typography.subtitle1), 26 | titleColor: theme.palette.getAccent(), 27 | subtitleFont: fontHelper(theme.typography.subtitle2), 28 | subtitleColor: theme.palette.getAccent600(), 29 | iconTint: "rgb(51, 153, 255)", 30 | } 31 | const themeMode = theme.palette.mode 32 | return ( 33 | 34 |
37 |
40 |
41 |
File Bubble
42 |
closeIcon
43 |
44 |
45 | CometChatFileBubble displays a media message containing a file. 46 |
47 |
48 | 49 |
50 |
51 |
) 52 | 53 | } 54 | export { FileBubble }; -------------------------------------------------------------------------------- /src/components/CallsCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import CallLogHistorySVG from "../../assets/call-log-history.svg"; 2 | import CallLogParticipantsSVG from "../../assets/call-log-participants.svg"; 3 | import CallLogRecordingsSVG from "../../assets/call-log-recordings.svg"; 4 | import CallLogSVG from "../../assets/call-logs.svg"; 5 | import { CardList } from "../CardList"; 6 | import { ICardProps } from "../Card"; 7 | import Sidebar from "../../assets/sidebar.png"; 8 | 9 | const cardDataList : Omit[] = [ 10 | { 11 | title: "call buttons", 12 | description: "CometChatCallButtons is an independent component used to initiate 1v1 and direct calling", 13 | imageInfo: { 14 | url: Sidebar, 15 | altText: "sidebar" 16 | } 17 | }, 18 | { 19 | title: "call logs", 20 | description: "CometChatCallLogs is an independent component used to display call logs", 21 | imageInfo: { 22 | url: CallLogSVG , 23 | altText: "sidebar" 24 | } 25 | }, 26 | { 27 | title: "call log details", 28 | description: "CometChatCallLogDetails is an independent component used to display call log details", 29 | imageInfo: { 30 | url: CallLogSVG, 31 | altText: "sidebar" 32 | } 33 | }, 34 | { 35 | title: "call log history", 36 | description: "CometChatCallLogHistory is an independent component used to display call log history", 37 | imageInfo: { 38 | url: CallLogHistorySVG, 39 | altText: "sidebar" 40 | } 41 | }, 42 | { 43 | title: "call log participants", 44 | description: "CometChatCallLogParticipants is an independent component used to display call log participants", 45 | imageInfo: { 46 | url: CallLogParticipantsSVG, 47 | altText: "sidebar" 48 | } 49 | }, 50 | { 51 | title: "call log recordings", 52 | description: "CometChatCallLogRecordings is an independent component used to display call log recordings", 53 | imageInfo: { 54 | url: CallLogRecordingsSVG, 55 | altText: "sidebar" 56 | } 57 | }, 58 | { 59 | title: "call logs with details", 60 | description: "CometChatCallLogs is an independent component used to display call logs with details", 61 | imageInfo: { 62 | url: CallLogSVG, 63 | altText: "sidebar" 64 | } 65 | } 66 | ]; 67 | 68 | export function CallsCardList() { 69 | return ( 70 | 74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /src/assets/transfer-ownership-icon.svg: -------------------------------------------------------------------------------- 1 | a -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/TextBubble/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 5 | import { fontHelper } from "@cometchat/uikit-resources"; 6 | import { useContext } from "react"; 7 | 8 | const TextBubble = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "text-bubble" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | const { theme } = useContext(CometChatThemeContext); 19 | const themeMode = theme.palette.mode 20 | const receiverBubbleStyle = { 21 | borderRadius:"8px", 22 | background:theme.palette.getAccent200(), 23 | textFont: fontHelper(theme.typography.text2), 24 | textColor: theme.palette.getAccent(), 25 | } 26 | const senderBubbleStyle = { 27 | borderRadius:"8px", 28 | background:theme.palette.getPrimary(), 29 | textFont: fontHelper(theme.typography.text2), 30 | textColor: theme.palette.getAccent("dark"), 31 | } 32 | 33 | return ( 34 | 35 |
38 |
41 |
42 |
Text Bubble
43 |
closeIcon
44 |
45 |
46 | CometChatTextBubble component displays a text message. 47 |
48 |
49 |
50 | 51 |
52 |
53 | 54 |
55 |
56 |
57 |
) 58 | 59 | } 60 | export { TextBubble }; -------------------------------------------------------------------------------- /src/components/LoginSignup/index.tsx: -------------------------------------------------------------------------------- 1 | import { cardStyle, chatHeaderTextStyle, contentContainerStyle, contentStyle, footerStyle, headerStyle, headerTitle, imageStyle, loginSignupStyle, mainContainerStyle, titleStyle, versionStyle } from "./style"; 2 | 3 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 4 | import Image from "../../assets/Image-518@1x.png"; 5 | import { IsMobileViewContext } from "../../IsMobileViewContext"; 6 | import { metaInfo } from "../../metaInfo"; 7 | import { useContext } from "react"; 8 | 9 | interface ILoginSignupProps { 10 | title : string, 11 | children : JSX.Element 12 | }; 13 | 14 | export function LoginSignup(props : ILoginSignupProps) { 15 | const { 16 | title, 17 | children 18 | } = props; 19 | 20 | const { theme } = useContext(CometChatThemeContext); 21 | const isMobileView = useContext(IsMobileViewContext); 22 | 23 | function getHeader() { 24 | return ( 25 |
28 |
31 | comet 32 | 35 | chat 36 | 37 |
38 |
41 | v{metaInfo.version} 42 |
43 |
44 | ); 45 | } 46 | 47 | function getContent() { 48 | return ( 49 |
52 |
55 |
58 | {title} 59 |
60 |
63 | {children} 64 |
65 |
66 | Login signup 71 |
72 | ); 73 | } 74 | 75 | function getFooter() { 76 | return ( 77 |
80 | <> 81 |
82 | ); 83 | } 84 | 85 | return ( 86 |
89 |
92 | {getHeader()} 93 | {getContent()} 94 | {getFooter()} 95 |
96 |
97 | ); 98 | } 99 | -------------------------------------------------------------------------------- /src/components/LoginSignup/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 3 | 4 | export function loginSignupStyle() : CSSProperties { 5 | return { 6 | height: "100%", 7 | display: "flex", 8 | justifyContent: "center" 9 | }; 10 | } 11 | 12 | export function mainContainerStyle() : CSSProperties { 13 | return { 14 | width: "min(100%, 1400px)", 15 | height: "100%", 16 | display: "flex", 17 | flexDirection: "column", 18 | alignItems: "center", 19 | rowGap: "8px", 20 | boxSizing: "border-box", 21 | padding: "8px" 22 | }; 23 | } 24 | 25 | export function headerStyle(theme : CometChatTheme) : CSSProperties { 26 | return { 27 | width: "100%", 28 | padding: "16px", 29 | display: "flex", 30 | justifyContent: "space-between", 31 | borderBottom: `1px solid ${theme.palette.getAccent100()}` 32 | }; 33 | } 34 | 35 | export function contentContainerStyle() : CSSProperties { 36 | return { 37 | width: "100%", 38 | display: "flex", 39 | justifyContent: "center", 40 | alignItems: "center", 41 | columnGap: "8px" 42 | }; 43 | } 44 | 45 | export function footerStyle(theme : CometChatTheme) : CSSProperties { 46 | return { 47 | padding: "16px", 48 | flexGrow: "1", 49 | font: fontHelper(theme.typography.subtitle2), 50 | color: theme.palette.getAccent500(), 51 | display: "flex", 52 | alignItems: "flex-end" 53 | }; 54 | } 55 | 56 | export function chatHeaderTextStyle() : CSSProperties { 57 | return { 58 | fontWeight: "bold" 59 | }; 60 | } 61 | 62 | export function contentStyle(isMobileView : boolean) : CSSProperties { 63 | return { 64 | display: "flex", 65 | flexDirection: "column", 66 | rowGap: "8px", 67 | width: isMobileView ? "80%" : "50%" 68 | }; 69 | } 70 | 71 | export function titleStyle(theme : CometChatTheme) : CSSProperties { 72 | return { 73 | font: fontHelper(theme.typography.heading), 74 | color: theme.palette.getAccent() 75 | }; 76 | } 77 | 78 | export function cardStyle() : CSSProperties { 79 | return { 80 | backgroundColor: "white", 81 | borderRadius: "8px", 82 | boxShadow: "0 0 8px rgb(20, 20, 20, 0.33)", 83 | padding: "16px" 84 | }; 85 | } 86 | 87 | export function imageStyle(showImage : boolean) : CSSProperties { 88 | return { 89 | display: showImage ? "inline" : "none", 90 | width: "50%", 91 | backgroundSize: "contain" 92 | }; 93 | } 94 | 95 | export function headerTitle(theme : CometChatTheme) : CSSProperties { 96 | return { 97 | font: fontHelper(theme.typography.name) 98 | }; 99 | } 100 | 101 | export function versionStyle(theme : CometChatTheme) : CSSProperties { 102 | return { 103 | font: fontHelper(theme.typography.subtitle2), 104 | color: theme.palette.getAccent400() 105 | }; 106 | } 107 | -------------------------------------------------------------------------------- /src/components/CardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { CSSProperties, useContext, useState } from "react"; 2 | import { Card, ICardProps } from "../Card"; 3 | import { useLocation, useNavigate } from "react-router-dom"; 4 | 5 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 6 | import { Shared } from "./Shared"; 7 | import { fontHelper } from "@cometchat/uikit-resources"; 8 | 9 | interface ICardListProps { 10 | title : string, 11 | cardDataList : Omit[], 12 | titleStyle? : CSSProperties, 13 | }; 14 | 15 | type CardData = ICardListProps["cardDataList"][number]; 16 | 17 | export function CardList({ title, cardDataList, titleStyle } : ICardListProps) { 18 | const navigate = useNavigate(); 19 | const location = useLocation(); 20 | const { theme } = useContext(CometChatThemeContext); 21 | const [showComponentModal, setShowComponentModal] = useState(false); 22 | const [activeComponent, setActiveComponent] = useState(''); 23 | 24 | function handleClick({ title : cardTitle } : CardData) { 25 | 26 | if(location.pathname === "/home/shared-module") 27 | { 28 | // console.log("cardTitle.toLowerCase()",cardTitle.toLowerCase()) 29 | setActiveComponent(cardTitle.toLowerCase().replaceAll(" ", "-")) 30 | setShowComponentModal(true) 31 | } 32 | else 33 | navigate(`/home/${title.toLowerCase()}-module/${cardTitle.toLowerCase().replaceAll(" ", "-")}`); 34 | } 35 | 36 | function handleCloseComponentModal() { 37 | setShowComponentModal(false) 38 | setActiveComponent('') 39 | } 40 | 41 | return ( 42 |
51 | {} 52 |
60 | {title} 61 |
62 |
68 |
75 | { 76 | cardDataList.map(cardData => ( 77 | handleClick(cardData)} 83 | /> 84 | )) 85 | } 86 |
87 |
88 |
89 | ); 90 | } 91 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Localize/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | import { useContext, useState } from "react"; 3 | 4 | import CloseIcon from "../assets/close2x.png"; 5 | import { CometChatLocalize } from "@cometchat/uikit-resources"; 6 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 7 | import Switch from "react-switch"; 8 | import { useNavigate } from "react-router-dom"; 9 | 10 | const Localize = (props:any) => { 11 | const [languageChoice, setLanguageChoice] = useState("english") 12 | const { 13 | activeComponent, 14 | handleCloseComponentModal, 15 | showComponentModal, 16 | } = props; 17 | let showModal = false; 18 | const bubbleSlug = "localize" 19 | if(showComponentModal && activeComponent === bubbleSlug) 20 | showModal = true 21 | const handleChange = (checked:boolean) => { 22 | setLanguageChoice(checked ? "english" : "hindi") 23 | CometChatLocalize.setLocale(checked ? "en" : "hi") 24 | } 25 | const navigate = useNavigate(); 26 | const handleNavigateToConversations = () => { 27 | navigate("/home/chats-module/conversations-with-messages"); 28 | } 29 | const { theme } = useContext(CometChatThemeContext); 30 | const themeMode = theme.palette.mode 31 | return ( 32 | 33 |
36 |
39 |
40 |
Localize
41 |
closeIcon
42 |
43 |
44 | CometChatLocalize allows you to detect the language of your users based on their browser or device settings and set the language accordingly. 45 |
46 |
47 |
48 | Language 49 |
50 |
51 | हिन्दी
} checked={languageChoice === "english" ? true : false} checkedIcon={
English
} /> 53 |
54 |
55 |
56 |
57 | ) 58 | 59 | } 60 | export { Localize }; -------------------------------------------------------------------------------- /src/components/CreateGroupWrapper/style.ts: -------------------------------------------------------------------------------- 1 | import { CreateGroupStyle } from "@cometchat/uikit-elements"; 2 | import { CSSProperties } from "react"; 3 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 4 | 5 | export function createGroupStyle(isMobileView : boolean, theme : CometChatTheme) : CreateGroupStyle { 6 | return { 7 | boxShadow: `${theme.palette.getAccent100()} 4px 16px 32px 4px`, 8 | groupTypeTextFont: fontHelper(theme.typography.subtitle2), 9 | groupTypeBorder: `1px solid ${theme.palette.getAccent600()}`, 10 | groupTypeBorderRadius: "0", 11 | groupTypeTextColor: theme.palette.getAccent(), 12 | groupTypeTextBackground: "transparent", 13 | groupTypeBackground: theme.palette.getAccent100(), 14 | activeGroupTypeTextFont: fontHelper(theme.typography.subtitle2), 15 | activeGroupTypeTextColor: theme.palette.getAccent(), 16 | activeGroupTypeBackground: theme.palette.getAccent900(), 17 | activeGroupTypeBoxShadow: `${theme.palette.getAccent200()} 0 3px 8px 0`, 18 | activeGroupTypeBorderRadius: "8px", 19 | activeGroupTypeBorder: "none", 20 | groupTypeTextBoxShadow: "none", 21 | groupTypeTextBorderRadius: "0", 22 | closeIconTint: theme.palette.getPrimary(), 23 | titleTextFont: fontHelper(theme.typography.title1), 24 | titleTextColor: theme.palette.getAccent(), 25 | errorTextFont: fontHelper(theme.typography.subtitle1), 26 | errorTextBackground: theme.palette.getError(), 27 | errorTextBorderRadius: "8px", 28 | errorTextBorder: "none", 29 | errorTextColor: theme.palette.getError(), 30 | nameInputPlaceholderTextFont: fontHelper(theme.typography.subtitle1), 31 | nameInputPlaceholderTextColor: theme.palette.getAccent600(), 32 | nameInputBackground: theme.palette.getAccent100(), 33 | nameInputTextFont: fontHelper(theme.typography.subtitle1), 34 | nameInputTextColor: theme.palette.getAccent(), 35 | nameInputBorder: "none", 36 | nameInputBorderRadius: "8px", 37 | nameInputBoxShadow: `${theme.palette.getAccent100()} 0 0 0 1px`, 38 | passwordInputPlaceholderTextFont: fontHelper(theme.typography.subtitle1), 39 | passwordInputPlaceholderTextColor: theme.palette.getAccent600(), 40 | passwordInputBackground: theme.palette.getAccent100(), 41 | passwordInputBorder: "none", 42 | passwordInputBorderRadius: "8px", 43 | passwordInputBoxShadow: `${theme.palette.getAccent100()} 0 0 0 1px`, 44 | passwordInputTextFont: fontHelper(theme.typography.subtitle1), 45 | passwordInputTextColor: theme.palette.getAccent(), 46 | createGroupButtonTextFont: fontHelper(theme.typography.text2), 47 | createGroupButtonTextColor: theme.palette.getAccent900(), 48 | createGroupButtonBackground: theme.palette.getPrimary(), 49 | createGroupButtonBorderRadius: "8px", 50 | createGroupButtonBorder: "none", 51 | height: "620px", 52 | width: isMobileView ? "290px" : "360px", 53 | borderRadius: "8px", 54 | background: theme.palette.getBackground(), 55 | border: `3px solid ${theme.palette.getAccent200()}` 56 | }; 57 | } 58 | 59 | export function createGroupWrapperStyle(theme : CometChatTheme) : CSSProperties { 60 | return { 61 | background: theme.palette.getBackground(), 62 | display: "flex", 63 | justifyContent: "center", 64 | alignItems: "center", 65 | height: "100%" 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/index.tsx: -------------------------------------------------------------------------------- 1 | import { AudioBubble } from "./Bubbles/AudioBubble"; 2 | import { Avatar } from "./Bubbles/Avatar"; 3 | import { Badge } from "./Bubbles/Badge"; 4 | import { CardBubble } from "./Bubbles/CardBubble"; 5 | import { FileBubble } from "./Bubbles/FileBubble"; 6 | import { FormBubble } from "./Bubbles/FormBubble" 7 | import { SchedulerBubble } from "./Bubbles/SchedulerBubble"; 8 | import { ImageBubble } from "./Bubbles/ImageBubble"; 9 | import { ListItem } from "./Bubbles/ListItem"; 10 | import { Localize } from "./Bubbles/Localize"; 11 | import { Receipt } from "./Bubbles/Receipt"; 12 | import { SoundManager } from "./Bubbles/SoundManager"; 13 | import { StatusIndicator } from "./Bubbles/StatusIndicator"; 14 | import { TextBubble } from "./Bubbles/TextBubble"; 15 | import { Theme } from "./Bubbles/Theme"; 16 | import { VideoBubble } from "./Bubbles/VideoBubble"; 17 | 18 | const Shared = (props:any) => { 19 | const { 20 | activeComponent, 21 | handleCloseComponentModal, 22 | showComponentModal, 23 | } = props; 24 | return ( 25 | <> 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | ) 44 | } 45 | export { Shared }; -------------------------------------------------------------------------------- /src/components/GroupsCardList/index.tsx: -------------------------------------------------------------------------------- 1 | import { ICardProps } from "../Card"; 2 | import Sidebar from "../../assets/sidebar.png"; 3 | import ListWrapper from "../../assets/listwrapper.png"; 4 | import CreateGroup from "../../assets/create-group.svg"; 5 | import PasswordGroup from "../../assets/password-group.svg"; 6 | import GroupMembers from "../../assets/group-member.svg"; 7 | import AddMembers from "../../assets/add-members.svg"; 8 | import TransferOwnership from "../../assets/transfer-ownership-icon.svg"; 9 | import BannedMembers from "../../assets/ban-members.svg"; 10 | import Details from "../../assets/details.svg"; 11 | import { CardList } from "../CardList"; 12 | 13 | const cardDataList : Omit[] = [ 14 | { 15 | title: "groups with messages", 16 | description: "CometChatGroupsWithMessages is an independent component used to set up a screen that shows the list of groups available in your app and gives you the ability to search for a specific group and to start a conversation.", 17 | imageInfo: { 18 | url: Sidebar, 19 | altText: "chat screen" 20 | } 21 | }, 22 | { 23 | title: "groups", 24 | description: "CometChatGroups is an independent component used to set up a screen that displays the list of groups available in your app and gives you the ability to search for a specific group.", 25 | imageInfo: { 26 | url: ListWrapper, 27 | altText: "list wrapper" 28 | } 29 | }, 30 | { 31 | title: "create group", 32 | description: "This component is used to create a new group. Groups can be of three types - public, private or password-protected.", 33 | imageInfo: { 34 | url: CreateGroup, 35 | altText: "create group" 36 | } 37 | }, 38 | { 39 | title: "join protected group", 40 | description: "This component is used to join a password-protected group.", 41 | imageInfo: { 42 | url: PasswordGroup, 43 | altText: "password protected group" 44 | } 45 | }, 46 | { 47 | title: "group members", 48 | description: "This component is used to view members of a group.", 49 | imageInfo: { 50 | url: GroupMembers, 51 | altText: "group members" 52 | } 53 | }, 54 | { 55 | title: "add members", 56 | description: "This component is used to add users to a group.", 57 | imageInfo: { 58 | url: AddMembers, 59 | altText: "add members" 60 | } 61 | }, 62 | { 63 | title: "transfer ownership", 64 | description: "This component is used to transfer ownership of a group from one user to another.", 65 | imageInfo: { 66 | url: TransferOwnership, 67 | altText: "transfer ownership" 68 | } 69 | }, 70 | { 71 | title: "banned members", 72 | description: "This component is used to view banned members of a group.", 73 | imageInfo: { 74 | url: BannedMembers, 75 | altText: "banned members" 76 | } 77 | }, 78 | { 79 | title: "group details", 80 | description: "CometChatDetails component for a group.", 81 | imageInfo: { 82 | url: Details, 83 | altText: "details" 84 | } 85 | } 86 | ]; 87 | 88 | export function GroupsCardList() { 89 | return ( 90 | 94 | ); 95 | } 96 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/StatusIndicator/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | import { statusIndicatorStyle, statusIndicatorWrapperStyle } from "./style"; 3 | import { useContext, useState } from "react"; 4 | 5 | import CloseIcon from "../assets/close2x.png"; 6 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 7 | import Switch from "react-switch"; 8 | 9 | const StatusIndicator = (props:any) => { 10 | const { 11 | activeComponent, 12 | handleCloseComponentModal, 13 | showComponentModal, 14 | } = props; 15 | let showModal = false; 16 | const bubbleSlug = "status-indicator" 17 | if(showComponentModal && activeComponent === bubbleSlug) 18 | showModal = true 19 | const { theme } = useContext(CometChatThemeContext); 20 | const themeMode = theme.palette.mode 21 | const colorOnline = theme.palette.getSuccess() 22 | const colorOffline = theme.palette.getAccent600() 23 | 24 | const [toggleState, setToggleState] = useState(true) 25 | const handleChange = (checked:boolean) => { 26 | setToggleState(checked) 27 | } 28 | return ( 29 |
32 |
35 |
36 |
StatusIndicator
37 |
closeIcon
38 |
39 |
40 | StatusIndicator component indicates whether a user is online or offline.. 41 |
42 | {toggleState && (
43 | 44 |
)} 45 | {!toggleState && (
46 | 47 |
)} 48 | 49 |
50 |
51 | Status 52 |
53 |
54 | Offline
} checkedIcon={
Online
} onChange={handleChange} checked={toggleState} /> 59 |
60 |
61 |
62 | ) 63 | } 64 | export { StatusIndicator }; -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Theme/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | import { useContext, useState } from "react"; 3 | 4 | import CloseIcon from "../assets/close2x.png"; 5 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 6 | import Switch from "react-switch"; 7 | import { useNavigate } from "react-router-dom"; 8 | 9 | const Theme = (props:any) => { 10 | 11 | const [themeChoice, setThemeChoice] = useState("default") 12 | const { 13 | activeComponent, 14 | handleCloseComponentModal, 15 | showComponentModal, 16 | } = props; 17 | let showModal = false; 18 | const bubbleSlug = "theme" 19 | if(showComponentModal && activeComponent === bubbleSlug) 20 | showModal = true 21 | const handleModeChange = (checked:boolean) => { 22 | setThemeChoice(checked ? "default" : "custom") 23 | } 24 | const navigate = useNavigate(); 25 | const handleNavigateToConversations = () => { 26 | if(themeChoice === "custom") 27 | { 28 | navigate("/home/chats-module/conversations-with-messages", {state: {changeThemeToCustom: true}}); 29 | } 30 | else 31 | { 32 | navigate("/home/chats-module/conversations-with-messages", {state: {changeThemeToCustom: false}}); 33 | } 34 | } 35 | const { theme } = useContext(CometChatThemeContext); 36 | const themeMode = theme.palette.mode 37 | return ( 38 | 39 |
42 |
45 |
46 |
Theme
47 |
closeIcon
48 |
49 |
50 | CometChatTheme is a style applied to every component and every view in the activity or component in the UI Kit. 51 |
52 |
53 |
54 | Theme 55 |
56 |
57 | Custom
} checked={themeChoice === "default" ? true : false} checkedIcon={
Default
} /> 59 |
60 |
61 |
62 |
63 | ) 64 | 65 | } 66 | export { Theme }; -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/SoundManager/index.tsx: -------------------------------------------------------------------------------- 1 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 2 | 3 | import CloseIcon from "../assets/close2x.png"; 4 | import { CometChatSoundManager } from '@cometchat/uikit-shared'; 5 | import {CometChatThemeContext} from "@cometchat/chat-uikit-react" 6 | import { useContext } from "react"; 7 | 8 | const SoundManager = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "sound-manager" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | 19 | const playIncoming = ()=>{ 20 | CometChatSoundManager.play(CometChatSoundManager.Sound.incomingMessage) 21 | } 22 | const playOutgoing = ()=>{ 23 | CometChatSoundManager.play(CometChatSoundManager.Sound.outgoingMessage) 24 | } 25 | const { theme } = useContext(CometChatThemeContext); 26 | const themeMode = theme.palette.mode 27 | return ( 28 | 29 |
32 |
35 |
36 |
Sound Manager
37 |
closeIcon
38 |
39 |
40 | CometChatSoundManager allows you to play different types of audio which is required for incoming and outgoing events in UI Kit. for example, events like incoming and outgoing messages. 41 |
42 |
43 |
44 |
Incoming Messages
45 |
46 |
47 |
48 |
Outgoing Messages
49 |
50 |
51 |
52 |
53 |
) 54 | 55 | } 56 | export { SoundManager }; -------------------------------------------------------------------------------- /src/assets/group-member.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 13 | 16 | 20 | 24 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Badge/index.tsx: -------------------------------------------------------------------------------- 1 | import {CometChatThemeContext, fontHelper} from "@cometchat/chat-uikit-react" 2 | import { badgeDemoStyle, colorButtonStyle, inputStyle } from "./style"; 3 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 4 | import { useContext, useState } from "react"; 5 | 6 | import CloseIcon from "../assets/close2x.png"; 7 | 8 | const Badge = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const [badgeCountValue, setBadgeCountValue] = useState("10") 16 | const [badgeColor, setBadgeColor] = useState("#3399ff") 17 | const handleInputChange = (value:string) => { 18 | setBadgeCountValue(value) 19 | } 20 | const bubbleSlug = "badge" 21 | if(showComponentModal && activeComponent === bubbleSlug) 22 | showModal = true 23 | 24 | const { theme } = useContext(CometChatThemeContext); 25 | let badgeStyle = { 26 | textFont: fontHelper(theme.typography.subtitle2), 27 | textColor: theme.palette.getAccent("dark"), 28 | background:badgeColor, 29 | borderRadius:"16px", 30 | width:"fit-content", 31 | height:"16px", 32 | border: "none" 33 | } 34 | const handleColorChange = (color:string) => { 35 | setBadgeColor(color) 36 | } 37 | const themeMode = theme.palette.mode 38 | return ( 39 | 40 |
43 |
46 |
47 |
Badge Count
48 |
closeIcon
49 |
50 |
51 | CometChatBadgeCount is a custom component which is used to display the unread message count. It can be used in places like ConversationListItem ,etc. 52 |
53 |
54 |
55 | 56 |
57 | handleInputChange(e.target.value)} /> 58 |
59 |
60 |
61 | Background Color 62 |
63 |
64 | 65 | 66 | 67 | 68 |
69 |
70 |
71 |
) 72 | 73 | } 74 | export { Badge }; -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Avatar/index.tsx: -------------------------------------------------------------------------------- 1 | import {CometChatThemeContext, fontHelper} from "@cometchat/chat-uikit-react" 2 | import { avatarWrapperStyle, inputStyle } from "./style"; 3 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 4 | import { useContext, useState } from "react"; 5 | 6 | import CloseIcon from "../assets/close2x.png"; 7 | import Switch from "react-switch"; 8 | 9 | const Avatar = (props:any) => { 10 | const { 11 | activeComponent, 12 | handleCloseComponentModal, 13 | showComponentModal, 14 | } = props; 15 | let showModal = false; 16 | const bubbleSlug = "avatar" 17 | if(showComponentModal && activeComponent === bubbleSlug) 18 | showModal = true 19 | const [avatarChoice, setAvatarChoice] = useState("image") 20 | const [avatarBorderRadius, setAvatarBorderRadius] = useState("28") 21 | const handleChange = (checked:boolean) => { 22 | 23 | setAvatarChoice(checked ? "image" : "name") 24 | } 25 | const handleInputChange = (value:string) => { 26 | setAvatarBorderRadius(value) 27 | } 28 | const { theme } = useContext(CometChatThemeContext); 29 | const themeMode = theme.palette.mode 30 | let avatarStyle = { 31 | borderRadius: `${avatarBorderRadius}px`, 32 | width: "36px", 33 | height: "36px", 34 | border: "1px solid #eee", 35 | backgroundColor: "transparent", 36 | backgroundSize: "cover", 37 | nameTextColor: theme.palette.getAccent900(), 38 | nameTextFont: fontHelper(theme.typography.subtitle1), 39 | outerViewBorder: "", 40 | outerViewBorderSpacing: "", 41 | } 42 | if(avatarChoice === "name") 43 | { 44 | avatarStyle.backgroundColor = "#6929ca" 45 | } 46 | return ( 47 | 48 |
51 |
54 |
55 |
Avatar
56 |
closeIcon
57 |
58 |
59 | CometChatAvatar component displays an image or user/group avatar with fallback to the first two letters of the user name/group name. 60 |
61 |
62 | {avatarChoice === "image" && () } 63 | {avatarChoice === "name" && () } 64 | handleInputChange(e.target.value)} /> 65 |
66 |
67 |
68 | Avatar type 69 |
70 |
71 | Name
} checked={avatarChoice === "image" ? true : false} checkedIcon={
Image
} /> 73 |
74 |
75 |
76 | ) 77 | 78 | } 79 | export { Avatar }; -------------------------------------------------------------------------------- /src/components/Login/style.ts: -------------------------------------------------------------------------------- 1 | import { CSSProperties } from "react"; 2 | import { CometChatTheme, fontHelper } from "@cometchat/uikit-resources"; 3 | 4 | export function loginStyle() : CSSProperties { 5 | return { 6 | display: "flex", 7 | flexDirection: "column", 8 | rowGap: "48px" 9 | }; 10 | } 11 | 12 | export function userBtnStyle(theme : CometChatTheme) : CSSProperties { 13 | return { 14 | flexBasis: "48%", 15 | padding: "8px", 16 | backgroundColor: theme.palette.getAccent100("light"), 17 | borderRadius: "8px", 18 | display: "flex", 19 | alignItems: "center", 20 | columnGap: "8px", 21 | cursor: "pointer", 22 | border: `1px solid ${theme.palette.getAccent100("light")}`, 23 | }; 24 | } 25 | 26 | export function userAvatarStyle() : CSSProperties { 27 | return { 28 | width: "32px", 29 | height: "32px", 30 | backgroundColor: "white", 31 | borderRadius: "24px" 32 | }; 33 | } 34 | 35 | export function defaultUserBtnsContainerStyle() : CSSProperties { 36 | return { 37 | display: "grid", 38 | gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))", 39 | gap: "8px" 40 | }; 41 | } 42 | 43 | export function loginSampleUsersContainerStyle() : CSSProperties { 44 | return { 45 | display: "flex", 46 | flexDirection: "column", 47 | rowGap: "4px" 48 | } 49 | } 50 | 51 | export function loginBtnStyle(theme : CometChatTheme) : CSSProperties { 52 | return { 53 | backgroundColor: theme.palette.getPrimary(), 54 | font: fontHelper(theme.typography.subtitle1), 55 | color: theme.palette.getAccent900("light"), 56 | borderRadius: "8px", 57 | padding: "8px", 58 | border: `1px solid ${theme.palette.getAccent100("light")}`, 59 | width: "100%", 60 | cursor: "pointer" 61 | }; 62 | } 63 | 64 | export function loginUidFormStyle() : CSSProperties { 65 | return { 66 | display: "flex", 67 | flexDirection: "column", 68 | rowGap: "8px" 69 | }; 70 | } 71 | 72 | export function goToSignupContainerStyle() : CSSProperties { 73 | return { 74 | paddingTop: "16px", 75 | display: "flex", 76 | flexDirection: "column", 77 | rowGap: "16px", 78 | alignItems: "center", 79 | paddingBottom: "32px", 80 | textAlign: "center" 81 | }; 82 | } 83 | 84 | export function goToSignupStyle(theme : CometChatTheme) : CSSProperties { 85 | return { 86 | font: fontHelper(theme.typography.title2), 87 | backgroundColor: "transparent", 88 | borderRadius: "4px", 89 | color: theme.palette.getAccent600("light"), 90 | textTransform: "capitalize", 91 | border: `1px solid ${theme.palette.getAccent100("light")}`, 92 | cursor: "pointer" 93 | }; 94 | } 95 | 96 | export function usingSampleUsersTextStyle(theme : CometChatTheme) : CSSProperties { 97 | return { 98 | font: fontHelper(theme.typography.subtitle2), 99 | color: theme.palette.getAccent600("light") 100 | }; 101 | } 102 | 103 | export function noAccountStyle(theme : CometChatTheme) : CSSProperties { 104 | return { 105 | font: fontHelper(theme.typography.subtitle1), 106 | color: theme.palette.getAccent600("light") 107 | }; 108 | } 109 | 110 | export function userNameStyle(theme : CometChatTheme) : CSSProperties { 111 | return { 112 | textTransform: "capitalize", 113 | font: fontHelper(theme.typography.name), 114 | color: theme.palette.getAccent("light"), 115 | textAlign: "left" 116 | }; 117 | } 118 | 119 | export function userUidStyle(theme : CometChatTheme) : CSSProperties { 120 | return { 121 | font: fontHelper(theme.typography.subtitle2), 122 | color: theme.palette.getAccent600("light") 123 | }; 124 | } 125 | 126 | export function userNameAndUidContainerStyle() : CSSProperties { 127 | return { 128 | display: "flex", 129 | flexDirection: "column", 130 | rowGap: "2px", 131 | alignItems: "flex-start" 132 | }; 133 | } 134 | 135 | export function errorMessageStyle(theme : CometChatTheme) : CSSProperties { 136 | return { 137 | font: fontHelper(theme.typography.subtitle2), 138 | color: theme.palette.getError() 139 | }; 140 | } 141 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | Please note we have a code of conduct, please follow it in all your interactions with the project. 7 | 8 | ## Pull Request Process 9 | 10 | 1. Ensure any install or build dependencies are removed before the end of the layer when doing a 11 | build. 12 | 2. Update the README.md with details of changes to the interface, this includes new environment 13 | variables, exposed ports, useful file locations and container parameters. 14 | 3. Increase the version numbers in any examples files and the README.md to the new version that this 15 | Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). 16 | 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you 17 | do not have permission to do that, you may request the second reviewer to merge it for you. 18 | 19 | ## Code of Conduct 20 | 21 | ### Our Pledge 22 | 23 | In the interest of fostering an open and welcoming environment, we as 24 | contributors and maintainers pledge to making participation in our project and 25 | our community a harassment-free experience for everyone, regardless of age, body 26 | size, disability, ethnicity, gender identity and expression, level of experience, 27 | nationality, personal appearance, race, religion, or sexual identity and 28 | orientation. 29 | 30 | ### Our Standards 31 | 32 | Examples of behavior that contributes to creating a positive environment 33 | include: 34 | 35 | * Using welcoming and inclusive language 36 | * Being respectful of differing viewpoints and experiences 37 | * Gracefully accepting constructive criticism 38 | * Focusing on what is best for the community 39 | * Showing empathy towards other community members 40 | 41 | Examples of unacceptable behavior by participants include: 42 | 43 | * The use of sexualized language or imagery and unwelcome sexual attention or 44 | advances 45 | * Trolling, insulting/derogatory comments, and personal or political attacks 46 | * Public or private harassment 47 | * Publishing others' private information, such as a physical or electronic 48 | address, without explicit permission 49 | * Other conduct which could reasonably be considered inappropriate in a 50 | professional setting 51 | 52 | ### Our Responsibilities 53 | 54 | Project maintainers are responsible for clarifying the standards of acceptable 55 | behavior and are expected to take appropriate and fair corrective action in 56 | response to any instances of unacceptable behavior. 57 | 58 | Project maintainers have the right and responsibility to remove, edit, or 59 | reject comments, commits, code, wiki edits, issues, and other contributions 60 | that are not aligned to this Code of Conduct, or to ban temporarily or 61 | permanently any contributor for other behaviors that they deem inappropriate, 62 | threatening, offensive, or harmful. 63 | 64 | ### Scope 65 | 66 | This Code of Conduct applies both within project spaces and in public spaces 67 | when an individual is representing the project or its community. Examples of 68 | representing a project or community include using an official project e-mail 69 | address, posting via an official social media account, or acting as an appointed 70 | representative at an online or offline event. Representation of a project may be 71 | further defined and clarified by project maintainers. 72 | 73 | ### Enforcement 74 | 75 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 76 | reported by contacting the project team at [INSERT EMAIL ADDRESS]. All 77 | complaints will be reviewed and investigated and will result in a response that 78 | is deemed necessary and appropriate to the circumstances. The project team is 79 | obligated to maintain confidentiality with regard to the reporter of an incident. 80 | Further details of specific enforcement policies may be posted separately. 81 | 82 | Project maintainers who do not follow or enforce the Code of Conduct in good 83 | faith may face temporary or permanent repercussions as determined by other 84 | members of the project's leadership. 85 | 86 | ### Attribution 87 | 88 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 89 | available at [http://contributor-covenant.org/version/1/4][version] 90 | 91 | [homepage]: http://contributor-covenant.org 92 | [version]: http://contributor-covenant.org/version/1/4/ 93 | -------------------------------------------------------------------------------- /src/components/CardList/Shared/Bubbles/Receipt/index.tsx: -------------------------------------------------------------------------------- 1 | import {CometChatThemeContext, Receipts} from "@cometchat/chat-uikit-react" 2 | import { componentDetailModalCloseIconStyle, componentDetailsModalCloseIconWrapperStyle, componentDetailsModalDescriptionStyle, componentDetailsModalHeaderStyle, componentDetailsModalTitleStyle, loadingComponentModalStyle } from "../../style"; 3 | 4 | import CloseIcon from "../assets/close2x.png"; 5 | import {componentDetailsModalStyle} from "./style" 6 | import { useContext } from "react"; 7 | 8 | export const Receipt = (props:any) => { 9 | const { 10 | activeComponent, 11 | handleCloseComponentModal, 12 | showComponentModal, 13 | } = props; 14 | let showModal = false; 15 | const bubbleSlug = "receipt" 16 | if(showComponentModal && activeComponent === bubbleSlug) 17 | showModal = true 18 | const receipt:typeof Receipts = Receipts 19 | const { theme } = useContext(CometChatThemeContext); 20 | const themeMode = theme.palette.mode 21 | const boxColor = themeMode === "dark" ? "#ccc" :"#464545" 22 | return ( 23 | 24 |
27 |
30 |
31 |
Message Receipt
32 |
closeIcon
33 |
34 |
35 | CometChatReceipt component renders the receipts such as sending, sent, delivered, read and error state indicator of a message.. 36 |
37 |
38 |
39 |
Progress Status
40 |
41 |
42 |
43 |
Sent Receipt
44 |
45 |
46 |
47 |
Delivered Receipt
48 |
49 |
50 |
51 |
52 |
53 |
Read Receipt
54 |
55 |
56 |
57 |
Error Status
58 |
59 |
60 |
61 |
62 |
) 63 | 64 | } -------------------------------------------------------------------------------- /src/components/MessageInformationWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | CometChatMessageBubble, 3 | CometChatMessageInformation, 4 | CometChatPalette, 5 | CometChatTheme, 6 | CometChatThemeContext, 7 | MessageBubbleAlignment, 8 | fontHelper, 9 | } from "@cometchat/chat-uikit-react"; 10 | import { useContext, useMemo } from "react"; 11 | 12 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 13 | import { useLocation } from "react-router-dom"; 14 | 15 | export function MessageInformationWrapper() { 16 | const { state } = useLocation(); 17 | const changeThemeToCustom = state?.changeThemeToCustom; 18 | const { theme } = useContext(CometChatThemeContext); 19 | 20 | const themeContext = useMemo(() => { 21 | let res = theme; 22 | if (changeThemeToCustom) { 23 | res = new CometChatTheme({ 24 | palette: new CometChatPalette({ 25 | mode: theme.palette.mode, 26 | primary: { 27 | light: "#D422C2", 28 | dark: "#D422C2", 29 | }, 30 | accent: { 31 | light: "#07E676", 32 | dark: "#B6F0D3", 33 | }, 34 | accent50: { 35 | light: "#39f", 36 | dark: "#141414", 37 | }, 38 | accent900: { 39 | light: "white", 40 | dark: "black", 41 | }, 42 | }), 43 | }); 44 | } 45 | return { theme: res }; 46 | }, [theme, changeThemeToCustom]); 47 | const getContentView = (message: CometChat.TextMessage) => { 48 | return ( 49 | 56 | ); 57 | }; 58 | const getBubbleView = (item: CometChat.BaseMessage) => { 59 | return ( 60 |
69 | 86 |
87 | ); 88 | }; 89 | const messageObject: any = { 90 | getReceiver: () => { 91 | return { 92 | getAvatar: () => 93 | "https://data-us.cometchat.io/assets/images/avatars/ironman.png", 94 | getBlockedByMe: () => false, 95 | getDeactivatedAt: () => 0, 96 | getHasBlockedMe: () => false, 97 | getLastActiveAt: () => 1693306209, 98 | getName: () => "Iron Man", 99 | getRole: () => "default", 100 | getStatus: () => "online", 101 | getUid: () => "superhero2", 102 | }; 103 | }, 104 | getSender: () => { 105 | return { 106 | getAvatar: () => 107 | "https://data-us.cometchat.io/assets/images/avatars/ironman.png", 108 | getBlockedByMe: () => false, 109 | getDeactivatedAt: () => 0, 110 | getHasBlockedMe: () => false, 111 | getLastActiveAt: () => 1693306209, 112 | getName: () => "Iron Man", 113 | getRole: () => "default", 114 | getStatus: () => "online", 115 | getUid: () => "superhero1", 116 | }; 117 | }, 118 | getConversationId: () => "conversationId1234", 119 | getText: () => "Hello, how are you.", 120 | getSentAt: () => 1693322055785, 121 | getReadAt: () => 1693322055785, 122 | getDeliveredAt: () => 1693322055765, 123 | getReceiverType: () => "user", 124 | getReceiverId: () => "superhero2", 125 | getId: () => 1234, 126 | getType: () => "text", 127 | getCategory: () => "message", 128 | }; 129 | return ( 130 | 131 | getBubbleView(message)} 134 | /> 135 | 136 | ); 137 | } 138 | -------------------------------------------------------------------------------- /src/components/Signup/index.tsx: -------------------------------------------------------------------------------- 1 | import { Navigate, useNavigate } from "react-router-dom"; 2 | import { checkboxTextStyle, errorMessageStyle, formStyle, generateUidCheckboxStyle, generateUidStyle, submitBtnStyle } from "./style"; 3 | import { useContext, useState } from "react"; 4 | 5 | import { AppConstants } from "../../AppConstants"; 6 | import { CometChat } from "@cometchat/chat-sdk-javascript"; 7 | import { CometChatThemeContext } from "@cometchat/chat-uikit-react"; 8 | import { LoginSignup } from "../LoginSignup"; 9 | import { TextInput } from "../TextInput"; 10 | 11 | interface ISignUp { 12 | loggedInUser : CometChat.User | null | undefined, 13 | setLoggedInUser : React.Dispatch>, 14 | setInterestingAsyncOpStarted : React.Dispatch> 15 | }; 16 | 17 | export function Signup({ loggedInUser, setLoggedInUser, setInterestingAsyncOpStarted } : ISignUp) { 18 | const [name, setName] = useState(""); 19 | const [uid, setUid] = useState(""); 20 | const [generateUid, setGenerateUid] = useState(false); 21 | const [errorMessage, setErrorMessage] = useState(""); 22 | const navigate = useNavigate(); 23 | const { theme } = useContext(CometChatThemeContext); 24 | 25 | async function handleSubmit(e : React.FormEvent) { 26 | e.preventDefault(); 27 | console.log("Form submitted"); 28 | let newUserUid = uid; 29 | if (generateUid) { 30 | newUserUid = `${name.replaceAll(" ", "")}_${Date.now()}`; 31 | } 32 | const newUser = new CometChat.User(newUserUid); 33 | newUser.setName(name); 34 | try { 35 | setInterestingAsyncOpStarted(true); 36 | const createdUser = await CometChat.createUser(newUser, AppConstants.AUTH_KEY); 37 | console.log("User created:", createdUser); 38 | console.log(`User having uid: ${createdUser.getUid()} created successfully.`); 39 | setLoggedInUser(createdUser); 40 | // Don't think resetting states makes a difference since I am navigating to a different page 41 | setName(""); 42 | setUid(""); 43 | setGenerateUid(false); 44 | navigate("/home"); 45 | } 46 | catch(error) { 47 | if (error instanceof CometChat.CometChatException && error.message) { 48 | setErrorMessage(error.message); 49 | } 50 | console.log(error); 51 | } 52 | finally { 53 | setInterestingAsyncOpStarted(false); 54 | } 55 | } 56 | 57 | if (loggedInUser === undefined) { 58 | return null; 59 | } 60 | 61 | if (loggedInUser) { 62 | return ; 63 | } 64 | 65 | return ( 66 | 69 |
73 | 79 | 86 |
89 | setGenerateUid(!generateUid)} 93 | style = {generateUidCheckboxStyle()} 94 | /> 95 | 98 | By clicking on this checkbox, UID will be generated automatically. 99 | 100 |
101 |
104 | {errorMessage} 105 |
106 | 112 | 113 |
114 | ); 115 | } 116 | -------------------------------------------------------------------------------- /src/components/CallLogRecordingsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CallLog, CallUser } from "@cometchat/calls-sdk-javascript"; 2 | import { 3 | CometChatCallLogRecordings, 4 | CometChatIncomingCall, 5 | CometChatPalette, 6 | CometChatTheme, 7 | CometChatThemeContext, 8 | CometChatUIKit, 9 | } from "@cometchat/chat-uikit-react"; 10 | import { useCallback, useContext, useEffect, useMemo, useState } from "react"; 11 | 12 | import { useLocation } from "react-router-dom"; 13 | 14 | export function CallLogRecordingsWrapper({ isMobileView }: { isMobileView: boolean }) { 15 | const { state } = useLocation(); 16 | const changeThemeToCustom = state?.changeThemeToCustom; 17 | const { theme } = useContext(CometChatThemeContext); 18 | const [loggedInUser, setLoggedInUser] = useState(null); 19 | const [call, setCall] = useState(null); 20 | 21 | const themeContext = useMemo(() => { 22 | let res = theme; 23 | if (changeThemeToCustom) { 24 | res = new CometChatTheme({ 25 | palette: new CometChatPalette({ 26 | mode: theme.palette.mode, 27 | primary: { 28 | light: "#D422C2", 29 | dark: "#D422C2", 30 | }, 31 | accent: { 32 | light: "#07E676", 33 | dark: "#B6F0D3", 34 | }, 35 | accent50: { 36 | light: "#39f", 37 | dark: "#141414", 38 | }, 39 | accent900: { 40 | light: "white", 41 | dark: "black", 42 | }, 43 | }), 44 | }); 45 | } 46 | return { theme: res }; 47 | }, [theme, changeThemeToCustom]); 48 | 49 | const getCall = useCallback(() => { 50 | const initiator = CallUser.getUserFromJson({ 51 | name: loggedInUser?.name, 52 | avatar: loggedInUser?.avatar, 53 | uid: loggedInUser?.uid, 54 | }); 55 | 56 | const receiver = CallUser.getUserFromJson({ 57 | name: "Kevin", 58 | avatar: 59 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 60 | uid: "UID233", 61 | }); 62 | 63 | const call = CallLog.callLogFromJson({ 64 | initiator, 65 | receiver, 66 | participants: [ 67 | { 68 | uid: loggedInUser?.uid, 69 | avatar: loggedInUser?.avatar, 70 | name: loggedInUser?.name, 71 | totalAudioMinutes: 120, 72 | totalDurationInMinutes: 120, 73 | totalVideoMinutes: 60, 74 | }, 75 | { 76 | uid: "UID233", 77 | avatar: 78 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 79 | name: "Kevin", 80 | totalAudioMinutes: 120, 81 | totalDurationInMinutes: 120, 82 | totalVideoMinutes: 60, 83 | }, 84 | ], 85 | recordings: [ 86 | { 87 | startTime: 101, 88 | rid: "Recordings", 89 | recording_url: 90 | "https://recordings-us.cometchat.io/236497dcc2cd529b/2023-12-15/v1.us.236497dcc2cd529b.170264141733632a2e3171d8a5dcb1f82b743fbc2730422263_2023-12-15-11-57-16.mp4", 91 | endTime: 101, 92 | duration: 100, 93 | }, 94 | ], 95 | totalDurationInMinutes: 0.6833333333333333, 96 | totalParticipants: 2, 97 | type: "audio", 98 | mid: "dcb170b0-99da-4beb-b65a8-86e48c89ef18", 99 | startedAt: 1697458341, 100 | endedAt: 1697458382, 101 | totalAudioMinutes: 0.6833333333333333, 102 | totalVideoMinutes: 0, 103 | totalDuration: "00:00:41", 104 | hasRecording: true, 105 | initiatedAt: 1697458328, 106 | }); 107 | console.log(call); 108 | 109 | return call; 110 | }, [loggedInUser?.avatar, loggedInUser?.name, loggedInUser?.uid]); 111 | 112 | useEffect(() => { 113 | CometChatUIKit.getLoggedinUser().then((user) => { 114 | setLoggedInUser(user!); 115 | setCall(getCall()); 116 | }); 117 | }, [getCall]); 118 | 119 | return ( 120 | 121 | { 122 | call && ( 123 | 126 | ) 127 | } 128 | 129 | 130 | ); 131 | } 132 | -------------------------------------------------------------------------------- /src/components/CallLogHistoryWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CallLog, CallUser } from "@cometchat/calls-sdk-javascript"; 2 | import { 3 | CometChatCallLogHistory, 4 | CometChatIncomingCall, 5 | CometChatPalette, 6 | CometChatTheme, 7 | CometChatThemeContext, 8 | CometChatUIKit, 9 | } from "@cometchat/chat-uikit-react"; 10 | import { useCallback, useContext, useEffect, useMemo, useState } from "react"; 11 | 12 | import { useLocation } from "react-router-dom"; 13 | 14 | export function CallLogHistoryWrapper({ isMobileView }: { isMobileView: boolean }) { 15 | const { state } = useLocation(); 16 | const changeThemeToCustom = state?.changeThemeToCustom; 17 | const { theme } = useContext(CometChatThemeContext); 18 | const [loggedInUser, setLoggedInUser] = useState(null); 19 | const [call, setCall] = useState(null); 20 | 21 | const themeContext = useMemo(() => { 22 | let res = theme; 23 | if (changeThemeToCustom) { 24 | res = new CometChatTheme({ 25 | palette: new CometChatPalette({ 26 | mode: theme.palette.mode, 27 | primary: { 28 | light: "#D422C2", 29 | dark: "#D422C2", 30 | }, 31 | accent: { 32 | light: "#07E676", 33 | dark: "#B6F0D3", 34 | }, 35 | accent50: { 36 | light: "#39f", 37 | dark: "#141414", 38 | }, 39 | accent900: { 40 | light: "white", 41 | dark: "black", 42 | }, 43 | }), 44 | }); 45 | } 46 | return { theme: res }; 47 | }, [theme, changeThemeToCustom]); 48 | 49 | const getCall = useCallback(() => { 50 | const initiator = CallUser.getUserFromJson({ 51 | name: loggedInUser?.name, 52 | avatar: loggedInUser?.avatar, 53 | uid: loggedInUser?.uid, 54 | }); 55 | 56 | const receiver = CallUser.getUserFromJson({ 57 | name: "Kevin", 58 | avatar: 59 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 60 | uid: "UID233", 61 | }); 62 | 63 | const call = CallLog.callLogFromJson({ 64 | initiator, 65 | receiver, 66 | participants: [ 67 | { 68 | uid: loggedInUser?.uid, 69 | avatar: loggedInUser?.avatar, 70 | name: loggedInUser?.name, 71 | totalAudioMinutes: 120, 72 | totalDurationInMinutes: 120, 73 | totalVideoMinutes: 60, 74 | }, 75 | { 76 | uid: "UID233", 77 | avatar: 78 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 79 | name: "Kevin", 80 | totalAudioMinutes: 120, 81 | totalDurationInMinutes: 120, 82 | totalVideoMinutes: 60, 83 | }, 84 | ], 85 | recordings: [ 86 | { 87 | startTime: 101, 88 | rid: "Recordings", 89 | recording_url: 90 | "https://recordings-us.cometchat.io/236497dcc2cd529b/2023-12-15/v1.us.236497dcc2cd529b.170264141733632a2e3171d8a5dcb1f82b743fbc2730422263_2023-12-15-11-57-16.mp4", 91 | endTime: 101, 92 | duration: 100, 93 | }, 94 | ], 95 | totalDurationInMinutes: 0.6833333333333333, 96 | totalParticipants: 2, 97 | type: "audio", 98 | mid: "dcb170b0-99da-4beb-b65a8-86e48c89ef18", 99 | startedAt: 1697458341, 100 | endedAt: 1697458382, 101 | totalAudioMinutes: 0.6833333333333333, 102 | totalVideoMinutes: 0, 103 | totalDuration: "00:00:41", 104 | hasRecording: true, 105 | initiatedAt: 1697458328, 106 | }); 107 | console.log(call); 108 | 109 | return call; 110 | }, [loggedInUser?.avatar, loggedInUser?.name, loggedInUser?.uid]); 111 | 112 | useEffect(() => { 113 | CometChatUIKit.getLoggedinUser().then((user) => { 114 | setLoggedInUser(user!); 115 | setCall(getCall()); 116 | }); 117 | }, [getCall]); 118 | 119 | return ( 120 | 121 | { 122 | call && ( 123 | 126 | ) 127 | } 128 | 129 | 130 | ); 131 | } 132 | -------------------------------------------------------------------------------- /src/components/CallLogDetailsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CallLog, CallUser } from "@cometchat/calls-sdk-javascript"; 2 | import { 3 | CometChatCallLogDetails, 4 | CometChatIncomingCall, 5 | CometChatPalette, 6 | CometChatTheme, 7 | CometChatThemeContext, 8 | CometChatUIKit, 9 | } from "@cometchat/chat-uikit-react"; 10 | import { useCallback, useContext, useEffect, useMemo, useState } from "react"; 11 | 12 | import { useLocation } from "react-router-dom"; 13 | 14 | export function CallLogDetailsWrapper({ isMobileView }: { isMobileView: boolean }) { 15 | const { state } = useLocation(); 16 | const changeThemeToCustom = state?.changeThemeToCustom; 17 | const { theme } = useContext(CometChatThemeContext); 18 | const [loggedInUser, setLoggedInUser] = useState(null); 19 | const [call, setCall] = useState(null); 20 | 21 | const themeContext = useMemo(() => { 22 | let res = theme; 23 | if (changeThemeToCustom) { 24 | res = new CometChatTheme({ 25 | palette: new CometChatPalette({ 26 | mode: theme.palette.mode, 27 | primary: { 28 | light: "#D422C2", 29 | dark: "#D422C2", 30 | }, 31 | accent: { 32 | light: "#07E676", 33 | dark: "#B6F0D3", 34 | }, 35 | accent50: { 36 | light: "#39f", 37 | dark: "#141414", 38 | }, 39 | accent900: { 40 | light: "white", 41 | dark: "black", 42 | }, 43 | }), 44 | }); 45 | } 46 | return { theme: res }; 47 | }, [theme, changeThemeToCustom]); 48 | 49 | const getCall = useCallback(() => { 50 | const initiator = CallUser.getUserFromJson({ 51 | name: loggedInUser?.name, 52 | avatar: loggedInUser?.avatar, 53 | uid: loggedInUser?.uid, 54 | }); 55 | 56 | const receiver = CallUser.getUserFromJson({ 57 | name: "Kevin", 58 | avatar: 59 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 60 | uid: "UID233", 61 | }); 62 | 63 | const call = CallLog.callLogFromJson({ 64 | initiator, 65 | receiver, 66 | participants: [ 67 | { 68 | uid: loggedInUser?.uid, 69 | avatar: loggedInUser?.avatar, 70 | name: loggedInUser?.name, 71 | totalAudioMinutes: 120, 72 | totalDurationInMinutes: 120, 73 | totalVideoMinutes: 60, 74 | }, 75 | { 76 | uid: "UID233", 77 | avatar: 78 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 79 | name: "Kevin", 80 | totalAudioMinutes: 120, 81 | totalDurationInMinutes: 120, 82 | totalVideoMinutes: 60, 83 | }, 84 | ], 85 | recordings: [ 86 | { 87 | startTime: 101, 88 | rid: "Recordings", 89 | recording_url: 90 | "https://recordings-us.cometchat.io/236497dcc2cd529b/2023-12-15/v1.us.236497dcc2cd529b.170264141733632a2e3171d8a5dcb1f82b743fbc2730422263_2023-12-15-11-57-16.mp4", 91 | endTime: 101, 92 | duration: 100, 93 | }, 94 | ], 95 | totalDurationInMinutes: 0.6833333333333333, 96 | totalParticipants: 2, 97 | type: "audio", 98 | mid: "dcb170b0-99da-4beb-b65a8-86e48c89ef18", 99 | startedAt: 1697458341, 100 | endedAt: 1697458382, 101 | totalAudioMinutes: 0.6833333333333333, 102 | totalVideoMinutes: 0, 103 | totalDuration: "00:00:41", 104 | hasRecording: true, 105 | initiatedAt: 1697458328, 106 | }); 107 | console.log(call); 108 | 109 | return call; 110 | }, [loggedInUser?.avatar, loggedInUser?.name, loggedInUser?.uid]); 111 | 112 | useEffect(() => { 113 | CometChatUIKit.getLoggedinUser().then((user) => { 114 | setLoggedInUser(user!); 115 | setCall(getCall()); 116 | }); 117 | }, [getCall]); 118 | 119 | return ( 120 | 121 | { 122 | call && ( 123 | 126 | ) 127 | } 128 | 129 | 130 | ); 131 | } 132 | -------------------------------------------------------------------------------- /src/components/CallLogParticipantsWrapper/index.tsx: -------------------------------------------------------------------------------- 1 | import { CallLog, CallUser } from "@cometchat/calls-sdk-javascript"; 2 | import { 3 | CometChatCallLogParticipants, 4 | CometChatIncomingCall, 5 | CometChatPalette, 6 | CometChatTheme, 7 | CometChatThemeContext, 8 | CometChatUIKit, 9 | } from "@cometchat/chat-uikit-react"; 10 | import { useCallback, useContext, useEffect, useMemo, useState } from "react"; 11 | 12 | import { useLocation } from "react-router-dom"; 13 | 14 | export function CallLogParticipantsWrapper({ isMobileView }: { isMobileView: boolean }) { 15 | const { state } = useLocation(); 16 | const changeThemeToCustom = state?.changeThemeToCustom; 17 | const { theme } = useContext(CometChatThemeContext); 18 | const [loggedInUser, setLoggedInUser] = useState(null); 19 | const [call, setCall] = useState(null); 20 | 21 | const themeContext = useMemo(() => { 22 | let res = theme; 23 | if (changeThemeToCustom) { 24 | res = new CometChatTheme({ 25 | palette: new CometChatPalette({ 26 | mode: theme.palette.mode, 27 | primary: { 28 | light: "#D422C2", 29 | dark: "#D422C2", 30 | }, 31 | accent: { 32 | light: "#07E676", 33 | dark: "#B6F0D3", 34 | }, 35 | accent50: { 36 | light: "#39f", 37 | dark: "#141414", 38 | }, 39 | accent900: { 40 | light: "white", 41 | dark: "black", 42 | }, 43 | }), 44 | }); 45 | } 46 | return { theme: res }; 47 | }, [theme, changeThemeToCustom]); 48 | 49 | const getCall = useCallback(() => { 50 | const initiator = CallUser.getUserFromJson({ 51 | name: loggedInUser?.name, 52 | avatar: loggedInUser?.avatar, 53 | uid: loggedInUser?.uid, 54 | }); 55 | 56 | const receiver = CallUser.getUserFromJson({ 57 | name: "Kevin", 58 | avatar: 59 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 60 | uid: "UID233", 61 | }); 62 | 63 | const call = CallLog.callLogFromJson({ 64 | initiator, 65 | receiver, 66 | participants: [ 67 | { 68 | uid: loggedInUser?.uid, 69 | avatar: loggedInUser?.avatar, 70 | name: loggedInUser?.name, 71 | totalAudioMinutes: 120, 72 | totalDurationInMinutes: 120, 73 | totalVideoMinutes: 60, 74 | }, 75 | { 76 | uid: "UID233", 77 | avatar: 78 | "https://data-us.cometchat.io/assets/images/avatars/spiderman.png", 79 | name: "Kevin", 80 | totalAudioMinutes: 120, 81 | totalDurationInMinutes: 120, 82 | totalVideoMinutes: 60, 83 | }, 84 | ], 85 | recordings: [ 86 | { 87 | startTime: 101, 88 | rid: "Recordings", 89 | recording_url: 90 | "https://recordings-us.cometchat.io/236497dcc2cd529b/2023-12-15/v1.us.236497dcc2cd529b.170264141733632a2e3171d8a5dcb1f82b743fbc2730422263_2023-12-15-11-57-16.mp4", 91 | endTime: 101, 92 | duration: 100, 93 | }, 94 | ], 95 | totalDurationInMinutes: 0.6833333333333333, 96 | totalParticipants: 2, 97 | type: "audio", 98 | mid: "dcb170b0-99da-4beb-b65a8-86e48c89ef18", 99 | startedAt: 1697458341, 100 | endedAt: 1697458382, 101 | totalAudioMinutes: 0.6833333333333333, 102 | totalVideoMinutes: 0, 103 | totalDuration: "00:00:41", 104 | hasRecording: true, 105 | initiatedAt: 1697458328, 106 | }); 107 | console.log(call); 108 | 109 | return call; 110 | }, [loggedInUser?.avatar, loggedInUser?.name, loggedInUser?.uid]); 111 | 112 | useEffect(() => { 113 | CometChatUIKit.getLoggedinUser().then((user) => { 114 | setLoggedInUser(user!); 115 | setCall(getCall()); 116 | }); 117 | }, [getCall]); 118 | 119 | return ( 120 | 121 | { 122 | call && ( 123 | 126 | ) 127 | } 128 | 129 | 130 | ); 131 | } 132 | --------------------------------------------------------------------------------