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

@wethegit/preact-stickerbook

v5.0.0

Published

Easily create collage apps that are accessible by default.

Downloads

199

Readme

preact-stickerbook

Easily create collage apps that are accessible by default.

Demo

Local development

To run and test the library localy, simply:

  1. Clone the repo: git clone [email protected]:wethegit/preact-stickerbook.git
  2. Install dependencies: npm i
  3. Start the dev server: npm run dev

Table of contents

Basic usage

This is the most simplistic way of using it, it's an artboard with the stickers.

Most likely you will want more control, you will want to generate downloads, add and remove stickers, and more. Check out the full demo on Codepen and also the complete implementation in the Playground.

import { h, render } from "preact"
import { Stickerbook, Sticker } from "@wethegit/preact-stickerbook"

const App = () => {
  const stickers = [
    {
      id: "my-id-1",
      image: "https://media.giphy.com/media/10mgrhuEWNasNO/giphy.gif",
      order: 0,
    },
  ]

  return (
    <Stickerbook outputWidth={500} outputHeight={500}>
      {stickers.map(({ id, ...sticker }) => (
        <Sticker key={id} id={id} {...sticker} />
      ))}
    </Stickerbook>
  )
}

render(<App />, document.body)

Stickerbook

Your main artboard. Responsible for containing and providing the Stickers with a context and all the required references so they can properly scale and translate. Apart from the Stickers, the Stickerbook can also have backgrounds, foregrounds and a frame.

Props

Type: StickerbookProps

Sticker

All of the elements that form the collage.

Props

Type: StickerProps.

useStickerbook

A hook that provides the Stickerbook context and all the handlers to manipulate the stickers.

Props

Type: UseStickerbookProps

Return

Type: UseStickerbookReturn

Helpers

exportStickerbook

Returns a representation of the stickerbook in the chosen format.

Type: ExportStickerbookOptions

reorderSticker

Returns a reordered copy of the provided stickers array.

Type: ReorderStickerOptions

addSticker

Returns a copy of the provided stickers array with the new sticker containing the required required id and id fields.

Type: AddStickerOptions

deleteSticker

Returns a copy of the provided stickers array without the selected sticker.

Type: DeleteStickerOptions

patchSticker

Returns a copy of the provided stickers array with the updated ("patched") sticker in place.

Type: PatchStickerOptions