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

wc-bubble

v0.1.5

Published

A lightweight and well designed chat bubble WebComponent.

Downloads

819

Readme

wc-bubble

published coverage npm npm jsDelivr GitHub issues license

NPM

A custom web component for a speech bubble.

Demo image

Installation

You can install wc-bubble with npm, or just get started quickly with CDN.

Install from npm

To install from npm, open terminal in your project folder and run:

npm install wc-bubble

After the package is installed, then you can import the bubble web component into you code:

import 'wc-bubble';

window.onload = function() {
  let bubbleElement = document.createElement('chat-bubble');
  bubbleElement.textContent = 'Hello World';
  document.body.appendChild(bubbleElement);
}

Install from CDN

There is jsDelivr CDN available for quickly integrated with your web page.

<!-- Latest version -->
<script src="https://cdn.jsdelivr.net/npm/wc-bubble"></script>

<!-- Specific version -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>

Basic Usages:

<html>
  <head>

    <!-- Load Bubble WebComponent library -->
    <script src="https://cdn.jsdelivr.net/npm/wc-bubble"></script>
    <!-- End Load -->

  </head>

  <body>

    <!-- Using "chat-bubble" html tag to generate Bubble -->
    <chat-bubble>
      <p>Hello World</p>
    </chat-bubble>

  </body>
</html>

Demo page

Live Demo

Attributes

right

If this attribute is set, the chat bubble will be aligned to the right.

avatar

String type. The URL or base64 encoded image of the user's profile picture.

continued

If this attribute is set, the chat bubble will hide the avatar and tail, making it appear as a "continued" chat message bubble.

loading

If this attribute is set, the chat bubble will display a CSS loading animation instead of the chat message content.

delay

Number type. The chat bubble display animation will be delayed by the delay value multiplied by the CSS variable --chat-bubble-delay time interval.

Element Properties

| Property | Type | Description | | --------- | ------- | ----------- | | right | Boolean | Indicates whether the chat bubble is aligned to the right side of the chat window.. | | continued | Boolean | Indicates whether the chat bubble is a continuation of a previous message. | | loading | Boolean | When this property is set to a truthy value, the component displays a loading animation in place of the bubble content. |

You can update the bubble component by setting its properties.

For example:

const chatBubble = document.getElementsByTagName("chat-bubble")[0];

if (chatBubble !== undefined) {
  chatBubble.innerHTML = `<p>hello world</p>`
  chatBubble.right = false;
  chatBubble.continued = true;
}

Event

mounted event

When the bubble is rendered and the display animation is finished, a mounted event will be dispatched.

Customized styles

By specifying CSS variables, you can customize the chat bubble styles, including the background color, font color, and animation delays.

For example:

<style>
  chat-bubble {
    --chat-bubble-color: #F5F5F5;
    --chat-bubble-right-color: blue;
    --chat-bubble-font-color: #333;
    --chat-bubble-font-right-color: white;
    --chat-bubble-avatar-color: yellow;
    --chat-bubble-delay: 0.2s;
  }
</style>

In this example, the --chat-bubble-color variable is set to #F5F5F5, which is a light gray color that will be used as the background color for the chat bubble.The --chat-bubble-font-color variable is set to #333, which is a dark gray color that will be used as the font color (text color) for the chat bubble.

The --chat-bubble-right-color variable is set to blue, which will be used as the background color for chat bubbles that are aligned to the right. The --chat-bubble-font-right-color variable is set to white, which will be used as the font color for chat bubbles that are aligned to the right.

The --chat-bubble-avatar-color variable is set to yellow, which means that the chat bubble avatar will be displayed in yellow color. You can customize this variable by adjusting its value to match your design preferences.

Finally, the --chat-bubble-delay variable is set to 0.2s, which means that the chat bubble display animation will be delayed by 0.2 seconds. You can customize these variables by adjusting their values to match your design preferences.