skydancer 2.11.0 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,28 @@ Embeds point at `@2`, which follows the newest `v2.x.x` tag, so everything
4
4
  below reaches an existing embed as soon as it is tagged. This is the place to
5
5
  look when a dancer starts looking different.
6
6
 
7
+ ## v2.13.0 — 2026-11-23
8
+
9
+ - `link-label` and `poke-label` say the two bits of wording a reader meets
10
+ rather than sees. They were English only, which on a page in another
11
+ language was the only English a screen reader hit.
12
+ - **Fixed:** a negative `girth` asked the canvas for a negative radius and
13
+ threw on every frame, leaving nothing on screen; an enormous one left
14
+ nothing on screen either. Numbers that have a sensible range are held to
15
+ it now, since a dancer's settings can arrive from a page's templating or
16
+ a shared link rather than from someone watching the result.
17
+
18
+ ## v2.12.0 — 2026-11-20
19
+
20
+ - Pushing a version tag publishes to npm, with provenance, instead of it
21
+ being done by hand. The tag and `package.json` have to agree or the run
22
+ stops.
23
+ - The package carries its own types, so `querySelector('sky-dancer')` is the
24
+ element rather than a bare `HTMLElement`, and the attributes are written
25
+ down where an editor can offer them. No JSX declaration, since typing an
26
+ intrinsic element means naming a framework's own types and nobody should
27
+ have to carry those to install a tube man.
28
+
7
29
  ## v2.11.0 — 2026-11-20
8
30
 
9
31
  - A dancer with something to `shout` can be poked from a keyboard: it carries
package/README.md CHANGED
@@ -13,19 +13,37 @@ An animated inflatable tube man as an embeddable web widget. It is transparent,
13
13
  <sky-dancer color="#7d3cff" accent="#00e0c6" face="cool" style="height: 500px"></sky-dancer>
14
14
  ```
15
15
 
16
- With a bundler, install it and import it once instead -- for its side effect,
17
- since importing is what registers `<sky-dancer>`:
16
+ ### From npm
18
17
 
19
18
  ```sh
20
19
  npm install skydancer
21
20
  ```
22
21
 
22
+ Import it once, anywhere that runs before the markup does. There is nothing to
23
+ call and nothing to configure: importing is what registers `<sky-dancer>`.
24
+
23
25
  ```js
24
26
  import 'skydancer';
25
27
  ```
26
28
 
27
- It is the same file either way: no build step, no dependencies, and nothing to
28
- call once it is in.
29
+ After that it is an ordinary tag, so it works in whatever renders your HTML:
30
+
31
+ ```html
32
+ <sky-dancer color="#e8452c" accent="#ffd60a" print="SALE"
33
+ placard="Open till 8" hours="9-17" style="height: 420px"></sky-dancer>
34
+ ```
35
+
36
+ ```js
37
+ // the methods are on the element, so a reference to it is all you need
38
+ document.querySelector('sky-dancer').cheer();
39
+ ```
40
+
41
+ Every attribute is a plain string, so nothing needs a wrapper to pass one.
42
+ Importing where there is no browser, as when a page is rendered on a server,
43
+ does nothing rather than throwing.
44
+
45
+ It is the same file either way: no build step, no dependencies. Types come
46
+ with it, so `querySelector('sky-dancer')` knows what it has found.
29
47
 
30
48
  The widget is 400px tall by default and crops to the dancer: its width follows its height (1.4x, plus a little per extra dancer), so it sits inline like an image rather than filling the page. Size it with CSS -- set the height and the width follows, or set both to override the crop. The dancer scales with the height and keeps its proportions.
31
49
 
@@ -38,6 +56,8 @@ The widget is 400px tall by default and crops to the dancer: its width follows i
38
56
  | `speed` | `1` | animation speed |
39
57
  | `wildness` | `1` | how much it flails |
40
58
  | `wind` | `1` | wind strength; `0` is calm. Scales the gusts, the pointer, and the page scrolling past |
59
+ | `link-label` | none | what the link is called when the sign says nothing; English `Find out more` otherwise |
60
+ | `poke-label` | none | what the poke button is called; English `Poke the dancer` otherwise |
41
61
  | `hours` | none | when it is worth dancing, as `9-17`; `22-6` runs through midnight. Outside them the air is out and the dancer lies flat |
42
62
  | `face` | `happy` | `happy`, `surprised`, `cool`, `wink`, `joy`, `sleepy` or `angry` |
43
63
  | `pattern` | `none` | markings on the body: `none`, `rings` or `spiral` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skydancer",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "An embeddable inflatable tube dancer, as a custom element. Vanilla canvas, no dependencies.",
5
5
  "keywords": [
6
6
  "custom-element",
@@ -21,7 +21,10 @@
21
21
  "author": "Marjan Bajc",
22
22
  "type": "module",
23
23
  "exports": {
24
- ".": "./skydancer.js"
24
+ ".": {
25
+ "types": "./skydancer.d.ts",
26
+ "default": "./skydancer.js"
27
+ }
25
28
  },
26
29
  "main": "./skydancer.js",
27
30
  "module": "./skydancer.js",
@@ -29,6 +32,7 @@
29
32
  "jsdelivr": "./skydancer.js",
30
33
  "files": [
31
34
  "skydancer.js",
35
+ "skydancer.d.ts",
32
36
  "README.md",
33
37
  "CHANGELOG.md",
34
38
  "LICENSE"
@@ -36,5 +40,6 @@
36
40
  "sideEffects": true,
37
41
  "engines": {
38
42
  "node": ">=18"
39
- }
43
+ },
44
+ "types": "./skydancer.d.ts"
40
45
  }
package/skydancer.d.ts ADDED
@@ -0,0 +1,104 @@
1
+ // Types for <sky-dancer>. Importing the package registers the element and
2
+ // nothing else, so there is no value to type -- what these describe is the
3
+ // element you then write in your markup.
4
+
5
+ export {};
6
+
7
+ /** A face to wear. */
8
+ export type SkyDancerFace =
9
+ | 'happy' | 'surprised' | 'cool' | 'wink' | 'joy' | 'sleepy' | 'angry';
10
+
11
+ /** Markings down the body. */
12
+ export type SkyDancerPattern = 'none' | 'rings' | 'spiral';
13
+
14
+ /** The shape of the speech balloon. */
15
+ export type SkyDancerBubble = 'drawn' | 'box' | 'burst';
16
+
17
+ /**
18
+ * The element itself. Every setting is an attribute, so the methods below are
19
+ * the whole of the interface.
20
+ */
21
+ export interface SkyDancerElement extends HTMLElement {
22
+ /** Set it off: the same burst a poke gives it. A held pose stays still. */
23
+ cheer(): void;
24
+ /** Let the air out. It stays on show -- this is a mood, not `hide()`. */
25
+ deflate(): void;
26
+ /** Put the air back. */
27
+ inflate(): void;
28
+ /** Take it off the page. */
29
+ hide(): void;
30
+ /** Put it back. */
31
+ show(): void;
32
+ }
33
+
34
+ /**
35
+ * What a dancer can be told, as attributes. Everything is optional, and
36
+ * everything is written as a string the way an attribute always is -- the
37
+ * numbers included.
38
+ */
39
+ export interface SkyDancerAttributes {
40
+ /** Body colour. Any CSS colour. Default `#ff3b30`. */
41
+ color?: string;
42
+ /** Arms and hair colour. Default `#ffd60a`. */
43
+ accent?: string;
44
+ /** How fat the tube is, in px at a 1000px reference height. Default `64`. */
45
+ girth?: string | number;
46
+ /** Arm length as a fraction of body height. Default `0.32`. */
47
+ 'arm-length'?: string | number;
48
+ /** How fast it dances. `0` holds the pose. Default `1`. */
49
+ speed?: string | number;
50
+ /** How much it flails. Default `1`. */
51
+ wildness?: string | number;
52
+ /** Wind strength; `0` is calm. Scales gusts, the pointer and the page's
53
+ * scrolling. Default `1`. */
54
+ wind?: string | number;
55
+ /** Which face it wears. Default `happy`. */
56
+ face?: SkyDancerFace;
57
+ /** `false` hides the hair. Default `true`. */
58
+ hair?: string | boolean;
59
+ /** How many stand together, 1 to 6. Default `1`. */
60
+ count?: string | number;
61
+ /** Give a crowd a colour, face and build each. Default `false`. */
62
+ variety?: string | boolean;
63
+ /** Hold the pose. It stays on show, it simply stops. Default `false`. */
64
+ paused?: string | boolean;
65
+ /** Markings on the body. Default `none`. */
66
+ pattern?: SkyDancerPattern;
67
+ /** Words printed down the body, bending with the tube. */
68
+ print?: string;
69
+ /** Words on a board staked at its feet, which hold still. */
70
+ placard?: string;
71
+ /** What it blurts when poked. Divide several with `|`, `||` for a literal
72
+ * pipe; each poke takes one, never the one it took last. */
73
+ shout?: string;
74
+ /** Where a click leads, opened in a new tab. Only `http`, `https`, `mailto`
75
+ * and `tel` are followed. */
76
+ href?: string;
77
+ /** Words in a speech balloon. Divide several with `|` and it works through
78
+ * them in turn; `||` writes a literal pipe. */
79
+ sign?: string;
80
+ /** The balloon's shape. Default `drawn`. */
81
+ bubble?: SkyDancerBubble;
82
+ /** What the link is called when the sign says nothing. English `Find out
83
+ * more` when unset. */
84
+ 'link-label'?: string;
85
+ /** What the poke button is called. English `Poke the dancer` when
86
+ * unset. */
87
+ 'poke-label'?: string;
88
+ /** When it is worth dancing, as `9-17`; `22-6` runs through midnight.
89
+ * Outside them the air is out and it lies flat. Read from the reader's own
90
+ * clock. Empty means always. */
91
+ hours?: string;
92
+ }
93
+
94
+ declare global {
95
+ // So `document.querySelector('sky-dancer')` and `createElement` are typed.
96
+ interface HTMLElementTagNameMap {
97
+ 'sky-dancer': SkyDancerElement;
98
+ }
99
+ }
100
+
101
+ // No JSX declaration here on purpose: typing an intrinsic element means
102
+ // naming a framework's own JSX types, and this package should not make
103
+ // everyone who installs it carry React's. A JSX user can write their own in
104
+ // a few lines, from `SkyDancerAttributes` above.
package/skydancer.js CHANGED
@@ -34,6 +34,11 @@
34
34
  sign: '', // words in a speech bubble by the dancer; empty for none
35
35
  bubble: 'drawn', // drawn | box | burst
36
36
  hours: '', // when it is worth dancing, as `9-17`; empty for always
37
+ // The two bits of wording a reader meets rather than sees. They are in
38
+ // English because something has to be; a page in another language can
39
+ // say them its own way.
40
+ linkLabel: '', // what the link is called when the sign says nothing
41
+ pokeLabel: '', // what the poke button is called
37
42
  };
38
43
 
39
44
  const OFF = ['false', '0', 'no', 'off'];
@@ -52,6 +57,20 @@
52
57
  return from < to ? h >= from && h < to : h >= from || h < to;
53
58
  }
54
59
 
60
+ // What a number may be, when being outside it is worse than useless. A
61
+ // dancer's settings can arrive from a page's own templating or from a
62
+ // shared link, so they are not always written by someone watching the
63
+ // result: a negative girth asked the canvas for a negative radius and threw
64
+ // on every frame, and a girth of 100000 left nothing on screen at all.
65
+ // Outside these a dancer is still a dancer, just a silly one.
66
+ const LIMITS = {
67
+ girth: [1, 400],
68
+ armLength: [0, 3],
69
+ speed: [0, 20],
70
+ wildness: [0, 10],
71
+ wind: [0, 10],
72
+ };
73
+
55
74
  const attrName = key => key.replace(/[A-Z]/g, c => `-${c.toLowerCase()}`);
56
75
  const KEYS = Object.keys(DEFAULTS);
57
76
 
@@ -61,7 +80,9 @@
61
80
  if (typeof DEFAULTS[key] === 'number') {
62
81
  // Number, not parseFloat: height="500px" should fall back, not mean 500x the canvas
63
82
  const n = value.trim() === '' ? NaN : Number(value);
64
- return Number.isFinite(n) ? n : DEFAULTS[key];
83
+ if (!Number.isFinite(n)) return DEFAULTS[key];
84
+ const bounds = LIMITS[key];
85
+ return bounds ? Math.min(bounds[1], Math.max(bounds[0], n)) : n;
65
86
  }
66
87
  return value;
67
88
  }
@@ -530,7 +551,7 @@
530
551
  let labelled = null;
531
552
 
532
553
  function labelLink(sign) {
533
- const label = sign || 'Find out more';
554
+ const label = sign || cfg.linkLabel.trim() || 'Find out more';
534
555
  if (!aimed || label === labelled) return;
535
556
  labelled = label;
536
557
  leadsTo.textContent = label;
@@ -607,13 +628,17 @@
607
628
  // merely wiggled has nothing to report to a reader who cannot see it -- so
608
629
  // it stays out of the page's tab order rather than costing a stop per
609
630
  // embed for a flourish. A held pose swallows a poke, so it offers none.
610
- let offering = null;
631
+ let offering = null, offeredAs = null;
611
632
  function offerPoke() {
612
633
  const worth = phrasesOf(cfg.shout).length > 0 && !held();
613
- if (worth === offering) return;
634
+ const label = cfg.pokeLabel.trim() || 'Poke the dancer';
635
+ // the wording is watched as well as the offer, or renaming the button
636
+ // while it is already showing would not reach it
637
+ if (worth === offering && label === offeredAs) return;
614
638
  offering = worth;
639
+ offeredAs = label;
615
640
  pokeButton.hidden = !worth;
616
- if (worth) pokeButton.textContent = 'Poke the dancer';
641
+ if (worth) pokeButton.textContent = label;
617
642
  }
618
643
 
619
644
  // A page can theme the dancer in CSS rather than in attributes, which is