Components/Superpowers

Superpowers

Pals that step out of the page, do real interface jobs, or turn your site into a game.

Beyond the page 5

Polly

pal="polly"

Reads your page aloud, hopping along each word as it is spoken.

A short story

Once there was a parrot who loved words. It read every page it could find, out loud, hopping from word to word so nobody lost their place.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<button id="listen">Listen</button>

<article>
  <piix-pal pal="polly" button="#listen"></piix-pal>
  <h1>My post</h1>
  <p>…</p>
</article>
Options
on
what to read (or put the tag inside it)
button
a real button that starts and pauses it
rate
speaking speed (default 1)
pitch
voice pitch (default 1.15, a bit parrot)
voice
part of a voice name to prefer, e.g. "Samantha"
API
el.ctl.read() el.ctl.pause() el.ctl.stop()
events
piix:read-start, piix:read-end { done }

Gist

pal="gist"

An owl that sums up your article in a few key points.

Why pixel pals?

Websites got very serious. Every page looks like every other page. Pixel pals give a site a little life without getting in the way. They never block a click and they stay out of the way of screen readers. They are small, free and made for anyone.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<article>
  <piix-pal pal="gist"></piix-pal>
  <h1>My long post</h1>
  <p>…</p>
</article>
Options
on
what to summarise (or put the tag inside it)
points
how many points (default 3)
button
a real button that asks for the summary
API
el.ctl.summarize()
events
piix:gist { points, source }

Tabby

pal="tabby"

A cat that lives in your browser tab’s icon and naps while you’re away.

Superpowers · Piixpal×
<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<footer>
  <piix-pal pal="tabby" progress
    away="Come back! Tabby misses you"></piix-pal>
</footer>
Options
away
what the tab title says while you are gone (default “Come back! Tabby misses you”)
progress
draw a reading-progress ring around the icon
preview
also draw the icon on these <canvas> elements

Sprout

pal="sprout"

A focus-timer plant that pops out into its own always-on-top window.

A focus timer that grows. Click the plant.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<footer>
  <piix-pal pal="sprout" minutes="25" break="5"></piix-pal>
</footer>
Options
minutes
focus length (default 25)
break
break length (default 5)
API
el.ctl.open() el.ctl.popout()
events
piix:bloom, piix:popout

Nomad

pal="nomad"

A little traveller who walks between your browser windows.

Nomad walks out of this box and into the other window, then back again.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<!-- on every page of your site -->
<piix-pal pal="nomad"></piix-pal>
Options
window
the page to open with el.ctl.invite() (default: this page)
API
el.ctl.invite()
events
piix:arrive, piix:depart

Pals with jobs 13

Bulb

pal="bulb"

A pull-chain light switch for dark mode.

Lights?

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<!-- anywhere: it hangs from the top of the screen -->
<piix-pal pal="bulb" toggle="data-theme:dark|light"></piix-pal>
Options
toggle
class:dark (default) or an attribute cycle like data-theme:dark|light; the first value is lights-off
target
what to toggle (default <html>)
at
where across the screen it hangs, 0–1 (default .9)
length
chain length in px (default 120)
top
px from the top, to clear a sticky header
events
piix:toggle { dark, value }

Pidge

pal="pidge"

Toast notifications, delivered by pigeon.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/dist/c/pidge.min.js"></script>
<script>
  Piixpal.toast("Saved!", { type: "ok" });
</script>
Options
type
{ type: "ok" | "error" | "info" }
title
{ title: "Mia" } a bold first line
time
{ time: 6000 } ms on screen, 0 = until dismissed (default 4200)
API
Piixpal.toast(msg, opts) el.ctl.toast(msg, opts) el.ctl.clear()

Plane

pal="plane"

A plane that tows your announcement banner across the page.

Banners are real links, so they work with keyboards and screen readers too.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<piix-pal pal="plane"
  text="v2 is out! Read the post →"
  href="/blog/v2"></piix-pal>
Options
text
what the banner says
href
makes the banner a link
top
px from the top of the screen (default 90)
repeat
seconds between passes, 0 = once (default 0)
always
fly on every page view, not once per session
API
el.ctl.fly()

Fetch

pal="fetch"

A dog that runs off on every fetch() and brings back the response.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<footer>
  …
  <piix-pal pal="fetch" match="/api/"></piix-pal>
</footer>
Options
match
only count requests whose URL contains this, e.g. /api/
at
where it sits on its element, 0–1
API
Piixpal.busy(promise)

Scout

pal="scout"

Onboarding tours, guided by a tiny explorer.

MK

Click Scout to take the tour.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<button data-tour="Start a new project here">New</button>
<input data-tour="Search everything">

<header>
  <piix-pal pal="scout"></piix-pal>
</header>
Options
data-tour
on any element: the text for that stop (data-tour-step to order, data-tour-title for a heading)
steps
or list the stops on the tag: #new: Start here | #search: Find anything
start
"auto" begins by itself, once per visitor
API
el.ctl.start(steps?) el.ctl.next() el.ctl.back() el.ctl.end()
events
piix:tour-step, piix:tour-end

Drone

pal="drone"

Flies the product picture into your cart when someone adds to cart.

Cart 0
Pixel tee
Mug
Cap
<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<a id="cart">Cart <b class="count">0</b></a>

<article data-product>
  <img src="tee.png" alt="Pixel tee">
  <button class="add-to-cart">Add to cart</button>
</article>

<piix-pal pal="drone" on="#cart"></piix-pal>
Options
on
your cart icon (the drone lives next to it)
from
which buttons send it (default .add-to-cart, [data-add-to-cart])
count
a number in the cart to add one to (default .count, [data-count])
events
piix:delivered { button } on the pal and the cart

Crumb

pal="crumb"

A mouse that eats your cookie banner when someone accepts or rejects.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<div id="cookie-banner">
  We use cookies…
  <button>Accept</button>
  <button>Reject</button>
  <piix-pal pal="crumb"></piix-pal>
</div>
Options
on
the banner (or put the tag inside it)
at
where it sits on the banner, 0–1 (default .82)
events
piix:eaten

Avatar

<piix-avatar>

A unique animated pixel avatar for any name.

mia These little guys are so good.

sam Mine has horns!

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<div class="comment">
  <piix-avatar seed="mia" size="40"></piix-avatar>
  <p><b>mia</b> Hello!</p>
</div>
Options
seed
any word; same word, same creature
size
width in px (default 64)
render
pixel, dots, halftone, dither, ascii or voxel
look
mouse, wander or none

Buff

pal="buff"

A password-strength meter that lifts heavier as the password gets stronger.

Choose a password:

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<label>
  Password
  <input type="password">
  <piix-pal pal="buff"></piix-pal>
</label>
Options
on
the password input (or put the tag inside its label)
at
where it stands on the field, 0–1 (default .9)
API
el.ctl.score
events
piix:strength { score, label }

Meh

pal="meh"

A face that rides your rating slider, from furious to delighted.

How was your day?

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<label>
  How was it?
  <input type="range" min="0" max="10">
  <piix-pal pal="meh"></piix-pal>
</label>
Options
on
the slider, a group of radio buttons, or a select
events
piix:mood { value, level }

Squish

pal="squish"

A marshmallow that gets squashed as the text nears its limit.

Write a very short bio:

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<label>
  Bio
  <textarea maxlength="140"></textarea>
  <piix-pal pal="squish"></piix-pal>
</label>
Options
on
the textarea or input (or put the tag inside its label)
limit
the limit, if the field has no maxlength (default 280)
events
piix:limit { length, limit, left }

Gulp

pal="gulp"

A pelican that gulps down files dropped on your drop zone.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<div id="drop">Drop files here</div>
<piix-pal pal="gulp" on="#drop" accept></piix-pal>
Options
on
the drop zone, or a file input
accept
let the zone take drops by itself (leave it off if your code already handles them)
at
where it stands on the zone, 0–1
events
piix:gulp { files }

Plug

pal="plug"

Shows up when the connection drops, plugs back in when it returns.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<!-- anywhere: it waits in the corner -->
<piix-pal pal="plug"></piix-pal>
Options
always
stay in the corner, plugged in, even when online
API
el.ctl.offline() el.ctl.online()
events
piix:offline, piix:online

Play your site 5

Pix

pal="pix"

A tiny hero that lets visitors play your page as a platformer.

Play me

Every line of text is a platform. Bump the buttons from below.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<h1>
  Welcome to my site
  <piix-pal pal="pix"></piix-pal>
</h1>
Options
coins
how many coins to hide, 0 for none (default 10)
land
CSS selector for what counts as a platform
play
"keys" lets the arrow keys start a game too
API
el.ctl.start() el.ctl.stop()
events
piix:play, piix:coin, piix:win, piix:stop

Weather

<piix-weather>

Snow that settles on your letters, plus rain, leaves and petals.

Let it snow

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<!-- the whole page -->
<piix-weather kind="snow"></piix-weather>

<!-- or just inside one element -->
<header class="hero">
  <h1>Happy holidays</h1>
  <piix-weather kind="snow" amount="2"></piix-weather>
</header>
Options
kind
snow, rain, leaves or petals (default snow)
amount
0–3, how much falls (default 1)
land
CSS selector for what it settles on
box
keep it inside one element; put the tag inside any element (not <body>) and it stays in there too
API
el.clear()

Hatch

pal="hatch"

Every visitor hatches their own one-of-a-kind pet.

Tap the egg. What hatches is yours alone.

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<footer>
  <piix-pal pal="hatch" visits="3"></piix-pal>
</footer>
Options
visits
visits before it hatches on its own (default 3)
at
where it lives on its element, 0–1
API
el.ctl.hatch() el.ctl.reset() el.ctl.name
events
piix:hatch { name, seed }

Gem

pal="gem"

A treasure hunt across your whole site.

Treasure

Gems hide on headings, on lines of text, on buttons, anywhere.

A button
<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<!-- one per gem, on any pages you like -->
<piix-pal pal="gem" hunt="launch" gem="1" total="5"
  reward="PIX10"></piix-pal>
Options
hunt
the name of the hunt (gems of one hunt share a jar)
gem
this gem’s id within the hunt
total
how many gems there are
reward
a code to show when the jar is full
color
the gem’s colour
API
el.ctl.reset()
events
piix:gem { hunt, found, total }, piix:hunt-done { hunt, reward }

Stickers

<piix-stickers>

A sheet of stickers visitors peel off and stick anywhere on your page.

Stick it here

<!-- once, anywhere on the page -->
<script src="https://cdn.jsdelivr.net/npm/piixpal@0.4/piixpal.min.js"></script>

<piix-stickers names="heart,star,bolt,mochi,ufo"></piix-stickers>
Options
names
which stickers, comma separated: heart, star, bolt, smile, crown, wow, or any sprite’s name
box
only let them stick inside one element
API
el.clear()