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

q-chat

v1.0.1

Published

a simple chat widget

Downloads

1

Readme

q-chat Widget

The q-chat widget is a simple, customizable chat UI that you can easily integrate into any web project. It provides a chat button that users can click to open a chat window. The widget allows users to send messages, and it's designed to be integrated with a server or other backends to manage chat sessions.

Features

  • Toggleable chat window
  • Customizable look via CSS
  • Easy-to-hook event system for custom backend integrations
  • Lightweight, with no external dependencies
  • SVG-based icons for scalability and customization
  • Includes 'Send' button in addition to 'Enter' key for message sending

Installation

To install the q-chat widget, you can include the JavaScript and CSS files in your HTML:

<script src="/path/to/q-chat.js"></script>
<link rel="stylesheet" href="/path/to/q-chat.css" id="q-chat-css">

Make sure to replace /path/to/ with the actual path to the widget files.

Usage

Once you've included the widget files, the chat UI should be automatically activated on your webpage.

JavaScript Events

The q-chat widget emits the following custom events:

  • qChatBefore: Fired before a message is sent. Can be canceled/edited.
  • qChatAfter: Fired after a message is sent.

Example to hook into the qChatBefore event:

document.addEventListener('qChatBefore', function(event) {
  console.log("Before message send:", event.detail.content);
});

You can also send a message to the chat UI using the qChatReceive event like this:

document.dispatchEvent(new CustomEvent("qChatReceive", {
  detail: { content: "Hello from server" }
}));

Customization

The chat widget is styled using CSS, and you can override these styles to better fit the widget into your application. The following are the main CSS IDs used within the widget:

If a css sheet is already loaded, with id "q-chat-css", then the default styles will not be applied.

Main Components

  • #chat-button: The floating chat button.
  • #chat-window: The main chat window.
  • #messages-div: The container for all chat messages.
  • #input-wrapper: The wrapper for the input field and the send button.

Input and Buttons

  • #input-field: The text area where users can type messages.
  • #send-button: The button to send messages.

API

The widget exposes a global object qChat with methods for programmatic interaction:

  • qChat.sendMessage(content): Send a message as the user.
  • qChat.receiveMessage(content): Receive a message as the server/assistant.
  • qChat.getMessages(): Retrieve the list of all messages in the format [{"role": "assistant", "content": "message"}, {"role": "user", "content": "message"}].
  • qChat.setMessages(messages): Set all messages from a loaded context or history.

Contributing

Feel free to fork this project, open issues, or submit PRs. For major changes, please open an issue first.

License

MIT License