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.
- package/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/Accordion.d.ts +52 -0
- package/dist/Accordion.js +192 -0
- package/dist/AchievementToast.d.ts +36 -0
- package/dist/AchievementToast.js +162 -0
- package/dist/AgentCard.d.ts +41 -0
- package/dist/AgentCard.js +168 -0
- package/dist/ArcadeButtons.d.ts +23 -0
- package/dist/ArcadeButtons.js +169 -0
- package/dist/AuroraBands.d.ts +19 -0
- package/dist/AuroraBands.js +126 -0
- package/dist/AvatarTooltips.d.ts +32 -0
- package/dist/AvatarTooltips.js +121 -0
- package/dist/BarRace.d.ts +39 -0
- package/dist/BarRace.js +227 -0
- package/dist/BentoGrid.d.ts +50 -0
- package/dist/BentoGrid.js +145 -0
- package/dist/BootSequence.d.ts +48 -0
- package/dist/BootSequence.js +234 -0
- package/dist/BreadcrumbTrail.d.ts +31 -0
- package/dist/BreadcrumbTrail.js +181 -0
- package/dist/CRTPower.d.ts +30 -0
- package/dist/CRTPower.js +142 -0
- package/dist/CardDeck.d.ts +29 -0
- package/dist/CardDeck.js +154 -0
- package/dist/ChangelogTimeline.d.ts +35 -0
- package/dist/ChangelogTimeline.js +137 -0
- package/dist/ChapterProgress.d.ts +23 -0
- package/dist/ChapterProgress.js +211 -0
- package/dist/ChatBubbles.d.ts +42 -0
- package/dist/ChatBubbles.js +198 -0
- package/dist/ChiptuneKit.d.ts +158 -0
- package/dist/ChiptuneKit.js +207 -0
- package/dist/CipherCard.d.ts +22 -0
- package/dist/CipherCard.js +91 -0
- package/dist/CloudSky.d.ts +28 -0
- package/dist/CloudSky.js +222 -0
- package/dist/CodeRain.d.ts +24 -0
- package/dist/CodeRain.js +158 -0
- package/dist/CodeShowcase.d.ts +50 -0
- package/dist/CodeShowcase.js +307 -0
- package/dist/ColorDial.d.ts +42 -0
- package/dist/ColorDial.js +288 -0
- package/dist/CommandPalette.d.ts +59 -0
- package/dist/CommandPalette.js +349 -0
- package/dist/CompareSlider.d.ts +33 -0
- package/dist/CompareSlider.js +152 -0
- package/dist/Confetti.d.ts +61 -0
- package/dist/Confetti.js +176 -0
- package/dist/ConnectBeams.d.ts +39 -0
- package/dist/ConnectBeams.js +132 -0
- package/dist/ContextOrb.d.ts +34 -0
- package/dist/ContextOrb.js +269 -0
- package/dist/ContourLines.d.ts +20 -0
- package/dist/ContourLines.js +159 -0
- package/dist/Coverflow.d.ts +27 -0
- package/dist/Coverflow.js +167 -0
- package/dist/CursorAttractor.d.ts +21 -0
- package/dist/CursorAttractor.js +136 -0
- package/dist/CutReveal.d.ts +21 -0
- package/dist/CutReveal.js +116 -0
- package/dist/DateRange.d.ts +45 -0
- package/dist/DateRange.js +327 -0
- package/dist/DeviceFrame.d.ts +30 -0
- package/dist/DeviceFrame.js +145 -0
- package/dist/DiffReveal.d.ts +36 -0
- package/dist/DiffReveal.js +247 -0
- package/dist/DirectionHover.d.ts +15 -0
- package/dist/DirectionHover.js +90 -0
- package/dist/Discard.d.ts +18 -0
- package/dist/Discard.js +61 -0
- package/dist/DitherField.d.ts +15 -0
- package/dist/DitherField.js +157 -0
- package/dist/DotGlobe.d.ts +48 -0
- package/dist/DotGlobe.js +312 -0
- package/dist/DotMap.d.ts +47 -0
- package/dist/DotMap.js +172 -0
- package/dist/DropZone.d.ts +57 -0
- package/dist/DropZone.js +304 -0
- package/dist/DynamicIsland.d.ts +32 -0
- package/dist/DynamicIsland.js +92 -0
- package/dist/EdgeFX.d.ts +27 -0
- package/dist/EdgeFX.js +98 -0
- package/dist/ElasticString.d.ts +22 -0
- package/dist/ElasticString.js +127 -0
- package/dist/ExpandCard.d.ts +44 -0
- package/dist/ExpandCard.js +182 -0
- package/dist/FeatureTabs.d.ts +34 -0
- package/dist/FeatureTabs.js +169 -0
- package/dist/FeedList.d.ts +37 -0
- package/dist/FeedList.js +163 -0
- package/dist/FlickerGrid.d.ts +29 -0
- package/dist/FlickerGrid.js +156 -0
- package/dist/FocusGrid.d.ts +20 -0
- package/dist/FocusGrid.js +48 -0
- package/dist/FocusPull.d.ts +26 -0
- package/dist/FocusPull.js +106 -0
- package/dist/Footprints.d.ts +24 -0
- package/dist/Footprints.js +126 -0
- package/dist/FunnelFlow.d.ts +34 -0
- package/dist/FunnelFlow.js +267 -0
- package/dist/GameOver.d.ts +46 -0
- package/dist/GameOver.js +191 -0
- package/dist/GaugeMeter.d.ts +38 -0
- package/dist/GaugeMeter.js +195 -0
- package/dist/GlassPanel.d.ts +27 -0
- package/dist/GlassPanel.js +80 -0
- package/dist/GrainFX.d.ts +34 -0
- package/dist/GrainFX.js +122 -0
- package/dist/GravityBox.d.ts +30 -0
- package/dist/GravityBox.js +220 -0
- package/dist/HealthBar.d.ts +33 -0
- package/dist/HealthBar.js +140 -0
- package/dist/Heatmap.d.ts +42 -0
- package/dist/Heatmap.js +232 -0
- package/dist/HexField.d.ts +29 -0
- package/dist/HexField.js +188 -0
- package/dist/HoldToConfirm.d.ts +29 -0
- package/dist/HoldToConfirm.js +163 -0
- package/dist/HorizontalTrack.d.ts +28 -0
- package/dist/HorizontalTrack.js +195 -0
- package/dist/HotbarDock.d.ts +40 -0
- package/dist/HotbarDock.js +148 -0
- package/dist/InkText.d.ts +27 -0
- package/dist/InkText.js +65 -0
- package/dist/InlineEdit.d.ts +30 -0
- package/dist/InlineEdit.js +198 -0
- package/dist/InteractiveGrid.d.ts +25 -0
- package/dist/InteractiveGrid.js +194 -0
- package/dist/InventoryGrid.d.ts +45 -0
- package/dist/InventoryGrid.js +272 -0
- package/dist/JellyBlob.d.ts +30 -0
- package/dist/JellyBlob.js +209 -0
- package/dist/KineticHeadline.d.ts +30 -0
- package/dist/KineticHeadline.js +133 -0
- package/dist/LavaLamp.d.ts +21 -0
- package/dist/LavaLamp.js +133 -0
- package/dist/LetterSwap.d.ts +20 -0
- package/dist/LetterSwap.js +78 -0
- package/dist/LevelMap.d.ts +35 -0
- package/dist/LevelMap.js +189 -0
- package/dist/LightShafts.d.ts +22 -0
- package/dist/LightShafts.js +170 -0
- package/dist/LightboxGallery.d.ts +26 -0
- package/dist/LightboxGallery.js +327 -0
- package/dist/LinkPeek.d.ts +36 -0
- package/dist/LinkPeek.js +194 -0
- package/dist/LogoOrbit.d.ts +37 -0
- package/dist/LogoOrbit.js +117 -0
- package/dist/Marquee.d.ts +33 -0
- package/dist/Marquee.js +148 -0
- package/dist/MarqueeLine.d.ts +33 -0
- package/dist/MarqueeLine.js +167 -0
- package/dist/MasonryWall.d.ts +13 -0
- package/dist/MasonryWall.js +90 -0
- package/dist/MegaMenu.d.ts +32 -0
- package/dist/MegaMenu.js +280 -0
- package/dist/MeteorShower.d.ts +24 -0
- package/dist/MeteorShower.js +155 -0
- package/dist/Minimap.d.ts +21 -0
- package/dist/Minimap.js +236 -0
- package/dist/MobileTabBar.d.ts +38 -0
- package/dist/MobileTabBar.js +148 -0
- package/dist/MorphDialog.d.ts +34 -0
- package/dist/MorphDialog.js +199 -0
- package/dist/MorphPopover.d.ts +33 -0
- package/dist/MorphPopover.js +168 -0
- package/dist/MorphWords.d.ts +18 -0
- package/dist/MorphWords.js +136 -0
- package/dist/OTPInput.d.ts +43 -0
- package/dist/OTPInput.js +174 -0
- package/dist/OverlayKit.d.ts +97 -0
- package/dist/OverlayKit.js +466 -0
- package/dist/OverlayMenu.d.ts +32 -0
- package/dist/OverlayMenu.js +154 -0
- package/dist/ParallaxCollage.d.ts +41 -0
- package/dist/ParallaxCollage.js +143 -0
- package/dist/PasswordMeter.d.ts +44 -0
- package/dist/PasswordMeter.js +165 -0
- package/dist/PegBoard.d.ts +26 -0
- package/dist/PegBoard.js +184 -0
- package/dist/PinCard.d.ts +21 -0
- package/dist/PinCard.js +84 -0
- package/dist/PixelAvatar.d.ts +33 -0
- package/dist/PixelAvatar.js +144 -0
- package/dist/PixelButton.d.ts +20 -0
- package/dist/PixelButton.js +128 -0
- package/dist/PixelExplode.d.ts +31 -0
- package/dist/PixelExplode.js +164 -0
- package/dist/PixelLoader.d.ts +32 -0
- package/dist/PixelLoader.js +142 -0
- package/dist/PixelParallax.d.ts +41 -0
- package/dist/PixelParallax.js +151 -0
- package/dist/PixelSpinners.d.ts +21 -0
- package/dist/PixelSpinners.js +110 -0
- package/dist/PixelType.d.ts +26 -0
- package/dist/PixelType.js +220 -0
- package/dist/PointerKit.d.ts +23 -0
- package/dist/PointerKit.js +222 -0
- package/dist/Polaroids.d.ts +41 -0
- package/dist/Polaroids.js +293 -0
- package/dist/PressStart.d.ts +28 -0
- package/dist/PressStart.js +99 -0
- package/dist/PricingFlip.d.ts +52 -0
- package/dist/PricingFlip.js +190 -0
- package/dist/ProximityType.d.ts +26 -0
- package/dist/ProximityType.js +135 -0
- package/dist/QuestDialog.d.ts +50 -0
- package/dist/QuestDialog.js +204 -0
- package/dist/QuestLog.d.ts +39 -0
- package/dist/QuestLog.js +214 -0
- package/dist/RangeDual.d.ts +34 -0
- package/dist/RangeDual.js +238 -0
- package/dist/RatingPips.d.ts +25 -0
- package/dist/RatingPips.js +129 -0
- package/dist/RetroHorizon.d.ts +27 -0
- package/dist/RetroHorizon.js +169 -0
- package/dist/Reveal.d.ts +30 -0
- package/dist/Reveal.js +92 -0
- package/dist/RingProgress.d.ts +45 -0
- package/dist/RingProgress.js +180 -0
- package/dist/RollingNumber.d.ts +28 -0
- package/dist/RollingNumber.js +108 -0
- package/dist/ScanScope.d.ts +24 -0
- package/dist/ScanScope.js +164 -0
- package/dist/ScoreTicker.d.ts +32 -0
- package/dist/ScoreTicker.js +176 -0
- package/dist/ScreenScroller.d.ts +24 -0
- package/dist/ScreenScroller.js +138 -0
- package/dist/Screensaver.d.ts +31 -0
- package/dist/Screensaver.js +221 -0
- package/dist/ScrollTilt.d.ts +27 -0
- package/dist/ScrollTilt.js +100 -0
- package/dist/ScrollTypography.d.ts +26 -0
- package/dist/ScrollTypography.js +124 -0
- package/dist/ScrollZoom.d.ts +31 -0
- package/dist/ScrollZoom.js +123 -0
- package/dist/ScrubNumber.d.ts +29 -0
- package/dist/ScrubNumber.js +152 -0
- package/dist/ShadowStack.d.ts +28 -0
- package/dist/ShadowStack.js +116 -0
- package/dist/SideRail.d.ts +43 -0
- package/dist/SideRail.js +253 -0
- package/dist/SignalText.d.ts +25 -0
- package/dist/SignalText.js +178 -0
- package/dist/SkeletonShimmer.d.ts +18 -0
- package/dist/SkeletonShimmer.js +111 -0
- package/dist/SketchHighlight.d.ts +27 -0
- package/dist/SketchHighlight.js +180 -0
- package/dist/SlideTabs.d.ts +40 -0
- package/dist/SlideTabs.js +190 -0
- package/dist/SmartNavbar.d.ts +48 -0
- package/dist/SmartNavbar.js +188 -0
- package/dist/SparkChart.d.ts +41 -0
- package/dist/SparkChart.js +188 -0
- package/dist/Spoiler.d.ts +22 -0
- package/dist/Spoiler.js +97 -0
- package/dist/SpotlightTour.d.ts +38 -0
- package/dist/SpotlightTour.js +231 -0
- package/dist/SpringDrawer.d.ts +39 -0
- package/dist/SpringDrawer.js +360 -0
- package/dist/SpriteAnimator.d.ts +41 -0
- package/dist/SpriteAnimator.js +124 -0
- package/dist/StatCard.d.ts +43 -0
- package/dist/StatCard.js +168 -0
- package/dist/StepLoader.d.ts +41 -0
- package/dist/StepLoader.js +191 -0
- package/dist/StepperForm.d.ts +41 -0
- package/dist/StepperForm.js +206 -0
- package/dist/StickerBoard.d.ts +39 -0
- package/dist/StickerBoard.js +209 -0
- package/dist/StickyReveal.d.ts +42 -0
- package/dist/StickyReveal.js +181 -0
- package/dist/StoryViewer.d.ts +36 -0
- package/dist/StoryViewer.js +175 -0
- package/dist/StreamingText.d.ts +29 -0
- package/dist/StreamingText.js +271 -0
- package/dist/SuggestionChips.d.ts +32 -0
- package/dist/SuggestionChips.js +96 -0
- package/dist/SwipeActions.d.ts +30 -0
- package/dist/SwipeActions.js +141 -0
- package/dist/TagInput.d.ts +30 -0
- package/dist/TagInput.js +284 -0
- package/dist/TallyUp.d.ts +38 -0
- package/dist/TallyUp.js +157 -0
- package/dist/TerminalDemo.d.ts +63 -0
- package/dist/TerminalDemo.js +214 -0
- package/dist/TestimonialWall.d.ts +35 -0
- package/dist/TestimonialWall.js +131 -0
- package/dist/TextOnPath.d.ts +36 -0
- package/dist/TextOnPath.js +130 -0
- package/dist/ThinkingShimmer.d.ts +36 -0
- package/dist/ThinkingShimmer.js +132 -0
- package/dist/ToastStack.d.ts +62 -0
- package/dist/ToastStack.js +289 -0
- package/dist/ToggleGroup.d.ts +39 -0
- package/dist/ToggleGroup.js +190 -0
- package/dist/ToggleKit.d.ts +70 -0
- package/dist/ToggleKit.js +229 -0
- package/dist/TracingLine.d.ts +24 -0
- package/dist/TracingLine.js +139 -0
- package/dist/TradingCard.d.ts +30 -0
- package/dist/TradingCard.js +147 -0
- package/dist/VanishInput.d.ts +34 -0
- package/dist/VanishInput.js +190 -0
- package/dist/VideoHero.d.ts +32 -0
- package/dist/VideoHero.js +207 -0
- package/dist/VoiceOrb.d.ts +23 -0
- package/dist/VoiceOrb.js +182 -0
- package/dist/VoxelTiles.d.ts +38 -0
- package/dist/VoxelTiles.js +201 -0
- package/dist/WarpField.d.ts +18 -0
- package/dist/WarpField.js +160 -0
- package/dist/WebcamPixels.d.ts +38 -0
- package/dist/WebcamPixels.js +292 -0
- package/dist/WheelPicker.d.ts +29 -0
- package/dist/WheelPicker.js +199 -0
- package/dist/WobbleCard.d.ts +23 -0
- package/dist/WobbleCard.js +112 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +159 -0
- package/package.json +58 -4
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-sticky-reveal";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-sreveal-wrap { container-type: inline-size; width: 100%; }
|
|
7
|
+
.bl-sreveal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--bl-gap); color: var(--bl-ink); font-family: var(--bl-font); }
|
|
8
|
+
.bl-sreveal[data-side="left"] .bl-sreveal__media { order: -1; }
|
|
9
|
+
.bl-sreveal__text { display: flex; flex-direction: column; }
|
|
10
|
+
.bl-sreveal__section { min-height: var(--bl-section); display: flex; flex-direction: column; justify-content: center; padding: 24px 0; opacity: 0.35; transition: opacity 400ms; }
|
|
11
|
+
.bl-sreveal__section[data-active] { opacity: 1; }
|
|
12
|
+
.bl-sreveal__index { color: var(--bl-accent); font-size: 12px; letter-spacing: 0.12em; margin-bottom: 10px; font-family: var(--bl-font-label); }
|
|
13
|
+
.bl-sreveal__title { margin: 0 0 12px; font-size: var(--bl-title-size); font-weight: 700; line-height: 1.25; font-family: var(--bl-font-title); }
|
|
14
|
+
.bl-sreveal__body { margin: 0; color: var(--bl-muted); line-height: 1.6; }
|
|
15
|
+
.bl-sreveal__inline { display: none; }
|
|
16
|
+
.bl-sreveal__media { position: relative; }
|
|
17
|
+
.bl-sreveal__sticky { position: sticky; top: var(--bl-top); height: var(--bl-stage); }
|
|
18
|
+
.bl-sreveal__frame { position: relative; height: 100%; overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-stage-bg); box-shadow: inset 0 0 0 1px var(--bl-line); }
|
|
19
|
+
.bl-sreveal__slide { position: absolute; inset: 0; opacity: 0; transition: opacity 600ms ease, transform 800ms cubic-bezier(.2,.8,.2,1), clip-path 700ms cubic-bezier(.7,0,.2,1); }
|
|
20
|
+
.bl-sreveal__slide > img, .bl-sreveal__slide > video, .bl-sreveal__inline > img, .bl-sreveal__inline > video { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
21
|
+
.bl-sreveal__slide[data-active] { opacity: 1; transform: none; }
|
|
22
|
+
.bl-sreveal[data-effect="zoom"] .bl-sreveal__slide { transform: scale(1.12); }
|
|
23
|
+
.bl-sreveal[data-effect="slide"] .bl-sreveal__slide { opacity: 1; clip-path: inset(100% 0 0 0); }
|
|
24
|
+
.bl-sreveal[data-effect="slide"] .bl-sreveal__slide[data-before] { clip-path: inset(0 0 0 0); }
|
|
25
|
+
.bl-sreveal[data-effect="slide"] .bl-sreveal__slide[data-active] { clip-path: inset(0 0 0 0); z-index: 1; }
|
|
26
|
+
.bl-sreveal__dots { position: absolute; right: 14px; top: 50%; z-index: 2; display: grid; gap: 8px; transform: translateY(-50%); }
|
|
27
|
+
.bl-sreveal__dot { width: 8px; height: 8px; border-radius: var(--bl-dot-radius); background: rgba(255,255,255,0.35); transition: background-color 200ms, transform 200ms; }
|
|
28
|
+
.bl-sreveal__dot[data-active] { background: var(--bl-accent); transform: scale(1.4); }
|
|
29
|
+
@container (max-width: 640px) {
|
|
30
|
+
.bl-sreveal { grid-template-columns: minmax(0, 1fr); }
|
|
31
|
+
.bl-sreveal__media { display: none; }
|
|
32
|
+
.bl-sreveal__section { min-height: 0; opacity: 1; padding: 20px 0 28px; }
|
|
33
|
+
.bl-sreveal__inline { display: block; aspect-ratio: 4 / 3; margin-bottom: 16px; overflow: hidden; border-radius: var(--bl-radius); }
|
|
34
|
+
}
|
|
35
|
+
@media (prefers-reduced-motion: reduce) {
|
|
36
|
+
.bl-sreveal__slide, .bl-sreveal__section { transition: none; }
|
|
37
|
+
.bl-sreveal[data-effect] .bl-sreveal__slide { transform: none; clip-path: none; }
|
|
38
|
+
.bl-sreveal[data-effect] .bl-sreveal__slide:not([data-active]) { opacity: 0; }
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
function useStyles() {
|
|
42
|
+
useInsertionEffect(() => {
|
|
43
|
+
if (typeof document === "undefined") return;
|
|
44
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
45
|
+
style.textContent = CSS;
|
|
46
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
47
|
+
}, []);
|
|
48
|
+
}
|
|
49
|
+
function scrollParent(node) {
|
|
50
|
+
for (let el = node?.parentElement; el; el = el.parentElement) {
|
|
51
|
+
if (/(auto|scroll|overlay)/.test(getComputedStyle(el).overflowY) && el.scrollHeight > el.clientHeight) return el;
|
|
52
|
+
}
|
|
53
|
+
return window;
|
|
54
|
+
}
|
|
55
|
+
function StickyReveal({
|
|
56
|
+
sections = [],
|
|
57
|
+
effect = "fade",
|
|
58
|
+
mediaSide = "right",
|
|
59
|
+
sectionHeight = "80vh",
|
|
60
|
+
stageHeight = "70vh",
|
|
61
|
+
stickyTop = "15vh",
|
|
62
|
+
activeLine = 0.5,
|
|
63
|
+
onChange,
|
|
64
|
+
showDots = true,
|
|
65
|
+
gap = 48,
|
|
66
|
+
radius = 16,
|
|
67
|
+
textColor = "#f4f4f4",
|
|
68
|
+
mutedColor = "#94b0c2",
|
|
69
|
+
accentColor = "#ffcd75",
|
|
70
|
+
stageColor = "#1a1c2c",
|
|
71
|
+
lineColor = "rgba(255,255,255,0.08)",
|
|
72
|
+
titleSize = 26,
|
|
73
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
74
|
+
titleFontFamily,
|
|
75
|
+
labelFontFamily,
|
|
76
|
+
className = "",
|
|
77
|
+
style
|
|
78
|
+
}) {
|
|
79
|
+
useStyles();
|
|
80
|
+
const rootRef = useRef(null);
|
|
81
|
+
const sectionRefs = useRef([]);
|
|
82
|
+
const [active, setActive] = useState(0);
|
|
83
|
+
const onChangeRef = useRef(onChange);
|
|
84
|
+
onChangeRef.current = onChange;
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const scroller = scrollParent(rootRef.current);
|
|
87
|
+
let frame = 0;
|
|
88
|
+
let current = -1;
|
|
89
|
+
const update = () => {
|
|
90
|
+
frame = 0;
|
|
91
|
+
const viewTop = scroller === window ? 0 : scroller.getBoundingClientRect().top;
|
|
92
|
+
const viewHeight = scroller === window ? window.innerHeight : scroller.clientHeight;
|
|
93
|
+
const line = viewTop + viewHeight * activeLine;
|
|
94
|
+
let next = 0;
|
|
95
|
+
sectionRefs.current.forEach((node, index) => {
|
|
96
|
+
if (node && node.getBoundingClientRect().top <= line) next = index;
|
|
97
|
+
});
|
|
98
|
+
if (next !== current) {
|
|
99
|
+
current = next;
|
|
100
|
+
setActive(next);
|
|
101
|
+
onChangeRef.current?.(next);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const schedule = () => {
|
|
105
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
106
|
+
};
|
|
107
|
+
update();
|
|
108
|
+
scroller.addEventListener("scroll", schedule, { passive: true });
|
|
109
|
+
window.addEventListener("resize", schedule);
|
|
110
|
+
return () => {
|
|
111
|
+
cancelAnimationFrame(frame);
|
|
112
|
+
scroller.removeEventListener("scroll", schedule);
|
|
113
|
+
window.removeEventListener("resize", schedule);
|
|
114
|
+
};
|
|
115
|
+
}, [activeLine, sections.length]);
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: `bl-sreveal-wrap ${className}`, style, children: /* @__PURE__ */ jsxs(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
ref: rootRef,
|
|
120
|
+
className: "bl-sreveal",
|
|
121
|
+
"data-effect": effect,
|
|
122
|
+
"data-side": mediaSide,
|
|
123
|
+
style: {
|
|
124
|
+
"--bl-gap": `${gap}px`,
|
|
125
|
+
"--bl-section": sectionHeight,
|
|
126
|
+
"--bl-stage": stageHeight,
|
|
127
|
+
"--bl-top": stickyTop,
|
|
128
|
+
"--bl-radius": `${radius}px`,
|
|
129
|
+
"--bl-dot-radius": radius ? "50%" : "0",
|
|
130
|
+
"--bl-ink": textColor,
|
|
131
|
+
"--bl-muted": mutedColor,
|
|
132
|
+
"--bl-accent": accentColor,
|
|
133
|
+
"--bl-stage-bg": stageColor,
|
|
134
|
+
"--bl-line": lineColor,
|
|
135
|
+
"--bl-title-size": `${titleSize}px`,
|
|
136
|
+
"--bl-font": fontFamily,
|
|
137
|
+
"--bl-font-title": titleFontFamily ?? fontFamily,
|
|
138
|
+
"--bl-font-label": labelFontFamily ?? fontFamily
|
|
139
|
+
},
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx("div", { className: "bl-sreveal__text", children: sections.map((section, index) => /* @__PURE__ */ jsxs(
|
|
142
|
+
"section",
|
|
143
|
+
{
|
|
144
|
+
ref: (node) => {
|
|
145
|
+
sectionRefs.current[index] = node;
|
|
146
|
+
},
|
|
147
|
+
className: "bl-sreveal__section",
|
|
148
|
+
"data-active": index === active ? "" : void 0,
|
|
149
|
+
children: [
|
|
150
|
+
section.media && /* @__PURE__ */ jsx("div", { className: "bl-sreveal__inline", "aria-hidden": "true", children: section.media }),
|
|
151
|
+
/* @__PURE__ */ jsxs("div", { className: "bl-sreveal__index", children: [
|
|
152
|
+
String(index + 1).padStart(2, "0"),
|
|
153
|
+
" / ",
|
|
154
|
+
String(sections.length).padStart(2, "0")
|
|
155
|
+
] }),
|
|
156
|
+
section.title && /* @__PURE__ */ jsx("h3", { className: "bl-sreveal__title", children: section.title }),
|
|
157
|
+
typeof section.body === "string" ? /* @__PURE__ */ jsx("p", { className: "bl-sreveal__body", children: section.body }) : section.body
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
section.id ?? index
|
|
161
|
+
)) }),
|
|
162
|
+
/* @__PURE__ */ jsx("div", { className: "bl-sreveal__media", "aria-hidden": "true", children: /* @__PURE__ */ jsx("div", { className: "bl-sreveal__sticky", children: /* @__PURE__ */ jsxs("div", { className: "bl-sreveal__frame", children: [
|
|
163
|
+
sections.map((section, index) => /* @__PURE__ */ jsx(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
className: "bl-sreveal__slide",
|
|
167
|
+
"data-active": index === active ? "" : void 0,
|
|
168
|
+
"data-before": index < active ? "" : void 0,
|
|
169
|
+
children: section.media
|
|
170
|
+
},
|
|
171
|
+
section.id ?? index
|
|
172
|
+
)),
|
|
173
|
+
showDots && sections.length > 1 && /* @__PURE__ */ jsx("div", { className: "bl-sreveal__dots", children: sections.map((section, index) => /* @__PURE__ */ jsx("span", { className: "bl-sreveal__dot", "data-active": index === active ? "" : void 0 }, section.id ?? index)) })
|
|
174
|
+
] }) }) })
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
) });
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
StickyReveal as default
|
|
181
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface StorySlide {
|
|
3
|
+
/** An image or video URL. */
|
|
4
|
+
src?: string;
|
|
5
|
+
type?: 'image' | 'video';
|
|
6
|
+
/** Any content instead of src. */
|
|
7
|
+
content?: ReactNode;
|
|
8
|
+
alt?: string;
|
|
9
|
+
caption?: ReactNode;
|
|
10
|
+
/** Overrides the default slide time (videos use their own length). */
|
|
11
|
+
duration?: number;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export interface StoryViewerProps {
|
|
15
|
+
slides?: StorySlide[];
|
|
16
|
+
author?: string;
|
|
17
|
+
avatar?: ReactNode;
|
|
18
|
+
timestamp?: string;
|
|
19
|
+
/** Default slide time in ms. */
|
|
20
|
+
duration?: number;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
startAt?: number;
|
|
23
|
+
onChange?: (index: number) => void;
|
|
24
|
+
onEnd?: () => void;
|
|
25
|
+
/** Press length (ms) that counts as hold-to-pause rather than a tap. */
|
|
26
|
+
holdDelay?: number;
|
|
27
|
+
width?: number;
|
|
28
|
+
radius?: number;
|
|
29
|
+
backgroundColor?: string;
|
|
30
|
+
accentColor?: string;
|
|
31
|
+
fontFamily?: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
className?: string;
|
|
34
|
+
style?: CSSProperties;
|
|
35
|
+
}
|
|
36
|
+
export default function StoryViewer({ slides, author, avatar, timestamp, duration, loop, startAt, onChange, onEnd, holdDelay, width, radius, backgroundColor, accentColor, fontFamily, label, className, style }: StoryViewerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-story-viewer";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-story { position: relative; width: var(--bl-w); max-width: 100%; aspect-ratio: 9 / 16; overflow: hidden; border-radius: var(--bl-radius); background: var(--bl-bg); color: #fff; font-family: var(--bl-font); user-select: none; -webkit-user-select: none; touch-action: manipulation; outline: none; }
|
|
7
|
+
.bl-story:focus-visible { box-shadow: 0 0 0 3px var(--bl-accent); }
|
|
8
|
+
.bl-story__slide { position: absolute; inset: 0; display: grid; place-items: center; animation: bl-story-in 260ms ease both; }
|
|
9
|
+
.bl-story__slide > img, .bl-story__slide > video { width: 100%; height: 100%; object-fit: cover; }
|
|
10
|
+
.bl-story__shade { position: absolute; inset: 0 0 auto; height: 120px; background: linear-gradient(rgba(0,0,0,0.55), transparent); pointer-events: none; }
|
|
11
|
+
.bl-story__bars { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 2; display: flex; gap: 4px; }
|
|
12
|
+
.bl-story__bar { flex: 1; height: 3px; overflow: hidden; border-radius: 3px; background: rgba(255,255,255,0.35); }
|
|
13
|
+
.bl-story__bar i { display: block; height: 100%; width: 100%; background: #fff; transform-origin: left; transform: scaleX(var(--p, 0)); }
|
|
14
|
+
.bl-story__head { position: absolute; top: 22px; left: 12px; right: 12px; z-index: 2; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
|
|
15
|
+
.bl-story__avatar { display: grid; place-items: center; width: 32px; height: 32px; overflow: hidden; border-radius: 50%; box-shadow: 0 0 0 2px #fff; }
|
|
16
|
+
.bl-story__avatar img { width: 100%; height: 100%; object-fit: cover; }
|
|
17
|
+
.bl-story__time { color: rgba(255,255,255,0.75); font-weight: 400; }
|
|
18
|
+
.bl-story__pause { margin-left: auto; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: rgba(0,0,0,0.25); color: #fff; cursor: pointer; }
|
|
19
|
+
.bl-story__pause:focus-visible { outline: 2px solid #fff; }
|
|
20
|
+
.bl-story__caption { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 40px 16px 18px; background: linear-gradient(transparent, rgba(0,0,0,0.65)); font-size: 15px; line-height: 1.45; text-shadow: 0 1px 3px rgba(0,0,0,0.5); pointer-events: none; }
|
|
21
|
+
.bl-story__zones { position: absolute; inset: 0; z-index: 1; display: grid; grid-template-columns: 1fr 2fr; }
|
|
22
|
+
.bl-story__zones > span { cursor: pointer; }
|
|
23
|
+
.bl-story[data-held] .bl-story__head, .bl-story[data-held] .bl-story__bars, .bl-story[data-held] .bl-story__caption { opacity: 0; transition: opacity 200ms; }
|
|
24
|
+
.bl-story__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
25
|
+
@keyframes bl-story-in { from { opacity: 0.4; transform: scale(1.02); } }
|
|
26
|
+
@media (prefers-reduced-motion: reduce) { .bl-story__slide { animation: none; } }
|
|
27
|
+
`;
|
|
28
|
+
function useStyles() {
|
|
29
|
+
useInsertionEffect(() => {
|
|
30
|
+
if (typeof document === "undefined") return;
|
|
31
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
32
|
+
style.textContent = CSS;
|
|
33
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
34
|
+
}, []);
|
|
35
|
+
}
|
|
36
|
+
function StoryViewer({
|
|
37
|
+
slides = [],
|
|
38
|
+
author,
|
|
39
|
+
avatar,
|
|
40
|
+
timestamp,
|
|
41
|
+
duration = 5e3,
|
|
42
|
+
loop = false,
|
|
43
|
+
startAt = 0,
|
|
44
|
+
onChange,
|
|
45
|
+
onEnd,
|
|
46
|
+
holdDelay = 180,
|
|
47
|
+
width = 320,
|
|
48
|
+
radius = 20,
|
|
49
|
+
backgroundColor = "#0b0b14",
|
|
50
|
+
accentColor = "#73eff7",
|
|
51
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
52
|
+
label = "Story",
|
|
53
|
+
className = "",
|
|
54
|
+
style
|
|
55
|
+
}) {
|
|
56
|
+
useStyles();
|
|
57
|
+
const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
58
|
+
const [index, setIndex] = useState(startAt);
|
|
59
|
+
const [paused, setPaused] = useState(false);
|
|
60
|
+
const [held, setHeld] = useState(false);
|
|
61
|
+
const [ended, setEnded] = useState(false);
|
|
62
|
+
const barsRef = useRef(null);
|
|
63
|
+
const videoRef = useRef(null);
|
|
64
|
+
const progress = useRef(0);
|
|
65
|
+
const holdTimer = useRef(0);
|
|
66
|
+
const holding = useRef(false);
|
|
67
|
+
const indexRef = useRef(index);
|
|
68
|
+
indexRef.current = index;
|
|
69
|
+
const slide = slides[index];
|
|
70
|
+
const total = slides.length;
|
|
71
|
+
const go = (next) => {
|
|
72
|
+
if (next < 0) next = 0;
|
|
73
|
+
if (next >= total) {
|
|
74
|
+
if (loop) next = 0;
|
|
75
|
+
else {
|
|
76
|
+
setEnded(true);
|
|
77
|
+
onEnd?.();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
progress.current = 0;
|
|
82
|
+
indexRef.current = next;
|
|
83
|
+
setEnded(false);
|
|
84
|
+
setIndex(next);
|
|
85
|
+
onChange?.(next);
|
|
86
|
+
};
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const bars = barsRef.current?.children;
|
|
89
|
+
if (!bars) return void 0;
|
|
90
|
+
[...bars].forEach((bar2, i) => bar2.firstElementChild?.style.setProperty("--p", i < index ? "1" : i > index ? "0" : String(progress.current)));
|
|
91
|
+
if (ended) return void 0;
|
|
92
|
+
const bar = bars[index]?.firstElementChild;
|
|
93
|
+
const length = slide?.duration ?? duration;
|
|
94
|
+
let frame = 0;
|
|
95
|
+
let last = performance.now();
|
|
96
|
+
const tick = (now) => {
|
|
97
|
+
const dt = now - last;
|
|
98
|
+
last = now;
|
|
99
|
+
const video = videoRef.current;
|
|
100
|
+
if (!paused && !held && !document.hidden) {
|
|
101
|
+
progress.current = video && video.duration ? video.currentTime / video.duration : Math.min(1, progress.current + dt / length);
|
|
102
|
+
}
|
|
103
|
+
bar?.style.setProperty("--p", String(progress.current));
|
|
104
|
+
if (progress.current >= 1) go(index + 1);
|
|
105
|
+
else frame = requestAnimationFrame(tick);
|
|
106
|
+
};
|
|
107
|
+
frame = requestAnimationFrame(tick);
|
|
108
|
+
return () => cancelAnimationFrame(frame);
|
|
109
|
+
}, [index, paused, held, ended, duration, total]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const video = videoRef.current;
|
|
112
|
+
if (!video) return;
|
|
113
|
+
if (paused || held) video.pause();
|
|
114
|
+
else video.play?.().catch(() => {
|
|
115
|
+
});
|
|
116
|
+
}, [paused, held, index]);
|
|
117
|
+
const onPointerDown = () => {
|
|
118
|
+
clearTimeout(holdTimer.current);
|
|
119
|
+
holding.current = false;
|
|
120
|
+
holdTimer.current = setTimeout(() => {
|
|
121
|
+
holding.current = true;
|
|
122
|
+
setHeld(true);
|
|
123
|
+
}, holdDelay);
|
|
124
|
+
};
|
|
125
|
+
const onPointerUp = (direction) => {
|
|
126
|
+
clearTimeout(holdTimer.current);
|
|
127
|
+
if (holding.current) {
|
|
128
|
+
holding.current = false;
|
|
129
|
+
setHeld(false);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
go(indexRef.current + direction);
|
|
133
|
+
};
|
|
134
|
+
const onKeyDown = (event) => {
|
|
135
|
+
if (event.key === "ArrowRight") go(indexRef.current + 1);
|
|
136
|
+
else if (event.key === "ArrowLeft") go(indexRef.current - 1);
|
|
137
|
+
else if (event.key === " ") setPaused((p) => !p);
|
|
138
|
+
else return;
|
|
139
|
+
event.preventDefault();
|
|
140
|
+
};
|
|
141
|
+
useEffect(() => () => clearTimeout(holdTimer.current), []);
|
|
142
|
+
const media = slide?.src ? slide.type === "video" || /\.(mp4|webm|mov)$/i.test(slide.src) ? /* @__PURE__ */ jsx("video", { ref: videoRef, src: slide.src, muted: true, playsInline: true, autoPlay: true, "aria-label": slide.alt ?? "" }) : /* @__PURE__ */ jsx("img", { src: slide.src, alt: slide.alt ?? "", draggable: false, style: slide.style }) : slide?.content;
|
|
143
|
+
return /* @__PURE__ */ jsxs(
|
|
144
|
+
"section",
|
|
145
|
+
{
|
|
146
|
+
className: `bl-story ${className}`,
|
|
147
|
+
"aria-roledescription": "story",
|
|
148
|
+
"aria-label": author ? `${label} by ${author}` : label,
|
|
149
|
+
tabIndex: 0,
|
|
150
|
+
onKeyDown,
|
|
151
|
+
"data-held": held || void 0,
|
|
152
|
+
style: { "--bl-w": `${width}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-accent": accentColor, "--bl-font": fontFamily, ...style },
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx("div", { className: "bl-story__slide", children: media }, index),
|
|
155
|
+
/* @__PURE__ */ jsx("div", { className: "bl-story__shade", "aria-hidden": "true" }),
|
|
156
|
+
/* @__PURE__ */ jsx("div", { ref: barsRef, className: "bl-story__bars", "aria-hidden": "true", children: slides.map((_, i) => /* @__PURE__ */ jsx("span", { className: "bl-story__bar", children: /* @__PURE__ */ jsx("i", {}) }, i)) }),
|
|
157
|
+
/* @__PURE__ */ jsxs("div", { className: "bl-story__zones", "aria-hidden": "true", children: [
|
|
158
|
+
/* @__PURE__ */ jsx("span", { onPointerDown, onPointerUp: () => onPointerUp(-1), onPointerLeave: () => holding.current && onPointerUp(0) }),
|
|
159
|
+
/* @__PURE__ */ jsx("span", { onPointerDown, onPointerUp: () => onPointerUp(1), onPointerLeave: () => holding.current && onPointerUp(0) })
|
|
160
|
+
] }),
|
|
161
|
+
/* @__PURE__ */ jsxs("div", { className: "bl-story__head", children: [
|
|
162
|
+
avatar && /* @__PURE__ */ jsx("span", { className: "bl-story__avatar", "aria-hidden": "true", children: typeof avatar === "string" ? /* @__PURE__ */ jsx("img", { src: avatar, alt: "" }) : avatar }),
|
|
163
|
+
author && /* @__PURE__ */ jsx("span", { children: author }),
|
|
164
|
+
timestamp && /* @__PURE__ */ jsx("span", { className: "bl-story__time", children: timestamp }),
|
|
165
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "bl-story__pause", "aria-label": paused ? "Play story" : "Pause story", onClick: () => setPaused((p) => !p), children: /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "currentColor", "aria-hidden": "true", children: paused ? /* @__PURE__ */ jsx("path", { d: "M3 1.5v9l7.5-4.5z" }) : /* @__PURE__ */ jsx("path", { d: "M2.5 1.5h2.5v9H2.5zM7 1.5h2.5v9H7z" }) }) })
|
|
166
|
+
] }),
|
|
167
|
+
slide?.caption && /* @__PURE__ */ jsx("div", { className: "bl-story__caption", children: slide.caption }),
|
|
168
|
+
/* @__PURE__ */ jsx("p", { className: "bl-story__sr", "aria-live": "polite", id: `${uid}-status`, children: ended ? "End of story." : `Slide ${index + 1} of ${total}${slide?.alt ? `: ${slide.alt}` : ""}${slide?.caption && typeof slide.caption === "string" ? `. ${slide.caption}` : ""}` })
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
StoryViewer as default
|
|
175
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export interface StreamingTextProps {
|
|
3
|
+
/** Full text to stream word by word at `speed`. */
|
|
4
|
+
text?: string;
|
|
5
|
+
/** A real token stream; chunks appear as they arrive. */
|
|
6
|
+
stream?: AsyncIterable<string>;
|
|
7
|
+
/** Characters per second when streaming `text`. */
|
|
8
|
+
speed?: number;
|
|
9
|
+
/** Render the markdown subset. */
|
|
10
|
+
markdown?: boolean;
|
|
11
|
+
showCursor?: boolean;
|
|
12
|
+
/** Fade-in length of new chunks, in ms. */
|
|
13
|
+
fadeDuration?: number;
|
|
14
|
+
/** How many recent chunks are still fading. */
|
|
15
|
+
tail?: number;
|
|
16
|
+
onDone?: () => void;
|
|
17
|
+
fontSize?: number;
|
|
18
|
+
textColor?: string;
|
|
19
|
+
mutedColor?: string;
|
|
20
|
+
lineColor?: string;
|
|
21
|
+
codeBackground?: string;
|
|
22
|
+
accentColor?: string;
|
|
23
|
+
cursorColor?: string;
|
|
24
|
+
fontFamily?: string;
|
|
25
|
+
monoFontFamily?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
export default function StreamingText({ text, stream, speed, markdown, showCursor, fadeDuration, tail, onDone, fontSize, textColor, mutedColor, lineColor, codeBackground, accentColor, cursorColor, fontFamily, monoFontFamily, className, style }: StreamingTextProps): import("react").JSX.Element;
|