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

sitch-embed

v1.0.40

Published

For embedding Sitches made on mysitch.app into websites.

Downloads

313

Readme

What is it?

This package lets you use embedded Sitches on your website. Sitches are functionality focused web pages that you can build on https://mysitch.app. You can learn more about what they're for at https://sitch.cards.

Demo

The blog, store, and contact form on https://sitch.cards are all embedded Sitches.

Installation

yarn add sitch-embed

or

npm add sitch-embed

or if you're not using a package manager

<script src="https://storage.googleapis.com/sitch-public/sitch-embed.js"></script>

Usage

So first you need to specify which buttons load a Sitch. You do this by adding the "sitch-activation-button" class to each relevant button. Then for each button you need to specify which Sitch it loads. You do this by adding the following data attribute.

data-sitch-link

Every Sitch has a unique link. You can get this link by selecting the Sitch on https://mysitch.app and pressing "Copy Link", or by editing the Sitch and viewing it at the top of the edit page. As an example, for Sitch link https://sitch.app/s/i4lVvZB, you would add data-sitch-link="https://sitch.app/s/i4lVvZB" to a button.

There's two more attributes you can use to customize things:

data-sitch-max-width

Use this to determine how far in the embedded Sitch will slide in from the right when activated. The value is in pixels. An example would be data-sitch-max-width="500" to make the Sitch slide in from the right and stop at 500px in.

data-sitch-hash

To make the Sitches behave like proper webpages on your site you can add this data attribute to give them a hash addresses. For example, a Sitch button on https://sitch.cards has data-sitch-hash="store" on it, so if you visit https://sitch.cards/#store the store opens right away . Make sure any hash addresses you use are unique and aren't used as HTML "id" values on any elements on your page.

Finally to activate the buttons you would import the library:

import initializeSitchButtons from 'sitch-embed';

And call the imported function.

initializeSitchButtons();

If you're not using a package manager you would just call initializeSitchButtons(); once the script has loaded.

Options

initializeSitchButtons takes single argument for an options object.

baseZIndex (default: 999999)

You can provide a z-index for the embedded Sitches. So to make the Sitches use z-index 1000 you would write initializeSitchButtons({baseZIndex: 1000}).

backgroundColor (default: '')

A background color to show before the Sitch's theme is initialized and rendered. This is really only relevant if a Sitch is being shown on page load using data-sitch-hash or if the user opens a Sitch very very quickly after page load. You would want this color to match your theme background to make the color shift less jarring. Example: initializeSitchButtons({backgroundColor: '#000'}).

onSitchActivationCallback (default: () => undefined)

The function provided here will execute when a Sitch acivation button is clicked. An object of following structure is passed as an argument: { hash: string; url: string }.

Example:

onSitchActivationCallback: ({ hash, url }) => {
    if (hash === '#store' || url === 'sitch.app/store') {
        console.log('Someone viewed the store.')
    }
},

onAddToCartCallback (default: () => undefined)

The function provided here will execute when an item is added to the cart of a Shop Sitch. An object of following structure is passed as an argument: { amount: string; currency: string }. The amount is always an integer. For example, in USD an amount of 1 is 1 cent, and 100 is a dollar.

Example:

onAddToCartCallback: ({ amount, currency }) => {
    console.log(`Reporting add to cart of amount ${amount} in ${currency}.`)
},

onPaymentCallback (default: () => undefined)

The function provided here will execute when a payment is made either to a Shop Sitch or a Business Payment Sitch. An object of following structure is passed as an argument: { amount: string; currency: string }. The amount is always an integer. For example, in USD an amount of 1 is 1 cent, and 100 is a dollar.

Example:

onPaymentCallback: ({ amount, currency }) => {
    console.log(`Reporting payment of amount ${amount} in ${currency}.`)
},

Caveats

initializeSitchButtons() must be called after the Sitch buttons are mounted in the DOM. If your DOM dynamically changes you'll have to re-execute the function any time new Sitch buttons are constructed.