Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yomo/group-hug-react

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yomo/group-hug-react

Live collaborator avatars for multiplayer web apps

  • 1.0.15
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

GroupHug

Live collaborator avatars for multiplayer web apps

Online Demo

🥷🏼 Usage

Install with npm:

$ npm i --save @yomo/group-hug-react

Create a Presence instance

import Presence from "@yomo/presence";

// create an instance.
const presence = new Presence("https://lo.yomo.dev:8443/v1", {
  publicKey: "DEV_TOKEN",
  id,
  debug: true,
});

Add <GroupHug /> to pages:

const App = () => {
  const [darkMode, setDarkMode] = useState(true);
  return (
    <div>
      <GroupHug
        presence={presence}
        id={peerId}
        name={peerDisplayName}
        darkMode={darkMode}
      />
    </div>
  );
};

🧪 Props

According to the demo code above, we can see an avatar with the default style.

Furthermore, we offer the option to utilize custom styles should you desire

If the avatar image is not specified, avvvatars will be utilized as the placeholder.

Similarly, if you do not specify the color of avatarBorderColor, a random color will be assigned automatically.

Grouphug provides many style-related properties, you can customize the avatar with your own style by setting these properties.

Grouphug offers a plethora of style-related properties, enabling you to personalize the avatar according to your own preferences by configuring these properties.

Below are the comprehensive customization options:

<GroupHug
  presence={presence}
  channel={channel}
  id={id}
  name={"Noah"}
  placeholder={shape}
  size={24}
  darkMode={true}
  avatar={"https://avatars.githubusercontent.com/u/33050549?v=4"}
  avatarTextColor={"white"}
  avatarBorderWidth={3}
  avatarBorderColor={"blue"}
  avatarBackgroundColor={"red"}
  overlapping={true}
  transparency={0.5}
  maximum={6}
  MPOP={true}
  onMouseEnter={() => console.log(`mouse enter`)}
  onMouseLeave={() => console.log(`mouse leave`)}
/>;

Here are the full props:

nametypedescription
presencePromiseThe Presence instance
channelstringThe channel name of the Presence instance
idstringThe unique identifier of the user
namestringThe name or display name of the user
avatarstringThe avatar image url of the user
placeholder'shape', 'character'The placeholder image when avatar absence
MPOPbooleanA boolean value indicating whether the MPOP (Multiple Points of Presence) feature is enabled for the user
darkModebooleanA boolean value indicating whether the dark mode is enabled for the user
avatarTextColorstringThe color of the text displayed on the user's avatar
avatarBackgroundColorstringThe background color of the user's avatar
avatarBorderColorstringThe border color of the user's avatar
avatarBorderWidthnumberThe width of the border around the user's avatar
sizenumberThe size of the avatar in pixels
overlappingbooleanA boolean value indicating whether the avatars should overlap when multiple users are present
transparencynumberThe transparency level of the avatars, ranging from 0 (fully transparent) to 1 (fully opaque)
maximumnumberThe maximum number of avatars stacking
onMouseEnter(user: User) => voidA callback function triggered when the mouse pointer enters the user's avatar
onMouseLeave(user: User) => voidA callback function triggered when the mouse pointer leaves the user's avatar

👩‍🔬 Local Development

  1. Start local prscd dev server: bun run prscd:dev
  2. Start Grouphug code generator tool: bun run dev
image

🌎 Self-hosting

see Self-Hosting Doc

🧘🏻 License

The MIT License.

Keywords

FAQs

Package last updated on 29 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc