stickerpack v0.0.1
Stickers for Websites
Only the finest stickers, for your website. Add two lines of HTML or call one function, and folks can stick stuff all over your pages. The stickers stay put when they come back.
Use some HTML
Two lines. Load the script and drop in the custom element.
<script type="module" src="https://stickerpack.stucco.software/stickerpack.js"></script>
<sticker-pack></sticker-pack>Rather host it yourself? Download stickerpack.js and point the src at your copy.
Attributes
stickers- Space-separated image URLs to add to the pack. Relative URLs are resolved against the page.
no-default-pack- Only offer your own stickers.
slot="trigger"- Put this on a child element to use it instead of the ✦ button.
<sticker-pack stickers="/stickers/duck.png /stickers/cat.png" no-default-pack>
<button slot="trigger">Stickers!</button>
</sticker-pack>Use some JavaScripts
So you sling some code? Make stickers happen where, when, and how you want.
import StickerPack from 'stickerpack'
// Mount: adds the ✦ button and loads this page's stickers
const destroy = StickerPack()
// Unmount: removes the button and stickers, but keeps them saved
destroy()Options
stickersstring[]- Image URLs to add to the pack. Default:
[] defaultPackboolean- Include the Stucco default pack. Default:
true storageadapter- Where stickers are saved. See below. Default:
localStorageAdapter() triggerElement- Your own button to open the tray. Default:
the ✦ button
import StickerPack, { localStorageAdapter } from 'stickerpack'
const destroy = StickerPack({
stickers: ['/stickers/duck.png'], // added to the default pack
defaultPack: true, // false = only your stickers
storage: localStorageAdapter(), // where stickers are saved
trigger: document.querySelector('#stickers') // your own button
})One sticker pack per page. Don't get greedy!
// In a Svelte component, onMount cleans up for you
onMount(() => StickerPack())Stick stuff
What your visitors do:
- Open Hit the ✦ button to open the sticker tray.
- Pick Choose a sticker. It follows your cursor.
- Stick Click anywhere on the page. Links won’t fire. Esc cancels.
- Peel With the tray open, click a sticker to peel it off.