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 |
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 |
33 |
34 |
35 | CometChatImageBubble displays a media message containing an image.
36 |
44 | CometChatLocalize allows you to detect the language of your users based on their browser or device settings and set the language accordingly.
45 |
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 |
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 |
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 |
33 |
34 |
35 | CometChatReceipt component renders the receipts such as sending, sent, delivered, read and error state indicator of a message..
36 |