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

@beyonk/svelte-intercom

v1.1.3

Published

<p align="center"> <img width="186" height="90" src="https://user-images.githubusercontent.com/218949/44782765-377e7c80-ab80-11e8-9dd8-fce0e37c235b.png" alt="Beyonk" /> </p>

Downloads

41

Readme

Svelte Intercom

js-standard-style svelte-v3

Pure vanilla JS Intercom integration

Install

$ npm install --save-dev @beyonk/svelte-intercom

Usage (With Svelte)

Place the IntercomLauncher at the top level of your application (_layout.svelte for Sapper)

<IntercomLauncher appId='abcde12345' />

<script>
  import { IntercomLauncher, intercom } from '@beyonk/svelte-intercom'
</script>

Other configuration attributes

There are a number of configuration attributes you can pass, all but appId are optional.

List of possible options in the module:

| Option | Default | Required | Description | |-------------------|--------------|----------|---------------------------------------------------------------------------------------------------------------------------------------| | appId | - | true | Your Intercom app id |

Events

The Component emits all events emitted by the intercom module:

<IntercomLauncher appId='abcde12345' on:unread-count-change={logUnreadCount} />

<script>
  import { IntercomLauncher } from '@beyonk/svelte-intercom'

  function logUnreadCount (unreadCount) {
    console.log('Unread count', unreadCount)
  }
</script>

List of possible events in the module:

| Event | Description | |----------------------|-----------------------------------------------------------------------------------------------------------------------------------------| | unread-count-change | onUnreadCountChange | | show | onShow | | hide | onHide | | ready | Dispatched when the intercom component has finished initialising |

Methods

The Component has all methods listed in the intercom documentation.

These methods are exposed by the intercom module. This module can be imported anywhere in your project to call methods on the Messenger.

<IntercomLauncher appId='abcde12345' />

<script>
  import { IntercomLauncher, intercom } from '@beyonk/svelte-intercom'

  intercom.startTour()
</script>

The component implements a couple of extra convenience methods:

List of possible events in the module:

| Event | Description | | |----------------------|-------------------| | showLauncher() | show the launcher | | hideLauncher() | hide the launcher |

The underlying instance

You can access the underlying intercom instance for anything else you require:

<IntercomLauncher appId='abcde12345' bind:this={intercom} />

<script>
  import { IntercomLauncher } from '@beyonk/svelte-intercom'

  const rawIntercom = intercom.getIntercom()
</script>

Troubleshooting

Q. How do I hide the launcher for specific pages?

Because of the strange way intercom's launcher hiding works, you need to add the following to your route to hide it for that specific page.

import { onMount, onDestroy } from 'svelte'

onMount(async () => {
  intercom.overrideBootSettings({ hide_default_launcher: true })
  intercom.hideLauncher()
})

onDestroy(intercom.showLauncher)

This will:

  • add a boot setting for intercom to hide the launcher by default, if the page is the first page the user visits in your application.
  • hide the launcher immediately for the page
  • set a hook so that if the user navigates away from the page, the launcher shows again.

Developing

In order to run the local demo you must pass a valid intercom app id otherwise it won't work:

APP_ID=<your-app-id> npm run dev

License

MIT License