bits-lab 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +51 -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 +34 -4
package/dist/FeedList.js
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-feed-list";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-feed { margin: 0; padding: 6px; list-style: none; width: 100%; max-width: var(--bl-w); max-height: var(--bl-max-h); overflow-y: auto; box-sizing: border-box; border-radius: var(--bl-radius); background: var(--bl-bg); font-family: var(--bl-font); color: var(--bl-ink); box-shadow: inset 0 0 0 1px var(--bl-line); outline: none; }
|
|
7
|
+
.bl-feed:focus-visible { box-shadow: inset 0 0 0 2px var(--bl-accent); }
|
|
8
|
+
.bl-feed__item { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 280ms cubic-bezier(.3,.8,.3,1), opacity 220ms; }
|
|
9
|
+
.bl-feed__item[data-leaving] { grid-template-rows: 0fr; opacity: 0; }
|
|
10
|
+
.bl-feed__row { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 12px; min-height: 0; overflow: hidden; padding: 10px 12px; border-radius: 10px; }
|
|
11
|
+
.bl-feed__item[data-new] .bl-feed__row { animation: bl-feed-in 420ms cubic-bezier(.2,.9,.3,1.2) both; }
|
|
12
|
+
.bl-feed__item[data-selectable] .bl-feed__row { cursor: pointer; }
|
|
13
|
+
.bl-feed__item[data-selectable]:hover .bl-feed__row { background: var(--bl-hover); }
|
|
14
|
+
.bl-feed__item[data-active] .bl-feed__row { background: var(--bl-hover); box-shadow: inset 3px 0 0 var(--bl-accent); }
|
|
15
|
+
.bl-feed__icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--bl-chip); color: var(--tone, var(--bl-accent)); }
|
|
16
|
+
.bl-feed__text { display: grid; gap: 2px; min-width: 0; }
|
|
17
|
+
.bl-feed__title { font-size: 14px; font-weight: 600; line-height: 1.35; }
|
|
18
|
+
.bl-feed__body { color: var(--bl-muted); font-size: 13px; line-height: 1.4; }
|
|
19
|
+
.bl-feed__time { color: var(--bl-muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
20
|
+
.bl-feed__empty { padding: 18px 12px; color: var(--bl-muted); font-size: 14px; text-align: center; }
|
|
21
|
+
.bl-feed__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
22
|
+
@keyframes bl-feed-in { 0% { opacity: 0; transform: translateY(-10px); background: var(--bl-flash); } 60% { background: var(--bl-flash); } }
|
|
23
|
+
@media (prefers-reduced-motion: reduce) { .bl-feed__item { transition: none; } .bl-feed__item[data-new] .bl-feed__row { animation: none; } }
|
|
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 ago(time, now, locale) {
|
|
34
|
+
const s = Math.round((now - new Date(time).getTime()) / 1e3);
|
|
35
|
+
if (s < 45) return "just now";
|
|
36
|
+
const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto", style: "short" });
|
|
37
|
+
if (s < 3600) return rtf.format(-Math.round(s / 60), "minute");
|
|
38
|
+
if (s < 86400) return rtf.format(-Math.round(s / 3600), "hour");
|
|
39
|
+
if (s < 604800) return rtf.format(-Math.round(s / 86400), "day");
|
|
40
|
+
return new Date(time).toLocaleDateString(locale, { month: "short", day: "numeric" });
|
|
41
|
+
}
|
|
42
|
+
function FeedList({
|
|
43
|
+
items = [],
|
|
44
|
+
onSelect,
|
|
45
|
+
max = 50,
|
|
46
|
+
label = "Activity",
|
|
47
|
+
emptyLabel = "Nothing yet.",
|
|
48
|
+
locale,
|
|
49
|
+
width = 480,
|
|
50
|
+
maxHeight = 420,
|
|
51
|
+
radius = 14,
|
|
52
|
+
backgroundColor = "#1a1c2c",
|
|
53
|
+
textColor = "#f4f4f4",
|
|
54
|
+
mutedColor = "#94b0c2",
|
|
55
|
+
hoverColor = "rgba(255,255,255,0.05)",
|
|
56
|
+
chipColor = "rgba(255,255,255,0.07)",
|
|
57
|
+
lineColor = "#333c57",
|
|
58
|
+
accentColor = "#73eff7",
|
|
59
|
+
flashColor = "rgba(115,239,247,0.14)",
|
|
60
|
+
fontFamily = "inherit",
|
|
61
|
+
className = "",
|
|
62
|
+
style
|
|
63
|
+
}) {
|
|
64
|
+
useStyles();
|
|
65
|
+
const shown = items.slice(0, max);
|
|
66
|
+
const [rows, setRows] = useState(() => shown.map((item) => ({ item, state: "idle" })));
|
|
67
|
+
const [now, setNow] = useState(() => Date.now());
|
|
68
|
+
const [active, setActive] = useState(0);
|
|
69
|
+
const [announce, setAnnounce] = useState("");
|
|
70
|
+
const known = useRef(new Set(shown.map((i) => i.id)));
|
|
71
|
+
const listRef = useRef(null);
|
|
72
|
+
const selectable = typeof onSelect === "function";
|
|
73
|
+
const uid = `bl-feed-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
const ids = new Set(shown.map((i) => i.id));
|
|
76
|
+
const added = shown.filter((i) => !known.current.has(i.id));
|
|
77
|
+
known.current = ids;
|
|
78
|
+
setRows((prev) => {
|
|
79
|
+
const leaving = prev.filter((r) => !ids.has(r.item.id)).map((r) => ({ ...r, state: "leaving" }));
|
|
80
|
+
const next = shown.map((item) => ({ item, state: added.includes(item) ? "new" : "idle" }));
|
|
81
|
+
leaving.forEach((r) => {
|
|
82
|
+
const at = prev.findIndex((p) => p.item.id === r.item.id);
|
|
83
|
+
next.splice(Math.min(at, next.length), 0, r);
|
|
84
|
+
});
|
|
85
|
+
return next;
|
|
86
|
+
});
|
|
87
|
+
if (added.length) setAnnounce(added.length === 1 ? `New: ${added[0].title}` : `${added.length} new items`);
|
|
88
|
+
const id = setTimeout(() => setRows((prev) => prev.filter((r) => r.state !== "leaving")), 320);
|
|
89
|
+
return () => clearTimeout(id);
|
|
90
|
+
}, [shown.map((i) => i.id).join("|")]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const id = setInterval(() => setNow(Date.now()), 3e4);
|
|
93
|
+
return () => clearInterval(id);
|
|
94
|
+
}, []);
|
|
95
|
+
const live = rows.filter((r) => r.state !== "leaving");
|
|
96
|
+
const current = Math.min(active, Math.max(0, live.length - 1));
|
|
97
|
+
const onKeyDown = (event) => {
|
|
98
|
+
if (!selectable || !live.length) return;
|
|
99
|
+
const moves = { ArrowDown: 1, ArrowUp: -1, Home: -1e9, End: 1e9 };
|
|
100
|
+
if (moves[event.key] !== void 0) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
const next = Math.max(0, Math.min(live.length - 1, current + moves[event.key]));
|
|
103
|
+
setActive(next);
|
|
104
|
+
listRef.current?.querySelector(`#${uid}-${next}`)?.scrollIntoView({ block: "nearest" });
|
|
105
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
onSelect(live[current].item);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
111
|
+
/* @__PURE__ */ jsxs(
|
|
112
|
+
"ul",
|
|
113
|
+
{
|
|
114
|
+
ref: listRef,
|
|
115
|
+
className: `bl-feed ${className}`,
|
|
116
|
+
role: selectable ? "listbox" : "list",
|
|
117
|
+
"aria-label": label,
|
|
118
|
+
"aria-activedescendant": selectable && live.length ? `${uid}-${current}` : void 0,
|
|
119
|
+
tabIndex: selectable ? 0 : void 0,
|
|
120
|
+
onKeyDown,
|
|
121
|
+
style: { "--bl-w": `${width}px`, "--bl-max-h": `${maxHeight}px`, "--bl-radius": `${radius}px`, "--bl-bg": backgroundColor, "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-hover": hoverColor, "--bl-chip": chipColor, "--bl-line": lineColor, "--bl-accent": accentColor, "--bl-flash": flashColor, "--bl-font": fontFamily, ...style },
|
|
122
|
+
children: [
|
|
123
|
+
rows.map(({ item, state }) => {
|
|
124
|
+
const i = live.findIndex((r) => r.item.id === item.id);
|
|
125
|
+
return /* @__PURE__ */ jsx(
|
|
126
|
+
"li",
|
|
127
|
+
{
|
|
128
|
+
id: i >= 0 ? `${uid}-${i}` : void 0,
|
|
129
|
+
className: "bl-feed__item",
|
|
130
|
+
role: selectable ? "option" : void 0,
|
|
131
|
+
"aria-selected": selectable ? i === current : void 0,
|
|
132
|
+
"aria-hidden": state === "leaving" || void 0,
|
|
133
|
+
"data-new": state === "new" || void 0,
|
|
134
|
+
"data-leaving": state === "leaving" || void 0,
|
|
135
|
+
"data-selectable": selectable || void 0,
|
|
136
|
+
"data-active": selectable && i === current || void 0,
|
|
137
|
+
onClick: selectable && i >= 0 ? () => {
|
|
138
|
+
setActive(i);
|
|
139
|
+
onSelect(item);
|
|
140
|
+
} : void 0,
|
|
141
|
+
style: { "--tone": item.tone },
|
|
142
|
+
children: /* @__PURE__ */ jsxs("div", { className: "bl-feed__row", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "bl-feed__icon", "aria-hidden": "true", children: item.icon ?? "\u2022" }),
|
|
144
|
+
/* @__PURE__ */ jsxs("span", { className: "bl-feed__text", children: [
|
|
145
|
+
/* @__PURE__ */ jsx("span", { className: "bl-feed__title", children: item.title }),
|
|
146
|
+
item.body && /* @__PURE__ */ jsx("span", { className: "bl-feed__body", children: item.body })
|
|
147
|
+
] }),
|
|
148
|
+
item.time != null && /* @__PURE__ */ jsx("time", { className: "bl-feed__time", dateTime: new Date(item.time).toISOString(), children: ago(item.time, now, locale) })
|
|
149
|
+
] })
|
|
150
|
+
},
|
|
151
|
+
item.id
|
|
152
|
+
);
|
|
153
|
+
}),
|
|
154
|
+
!live.length && /* @__PURE__ */ jsx("li", { className: "bl-feed__empty", children: emptyLabel })
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
),
|
|
158
|
+
/* @__PURE__ */ jsx("span", { className: "bl-feed__sr", "aria-live": "polite", children: announce })
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
FeedList as default
|
|
163
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export interface FlickerGridProps {
|
|
3
|
+
/** Square size in px. */
|
|
4
|
+
squareSize?: number;
|
|
5
|
+
/** Space between squares in px. */
|
|
6
|
+
gap?: number;
|
|
7
|
+
/** Color of the flickering noise. */
|
|
8
|
+
color?: string;
|
|
9
|
+
/** Color of squares inside the mask. */
|
|
10
|
+
maskColor?: string;
|
|
11
|
+
/** Average re-rolls per cell per second. */
|
|
12
|
+
flickerChance?: number;
|
|
13
|
+
/** Brightest opacity a noise square reaches (0–1). */
|
|
14
|
+
maxOpacity?: number;
|
|
15
|
+
/** Opacity of masked squares (0–1). */
|
|
16
|
+
maskOpacity?: number;
|
|
17
|
+
/** A word that emerges from the grid; long text shrinks to fit. */
|
|
18
|
+
text?: string;
|
|
19
|
+
/** An image (e.g. a logo) used as the mask instead of text; its opaque pixels count. */
|
|
20
|
+
maskSrc?: string;
|
|
21
|
+
fontSize?: number;
|
|
22
|
+
fontWeight?: number | string;
|
|
23
|
+
fontFamily?: string;
|
|
24
|
+
/** Accessible name; defaults to text. Without either, the grid is decorative. */
|
|
25
|
+
label?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
export default function FlickerGrid({ squareSize, gap, color, maskColor, flickerChance, maxOpacity, maskOpacity, text, maskSrc, fontSize, fontWeight, fontFamily, label, className, style }: FlickerGridProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
function rgba(hex, alpha) {
|
|
5
|
+
const v = hex.replace("#", "");
|
|
6
|
+
const full = v.length === 3 ? v.replace(/./g, (c) => c + c) : v.slice(0, 6);
|
|
7
|
+
const n = parseInt(full, 16);
|
|
8
|
+
return `rgba(${n >> 16 & 255},${n >> 8 & 255},${n & 255},${alpha})`;
|
|
9
|
+
}
|
|
10
|
+
function FlickerGrid({
|
|
11
|
+
squareSize = 4,
|
|
12
|
+
gap = 4,
|
|
13
|
+
color = "#566c86",
|
|
14
|
+
maskColor = "#73eff7",
|
|
15
|
+
flickerChance = 1.5,
|
|
16
|
+
maxOpacity = 0.35,
|
|
17
|
+
maskOpacity = 0.95,
|
|
18
|
+
text,
|
|
19
|
+
maskSrc,
|
|
20
|
+
fontSize = 120,
|
|
21
|
+
fontWeight = 800,
|
|
22
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
23
|
+
label,
|
|
24
|
+
className = "",
|
|
25
|
+
style
|
|
26
|
+
}) {
|
|
27
|
+
const wrapRef = useRef(null);
|
|
28
|
+
const canvasRef = useRef(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const wrap = wrapRef.current;
|
|
31
|
+
const canvas = canvasRef.current;
|
|
32
|
+
const ctx = canvas.getContext("2d");
|
|
33
|
+
const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
34
|
+
let cols = 0;
|
|
35
|
+
let rows = 0;
|
|
36
|
+
let dpr = 1;
|
|
37
|
+
let opacity = new Float32Array(0);
|
|
38
|
+
let inMask = new Uint8Array(0);
|
|
39
|
+
let frame = 0;
|
|
40
|
+
let visible = true;
|
|
41
|
+
let last = performance.now();
|
|
42
|
+
let image = null;
|
|
43
|
+
let cancelled = false;
|
|
44
|
+
const buildMask = () => {
|
|
45
|
+
inMask = new Uint8Array(cols * rows);
|
|
46
|
+
if (!text && !image) return;
|
|
47
|
+
const off = document.createElement("canvas");
|
|
48
|
+
off.width = cols;
|
|
49
|
+
off.height = rows;
|
|
50
|
+
const octx = off.getContext("2d");
|
|
51
|
+
const cell = squareSize + gap;
|
|
52
|
+
if (image) {
|
|
53
|
+
const scale = Math.min(cols / image.width, rows / image.height) * 0.8;
|
|
54
|
+
const iw = image.width * scale;
|
|
55
|
+
const ih = image.height * scale;
|
|
56
|
+
octx.drawImage(image, (cols - iw) / 2, (rows - ih) / 2, iw, ih);
|
|
57
|
+
} else {
|
|
58
|
+
const size = Math.max(4, fontSize / cell);
|
|
59
|
+
octx.font = `${fontWeight} ${size}px ${fontFamily}`;
|
|
60
|
+
octx.textAlign = "center";
|
|
61
|
+
octx.textBaseline = "middle";
|
|
62
|
+
const width = octx.measureText(text).width;
|
|
63
|
+
if (width > cols * 0.92) octx.font = `${fontWeight} ${size * cols * 0.92 / width}px ${fontFamily}`;
|
|
64
|
+
octx.fillStyle = "#fff";
|
|
65
|
+
octx.fillText(text, cols / 2, rows / 2);
|
|
66
|
+
}
|
|
67
|
+
const data = octx.getImageData(0, 0, cols, rows).data;
|
|
68
|
+
for (let i = 0; i < cols * rows; i++) inMask[i] = data[i * 4 + 3] > 100 ? 1 : 0;
|
|
69
|
+
};
|
|
70
|
+
const layout = () => {
|
|
71
|
+
dpr = Math.min(2, window.devicePixelRatio || 1);
|
|
72
|
+
const width = wrap.clientWidth;
|
|
73
|
+
const height = wrap.clientHeight;
|
|
74
|
+
canvas.width = Math.round(width * dpr);
|
|
75
|
+
canvas.height = Math.round(height * dpr);
|
|
76
|
+
const cell = squareSize + gap;
|
|
77
|
+
cols = Math.max(1, Math.floor(width / cell));
|
|
78
|
+
rows = Math.max(1, Math.floor(height / cell));
|
|
79
|
+
opacity = new Float32Array(cols * rows).map(() => Math.random() * maxOpacity);
|
|
80
|
+
buildMask();
|
|
81
|
+
draw();
|
|
82
|
+
};
|
|
83
|
+
const draw = () => {
|
|
84
|
+
const cell = (squareSize + gap) * dpr;
|
|
85
|
+
const size = squareSize * dpr;
|
|
86
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
87
|
+
const ox = (canvas.width - cols * cell + gap * dpr) / 2;
|
|
88
|
+
const oy = (canvas.height - rows * cell + gap * dpr) / 2;
|
|
89
|
+
for (let r = 0; r < rows; r++) {
|
|
90
|
+
for (let c = 0; c < cols; c++) {
|
|
91
|
+
const i = r * cols + c;
|
|
92
|
+
const masked = inMask[i];
|
|
93
|
+
const a = masked ? Math.min(1, maskOpacity * (0.55 + opacity[i] / maxOpacity / 2)) : opacity[i];
|
|
94
|
+
ctx.fillStyle = rgba(masked ? maskColor : color, a);
|
|
95
|
+
ctx.fillRect(ox + c * cell, oy + r * cell, size, size);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const tick = (now) => {
|
|
100
|
+
frame = 0;
|
|
101
|
+
const dt = Math.min(0.1, (now - last) / 1e3);
|
|
102
|
+
last = now;
|
|
103
|
+
const p = Math.min(1, flickerChance * dt);
|
|
104
|
+
for (let i = 0; i < opacity.length; i++) if (Math.random() < p) opacity[i] = Math.random() * maxOpacity;
|
|
105
|
+
draw();
|
|
106
|
+
if (visible) frame = requestAnimationFrame(tick);
|
|
107
|
+
};
|
|
108
|
+
const start = () => {
|
|
109
|
+
if (reduced || frame || !visible || cancelled) return;
|
|
110
|
+
last = performance.now();
|
|
111
|
+
frame = requestAnimationFrame(tick);
|
|
112
|
+
};
|
|
113
|
+
const resize = new ResizeObserver(layout);
|
|
114
|
+
resize.observe(wrap);
|
|
115
|
+
const io = new IntersectionObserver(([entry]) => {
|
|
116
|
+
visible = entry.isIntersecting;
|
|
117
|
+
if (visible) start();
|
|
118
|
+
});
|
|
119
|
+
io.observe(wrap);
|
|
120
|
+
if (maskSrc) {
|
|
121
|
+
const img = new Image();
|
|
122
|
+
img.crossOrigin = "anonymous";
|
|
123
|
+
img.onload = () => {
|
|
124
|
+
if (cancelled) return;
|
|
125
|
+
image = img;
|
|
126
|
+
buildMask();
|
|
127
|
+
draw();
|
|
128
|
+
};
|
|
129
|
+
img.src = maskSrc;
|
|
130
|
+
}
|
|
131
|
+
layout();
|
|
132
|
+
start();
|
|
133
|
+
return () => {
|
|
134
|
+
cancelled = true;
|
|
135
|
+
cancelAnimationFrame(frame);
|
|
136
|
+
resize.disconnect();
|
|
137
|
+
io.disconnect();
|
|
138
|
+
};
|
|
139
|
+
}, [squareSize, gap, color, maskColor, flickerChance, maxOpacity, maskOpacity, text, maskSrc, fontSize, fontWeight, fontFamily]);
|
|
140
|
+
const name = label ?? text;
|
|
141
|
+
return /* @__PURE__ */ jsx(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
ref: wrapRef,
|
|
145
|
+
className,
|
|
146
|
+
role: name ? "img" : void 0,
|
|
147
|
+
"aria-label": name || void 0,
|
|
148
|
+
"aria-hidden": name ? void 0 : true,
|
|
149
|
+
style: { position: "relative", width: "100%", height: "100%", overflow: "hidden", ...style },
|
|
150
|
+
children: /* @__PURE__ */ jsx("canvas", { ref: canvasRef, "aria-hidden": "true", style: { position: "absolute", inset: 0, width: "100%", height: "100%" } })
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
export {
|
|
155
|
+
FlickerGrid as default
|
|
156
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface FocusGridProps {
|
|
3
|
+
/** Each child becomes a card. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Auto-fill column width in px. */
|
|
6
|
+
minWidth?: number;
|
|
7
|
+
gap?: number;
|
|
8
|
+
/** Blur on the other cards, in px. */
|
|
9
|
+
blur?: number;
|
|
10
|
+
/** Opacity of the other cards. */
|
|
11
|
+
dim?: number;
|
|
12
|
+
shrink?: number;
|
|
13
|
+
lift?: number;
|
|
14
|
+
duration?: number;
|
|
15
|
+
radius?: number;
|
|
16
|
+
label?: string;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
export default function FocusGrid({ children, minWidth, gap, blur, dim, shrink, lift, duration, radius, label, className, style }: FocusGridProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Children, useInsertionEffect } from "react";
|
|
4
|
+
const STYLE_ID = "bl-focus-grid";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-focus { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(var(--bl-min), 100%), 1fr)); gap: var(--bl-gap); width: 100%; margin: 0; padding: 0; list-style: none; }
|
|
7
|
+
.bl-focus__item { position: relative; min-width: 0; border-radius: var(--bl-radius); transition: filter var(--bl-dur) ease, opacity var(--bl-dur) ease, transform var(--bl-dur) cubic-bezier(.2,.9,.25,1); }
|
|
8
|
+
.bl-focus:has(.bl-focus__item:is(:hover, :focus-within)) .bl-focus__item:not(:is(:hover, :focus-within)) { filter: blur(var(--bl-blur)) saturate(0.6); opacity: var(--bl-dim); transform: scale(var(--bl-shrink)); }
|
|
9
|
+
.bl-focus__item:is(:hover, :focus-within) { transform: scale(var(--bl-lift)); z-index: 1; }
|
|
10
|
+
@media (prefers-reduced-motion: reduce) {
|
|
11
|
+
.bl-focus__item { transition: opacity 150ms; }
|
|
12
|
+
.bl-focus:has(.bl-focus__item:is(:hover, :focus-within)) .bl-focus__item:not(:is(:hover, :focus-within)) { filter: none; transform: none; }
|
|
13
|
+
.bl-focus__item:is(:hover, :focus-within) { transform: none; }
|
|
14
|
+
}
|
|
15
|
+
`;
|
|
16
|
+
function useStyles() {
|
|
17
|
+
useInsertionEffect(() => {
|
|
18
|
+
if (typeof document === "undefined") return;
|
|
19
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
20
|
+
style.textContent = CSS;
|
|
21
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
22
|
+
}, []);
|
|
23
|
+
}
|
|
24
|
+
function FocusGrid({ children, minWidth = 220, gap = 16, blur = 4, dim = 0.45, shrink = 0.97, lift = 1.02, duration = 300, radius = 14, label, className = "", style }) {
|
|
25
|
+
useStyles();
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
"ul",
|
|
28
|
+
{
|
|
29
|
+
className: `bl-focus ${className}`,
|
|
30
|
+
"aria-label": label,
|
|
31
|
+
style: {
|
|
32
|
+
"--bl-min": `${minWidth}px`,
|
|
33
|
+
"--bl-gap": `${gap}px`,
|
|
34
|
+
"--bl-blur": `${blur}px`,
|
|
35
|
+
"--bl-dim": dim,
|
|
36
|
+
"--bl-shrink": shrink,
|
|
37
|
+
"--bl-lift": lift,
|
|
38
|
+
"--bl-dur": `${duration}ms`,
|
|
39
|
+
"--bl-radius": `${radius}px`,
|
|
40
|
+
...style
|
|
41
|
+
},
|
|
42
|
+
children: Children.toArray(children).map((child, i) => /* @__PURE__ */ jsx("li", { className: "bl-focus__item", children: child }, child?.key ?? i))
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
FocusGrid as default
|
|
48
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type CSSProperties, type ElementType } from 'react';
|
|
2
|
+
export interface FocusPullProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
as?: ElementType;
|
|
5
|
+
/** How the focus moves: across the line, out from the middle, or all at once with a lens breathe. */
|
|
6
|
+
rack?: 'sweep' | 'center' | 'snap';
|
|
7
|
+
/** How long each letter takes to sharpen, in ms. */
|
|
8
|
+
pull?: number;
|
|
9
|
+
/** How long the sweep takes to cross the line, in ms. */
|
|
10
|
+
spread?: number;
|
|
11
|
+
/** Out-of-focus blur in px. */
|
|
12
|
+
depth?: number;
|
|
13
|
+
/** Colour-fringe offset in px while soft. */
|
|
14
|
+
fringe?: number;
|
|
15
|
+
trigger?: 'view' | 'mount' | 'hover';
|
|
16
|
+
/** Share of the line that must be visible before a "view" trigger fires. */
|
|
17
|
+
threshold?: number;
|
|
18
|
+
textColor?: string;
|
|
19
|
+
/** The two fringe colours, [left, right]. */
|
|
20
|
+
fringeColors?: [string, string];
|
|
21
|
+
/** Called when the whole line is sharp. */
|
|
22
|
+
onFocused?: () => void;
|
|
23
|
+
className?: string;
|
|
24
|
+
style?: CSSProperties;
|
|
25
|
+
}
|
|
26
|
+
export default function FocusPull({ text, as: Tag, rack, pull, spread, depth, fringe, trigger, threshold, textColor, fringeColors, onFocused, className, style }: FocusPullProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-focus-pull";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-focus { margin: 0; color: var(--bl-ink); }
|
|
7
|
+
.bl-focus__lens { display: inline; }
|
|
8
|
+
.bl-focus__word { display: inline-block; white-space: nowrap; }
|
|
9
|
+
.bl-focus__ch { display: inline-block; white-space: pre; transition: filter var(--bl-pull) cubic-bezier(.2,.7,.2,1), opacity var(--bl-pull) ease, text-shadow var(--bl-pull) cubic-bezier(.2,.7,.2,1); transition-delay: calc(var(--p) * var(--bl-spread)); }
|
|
10
|
+
.bl-focus[data-state="soft"] .bl-focus__ch { filter: blur(var(--bl-depth)); opacity: 0.35; text-shadow: var(--bl-fringe) 0 0 var(--bl-red), calc(var(--bl-fringe) * -1) 0 0 var(--bl-cyan); transition: none; }
|
|
11
|
+
.bl-focus[data-state="sharp"][data-rack="snap"] .bl-focus__ch { animation: bl-focus-breathe var(--bl-pull) cubic-bezier(.2,.7,.2,1) both; transition: none; }
|
|
12
|
+
.bl-focus__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
13
|
+
@keyframes bl-focus-breathe {
|
|
14
|
+
0% { filter: blur(var(--bl-depth)); opacity: 0.35; text-shadow: var(--bl-fringe) 0 0 var(--bl-red), calc(var(--bl-fringe) * -1) 0 0 var(--bl-cyan); }
|
|
15
|
+
55% { filter: blur(0); opacity: 1; text-shadow: 0 0 0 transparent, 0 0 0 transparent; }
|
|
16
|
+
72% { filter: blur(calc(var(--bl-depth) * 0.18)); text-shadow: calc(var(--bl-fringe) * 0.4) 0 0 var(--bl-red), calc(var(--bl-fringe) * -0.4) 0 0 var(--bl-cyan); }
|
|
17
|
+
100% { filter: blur(0); opacity: 1; text-shadow: 0 0 0 transparent, 0 0 0 transparent; }
|
|
18
|
+
}
|
|
19
|
+
@media (prefers-reduced-motion: reduce) { .bl-focus .bl-focus__ch { filter: none !important; opacity: 1 !important; text-shadow: none !important; transition: none !important; animation: none !important; } }
|
|
20
|
+
`;
|
|
21
|
+
function useStyles() {
|
|
22
|
+
useInsertionEffect(() => {
|
|
23
|
+
if (typeof document === "undefined") return;
|
|
24
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
25
|
+
style.textContent = CSS;
|
|
26
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
function FocusPull({
|
|
30
|
+
text = "",
|
|
31
|
+
as: Tag = "p",
|
|
32
|
+
rack = "sweep",
|
|
33
|
+
pull = 900,
|
|
34
|
+
spread = 700,
|
|
35
|
+
depth = 8,
|
|
36
|
+
fringe = 3,
|
|
37
|
+
trigger = "view",
|
|
38
|
+
threshold = 0.4,
|
|
39
|
+
textColor = "inherit",
|
|
40
|
+
fringeColors = ["rgba(239,125,87,0.7)", "rgba(115,239,247,0.7)"],
|
|
41
|
+
onFocused,
|
|
42
|
+
className = "",
|
|
43
|
+
style
|
|
44
|
+
}) {
|
|
45
|
+
useStyles();
|
|
46
|
+
const rootRef = useRef(null);
|
|
47
|
+
const focusedRef = useRef(onFocused);
|
|
48
|
+
focusedRef.current = onFocused;
|
|
49
|
+
const [state, setState] = useState(trigger === "mount" ? "sharp" : "soft");
|
|
50
|
+
const n = Math.max(1, [...text].length - 1);
|
|
51
|
+
const position = (i) => rack === "center" ? Math.abs(i / n - 0.5) * 2 : rack === "snap" ? 0 : i / n;
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (trigger !== "view") return void 0;
|
|
54
|
+
const root = rootRef.current;
|
|
55
|
+
const observer = new IntersectionObserver(
|
|
56
|
+
([entry]) => {
|
|
57
|
+
if (entry.isIntersecting) {
|
|
58
|
+
setState("sharp");
|
|
59
|
+
observer.disconnect();
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{ threshold }
|
|
63
|
+
);
|
|
64
|
+
observer.observe(root);
|
|
65
|
+
return () => observer.disconnect();
|
|
66
|
+
}, [trigger, threshold]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (state !== "sharp") return void 0;
|
|
69
|
+
const timer = setTimeout(() => focusedRef.current?.(), pull + (rack === "snap" ? 0 : spread));
|
|
70
|
+
return () => clearTimeout(timer);
|
|
71
|
+
}, [state, pull, spread, rack]);
|
|
72
|
+
const onPointerEnter = () => {
|
|
73
|
+
if (trigger !== "hover" || window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
74
|
+
setState("soft");
|
|
75
|
+
requestAnimationFrame(() => requestAnimationFrame(() => setState("sharp")));
|
|
76
|
+
};
|
|
77
|
+
let index = 0;
|
|
78
|
+
return /* @__PURE__ */ jsxs(
|
|
79
|
+
Tag,
|
|
80
|
+
{
|
|
81
|
+
ref: rootRef,
|
|
82
|
+
className: `bl-focus ${className}`,
|
|
83
|
+
"data-state": state,
|
|
84
|
+
"data-rack": rack,
|
|
85
|
+
onPointerEnter,
|
|
86
|
+
style: { "--bl-pull": `${pull}ms`, "--bl-spread": `${rack === "snap" ? 0 : spread}ms`, "--bl-depth": `${depth}px`, "--bl-fringe": `${fringe}px`, "--bl-red": fringeColors[0], "--bl-cyan": fringeColors[1], "--bl-ink": textColor, ...style },
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", { className: "bl-focus__sr", children: text }),
|
|
89
|
+
/* @__PURE__ */ jsx("span", { className: "bl-focus__lens", "aria-hidden": "true", children: text.split(/(\s+)/).map((part, w) => {
|
|
90
|
+
if (!part) return null;
|
|
91
|
+
if (/^\s+$/.test(part)) {
|
|
92
|
+
index += part.length;
|
|
93
|
+
return " ";
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ jsx("span", { className: "bl-focus__word", children: [...part].map((ch) => {
|
|
96
|
+
const i = index++;
|
|
97
|
+
return /* @__PURE__ */ jsx("span", { className: "bl-focus__ch", style: { "--p": position(i).toFixed(3) }, children: ch }, i);
|
|
98
|
+
}) }, w);
|
|
99
|
+
}) })
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
FocusPull as default
|
|
106
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface FootprintsProps {
|
|
3
|
+
/** The area to walk across. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Built-in pixel footprints, or image URLs cycled in order. */
|
|
6
|
+
stamps?: 'feet' | string[];
|
|
7
|
+
/** Distance between stamps in px. */
|
|
8
|
+
stride?: number;
|
|
9
|
+
/** Stamp width in px. */
|
|
10
|
+
size?: number;
|
|
11
|
+
/** Stamp lifetime in ms. */
|
|
12
|
+
life?: number;
|
|
13
|
+
/** How far apart left and right feet sit, in px. */
|
|
14
|
+
spread?: number;
|
|
15
|
+
/** Random tilt for image stamps, in degrees. */
|
|
16
|
+
jitter?: number;
|
|
17
|
+
/** Most stamps on screen at once. */
|
|
18
|
+
max?: number;
|
|
19
|
+
/** Footprint colour. */
|
|
20
|
+
color?: string;
|
|
21
|
+
className?: string;
|
|
22
|
+
style?: CSSProperties;
|
|
23
|
+
}
|
|
24
|
+
export default function Footprints({ children, stamps, stride, size, life, spread, jitter, max, color, className, style }: FootprintsProps): import("react").JSX.Element;
|