anentrypoint-design 0.0.351 → 0.0.353

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anentrypoint-design",
3
- "version": "0.0.351",
3
+ "version": "0.0.353",
4
4
  "description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
5
5
  "type": "module",
6
6
  "main": "./dist/247420.js",
@@ -112,10 +112,10 @@
112
112
  },
113
113
  "devDependencies": {
114
114
  "axe-core": "^4.12.1",
115
- "esbuild": "^0.28.0",
115
+ "esbuild": "^0.28.1",
116
116
  "playwright": "^1.61.1",
117
117
  "pngjs": "^7.0.0",
118
- "postcss": "^8.5.12",
118
+ "postcss": "^8.5.19",
119
119
  "postcss-prefix-selector": "^2.1.1"
120
120
  }
121
121
  }
package/src/index.js CHANGED
@@ -104,7 +104,7 @@ export const applyDiff = webjsx.applyDiff;
104
104
 
105
105
  // spoint kit paint surfaces (loading screen, HUD, editor chrome).
106
106
  export { renderLoadingScreen } from './kits/spoint/loading-screen.js';
107
- export { renderGameHud } from './kits/spoint/game-hud.js';
107
+ export { renderGameHud, Crosshair, AmmoCounter, HealthBar, BoostIndicator } from './kits/spoint/game-hud.js';
108
108
  export { renderHostJoinLobby } from './kits/spoint/host-join-lobby.js';
109
109
 
110
110
  // Re-export freddie helpers so consumers can `import { FREDDIE_PAGES } from
@@ -3,6 +3,61 @@
3
3
  // -> a vnode the consumer mounts. Pure presentation; the app owns all state.
4
4
  // `h` is the consumer's createElement (webjsx) so the tree composes into the
5
5
  // app's existing render() return.
6
+ //
7
+ // Composed from four independent primitives below (Crosshair, AmmoCounter,
8
+ // HealthBar, BoostIndicator) -- each takes the same `h` + a narrow slice of
9
+ // props and returns its own vnode, so a consumer that wants a custom HUD
10
+ // layout (e.g. reposition the ammo counter, drop the boost badge) can import
11
+ // just the pieces it needs instead of the whole composed tree.
12
+
13
+ /** Center-screen aim reticle. No props beyond `h`. */
14
+ export function Crosshair(h) {
15
+ return h('div', { class: 'sp-hud-crosshair' }, '+')
16
+ }
17
+
18
+ /**
19
+ * Ammo readout — `ammo/magazine`, or a reload-progress label while reloading.
20
+ * @param {Object} [props]
21
+ * @param {number} [props.ammo=0]
22
+ * @param {number} [props.magazine=30]
23
+ * @param {boolean} [props.reloading=false]
24
+ * @param {number} [props.reloadProgress=0]
25
+ */
26
+ export function AmmoCounter(h, props = {}) {
27
+ const { ammo = 0, magazine = 30, reloading = false, reloadProgress = 0 } = props
28
+ return h('div', { class: 'sp-hud-ammo' },
29
+ reloading
30
+ ? h('span', { class: 'sp-hud-ammo-reloading' }, `RELOADING ${reloadProgress}%`)
31
+ : h('span', null, `${ammo}/${magazine}`)
32
+ )
33
+ }
34
+
35
+ /**
36
+ * Bottom-center health bar with a threshold-colored fill and a numeric label.
37
+ * @param {Object} [props]
38
+ * @param {number} [props.hp=100]
39
+ */
40
+ export function HealthBar(h, props = {}) {
41
+ const { hp = 100 } = props
42
+ const hpClass = hp > 60 ? 'sp-hud-hp-high' : hp > 30 ? 'sp-hud-hp-mid' : 'sp-hud-hp-low'
43
+ return h('div', { class: 'sp-hud-health' },
44
+ h('div', { class: `sp-hud-health-fill ${hpClass}`, style: `width:${hp}%` }),
45
+ h('span', { class: 'sp-hud-health-num' }, String(hp))
46
+ )
47
+ }
48
+
49
+ /**
50
+ * Top-right boost badge. Renders nothing while boostSec <= 0 (consumer can
51
+ * check this before calling too; kept internal so composition stays a
52
+ * one-liner in renderGameHud).
53
+ * @param {Object} [props]
54
+ * @param {number} [props.boostSec=0]
55
+ */
56
+ export function BoostIndicator(h, props = {}) {
57
+ const { boostSec = 0 } = props
58
+ if (boostSec <= 0) return null
59
+ return h('div', { class: 'sp-hud-boost' }, `BOOSTED ${boostSec}s`)
60
+ }
6
61
 
7
62
  export function renderGameHud(h, state = {}) {
8
63
  const {
@@ -14,19 +69,10 @@ export function renderGameHud(h, state = {}) {
14
69
  boostSec = 0,
15
70
  } = state
16
71
 
17
- const hpClass = hp > 60 ? 'sp-hud-hp-high' : hp > 30 ? 'sp-hud-hp-mid' : 'sp-hud-hp-low'
18
-
19
72
  return h('div', { class: 'sp-hud' },
20
- h('div', { class: 'sp-hud-crosshair' }, '+'),
21
- h('div', { class: 'sp-hud-ammo' },
22
- reloading
23
- ? h('span', { class: 'sp-hud-ammo-reloading' }, `RELOADING ${reloadProgress}%`)
24
- : h('span', null, `${ammo}/${magazine}`)
25
- ),
26
- h('div', { class: 'sp-hud-health' },
27
- h('div', { class: `sp-hud-health-fill ${hpClass}`, style: `width:${hp}%` }),
28
- h('span', { class: 'sp-hud-health-num' }, String(hp))
29
- ),
30
- boostSec > 0 ? h('div', { class: 'sp-hud-boost' }, `BOOSTED ${boostSec}s`) : null
73
+ Crosshair(h),
74
+ AmmoCounter(h, { ammo, magazine, reloading, reloadProgress }),
75
+ HealthBar(h, { hp }),
76
+ BoostIndicator(h, { boostSec })
31
77
  )
32
78
  }
@@ -4,7 +4,7 @@
4
4
  // through the main bundle entry so spoint can import directly from unpkg.
5
5
 
6
6
  export { renderLoadingScreen } from './loading-screen.js';
7
- export { renderGameHud } from './game-hud.js';
7
+ export { renderGameHud, Crosshair, AmmoCounter, HealthBar, BoostIndicator } from './game-hud.js';
8
8
  export { renderHostJoinLobby } from './host-join-lobby.js';
9
9
 
10
10
  export const themeUrl = new URL('./loading-screen.css', import.meta.url).href;