bits-lab 0.0.0-stage → 0.1.2

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.
Files changed (323) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -2
  3. package/dist/Accordion.d.ts +52 -0
  4. package/dist/Accordion.js +192 -0
  5. package/dist/AchievementToast.d.ts +36 -0
  6. package/dist/AchievementToast.js +162 -0
  7. package/dist/AgentCard.d.ts +41 -0
  8. package/dist/AgentCard.js +168 -0
  9. package/dist/ArcadeButtons.d.ts +23 -0
  10. package/dist/ArcadeButtons.js +169 -0
  11. package/dist/AuroraBands.d.ts +19 -0
  12. package/dist/AuroraBands.js +126 -0
  13. package/dist/AvatarTooltips.d.ts +32 -0
  14. package/dist/AvatarTooltips.js +121 -0
  15. package/dist/BarRace.d.ts +39 -0
  16. package/dist/BarRace.js +227 -0
  17. package/dist/BentoGrid.d.ts +50 -0
  18. package/dist/BentoGrid.js +145 -0
  19. package/dist/BootSequence.d.ts +48 -0
  20. package/dist/BootSequence.js +234 -0
  21. package/dist/BreadcrumbTrail.d.ts +31 -0
  22. package/dist/BreadcrumbTrail.js +181 -0
  23. package/dist/CRTPower.d.ts +30 -0
  24. package/dist/CRTPower.js +142 -0
  25. package/dist/CardDeck.d.ts +29 -0
  26. package/dist/CardDeck.js +154 -0
  27. package/dist/ChangelogTimeline.d.ts +35 -0
  28. package/dist/ChangelogTimeline.js +137 -0
  29. package/dist/ChapterProgress.d.ts +23 -0
  30. package/dist/ChapterProgress.js +211 -0
  31. package/dist/ChatBubbles.d.ts +42 -0
  32. package/dist/ChatBubbles.js +198 -0
  33. package/dist/ChiptuneKit.d.ts +158 -0
  34. package/dist/ChiptuneKit.js +207 -0
  35. package/dist/CipherCard.d.ts +22 -0
  36. package/dist/CipherCard.js +91 -0
  37. package/dist/CloudSky.d.ts +28 -0
  38. package/dist/CloudSky.js +222 -0
  39. package/dist/CodeRain.d.ts +24 -0
  40. package/dist/CodeRain.js +158 -0
  41. package/dist/CodeShowcase.d.ts +50 -0
  42. package/dist/CodeShowcase.js +307 -0
  43. package/dist/ColorDial.d.ts +42 -0
  44. package/dist/ColorDial.js +288 -0
  45. package/dist/CommandPalette.d.ts +59 -0
  46. package/dist/CommandPalette.js +349 -0
  47. package/dist/CompareSlider.d.ts +33 -0
  48. package/dist/CompareSlider.js +152 -0
  49. package/dist/Confetti.d.ts +61 -0
  50. package/dist/Confetti.js +176 -0
  51. package/dist/ConnectBeams.d.ts +39 -0
  52. package/dist/ConnectBeams.js +132 -0
  53. package/dist/ContextOrb.d.ts +34 -0
  54. package/dist/ContextOrb.js +269 -0
  55. package/dist/ContourLines.d.ts +20 -0
  56. package/dist/ContourLines.js +159 -0
  57. package/dist/Coverflow.d.ts +27 -0
  58. package/dist/Coverflow.js +167 -0
  59. package/dist/CursorAttractor.d.ts +21 -0
  60. package/dist/CursorAttractor.js +136 -0
  61. package/dist/CutReveal.d.ts +21 -0
  62. package/dist/CutReveal.js +116 -0
  63. package/dist/DateRange.d.ts +45 -0
  64. package/dist/DateRange.js +327 -0
  65. package/dist/DeviceFrame.d.ts +30 -0
  66. package/dist/DeviceFrame.js +145 -0
  67. package/dist/DiffReveal.d.ts +36 -0
  68. package/dist/DiffReveal.js +247 -0
  69. package/dist/DirectionHover.d.ts +15 -0
  70. package/dist/DirectionHover.js +90 -0
  71. package/dist/Discard.d.ts +18 -0
  72. package/dist/Discard.js +61 -0
  73. package/dist/DitherField.d.ts +15 -0
  74. package/dist/DitherField.js +157 -0
  75. package/dist/DotGlobe.d.ts +48 -0
  76. package/dist/DotGlobe.js +312 -0
  77. package/dist/DotMap.d.ts +47 -0
  78. package/dist/DotMap.js +172 -0
  79. package/dist/DropZone.d.ts +57 -0
  80. package/dist/DropZone.js +304 -0
  81. package/dist/DynamicIsland.d.ts +32 -0
  82. package/dist/DynamicIsland.js +92 -0
  83. package/dist/EdgeFX.d.ts +27 -0
  84. package/dist/EdgeFX.js +98 -0
  85. package/dist/ElasticString.d.ts +22 -0
  86. package/dist/ElasticString.js +127 -0
  87. package/dist/ExpandCard.d.ts +44 -0
  88. package/dist/ExpandCard.js +182 -0
  89. package/dist/FeatureTabs.d.ts +34 -0
  90. package/dist/FeatureTabs.js +169 -0
  91. package/dist/FeedList.d.ts +37 -0
  92. package/dist/FeedList.js +163 -0
  93. package/dist/FlickerGrid.d.ts +29 -0
  94. package/dist/FlickerGrid.js +156 -0
  95. package/dist/FocusGrid.d.ts +20 -0
  96. package/dist/FocusGrid.js +48 -0
  97. package/dist/FocusPull.d.ts +26 -0
  98. package/dist/FocusPull.js +106 -0
  99. package/dist/Footprints.d.ts +24 -0
  100. package/dist/Footprints.js +126 -0
  101. package/dist/FunnelFlow.d.ts +34 -0
  102. package/dist/FunnelFlow.js +267 -0
  103. package/dist/GameOver.d.ts +46 -0
  104. package/dist/GameOver.js +191 -0
  105. package/dist/GaugeMeter.d.ts +38 -0
  106. package/dist/GaugeMeter.js +195 -0
  107. package/dist/GlassPanel.d.ts +27 -0
  108. package/dist/GlassPanel.js +80 -0
  109. package/dist/GrainFX.d.ts +34 -0
  110. package/dist/GrainFX.js +122 -0
  111. package/dist/GravityBox.d.ts +30 -0
  112. package/dist/GravityBox.js +220 -0
  113. package/dist/HealthBar.d.ts +33 -0
  114. package/dist/HealthBar.js +140 -0
  115. package/dist/Heatmap.d.ts +42 -0
  116. package/dist/Heatmap.js +232 -0
  117. package/dist/HexField.d.ts +29 -0
  118. package/dist/HexField.js +188 -0
  119. package/dist/HoldToConfirm.d.ts +29 -0
  120. package/dist/HoldToConfirm.js +163 -0
  121. package/dist/HorizontalTrack.d.ts +28 -0
  122. package/dist/HorizontalTrack.js +195 -0
  123. package/dist/HotbarDock.d.ts +40 -0
  124. package/dist/HotbarDock.js +148 -0
  125. package/dist/InkText.d.ts +27 -0
  126. package/dist/InkText.js +65 -0
  127. package/dist/InlineEdit.d.ts +30 -0
  128. package/dist/InlineEdit.js +198 -0
  129. package/dist/InteractiveGrid.d.ts +25 -0
  130. package/dist/InteractiveGrid.js +194 -0
  131. package/dist/InventoryGrid.d.ts +45 -0
  132. package/dist/InventoryGrid.js +272 -0
  133. package/dist/JellyBlob.d.ts +30 -0
  134. package/dist/JellyBlob.js +209 -0
  135. package/dist/KineticHeadline.d.ts +30 -0
  136. package/dist/KineticHeadline.js +133 -0
  137. package/dist/LavaLamp.d.ts +21 -0
  138. package/dist/LavaLamp.js +133 -0
  139. package/dist/LetterSwap.d.ts +20 -0
  140. package/dist/LetterSwap.js +78 -0
  141. package/dist/LevelMap.d.ts +35 -0
  142. package/dist/LevelMap.js +189 -0
  143. package/dist/LightShafts.d.ts +22 -0
  144. package/dist/LightShafts.js +170 -0
  145. package/dist/LightboxGallery.d.ts +26 -0
  146. package/dist/LightboxGallery.js +327 -0
  147. package/dist/LinkPeek.d.ts +36 -0
  148. package/dist/LinkPeek.js +194 -0
  149. package/dist/LogoOrbit.d.ts +37 -0
  150. package/dist/LogoOrbit.js +117 -0
  151. package/dist/Marquee.d.ts +33 -0
  152. package/dist/Marquee.js +148 -0
  153. package/dist/MarqueeLine.d.ts +33 -0
  154. package/dist/MarqueeLine.js +167 -0
  155. package/dist/MasonryWall.d.ts +13 -0
  156. package/dist/MasonryWall.js +90 -0
  157. package/dist/MegaMenu.d.ts +32 -0
  158. package/dist/MegaMenu.js +280 -0
  159. package/dist/MeteorShower.d.ts +24 -0
  160. package/dist/MeteorShower.js +155 -0
  161. package/dist/Minimap.d.ts +21 -0
  162. package/dist/Minimap.js +236 -0
  163. package/dist/MobileTabBar.d.ts +38 -0
  164. package/dist/MobileTabBar.js +148 -0
  165. package/dist/MorphDialog.d.ts +34 -0
  166. package/dist/MorphDialog.js +199 -0
  167. package/dist/MorphPopover.d.ts +33 -0
  168. package/dist/MorphPopover.js +168 -0
  169. package/dist/MorphWords.d.ts +18 -0
  170. package/dist/MorphWords.js +136 -0
  171. package/dist/OTPInput.d.ts +43 -0
  172. package/dist/OTPInput.js +174 -0
  173. package/dist/OverlayKit.d.ts +97 -0
  174. package/dist/OverlayKit.js +466 -0
  175. package/dist/OverlayMenu.d.ts +32 -0
  176. package/dist/OverlayMenu.js +154 -0
  177. package/dist/ParallaxCollage.d.ts +41 -0
  178. package/dist/ParallaxCollage.js +143 -0
  179. package/dist/PasswordMeter.d.ts +44 -0
  180. package/dist/PasswordMeter.js +165 -0
  181. package/dist/PegBoard.d.ts +26 -0
  182. package/dist/PegBoard.js +184 -0
  183. package/dist/PinCard.d.ts +21 -0
  184. package/dist/PinCard.js +84 -0
  185. package/dist/PixelAvatar.d.ts +33 -0
  186. package/dist/PixelAvatar.js +144 -0
  187. package/dist/PixelButton.d.ts +20 -0
  188. package/dist/PixelButton.js +128 -0
  189. package/dist/PixelExplode.d.ts +31 -0
  190. package/dist/PixelExplode.js +164 -0
  191. package/dist/PixelLoader.d.ts +32 -0
  192. package/dist/PixelLoader.js +142 -0
  193. package/dist/PixelParallax.d.ts +41 -0
  194. package/dist/PixelParallax.js +151 -0
  195. package/dist/PixelSpinners.d.ts +21 -0
  196. package/dist/PixelSpinners.js +110 -0
  197. package/dist/PixelType.d.ts +26 -0
  198. package/dist/PixelType.js +220 -0
  199. package/dist/PointerKit.d.ts +23 -0
  200. package/dist/PointerKit.js +222 -0
  201. package/dist/Polaroids.d.ts +41 -0
  202. package/dist/Polaroids.js +293 -0
  203. package/dist/PressStart.d.ts +28 -0
  204. package/dist/PressStart.js +99 -0
  205. package/dist/PricingFlip.d.ts +52 -0
  206. package/dist/PricingFlip.js +190 -0
  207. package/dist/ProximityType.d.ts +26 -0
  208. package/dist/ProximityType.js +135 -0
  209. package/dist/QuestDialog.d.ts +50 -0
  210. package/dist/QuestDialog.js +204 -0
  211. package/dist/QuestLog.d.ts +39 -0
  212. package/dist/QuestLog.js +214 -0
  213. package/dist/RangeDual.d.ts +34 -0
  214. package/dist/RangeDual.js +238 -0
  215. package/dist/RatingPips.d.ts +25 -0
  216. package/dist/RatingPips.js +129 -0
  217. package/dist/RetroHorizon.d.ts +27 -0
  218. package/dist/RetroHorizon.js +169 -0
  219. package/dist/Reveal.d.ts +30 -0
  220. package/dist/Reveal.js +92 -0
  221. package/dist/RingProgress.d.ts +45 -0
  222. package/dist/RingProgress.js +180 -0
  223. package/dist/RollingNumber.d.ts +28 -0
  224. package/dist/RollingNumber.js +108 -0
  225. package/dist/ScanScope.d.ts +24 -0
  226. package/dist/ScanScope.js +164 -0
  227. package/dist/ScoreTicker.d.ts +32 -0
  228. package/dist/ScoreTicker.js +176 -0
  229. package/dist/ScreenScroller.d.ts +24 -0
  230. package/dist/ScreenScroller.js +138 -0
  231. package/dist/Screensaver.d.ts +31 -0
  232. package/dist/Screensaver.js +221 -0
  233. package/dist/ScrollTilt.d.ts +27 -0
  234. package/dist/ScrollTilt.js +100 -0
  235. package/dist/ScrollTypography.d.ts +26 -0
  236. package/dist/ScrollTypography.js +124 -0
  237. package/dist/ScrollZoom.d.ts +31 -0
  238. package/dist/ScrollZoom.js +123 -0
  239. package/dist/ScrubNumber.d.ts +29 -0
  240. package/dist/ScrubNumber.js +152 -0
  241. package/dist/ShadowStack.d.ts +28 -0
  242. package/dist/ShadowStack.js +116 -0
  243. package/dist/SideRail.d.ts +43 -0
  244. package/dist/SideRail.js +253 -0
  245. package/dist/SignalText.d.ts +25 -0
  246. package/dist/SignalText.js +178 -0
  247. package/dist/SkeletonShimmer.d.ts +18 -0
  248. package/dist/SkeletonShimmer.js +111 -0
  249. package/dist/SketchHighlight.d.ts +27 -0
  250. package/dist/SketchHighlight.js +180 -0
  251. package/dist/SlideTabs.d.ts +40 -0
  252. package/dist/SlideTabs.js +190 -0
  253. package/dist/SmartNavbar.d.ts +48 -0
  254. package/dist/SmartNavbar.js +188 -0
  255. package/dist/SparkChart.d.ts +41 -0
  256. package/dist/SparkChart.js +188 -0
  257. package/dist/Spoiler.d.ts +22 -0
  258. package/dist/Spoiler.js +97 -0
  259. package/dist/SpotlightTour.d.ts +38 -0
  260. package/dist/SpotlightTour.js +231 -0
  261. package/dist/SpringDrawer.d.ts +39 -0
  262. package/dist/SpringDrawer.js +360 -0
  263. package/dist/SpriteAnimator.d.ts +41 -0
  264. package/dist/SpriteAnimator.js +124 -0
  265. package/dist/StatCard.d.ts +43 -0
  266. package/dist/StatCard.js +168 -0
  267. package/dist/StepLoader.d.ts +41 -0
  268. package/dist/StepLoader.js +191 -0
  269. package/dist/StepperForm.d.ts +41 -0
  270. package/dist/StepperForm.js +206 -0
  271. package/dist/StickerBoard.d.ts +39 -0
  272. package/dist/StickerBoard.js +209 -0
  273. package/dist/StickyReveal.d.ts +42 -0
  274. package/dist/StickyReveal.js +181 -0
  275. package/dist/StoryViewer.d.ts +36 -0
  276. package/dist/StoryViewer.js +175 -0
  277. package/dist/StreamingText.d.ts +29 -0
  278. package/dist/StreamingText.js +271 -0
  279. package/dist/SuggestionChips.d.ts +32 -0
  280. package/dist/SuggestionChips.js +96 -0
  281. package/dist/SwipeActions.d.ts +30 -0
  282. package/dist/SwipeActions.js +141 -0
  283. package/dist/TagInput.d.ts +30 -0
  284. package/dist/TagInput.js +284 -0
  285. package/dist/TallyUp.d.ts +38 -0
  286. package/dist/TallyUp.js +157 -0
  287. package/dist/TerminalDemo.d.ts +63 -0
  288. package/dist/TerminalDemo.js +214 -0
  289. package/dist/TestimonialWall.d.ts +35 -0
  290. package/dist/TestimonialWall.js +131 -0
  291. package/dist/TextOnPath.d.ts +36 -0
  292. package/dist/TextOnPath.js +130 -0
  293. package/dist/ThinkingShimmer.d.ts +36 -0
  294. package/dist/ThinkingShimmer.js +132 -0
  295. package/dist/ToastStack.d.ts +62 -0
  296. package/dist/ToastStack.js +289 -0
  297. package/dist/ToggleGroup.d.ts +39 -0
  298. package/dist/ToggleGroup.js +190 -0
  299. package/dist/ToggleKit.d.ts +70 -0
  300. package/dist/ToggleKit.js +229 -0
  301. package/dist/TracingLine.d.ts +24 -0
  302. package/dist/TracingLine.js +139 -0
  303. package/dist/TradingCard.d.ts +30 -0
  304. package/dist/TradingCard.js +147 -0
  305. package/dist/VanishInput.d.ts +34 -0
  306. package/dist/VanishInput.js +190 -0
  307. package/dist/VideoHero.d.ts +32 -0
  308. package/dist/VideoHero.js +207 -0
  309. package/dist/VoiceOrb.d.ts +23 -0
  310. package/dist/VoiceOrb.js +182 -0
  311. package/dist/VoxelTiles.d.ts +38 -0
  312. package/dist/VoxelTiles.js +201 -0
  313. package/dist/WarpField.d.ts +18 -0
  314. package/dist/WarpField.js +160 -0
  315. package/dist/WebcamPixels.d.ts +38 -0
  316. package/dist/WebcamPixels.js +292 -0
  317. package/dist/WheelPicker.d.ts +29 -0
  318. package/dist/WheelPicker.js +199 -0
  319. package/dist/WobbleCard.d.ts +23 -0
  320. package/dist/WobbleCard.js +112 -0
  321. package/dist/index.d.ts +158 -0
  322. package/dist/index.js +159 -0
  323. package/package.json +58 -4
@@ -0,0 +1,176 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-score-ticker";
5
+ const CSS = `
6
+ .bl-score { display: inline-grid; justify-items: center; gap: 10px; max-width: 100%; color: var(--bl-ink); font-family: var(--bl-font); }
7
+ .bl-score__label { display: flex; gap: 1.6em; font-size: calc(var(--bl-size) * 0.3); letter-spacing: 0.12em; color: var(--bl-muted); }
8
+ .bl-score__label b { color: var(--bl-high); font-weight: inherit; }
9
+ .bl-score__panel { position: relative; display: inline-flex; gap: calc(var(--bl-size) * 0.1); max-width: 100%; padding: calc(var(--bl-size) * 0.2); background: var(--bl-panel); box-shadow: 0 0 0 3px var(--bl-edge), 6px 6px 0 3px rgba(0,0,0,0.45); }
10
+ .bl-score__drum { position: relative; width: 0.8em; height: 1.2em; overflow: hidden; font-size: var(--bl-size); line-height: 1.2em; text-align: center; background: var(--bl-drum); box-shadow: inset 0 0.12em 0 rgba(0,0,0,0.45), inset 0 -0.08em 0 rgba(255,255,255,0.06); }
11
+ .bl-score__drum::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(rgba(0,0,0,0.45), transparent 30%, transparent 70%, rgba(0,0,0,0.45)); }
12
+ .bl-score__drum[data-lead] { color: var(--bl-dim); }
13
+ .bl-score__strip { display: block; transition: transform var(--bl-dur) cubic-bezier(.25,1.35,.5,1); }
14
+ .bl-score__strip > span { display: block; height: 1.2em; }
15
+ .bl-score__pops { position: absolute; left: 50%; top: 0; width: 0; pointer-events: none; }
16
+ .bl-score__pop { position: absolute; left: 0; bottom: 4px; white-space: nowrap; font-size: calc(var(--bl-size) * 0.36); color: var(--bl-accent); text-shadow: 2px 2px 0 rgba(0,0,0,0.6); animation: bl-score-pop 1100ms steps(12) forwards; }
17
+ .bl-score__pop em { margin-left: 0.6em; font-style: normal; color: var(--bl-combo); }
18
+ .bl-score__banner { min-height: 1.3em; font-size: calc(var(--bl-size) * 0.32); color: var(--bl-high); }
19
+ .bl-score__banner[data-show] { animation: bl-score-flash 0.5s steps(1) 6; }
20
+ .bl-score__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
21
+ @keyframes bl-score-pop { 0% { transform: translate(-50%, 10px); opacity: 0; } 15% { transform: translate(-50%, -4px); opacity: 1; } 100% { transform: translate(-50%, -44px); opacity: 0; } }
22
+ @keyframes bl-score-fade { 0%, 70% { transform: translate(-50%, -8px); opacity: 1; } 100% { transform: translate(-50%, -8px); opacity: 0; } }
23
+ @keyframes bl-score-flash { 50% { opacity: 0; } }
24
+ @media (prefers-reduced-motion: reduce) {
25
+ .bl-score__strip { transition: none; }
26
+ .bl-score__pop { animation: bl-score-fade 1100ms linear forwards; }
27
+ .bl-score__banner[data-show] { animation: none; }
28
+ }
29
+ `;
30
+ function useStyles() {
31
+ useInsertionEffect(() => {
32
+ if (typeof document === "undefined") return;
33
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
34
+ style.textContent = CSS;
35
+ if (!style.isConnected) document.head.appendChild(style);
36
+ }, []);
37
+ }
38
+ const STRIP = Array.from({ length: 30 }, (_, i) => i % 10);
39
+ const clampScore = (value, digits) => Math.max(0, Math.min(10 ** digits - 1, Math.floor(value || 0)));
40
+ const digitsOf = (value, digits) => String(value).padStart(digits, "0").split("").map(Number);
41
+ function ScoreTicker({
42
+ value = 0,
43
+ digits = 7,
44
+ label = "SCORE",
45
+ highScore,
46
+ combo = 1,
47
+ showPopups = true,
48
+ shakeAt = 1e3,
49
+ duration = 600,
50
+ size = 40,
51
+ textColor = "#f4f4f4",
52
+ dimColor = "#333c57",
53
+ mutedColor = "#94b0c2",
54
+ panelColor = "#1a1c2c",
55
+ edgeColor = "#566c86",
56
+ drumColor = "#0b0b14",
57
+ accentColor = "#ffcd75",
58
+ comboColor = "#ef7d57",
59
+ highColor = "#73eff7",
60
+ fontFamily = '"Press Start 2P", ui-monospace, monospace',
61
+ className = "",
62
+ style
63
+ }) {
64
+ useStyles();
65
+ const score = clampScore(value, digits);
66
+ const current = digitsOf(score, digits);
67
+ const [drums, setDrums] = useState(() => current.map((d) => ({ pos: 10 + d, still: false })));
68
+ const [pops, setPops] = useState([]);
69
+ const [newHigh, setNewHigh] = useState(false);
70
+ const [spoken, setSpoken] = useState(score);
71
+ const previous = useRef(score);
72
+ const panelRef = useRef(null);
73
+ const popId = useRef(0);
74
+ useLayoutEffect(() => {
75
+ const from = previous.current;
76
+ previous.current = score;
77
+ if (from === score) return;
78
+ const before = digitsOf(from, digits);
79
+ setDrums(
80
+ (list) => current.map((d, k) => {
81
+ const place = 10 ** (digits - 1 - k);
82
+ const turns = Math.floor(score / place) - Math.floor(from / place);
83
+ if (turns <= 0) return { pos: 10 + d, still: false };
84
+ const steps = (d - before[k] + 10) % 10;
85
+ const target = list[k].pos + steps;
86
+ return { pos: target > 29 ? target - 10 : target, still: false };
87
+ })
88
+ );
89
+ const gain = score - from;
90
+ if (gain > 0 && showPopups) {
91
+ popId.current += 1;
92
+ setPops((list) => [...list.slice(-4), { id: popId.current, gain, combo }]);
93
+ }
94
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
95
+ if (gain >= shakeAt && !reduced) {
96
+ panelRef.current?.animate(
97
+ [{ transform: "none" }, { transform: "translate(-3px, 2px)" }, { transform: "translate(3px, -2px)" }, { transform: "none" }],
98
+ { duration: 240, easing: "steps(3)" }
99
+ );
100
+ }
101
+ if (highScore != null && from <= highScore && score > highScore) setNewHigh(true);
102
+ if (highScore != null && score <= highScore) setNewHigh(false);
103
+ }, [score]);
104
+ useEffect(() => {
105
+ const timer = setTimeout(() => setSpoken(score), 700);
106
+ return () => clearTimeout(timer);
107
+ }, [score]);
108
+ const settle = (k) => {
109
+ setDrums((list) => list.map((drum, i) => i === k && drum.pos >= 20 ? { pos: drum.pos - 10, still: true } : drum));
110
+ requestAnimationFrame(
111
+ () => requestAnimationFrame(() => setDrums((list) => list.map((drum, i) => i === k && drum.still ? { ...drum, still: false } : drum)))
112
+ );
113
+ };
114
+ const firstNonZero = current.findIndex((d) => d !== 0);
115
+ const best = highScore != null ? Math.max(highScore, score) : null;
116
+ return /* @__PURE__ */ jsxs(
117
+ "div",
118
+ {
119
+ className: `bl-score ${className}`,
120
+ style: {
121
+ "--bl-size": `${size}px`,
122
+ "--bl-ink": textColor,
123
+ "--bl-dim": dimColor,
124
+ "--bl-muted": mutedColor,
125
+ "--bl-panel": panelColor,
126
+ "--bl-edge": edgeColor,
127
+ "--bl-drum": drumColor,
128
+ "--bl-accent": accentColor,
129
+ "--bl-combo": comboColor,
130
+ "--bl-high": highColor,
131
+ "--bl-dur": `${duration}ms`,
132
+ "--bl-font": fontFamily,
133
+ ...style
134
+ },
135
+ children: [
136
+ /* @__PURE__ */ jsxs("div", { className: "bl-score__label", "aria-hidden": "true", children: [
137
+ /* @__PURE__ */ jsx("span", { children: label }),
138
+ best != null && /* @__PURE__ */ jsxs("span", { children: [
139
+ "HI ",
140
+ /* @__PURE__ */ jsx("b", { children: String(best).padStart(digits, "0") })
141
+ ] })
142
+ ] }),
143
+ /* @__PURE__ */ jsxs("div", { ref: panelRef, className: "bl-score__panel", "aria-hidden": "true", children: [
144
+ drums.map((drum, k) => /* @__PURE__ */ jsx("span", { className: "bl-score__drum", "data-lead": (firstNonZero === -1 ? k < digits - 1 : k < firstNonZero) || void 0, children: /* @__PURE__ */ jsx(
145
+ "span",
146
+ {
147
+ className: "bl-score__strip",
148
+ style: { transform: `translateY(${-drum.pos * 1.2}em)`, transition: drum.still ? "none" : void 0 },
149
+ onTransitionEnd: () => settle(k),
150
+ children: STRIP.map((d, i) => /* @__PURE__ */ jsx("span", { children: d }, i))
151
+ }
152
+ ) }, k)),
153
+ /* @__PURE__ */ jsx("span", { className: "bl-score__pops", children: pops.map((pop) => /* @__PURE__ */ jsxs("span", { className: "bl-score__pop", onAnimationEnd: () => setPops((list) => list.filter((p) => p.id !== pop.id)), children: [
154
+ "+",
155
+ pop.gain.toLocaleString("en-US"),
156
+ pop.combo > 1 && /* @__PURE__ */ jsxs("em", { children: [
157
+ "\xD7",
158
+ pop.combo,
159
+ " COMBO"
160
+ ] })
161
+ ] }, pop.id)) })
162
+ ] }),
163
+ /* @__PURE__ */ jsx("div", { className: "bl-score__banner", "data-show": newHigh || void 0, "aria-hidden": "true", children: newHigh ? "NEW HIGH SCORE!" : "" }),
164
+ /* @__PURE__ */ jsxs("span", { className: "bl-score__sr", role: "status", children: [
165
+ label,
166
+ " ",
167
+ spoken.toLocaleString("en-US"),
168
+ newHigh ? ". New high score!" : ""
169
+ ] })
170
+ ]
171
+ }
172
+ );
173
+ }
174
+ export {
175
+ ScoreTicker as default
176
+ };
@@ -0,0 +1,24 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ type ScrollerDevice = 'laptop' | 'phone' | 'tablet';
3
+ export interface ScreenScrollerProps {
4
+ /** The page shown on the screen. Taller content scrolls further. */
5
+ children?: ReactNode;
6
+ /** Heading above the device; fades out as it rises. */
7
+ intro?: ReactNode;
8
+ device?: ScrollerDevice;
9
+ /** Section height: a number is vh, or pass any CSS length. */
10
+ scrollLength?: number | string;
11
+ /** Height of the sticky stage. Use the scroll box height when inside one. */
12
+ stageHeight?: string;
13
+ /** Starting tilt, in degrees. */
14
+ tilt?: number;
15
+ /** Share of the scroll spent rising flat before the screen scrolls (0–1). */
16
+ riseUntil?: number;
17
+ bodyColor?: string;
18
+ edgeColor?: string;
19
+ textColor?: string;
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ }
23
+ export default function ScreenScroller({ children, intro, device, scrollLength, stageHeight, tilt, riseUntil, bodyColor, edgeColor, textColor, className, style }: ScreenScrollerProps): import("react").JSX.Element;
24
+ export {};
@@ -0,0 +1,138 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef } from "react";
4
+ const STYLE_ID = "bl-screen-scroller";
5
+ const CSS = `
6
+ .bl-ss { position: relative; height: var(--bl-len); }
7
+ .bl-ss__stage { position: sticky; top: 0; height: var(--bl-stage); display: grid; place-items: center; overflow: hidden; perspective: 1400px; }
8
+ .bl-ss__intro { position: absolute; top: 9%; left: 0; right: 0; text-align: center; padding: 0 16px; color: var(--bl-ink); opacity: calc(1 - var(--bl-rise) * 1.6); transform: translateY(calc(var(--bl-rise) * -40px)); pointer-events: none; }
9
+ .bl-ss__device { position: relative; width: min(var(--bl-w), 92%); padding: var(--bl-bezel); border-radius: var(--bl-radius); background: var(--bl-body); box-shadow: inset 0 0 0 2px var(--bl-edge), 0 40px 80px -30px rgba(0,0,0,0.7); transform-origin: 50% 100%; transform: translateY(calc((1 - var(--bl-rise)) * 18%)) rotateX(calc((1 - var(--bl-rise)) * var(--bl-tilt))) scale(calc(0.82 + var(--bl-rise) * 0.18)); will-change: transform; }
10
+ .bl-ss__screen { position: relative; overflow: hidden; aspect-ratio: var(--bl-ratio); border-radius: var(--bl-screen-radius); background: #000; }
11
+ .bl-ss__content { position: absolute; top: 0; left: 0; right: 0; transform: translateY(calc(var(--bl-scroll) * var(--bl-travel) * -1px)); will-change: transform; }
12
+ .bl-ss__content > img { display: block; width: 100%; height: auto; }
13
+ .bl-ss__bar { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 3px; border-radius: 2px; background: rgba(255,255,255,0.12); opacity: var(--bl-rise); }
14
+ .bl-ss__thumb { position: absolute; left: 0; right: 0; height: 22%; border-radius: 2px; background: rgba(255,255,255,0.55); top: calc(var(--bl-scroll) * 78%); }
15
+ @media (prefers-reduced-motion: reduce) {
16
+ .bl-ss { height: auto; }
17
+ .bl-ss__stage { position: relative; height: auto; padding: 40px 0; }
18
+ .bl-ss__intro { position: static; opacity: 1; transform: none; margin-bottom: 24px; }
19
+ .bl-ss__device { transform: none; }
20
+ .bl-ss__screen { overflow: auto; }
21
+ .bl-ss__content { position: static; transform: none; }
22
+ .bl-ss__bar { display: none; }
23
+ }
24
+ `;
25
+ function useStyles() {
26
+ useInsertionEffect(() => {
27
+ if (typeof document === "undefined") return;
28
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
29
+ style.textContent = CSS;
30
+ if (!style.isConnected) document.head.appendChild(style);
31
+ }, []);
32
+ }
33
+ function scrollParent(node) {
34
+ for (let el = node?.parentElement; el; el = el.parentElement) {
35
+ const { overflowY } = getComputedStyle(el);
36
+ if (/(auto|scroll|overlay)/.test(overflowY) && el.scrollHeight > el.clientHeight) return el;
37
+ }
38
+ return window;
39
+ }
40
+ const clamp = (value) => Math.min(1, Math.max(0, value));
41
+ const DEVICES = {
42
+ laptop: { width: 760, ratio: "16 / 10", bezel: "14px 14px 22px", radius: "18px 18px 8px 8px", screenRadius: "4px" },
43
+ phone: { width: 300, ratio: "9 / 19", bezel: "12px", radius: "44px", screenRadius: "34px" },
44
+ tablet: { width: 520, ratio: "3 / 4", bezel: "18px", radius: "30px", screenRadius: "12px" }
45
+ };
46
+ function ScreenScroller({
47
+ children,
48
+ intro,
49
+ device = "laptop",
50
+ scrollLength = 300,
51
+ stageHeight = "100vh",
52
+ tilt = 38,
53
+ riseUntil = 0.35,
54
+ bodyColor = "#1f2230",
55
+ edgeColor = "#3a3f55",
56
+ textColor = "#f4f4f4",
57
+ className = "",
58
+ style
59
+ }) {
60
+ useStyles();
61
+ const rootRef = useRef(null);
62
+ const screenRef = useRef(null);
63
+ const contentRef = useRef(null);
64
+ const spec = DEVICES[device] ?? DEVICES.laptop;
65
+ useEffect(() => {
66
+ const root = rootRef.current;
67
+ const scroller = scrollParent(root);
68
+ let frame = 0;
69
+ const measureTravel = () => {
70
+ const travel = Math.max(0, contentRef.current.offsetHeight - screenRef.current.clientHeight);
71
+ root.style.setProperty("--bl-travel", String(travel));
72
+ };
73
+ const update = () => {
74
+ frame = 0;
75
+ const rect = root.getBoundingClientRect();
76
+ const viewTop = scroller === window ? 0 : scroller.getBoundingClientRect().top;
77
+ const viewHeight = scroller === window ? window.innerHeight : scroller.clientHeight;
78
+ const progress = clamp((viewTop - rect.top) / Math.max(1, rect.height - viewHeight));
79
+ const rise = clamp(progress / riseUntil);
80
+ const scroll = clamp((progress - riseUntil) / (1 - riseUntil));
81
+ root.style.setProperty("--bl-rise", rise.toFixed(4));
82
+ root.style.setProperty("--bl-scroll", scroll.toFixed(4));
83
+ };
84
+ const schedule = () => {
85
+ if (!frame) frame = requestAnimationFrame(update);
86
+ };
87
+ const resize = new ResizeObserver(() => {
88
+ measureTravel();
89
+ schedule();
90
+ });
91
+ resize.observe(contentRef.current);
92
+ resize.observe(screenRef.current);
93
+ measureTravel();
94
+ update();
95
+ scroller.addEventListener("scroll", schedule, { passive: true });
96
+ window.addEventListener("resize", schedule);
97
+ return () => {
98
+ cancelAnimationFrame(frame);
99
+ resize.disconnect();
100
+ scroller.removeEventListener("scroll", schedule);
101
+ window.removeEventListener("resize", schedule);
102
+ };
103
+ }, [riseUntil]);
104
+ return /* @__PURE__ */ jsx(
105
+ "section",
106
+ {
107
+ ref: rootRef,
108
+ className: `bl-ss ${className}`,
109
+ style: {
110
+ "--bl-len": typeof scrollLength === "number" ? `${scrollLength}vh` : scrollLength,
111
+ "--bl-stage": stageHeight,
112
+ "--bl-tilt": `${tilt}deg`,
113
+ "--bl-rise": 0,
114
+ "--bl-scroll": 0,
115
+ "--bl-travel": 0,
116
+ "--bl-w": `${spec.width}px`,
117
+ "--bl-ratio": spec.ratio,
118
+ "--bl-bezel": spec.bezel,
119
+ "--bl-radius": spec.radius,
120
+ "--bl-screen-radius": spec.screenRadius,
121
+ "--bl-body": bodyColor,
122
+ "--bl-edge": edgeColor,
123
+ "--bl-ink": textColor,
124
+ ...style
125
+ },
126
+ children: /* @__PURE__ */ jsxs("div", { className: "bl-ss__stage", children: [
127
+ intro && /* @__PURE__ */ jsx("div", { className: "bl-ss__intro", children: intro }),
128
+ /* @__PURE__ */ jsx("div", { className: "bl-ss__device", children: /* @__PURE__ */ jsxs("div", { ref: screenRef, className: "bl-ss__screen", tabIndex: 0, "aria-label": "Device screen preview", children: [
129
+ /* @__PURE__ */ jsx("div", { ref: contentRef, className: "bl-ss__content", children }),
130
+ /* @__PURE__ */ jsx("div", { className: "bl-ss__bar", "aria-hidden": "true", children: /* @__PURE__ */ jsx("div", { className: "bl-ss__thumb" }) })
131
+ ] }) })
132
+ ] })
133
+ }
134
+ );
135
+ }
136
+ export {
137
+ ScreenScroller as default
138
+ };
@@ -0,0 +1,31 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export interface ScreensaverProps {
3
+ /** What bounces; it takes the current colour (currentColor) on every wall. */
4
+ logo?: ReactNode;
5
+ /** Shown until the page has been idle for idleAfter ms (only when idleAfter > 0). */
6
+ children?: ReactNode;
7
+ /** 0 runs it always; otherwise it fades in after this many ms without input. */
8
+ idleAfter?: number;
9
+ /** Travel speed in px per second. */
10
+ speed?: number;
11
+ /** Colours cycled on each wall hit. */
12
+ colors?: string[];
13
+ /** How exact (in px) a corner hit must be. */
14
+ cornerTolerance?: number;
15
+ showCount?: boolean;
16
+ onCornerHit?: (count: number) => void;
17
+ height?: number | string;
18
+ radius?: number;
19
+ logoSize?: number;
20
+ backgroundColor?: string;
21
+ /** Behind the children in idle mode. */
22
+ contentColor?: string;
23
+ textColor?: string;
24
+ lineColor?: string;
25
+ fontFamily?: string;
26
+ /** Accessible name when always on. */
27
+ label?: string;
28
+ className?: string;
29
+ style?: CSSProperties;
30
+ }
31
+ export default function Screensaver({ logo, children, idleAfter, speed, colors, cornerTolerance, showCount, onCornerHit, height, radius, logoSize, backgroundColor, contentColor, textColor, lineColor, fontFamily, label, className, style }: ScreensaverProps): import("react").JSX.Element;
@@ -0,0 +1,221 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useInsertionEffect, useRef, useState } from "react";
4
+ const STYLE_ID = "bl-screensaver";
5
+ const CSS = `
6
+ .bl-saver { position: relative; box-sizing: border-box; width: 100%; height: var(--bl-h); overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-content-bg); box-shadow: 0 0 0 2px var(--bl-line); font-family: var(--bl-font); }
7
+ .bl-saver__content { height: 100%; }
8
+ .bl-saver__screen { position: absolute; inset: 0; overflow: hidden; background: var(--bl-bg); transition: opacity 600ms ease; }
9
+ .bl-saver[data-idle-mode]:not([data-idle]) .bl-saver__screen { opacity: 0; pointer-events: none; transition-duration: 150ms; }
10
+ .bl-saver__logo { position: absolute; top: 0; left: 0; display: grid; place-items: center; color: var(--bl-logo); font-size: var(--bl-logo-size); font-weight: 700; line-height: 1; white-space: nowrap; transition: color 120ms; will-change: transform; }
11
+ .bl-saver__logo svg, .bl-saver__logo img { display: block; }
12
+ .bl-saver__count { position: absolute; top: 10px; right: 12px; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,0.45); color: var(--bl-ink); font-size: 12px; font-variant-numeric: tabular-nums; }
13
+ .bl-saver__count[data-pop] { animation: bl-saver-pop 500ms steps(5); }
14
+ .bl-saver__spark { position: absolute; width: 8px; height: 8px; margin: -4px; background: var(--c); animation: bl-saver-spark 900ms cubic-bezier(.2,.8,.3,1) forwards; pointer-events: none; }
15
+ .bl-saver__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
16
+ @keyframes bl-saver-spark { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; } }
17
+ @keyframes bl-saver-pop { 50% { transform: scale(1.35); } }
18
+ @media (prefers-reduced-motion: reduce) { .bl-saver__spark { display: none; } .bl-saver__count[data-pop] { animation: none; } }
19
+ `;
20
+ function useStyles() {
21
+ useInsertionEffect(() => {
22
+ if (typeof document === "undefined") return;
23
+ const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
24
+ style.textContent = CSS;
25
+ if (!style.isConnected) document.head.appendChild(style);
26
+ }, []);
27
+ }
28
+ const PALETTE = ["#73eff7", "#a7f070", "#ffcd75", "#ef7d57", "#b13e53", "#41a6f6", "#f4f4f4"];
29
+ const ACTIVITY = ["pointermove", "pointerdown", "keydown", "wheel", "touchstart"];
30
+ function Screensaver({
31
+ logo = "BITS LAB",
32
+ children,
33
+ idleAfter = 0,
34
+ speed = 110,
35
+ colors = PALETTE,
36
+ cornerTolerance = 4,
37
+ showCount = true,
38
+ onCornerHit,
39
+ height = 320,
40
+ radius = 12,
41
+ logoSize = 34,
42
+ backgroundColor = "#0b0b14",
43
+ contentColor = "#1a1c2c",
44
+ textColor = "#f4f4f4",
45
+ lineColor = "#333c57",
46
+ fontFamily = '"Press Start 2P", ui-monospace, monospace',
47
+ label = "Screensaver",
48
+ className = "",
49
+ style
50
+ }) {
51
+ useStyles();
52
+ const rootRef = useRef(null);
53
+ const logoRef = useRef(null);
54
+ const countRef = useRef(null);
55
+ const hitRef = useRef(onCornerHit);
56
+ hitRef.current = onCornerHit;
57
+ const [idle, setIdle] = useState(idleAfter <= 0);
58
+ const [corners, setCorners] = useState(0);
59
+ const countValue = useRef(0);
60
+ const [bursts, setBursts] = useState([]);
61
+ const [announce, setAnnounce] = useState("");
62
+ useEffect(() => {
63
+ if (idleAfter <= 0) {
64
+ setIdle(true);
65
+ return void 0;
66
+ }
67
+ let timer = 0;
68
+ const reset = () => {
69
+ setIdle(false);
70
+ clearTimeout(timer);
71
+ timer = setTimeout(() => setIdle(true), idleAfter);
72
+ };
73
+ reset();
74
+ ACTIVITY.forEach((type) => window.addEventListener(type, reset, { passive: true }));
75
+ return () => {
76
+ clearTimeout(timer);
77
+ ACTIVITY.forEach((type) => window.removeEventListener(type, reset));
78
+ };
79
+ }, [idleAfter]);
80
+ useEffect(() => {
81
+ if (!idle) return void 0;
82
+ const root = rootRef.current;
83
+ const logoEl = logoRef.current;
84
+ const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
85
+ let colorIndex = 0;
86
+ const recolor = () => {
87
+ colorIndex = (colorIndex + 1) % colors.length;
88
+ logoEl.style.color = colors[colorIndex];
89
+ };
90
+ logoEl.style.color = colors[0];
91
+ if (reduced) {
92
+ const place = () => {
93
+ logoEl.style.transform = `translate(${(root.clientWidth - logoEl.offsetWidth) / 2}px, ${(root.clientHeight - logoEl.offsetHeight) / 2}px)`;
94
+ };
95
+ place();
96
+ const resize2 = new ResizeObserver(place);
97
+ resize2.observe(root);
98
+ const timer = setInterval(recolor, 4e3);
99
+ return () => {
100
+ resize2.disconnect();
101
+ clearInterval(timer);
102
+ };
103
+ }
104
+ const box = () => ({ w: Math.max(0, root.clientWidth - logoEl.offsetWidth), h: Math.max(0, root.clientHeight - logoEl.offsetHeight) });
105
+ let { w, h } = box();
106
+ const angle = Math.PI / 4 + (Math.random() - 0.5) * 0.5;
107
+ const p = { x: Math.random() * w, y: Math.random() * h, dx: Math.cos(angle), dy: Math.sin(angle) };
108
+ let visible = true;
109
+ let lastCorner = -Infinity;
110
+ let frame = 0;
111
+ let last = 0;
112
+ const celebrate = (x, y, now) => {
113
+ if (now - lastCorner < 600) return;
114
+ lastCorner = now;
115
+ countValue.current += 1;
116
+ const next = countValue.current;
117
+ setCorners(next);
118
+ setAnnounce(`Corner hit! ${next} so far.`);
119
+ hitRef.current?.(next);
120
+ const id = `${performance.now()}`;
121
+ const sparks = Array.from({ length: 14 }, (_, i) => {
122
+ const a = i / 14 * Math.PI * 2;
123
+ const dist = 50 + Math.random() * 60;
124
+ return { x, y, dx: Math.cos(a) * dist, dy: Math.sin(a) * dist, c: colors[i % colors.length] };
125
+ });
126
+ setBursts((list) => [...list.slice(-2), { id, sparks }]);
127
+ setTimeout(() => setBursts((list) => list.filter((b) => b.id !== id)), 950);
128
+ const count = countRef.current;
129
+ if (count) {
130
+ delete count.dataset.pop;
131
+ void count.offsetWidth;
132
+ count.dataset.pop = "";
133
+ }
134
+ };
135
+ const tick = (now) => {
136
+ const dt = Math.max(0, Math.min(0.05, (now - last) / 1e3));
137
+ last = now;
138
+ p.x += p.dx * speed * dt;
139
+ p.y += p.dy * speed * dt;
140
+ let hitX = false;
141
+ let hitY = false;
142
+ if (p.x <= 0 || p.x >= w) {
143
+ p.x = Math.max(0, Math.min(w, p.x));
144
+ p.dx = -p.dx;
145
+ hitX = true;
146
+ }
147
+ if (p.y <= 0 || p.y >= h) {
148
+ p.y = Math.max(0, Math.min(h, p.y));
149
+ p.dy = -p.dy;
150
+ hitY = true;
151
+ }
152
+ if (hitX || hitY) {
153
+ recolor();
154
+ const nearX = p.x <= cornerTolerance || p.x >= w - cornerTolerance;
155
+ const nearY = p.y <= cornerTolerance || p.y >= h - cornerTolerance;
156
+ if (nearX && nearY) celebrate(p.x < w / 2 ? 0 : root.clientWidth, p.y < h / 2 ? 0 : root.clientHeight, now);
157
+ }
158
+ logoEl.style.transform = `translate(${p.x.toFixed(1)}px, ${p.y.toFixed(1)}px)`;
159
+ frame = requestAnimationFrame(tick);
160
+ };
161
+ const start = () => {
162
+ if (frame || !visible || document.hidden) return;
163
+ last = performance.now();
164
+ frame = requestAnimationFrame(tick);
165
+ };
166
+ const stop = () => {
167
+ cancelAnimationFrame(frame);
168
+ frame = 0;
169
+ };
170
+ const observer = new IntersectionObserver(([entry]) => {
171
+ visible = entry.isIntersecting;
172
+ if (visible) start();
173
+ else stop();
174
+ });
175
+ observer.observe(root);
176
+ const resize = new ResizeObserver(() => {
177
+ ({ w, h } = box());
178
+ });
179
+ resize.observe(root);
180
+ resize.observe(logoEl);
181
+ const onVisibility = () => document.hidden ? stop() : start();
182
+ document.addEventListener("visibilitychange", onVisibility);
183
+ start();
184
+ return () => {
185
+ stop();
186
+ observer.disconnect();
187
+ resize.disconnect();
188
+ document.removeEventListener("visibilitychange", onVisibility);
189
+ };
190
+ }, [idle, speed, colors, cornerTolerance]);
191
+ const idleMode = idleAfter > 0;
192
+ return /* @__PURE__ */ jsxs(
193
+ "div",
194
+ {
195
+ ref: rootRef,
196
+ className: `bl-saver ${className}`,
197
+ "data-idle-mode": idleMode || void 0,
198
+ "data-idle": idle || void 0,
199
+ role: idleMode ? void 0 : "img",
200
+ "aria-label": idleMode ? void 0 : label,
201
+ style: { "--bl-h": typeof height === "number" ? `${height}px` : height, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-content-bg": contentColor, "--bl-ink": textColor, "--bl-line": lineColor, "--bl-logo": colors[0], "--bl-logo-size": `${logoSize}px`, "--bl-font": fontFamily, ...style },
202
+ children: [
203
+ idleMode && /* @__PURE__ */ jsx("div", { className: "bl-saver__content", children }),
204
+ /* @__PURE__ */ jsxs("div", { className: "bl-saver__screen", "aria-hidden": "true", children: [
205
+ /* @__PURE__ */ jsx("div", { ref: logoRef, className: "bl-saver__logo", children: logo }),
206
+ bursts.map(
207
+ (burst) => burst.sparks.map((s, i) => /* @__PURE__ */ jsx("span", { className: "bl-saver__spark", style: { left: s.x, top: s.y, "--dx": `${s.dx}px`, "--dy": `${s.dy}px`, "--c": s.c } }, `${burst.id}-${i}`))
208
+ ),
209
+ showCount && /* @__PURE__ */ jsxs("span", { ref: countRef, className: "bl-saver__count", children: [
210
+ "Corners: ",
211
+ corners
212
+ ] })
213
+ ] }),
214
+ /* @__PURE__ */ jsx("span", { className: "bl-saver__sr", "aria-live": "polite", children: announce })
215
+ ]
216
+ }
217
+ );
218
+ }
219
+ export {
220
+ Screensaver as default
221
+ };
@@ -0,0 +1,27 @@
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
+ export interface ScrollTiltProps {
3
+ /** The product shot: an image, video, device frame or live UI. */
4
+ children?: ReactNode;
5
+ /** Starting rotation, in degrees. */
6
+ tilt?: number;
7
+ /** Starting scale. */
8
+ scale?: number;
9
+ /** Starting downward offset, in px. */
10
+ lift?: number;
11
+ /** Viewport position (0 top, 1 bottom) of the card's top where the effect starts. */
12
+ start?: number;
13
+ /** Viewport position of the card's top where it is fully flat. */
14
+ end?: number;
15
+ /** 3D perspective, in px; lower is more dramatic. */
16
+ perspective?: number;
17
+ /** Light sweep across the card as it settles. */
18
+ shine?: boolean;
19
+ radius?: number;
20
+ borderWidth?: number;
21
+ borderColor?: string;
22
+ shineColor?: string;
23
+ shadowColor?: string;
24
+ className?: string;
25
+ style?: CSSProperties;
26
+ }
27
+ export default function ScrollTilt({ children, tilt, scale, lift, start, end, perspective, shine, radius, borderWidth, borderColor, shineColor, shadowColor, className, style }: ScrollTiltProps): import("react").JSX.Element;