npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

softchatjs-react

v3.2.30

Published

Install the softchat-js SDKs

Downloads

296

Readme

Integrating the React SDK

Install the softchat-js SDKs

yarn add softchatjs-react softchatjs-core
Or
npm install softchatjs-react softchatjs-core

Initialize the client. Create a free account at: https://www.softchatjs.com

import ChatClient from "softchatjs-core";

const client = ChatClient.getInstance({
  projectId: "your-project-id",
  subId: "your-sub-id",
});

Wrap your application with ChatClientProvider and pass the client instance.

import { ChatClientProvider } from "softchatjs-react"


export default function App(){
  return (
    <ChatClientProvider
      client={client}
    >
      <div>
        <p>My app</p>
      </div> 
    </ChatClientProvider>
  );
}

To use the chat interface component in your application, import it into any page where you want the chat feature to appear. The Chat component renders the main chat UI and accepts props that provide data about the active user and potential conversation participants.

Props

user -> An object that represents the currently active user's details, typically including properties like uid, username, profileUrl e.t.c.

userList -> An array of user objects, each representing a user that can be added to a conversation. Each user object might include uid, username and profileUrl to help identify participants in the UI.

import { Chat } from "softchatjs-react"
import { users } from '../contants/users 

export default function ChatPage() {
  return (
    <div style={{ height: "100vh", width: "100vw" }}>
      <Chat
        user={{
          uid: "30",
          username: "makaveli96",
          profileUrl:
            "profile-pic.png",
        }}
        userList={users}
      />  
    </div>
  );
}

Theming

The Softchat-js SDK offers a flexible way to customize the chat interface by allowing you to pass configuration properties (props) to personalize the UI.

Customizing the chat themes can be done by passing custom theme to the ChatClientProvider.


const sampleTheme = {
  background: {
    primary: "#FFFFFF", // White background for light mode
    secondary: "#F0F0F0", // Light grey for secondary background
    disabled: "#E0E0E0", // Lighter grey for disabled background
  },
  text: {
    primary: "#000000", // Black text for high contrast
    secondary: "#555555", // Dark grey for secondary text
    disabled: "#B0B0B0", // Light grey for disabled text
  },
  action: {
    primary: "#4F9ED0", // Dark teal for primary action buttons (accent color)
    secondary: "#B3D8F0", // Light teal for secondary action buttons
  },
  chatBubble: {
    left: {
      bgColor: "#F0F0F0", // Light grey for incoming message background
      messageColor: "#333333", // Dark grey for incoming message text
      messageTimeColor: "#777777", // Medium grey for message time
      replyBorderColor: "#D0D0D0", // Light border color for replies
    },
    right: {
      bgColor: "#B3D8F0", // Light teal for outgoing message background
      messageColor: "#000000", // Black for outgoing message text
      messageTimeColor: "#777777", // Medium grey for message time
      replyBorderColor: "#4F9ED0", // Accent color for reply border
    },
  },
  icon: "#555555", // Dark grey for icons
  divider: "#E0E0E0", // Light grey for dividers
  hideDivider: false,
  input: {
    bgColor: "#FFFFFF", // White background for input
    textColor: "#000000", // Black text for input
    emojiPickerTheme: "light", // Light theme for emoji picker
  },
};


export default function App(){
  return (
    <ChatClientProvider
      client={client}
      theme={theme}
    >
      <div>
        <p>My app</p>
      </div> 
    </ChatClientProvider>
  );
}

Custom components

Also, custom components can be used by passing them to the Chat component imported above. Full list of props below :

Prop | Usage|
--- | --- | user | The user object represents the active user's details. E.g UID, username, profileUrl | renderChatBubble | Allows rendering custom chat bubble component. | renderChatInput | Allows rendering custom chat input. | renderConversationList | Allows rendering custom conversation list. | renderNavbar | Allows rendering custom side navigation bar. |

Sample

renderChatBubble -> This can be used to customize how individual chat messages look by passing a custom component.

import { Chat } from "softchatjs-react"

export default function ChatPage() {
  return (
    <div style={{ height: "100vh", width: "100vw" }}>
      <Chat
        user={{
          uid: "30",
          username: "makaveli96",
          profileUrl:
            "profile-pic.png",
        }}
       
        renderChatBubble={(message) => (
          <div style={{ padding: "40px",  }}>
            {message.message}
          </div>
        )}
      /> 
    </div>
  );
}

The renderChatBubble takes the message argument that can be used in the custom chat bubble component. With access to the message object, message details like time, text, attachments e.t.c can be displayed based on your UI.