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

floating-chat

v1.0.4

Published

A framework-agnostic floating chat window web component written in Svelte

Downloads

69

Readme

Floating Chat web component

Floating Chat on desktop

Floating Chat on mobile

Demo

A framework-agnostic floating chat window web component written in Svelte

The primary purpose is embedding engageable content, in particular: helpdesks, chatbots or anything else that requires a floating box

Features:

  • Framework-agnostic integration (esmodule & umd)
  • Responsive UI with animations
  • Accessibility features
  • Customisation options
  • Custom javascript events

Installation

Browser

Add the following script to your <head>

<script defer src="https://unpkg.com/floating-chat@latest/dist/index.js"></script>

Using NPM

Install the floating-chat package

npm i floating-chat

Then import into your application with

import floatingChat from 'floating-chat'

Add the tag to your template

<floating-chat content="https://example.com" />

You can see the demo example in index.html

Customisation

Content area

Content area

HTML properties

Available attributes:

  • content, content address (to be displayed in <iframe>)
  • height, floating window height, default 600px, always 100% on mobile
  • width, floating window width, default 400px, always 100% on mobile
  • textOpen, text when the window is closed, default Open, hidden on mobile
  • textClose, text when the window is opened, default Close, hidden on mobile
  • textColor, the colour of text, default #000000 (black)
  • background, background color, can be either a color code or a css background property, default #FFFFFF (white)
  • logo, logo url, css background property, eg url(https://storage.googleapis.com/cloudprod-apiai/a0b2e356-b43e-4ca5-a094-b219475fa4ca_x.png)
  • position, y, x position on screen, default bottom right, possible options bottom, top, left, right
  • font, font name
  • borderRadius, corner radius, default 28px, 0px on mobile when opened
  • opened, boolean, whether floating window should start opened, default false

Styling with CSS variables

Available variables:

  • --height, floating window height, default 600px, always 100% on mobile
  • --width, floating window width, default 400px, always 100% on mobile
  • --textcolor, the colour of text, default #000000 (black)
  • --background, background color, can be either a color code or a css background property, default #FFFFFF (white)
  • --logo, logo url, css background property, eg url(https://storage.googleapis.com/cloudprod-apiai/a0b2e356-b43e-4ca5-a094-b219475fa4ca_x.png)
  • --positiony, y position on screen, default bottom
  • --positionx, x position on screen, default right
  • --font, font name
  • --borderradius, corner radius, default 28px, 0px on mobile when opened

Available CSS classes (modifiers):

  • floating-chat-open, when floating chat is open
  • floating-chat-closed, when floating chat is closed

Styling with JS

You can change the above HTML attributes in JS, example:

document.querySelector('floating-chat').width = '300px'
document.querySelector('floating-chat').opened = true

Events

Following events are emmited:

  • open, when the floating window state went from closed to open
  • close, when the floating window state went from open to closed
  • toggle, when the floating window state was changed

Example in Vue:

<template>
  <floating-chat @open="open" />
</template>

<script>
export default {
  methods: {
    open () {
      alert('Opened!')
    }
  }
}
</script>

Development

  1. Clone the repository

    git clone https://github.com/mishushakov/floating-chat.git
  2. Install the dependencies

    npm i
  3. Build

    npm run build

Acknowledgements