Bruce, in his element

Introducing the <bruce-lawson> web component.

No JavaScript? Fine by me. This is progressive enhancement: still a Bruce, just fewer moving parts.

Bruce Lawson, smirking
Looks
Props (one item per hand, newest wins)
Switches

Event log

Bruce fires bruce:rant, bruce:change, bruce:hoedown, bruce:flip and bruce:offended. They bubble out of the shadow DOM, like his opinions.

  • Nothing yet. Press Bruce.

Attributes

AttributeValuesWhat it does
headauto, happy1, happy2, cheeky, quizzical, talk, orly, glare, jaded, visionary, innocent, sceptical, smirk, vikingauto picks a face to suit his mood, and swaps it while he rants.
backgroundgallery, oslo, irises, stage, cma, eu, random, or an image URLHe brings his own stage, and the element becomes the whole framed card. Without it, he’s a cut-out.
topcompliant-tee, blazer, circles, pin-jacket, chaos, opera-tee, vivaldi-tee, cowboy, pink-blazer, kitten-tee, randomWhat he’s wearing on top.
legsjeans, black-jeans, formal, stripes, golden-shorts, randomTrousers, each with its own shoes.
propsSpace-separated: guitar, mic, clicker, laptop, phone, guinness, point-left, point-right, peace-left, peace-right, lanyard, lei, or randomWhat he’s holding or wearing. Each hand holds one thing, so when props clash the later one wins. Left and right are Bruce’s own.
rantengines, dma, ai, standards, randomThe topic of his speech bubble when pressed.
hoedownbooleanPlays a hoedown, and he jigs and pulls faces. Browsers block autoplay, so he waits for a press.
hoedown-srcURLPlays your audio file instead of the built-in hoedown.
glamorousanything except "false"Try "false" and check the console.
aibooleanHe refuses to work.
flippedbooleanTurns him over to show his source code, and someone turns up to have a word about it.
reduced-motionbooleanHe stops moving and glares, just as when your system asks for reduced motion.
quietbooleanNo sound when you press him or turn him over.

Methods: rant(), say(text), reroll(), hush() and flip().

On your own page

  1. Copy src/bruce-lawson.js and assets/ to your site, keeping that folder layout.
  2. Load it once: <script type="module" src="src/bruce-lawson.js"></script>
  3. Add him: <bruce-lawson top="cowboy" props="guitar"></bruce-lawson>
  4. Serve it from a web server (localhost is fine). With a background, give him a width and height. Without one, size him with --bruce-size and leave room above him for his opinions.