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,234 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-boot-sequence";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-boot { position: relative; width: 100%; height: 100%; min-height: var(--bl-min-h); overflow: hidden; background: var(--bl-bg); color: var(--bl-ink); font-family: var(--bl-font); font-size: var(--bl-size); line-height: 1.6; }
|
|
7
|
+
.bl-boot[data-skippable] { cursor: pointer; }
|
|
8
|
+
.bl-boot__screen { position: absolute; inset: 0; padding: 18px 20px 40px; overflow: hidden; }
|
|
9
|
+
.bl-boot__screen[data-off] { animation: bl-boot-off 420ms steps(6) forwards; }
|
|
10
|
+
.bl-boot__line { display: flex; gap: 1ch; min-height: 1.6em; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
11
|
+
.bl-boot__text { flex: 1; min-width: 0; }
|
|
12
|
+
.bl-boot__head { margin-bottom: 0.8em; color: var(--bl-accent); }
|
|
13
|
+
.bl-boot__tag { flex: 0 0 auto; white-space: pre; }
|
|
14
|
+
.bl-boot__tag[data-status="ok"] { color: var(--bl-ok); }
|
|
15
|
+
.bl-boot__tag[data-status="warn"] { color: var(--bl-warn); }
|
|
16
|
+
.bl-boot__tag[data-status="fail"] { color: var(--bl-fail); }
|
|
17
|
+
.bl-boot__cursor { display: inline-block; width: 0.6em; height: 1.1em; margin-left: 1px; vertical-align: text-bottom; background: currentColor; animation: bl-boot-blink 1s steps(1) infinite; }
|
|
18
|
+
.bl-boot__hint { position: absolute; right: 16px; bottom: 12px; left: 16px; color: var(--bl-muted); font-size: 0.8em; text-align: right; animation: bl-boot-blink 1.6s steps(1) infinite; }
|
|
19
|
+
.bl-boot__reveal { position: absolute; inset: 0; animation: bl-boot-on 520ms steps(8) both; }
|
|
20
|
+
.bl-boot__scan { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0,0,0,0.2) 2px 3px); }
|
|
21
|
+
.bl-boot__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
|
|
22
|
+
.bl-boot__skip { position: absolute; top: 8px; right: 8px; padding: 6px 10px; border: 1px solid var(--bl-muted); background: var(--bl-bg); color: var(--bl-ink); font: inherit; font-size: 0.8em; opacity: 0; pointer-events: none; }
|
|
23
|
+
.bl-boot__skip:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--bl-accent); }
|
|
24
|
+
@keyframes bl-boot-blink { 50% { opacity: 0; } }
|
|
25
|
+
@keyframes bl-boot-off { 60% { transform: scaleY(0.04); filter: brightness(2.5); opacity: 1; } 100% { transform: scale(0, 0.04); opacity: 0; } }
|
|
26
|
+
@keyframes bl-boot-on { from { clip-path: inset(50% 0 50% 0); filter: brightness(2.2); } to { clip-path: inset(0 0 0 0); filter: none; } }
|
|
27
|
+
@media (prefers-reduced-motion: reduce) {
|
|
28
|
+
.bl-boot__cursor, .bl-boot__hint { animation: none; }
|
|
29
|
+
.bl-boot__screen[data-off], .bl-boot__reveal { animation: none; }
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
function useStyles() {
|
|
33
|
+
useInsertionEffect(() => {
|
|
34
|
+
if (typeof document === "undefined") return;
|
|
35
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
36
|
+
style.textContent = CSS;
|
|
37
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
38
|
+
}, []);
|
|
39
|
+
}
|
|
40
|
+
const TAGS = { ok: "[ OK ]", warn: "[ WARN ]", fail: "[ FAIL ]" };
|
|
41
|
+
const DEFAULT_LINES = [
|
|
42
|
+
{ text: "Detecting CPU... PX-8 @ 4.77 MHz", status: "ok" },
|
|
43
|
+
{ text: "Memory test:", count: 640, unit: "K", status: "ok" },
|
|
44
|
+
{ text: "Video adapter... 16-color palette", status: "ok" },
|
|
45
|
+
{ text: "Sound chip... square, saw, noise", status: "ok" },
|
|
46
|
+
{ text: "Cartridge slot... empty", status: "warn" },
|
|
47
|
+
{ text: "Loading BITS.SYS", status: "ok" },
|
|
48
|
+
"Starting shell..."
|
|
49
|
+
];
|
|
50
|
+
let audio = null;
|
|
51
|
+
function beepOnce(frequency, seconds) {
|
|
52
|
+
try {
|
|
53
|
+
audio ?? (audio = new AudioContext());
|
|
54
|
+
if (audio.state === "suspended") audio.resume();
|
|
55
|
+
const osc = audio.createOscillator();
|
|
56
|
+
const gain = audio.createGain();
|
|
57
|
+
const now = audio.currentTime;
|
|
58
|
+
osc.type = "square";
|
|
59
|
+
osc.frequency.value = frequency;
|
|
60
|
+
gain.gain.setValueAtTime(0.05, now);
|
|
61
|
+
gain.gain.linearRampToValueAtTime(0, now + seconds);
|
|
62
|
+
osc.connect(gain).connect(audio.destination);
|
|
63
|
+
osc.start(now);
|
|
64
|
+
osc.stop(now + seconds);
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function BootSequence({
|
|
69
|
+
header = ["BITS LAB BIOS v1.0", "(C) 2026 Bits Lab. All rights reserved."],
|
|
70
|
+
lines = DEFAULT_LINES,
|
|
71
|
+
speed = 70,
|
|
72
|
+
lineDelay = 160,
|
|
73
|
+
countDuration = 900,
|
|
74
|
+
holdAfter = 700,
|
|
75
|
+
skippable = true,
|
|
76
|
+
beep = false,
|
|
77
|
+
replayKey,
|
|
78
|
+
onComplete,
|
|
79
|
+
children,
|
|
80
|
+
minHeight = 320,
|
|
81
|
+
fontSize = 14,
|
|
82
|
+
backgroundColor = "#0b0b14",
|
|
83
|
+
textColor = "#94b0c2",
|
|
84
|
+
accentColor = "#f4f4f4",
|
|
85
|
+
okColor = "#a7f070",
|
|
86
|
+
warnColor = "#ffcd75",
|
|
87
|
+
failColor = "#ef7d57",
|
|
88
|
+
mutedColor = "#566c86",
|
|
89
|
+
scanlines = true,
|
|
90
|
+
hint = "Click or press any key to skip",
|
|
91
|
+
label = "System boot",
|
|
92
|
+
fontFamily = "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
93
|
+
className = "",
|
|
94
|
+
style
|
|
95
|
+
}) {
|
|
96
|
+
useStyles();
|
|
97
|
+
const timeline = useMemo(() => {
|
|
98
|
+
let t = 0;
|
|
99
|
+
const items = lines.map((entry) => {
|
|
100
|
+
const line = typeof entry === "string" ? { text: entry } : entry;
|
|
101
|
+
const start = t;
|
|
102
|
+
const typeEnd = start + line.text.length / speed * 1e3;
|
|
103
|
+
const countEnd = typeEnd + (line.count != null ? countDuration : 0);
|
|
104
|
+
t = countEnd + (line.delay ?? lineDelay);
|
|
105
|
+
return { ...line, start, typeEnd, countEnd };
|
|
106
|
+
});
|
|
107
|
+
return { items, total: t + holdAfter };
|
|
108
|
+
}, [lines, speed, lineDelay, countDuration, holdAfter]);
|
|
109
|
+
const [elapsed, setElapsed] = useState(0);
|
|
110
|
+
const [phase, setPhase] = useState("boot");
|
|
111
|
+
const startRef = useRef(0);
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
const reduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
114
|
+
setPhase("boot");
|
|
115
|
+
setElapsed(0);
|
|
116
|
+
startRef.current = reduced ? -Infinity : performance.now();
|
|
117
|
+
let frame = 0;
|
|
118
|
+
const tick = (now) => {
|
|
119
|
+
const t = Math.min(timeline.total, now - startRef.current);
|
|
120
|
+
setElapsed(t);
|
|
121
|
+
if (t < timeline.total) frame = requestAnimationFrame(tick);
|
|
122
|
+
};
|
|
123
|
+
frame = requestAnimationFrame(tick);
|
|
124
|
+
return () => cancelAnimationFrame(frame);
|
|
125
|
+
}, [timeline, replayKey]);
|
|
126
|
+
const done = elapsed >= timeline.total;
|
|
127
|
+
const skip = () => {
|
|
128
|
+
startRef.current = -Infinity;
|
|
129
|
+
};
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (!skippable || done) return void 0;
|
|
132
|
+
const onKey = (event) => {
|
|
133
|
+
if (event.metaKey || event.ctrlKey || event.altKey || event.key === "Tab" || event.key === "Shift") return;
|
|
134
|
+
const el = event.target;
|
|
135
|
+
if (el instanceof HTMLElement && (el.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(el.tagName))) return;
|
|
136
|
+
skip();
|
|
137
|
+
};
|
|
138
|
+
window.addEventListener("keydown", onKey);
|
|
139
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
140
|
+
}, [skippable, done]);
|
|
141
|
+
const tagsShown = timeline.items.filter((item) => item.status && elapsed >= item.countEnd).length;
|
|
142
|
+
const beeped = useRef(0);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (tagsShown < beeped.current) beeped.current = 0;
|
|
145
|
+
if (beep && tagsShown > beeped.current) {
|
|
146
|
+
const latest = timeline.items.filter((item) => item.status)[tagsShown - 1];
|
|
147
|
+
beepOnce(latest?.status === "fail" ? 220 : 1320, 0.04);
|
|
148
|
+
}
|
|
149
|
+
beeped.current = tagsShown;
|
|
150
|
+
}, [tagsShown, beep, timeline]);
|
|
151
|
+
const completed = useRef(onComplete);
|
|
152
|
+
completed.current = onComplete;
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (!done) return;
|
|
155
|
+
if (beep) beepOnce(988, 0.2);
|
|
156
|
+
completed.current?.();
|
|
157
|
+
if (children) setPhase(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "revealed" : "off");
|
|
158
|
+
}, [done]);
|
|
159
|
+
let active = -1;
|
|
160
|
+
timeline.items.forEach((item, i) => {
|
|
161
|
+
if (elapsed >= item.start) active = i;
|
|
162
|
+
});
|
|
163
|
+
const finished = timeline.items.filter((item) => elapsed >= item.countEnd);
|
|
164
|
+
return /* @__PURE__ */ jsxs(
|
|
165
|
+
"div",
|
|
166
|
+
{
|
|
167
|
+
className: `bl-boot ${className}`,
|
|
168
|
+
role: "region",
|
|
169
|
+
"aria-label": label,
|
|
170
|
+
"data-skippable": skippable && !done || void 0,
|
|
171
|
+
onClick: skippable && !done ? skip : void 0,
|
|
172
|
+
style: {
|
|
173
|
+
"--bl-min-h": `${minHeight}px`,
|
|
174
|
+
"--bl-size": `${fontSize}px`,
|
|
175
|
+
"--bl-bg": backgroundColor,
|
|
176
|
+
"--bl-ink": textColor,
|
|
177
|
+
"--bl-accent": accentColor,
|
|
178
|
+
"--bl-ok": okColor,
|
|
179
|
+
"--bl-warn": warnColor,
|
|
180
|
+
"--bl-fail": failColor,
|
|
181
|
+
"--bl-muted": mutedColor,
|
|
182
|
+
"--bl-font": fontFamily,
|
|
183
|
+
...style
|
|
184
|
+
},
|
|
185
|
+
children: [
|
|
186
|
+
phase !== "revealed" && /* @__PURE__ */ jsxs(
|
|
187
|
+
"div",
|
|
188
|
+
{
|
|
189
|
+
className: "bl-boot__screen",
|
|
190
|
+
"data-off": phase === "off" || void 0,
|
|
191
|
+
"aria-hidden": "true",
|
|
192
|
+
onAnimationEnd: (event) => {
|
|
193
|
+
if (event.target === event.currentTarget) setPhase("revealed");
|
|
194
|
+
},
|
|
195
|
+
children: [
|
|
196
|
+
header.length > 0 && /* @__PURE__ */ jsx("div", { className: "bl-boot__head", children: header.map((line, i) => /* @__PURE__ */ jsx("div", { className: "bl-boot__line", children: line }, i)) }),
|
|
197
|
+
timeline.items.map((item, i) => {
|
|
198
|
+
if (elapsed < item.start) return null;
|
|
199
|
+
const chars = Math.min(item.text.length, Math.floor((elapsed - item.start) / 1e3 * speed));
|
|
200
|
+
let count = "";
|
|
201
|
+
if (item.count != null && elapsed >= item.typeEnd) {
|
|
202
|
+
const progress = Math.min(1, (elapsed - item.typeEnd) / countDuration);
|
|
203
|
+
count = ` ${Math.round(item.count * progress)}${item.unit ?? ""}`;
|
|
204
|
+
}
|
|
205
|
+
const tag = item.status && elapsed >= item.countEnd ? item.status : null;
|
|
206
|
+
return /* @__PURE__ */ jsxs("div", { className: "bl-boot__line", children: [
|
|
207
|
+
/* @__PURE__ */ jsxs("span", { className: "bl-boot__text", children: [
|
|
208
|
+
item.text.slice(0, chars),
|
|
209
|
+
count,
|
|
210
|
+
i === active && !done && /* @__PURE__ */ jsx("span", { className: "bl-boot__cursor" })
|
|
211
|
+
] }),
|
|
212
|
+
tag && /* @__PURE__ */ jsx("span", { className: "bl-boot__tag", "data-status": tag, children: TAGS[tag] })
|
|
213
|
+
] }, i);
|
|
214
|
+
}),
|
|
215
|
+
done && /* @__PURE__ */ jsx("div", { className: "bl-boot__line", children: /* @__PURE__ */ jsx("span", { className: "bl-boot__cursor" }) }),
|
|
216
|
+
skippable && !done && hint && /* @__PURE__ */ jsx("div", { className: "bl-boot__hint", children: hint })
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
),
|
|
220
|
+
phase === "revealed" && /* @__PURE__ */ jsx("div", { className: "bl-boot__reveal", children }),
|
|
221
|
+
scanlines && /* @__PURE__ */ jsx("div", { className: "bl-boot__scan", "aria-hidden": "true" }),
|
|
222
|
+
skippable && !done && /* @__PURE__ */ jsx("button", { type: "button", className: "bl-boot__skip", onClick: skip, children: "Skip boot sequence" }),
|
|
223
|
+
/* @__PURE__ */ jsx("div", { className: "bl-boot__sr", role: "log", "aria-live": "polite", children: finished.map((item, i) => /* @__PURE__ */ jsxs("div", { children: [
|
|
224
|
+
item.text,
|
|
225
|
+
item.count != null ? ` ${item.count}${item.unit ?? ""}` : "",
|
|
226
|
+
item.status ? ` ${item.status.toUpperCase()}` : ""
|
|
227
|
+
] }, i)) })
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
export {
|
|
233
|
+
BootSequence as default
|
|
234
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type CSSProperties, type MouseEvent as ReactMouseEvent, type ReactNode } from 'react';
|
|
2
|
+
export interface Crumb {
|
|
3
|
+
label: string;
|
|
4
|
+
/** Renders a link; without it the crumb is a button. */
|
|
5
|
+
href?: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export interface BreadcrumbTrailProps {
|
|
9
|
+
/** Root first, current page last. */
|
|
10
|
+
items?: Crumb[];
|
|
11
|
+
/** Any crumb or menu click; call event.preventDefault() for client-side routing. */
|
|
12
|
+
onNavigate?: (item: Crumb, index: number, event: ReactMouseEvent<HTMLElement>) => void;
|
|
13
|
+
separator?: ReactNode;
|
|
14
|
+
/** Accessible name of the "…" button and its menu. */
|
|
15
|
+
moreLabel?: string;
|
|
16
|
+
/** Accessible name of the nav landmark. */
|
|
17
|
+
label?: string;
|
|
18
|
+
fontSize?: number;
|
|
19
|
+
textColor?: string;
|
|
20
|
+
mutedColor?: string;
|
|
21
|
+
dimColor?: string;
|
|
22
|
+
hoverColor?: string;
|
|
23
|
+
chipColor?: string;
|
|
24
|
+
menuColor?: string;
|
|
25
|
+
lineColor?: string;
|
|
26
|
+
accentColor?: string;
|
|
27
|
+
fontFamily?: string;
|
|
28
|
+
className?: string;
|
|
29
|
+
style?: CSSProperties;
|
|
30
|
+
}
|
|
31
|
+
export default function BreadcrumbTrail({ items, onNavigate, separator, moreLabel, label, fontSize, textColor, mutedColor, dimColor, hoverColor, chipColor, menuColor, lineColor, accentColor, fontFamily, className, style }: BreadcrumbTrailProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useInsertionEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-breadcrumb-trail";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-crumbs { position: relative; min-width: 0; font-family: var(--bl-font); font-size: var(--bl-size); }
|
|
7
|
+
.bl-crumbs__list { display: flex; align-items: center; gap: 4px; min-width: 0; margin: 0; padding: 0; list-style: none; white-space: nowrap; }
|
|
8
|
+
.bl-crumbs__item { display: flex; align-items: center; gap: 4px; min-width: 0; animation: bl-crumbs-in 260ms cubic-bezier(.3,1.4,.5,1) both; }
|
|
9
|
+
.bl-crumbs__item:last-child { flex: 0 1 auto; }
|
|
10
|
+
.bl-crumbs__link { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--bl-muted); font: inherit; text-decoration: none; cursor: pointer; transition: background-color 150ms, color 150ms; }
|
|
11
|
+
.bl-crumbs__link:hover { background: var(--bl-hover); color: var(--bl-ink); }
|
|
12
|
+
.bl-crumbs__link:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 1px; }
|
|
13
|
+
.bl-crumbs__current { display: inline-flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 8px; color: var(--bl-ink); font-weight: 600; }
|
|
14
|
+
.bl-crumbs__text { overflow: hidden; text-overflow: ellipsis; }
|
|
15
|
+
.bl-crumbs__sep { flex: none; display: grid; place-items: center; color: var(--bl-dim); }
|
|
16
|
+
.bl-crumbs__more { display: grid; place-items: center; min-width: 32px; height: 30px; padding: 0 6px; border: 0; border-radius: 8px; background: var(--bl-chip); color: var(--bl-ink); font: inherit; letter-spacing: 1px; cursor: pointer; transition: background-color 150ms; }
|
|
17
|
+
.bl-crumbs__more:hover, .bl-crumbs__more[aria-expanded="true"] { background: var(--bl-hover); }
|
|
18
|
+
.bl-crumbs__more:focus-visible { outline: 2px solid var(--bl-accent); outline-offset: 1px; }
|
|
19
|
+
.bl-crumbs__menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: var(--bl-menu-x); min-width: 180px; margin: 0; padding: 5px; border-radius: 12px; background: var(--bl-menu); list-style: none; box-shadow: 0 0 0 1px var(--bl-line), 0 16px 32px -14px rgba(0,0,0,0.8); transform-origin: top left; animation: bl-crumbs-menu 200ms cubic-bezier(.3,1.4,.5,1) both; }
|
|
20
|
+
.bl-crumbs__menu .bl-crumbs__link { display: flex; width: 100%; box-sizing: border-box; padding: 8px 10px; animation: bl-crumbs-in 240ms cubic-bezier(.3,1.4,.5,1) both; animation-delay: calc(var(--i) * 35ms); }
|
|
21
|
+
.bl-crumbs__clip { position: absolute; top: 0; left: 0; width: 0; height: 0; overflow: hidden; visibility: hidden; pointer-events: none; }
|
|
22
|
+
.bl-crumbs__measure { width: max-content; }
|
|
23
|
+
@keyframes bl-crumbs-in { from { opacity: 0; transform: translateY(4px) scale(0.92); } }
|
|
24
|
+
@keyframes bl-crumbs-menu { from { opacity: 0; transform: scale(0.9) translateY(-4px); } }
|
|
25
|
+
@media (prefers-reduced-motion: reduce) { .bl-crumbs__item, .bl-crumbs__menu, .bl-crumbs__menu .bl-crumbs__link { animation: none; } }
|
|
26
|
+
`;
|
|
27
|
+
function useStyles() {
|
|
28
|
+
useInsertionEffect(() => {
|
|
29
|
+
if (typeof document === "undefined") return;
|
|
30
|
+
const style = document.getElementById(STYLE_ID) ?? Object.assign(document.createElement("style"), { id: STYLE_ID });
|
|
31
|
+
style.textContent = CSS;
|
|
32
|
+
if (!style.isConnected) document.head.appendChild(style);
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
const Chevron = () => /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M4.5 2.5 8 6l-3.5 3.5" }) });
|
|
36
|
+
function BreadcrumbTrail({
|
|
37
|
+
items = [],
|
|
38
|
+
onNavigate,
|
|
39
|
+
separator = /* @__PURE__ */ jsx(Chevron, {}),
|
|
40
|
+
moreLabel = "Show hidden pages",
|
|
41
|
+
label = "Breadcrumb",
|
|
42
|
+
fontSize = 14,
|
|
43
|
+
textColor = "#f4f4f4",
|
|
44
|
+
mutedColor = "#94b0c2",
|
|
45
|
+
dimColor = "#566c86",
|
|
46
|
+
hoverColor = "rgba(255,255,255,0.08)",
|
|
47
|
+
chipColor = "rgba(255,255,255,0.05)",
|
|
48
|
+
menuColor = "#1a1c2c",
|
|
49
|
+
lineColor = "#333c57",
|
|
50
|
+
accentColor = "#73eff7",
|
|
51
|
+
fontFamily = "ui-sans-serif, system-ui, sans-serif",
|
|
52
|
+
className = "",
|
|
53
|
+
style
|
|
54
|
+
}) {
|
|
55
|
+
useStyles();
|
|
56
|
+
const uid = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
57
|
+
const navRef = useRef(null);
|
|
58
|
+
const measureRef = useRef(null);
|
|
59
|
+
const moreRef = useRef(null);
|
|
60
|
+
const menuRef = useRef(null);
|
|
61
|
+
const [hidden, setHidden] = useState(0);
|
|
62
|
+
const [open, setOpen] = useState(false);
|
|
63
|
+
const [menuX, setMenuX] = useState(0);
|
|
64
|
+
useLayoutEffect(() => {
|
|
65
|
+
const nav = navRef.current;
|
|
66
|
+
const measure = measureRef.current;
|
|
67
|
+
const fit = () => {
|
|
68
|
+
const widths = [...measure.children].map((node) => node.getBoundingClientRect().width);
|
|
69
|
+
const more = widths.pop();
|
|
70
|
+
const gap = 4;
|
|
71
|
+
const available = nav.clientWidth;
|
|
72
|
+
const total = (n2) => widths.reduce((sum, w, i) => i >= 1 && i <= n2 ? sum : sum + w + gap, 0) + (n2 ? more + gap : 0);
|
|
73
|
+
let n = 0;
|
|
74
|
+
while (n < items.length - 2 && total(n) > available) n++;
|
|
75
|
+
setHidden(n);
|
|
76
|
+
};
|
|
77
|
+
fit();
|
|
78
|
+
const resize = new ResizeObserver(fit);
|
|
79
|
+
resize.observe(nav);
|
|
80
|
+
resize.observe(measure);
|
|
81
|
+
return () => resize.disconnect();
|
|
82
|
+
}, [items, fontSize, fontFamily]);
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!hidden) setOpen(false);
|
|
85
|
+
}, [hidden]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!open) return void 0;
|
|
88
|
+
const menu = menuRef.current;
|
|
89
|
+
const button = moreRef.current;
|
|
90
|
+
const nav = navRef.current;
|
|
91
|
+
setMenuX(button.offsetLeft);
|
|
92
|
+
menu.querySelector(".bl-crumbs__link")?.focus();
|
|
93
|
+
const entries = () => [...menu.querySelectorAll(".bl-crumbs__link")];
|
|
94
|
+
const onKey = (event) => {
|
|
95
|
+
const list = entries();
|
|
96
|
+
const at = list.indexOf(document.activeElement);
|
|
97
|
+
if (event.key === "Escape") {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
setOpen(false);
|
|
100
|
+
button.focus();
|
|
101
|
+
} else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
list[(at + (event.key === "ArrowDown" ? 1 : -1) + list.length) % list.length]?.focus();
|
|
104
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
list[event.key === "Home" ? 0 : list.length - 1]?.focus();
|
|
107
|
+
} else if (event.key === "Tab") setOpen(false);
|
|
108
|
+
};
|
|
109
|
+
const onDown = (event) => {
|
|
110
|
+
if (!nav.contains(event.target)) setOpen(false);
|
|
111
|
+
};
|
|
112
|
+
menu.addEventListener("keydown", onKey);
|
|
113
|
+
document.addEventListener("pointerdown", onDown);
|
|
114
|
+
return () => {
|
|
115
|
+
menu.removeEventListener("keydown", onKey);
|
|
116
|
+
document.removeEventListener("pointerdown", onDown);
|
|
117
|
+
};
|
|
118
|
+
}, [open]);
|
|
119
|
+
const content = (item) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
|
+
item.icon && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: item.icon }),
|
|
121
|
+
/* @__PURE__ */ jsx("span", { className: "bl-crumbs__text", children: item.label })
|
|
122
|
+
] });
|
|
123
|
+
const link = (item, index, extra = {}) => {
|
|
124
|
+
const onClick = (event) => {
|
|
125
|
+
onNavigate?.(item, index, event);
|
|
126
|
+
setOpen(false);
|
|
127
|
+
};
|
|
128
|
+
return item.href ? /* @__PURE__ */ jsx("a", { className: "bl-crumbs__link", href: item.href, onClick, ...extra, children: content(item) }) : /* @__PURE__ */ jsx("button", { type: "button", className: "bl-crumbs__link", onClick, ...extra, children: content(item) });
|
|
129
|
+
};
|
|
130
|
+
const crumb = (item, index) => {
|
|
131
|
+
const last = index === items.length - 1;
|
|
132
|
+
return /* @__PURE__ */ jsxs("li", { className: "bl-crumbs__item", children: [
|
|
133
|
+
last ? /* @__PURE__ */ jsx("span", { className: "bl-crumbs__current", "aria-current": "page", children: content(item) }) : link(item, index),
|
|
134
|
+
!last && /* @__PURE__ */ jsx("span", { className: "bl-crumbs__sep", "aria-hidden": "true", children: separator })
|
|
135
|
+
] }, `${index}-${item.label}`);
|
|
136
|
+
};
|
|
137
|
+
const folded = items.slice(1, 1 + hidden);
|
|
138
|
+
return /* @__PURE__ */ jsxs("nav", { ref: navRef, "aria-label": label, className: `bl-crumbs ${className}`, style: { "--bl-size": `${fontSize}px`, "--bl-ink": textColor, "--bl-muted": mutedColor, "--bl-dim": dimColor, "--bl-hover": hoverColor, "--bl-chip": chipColor, "--bl-menu": menuColor, "--bl-line": lineColor, "--bl-accent": accentColor, "--bl-font": fontFamily, "--bl-menu-x": `${menuX}px`, ...style }, children: [
|
|
139
|
+
/* @__PURE__ */ jsxs("ol", { className: "bl-crumbs__list", children: [
|
|
140
|
+
items.length > 0 && crumb(items[0], 0),
|
|
141
|
+
hidden > 0 && /* @__PURE__ */ jsxs("li", { className: "bl-crumbs__item", children: [
|
|
142
|
+
/* @__PURE__ */ jsx(
|
|
143
|
+
"button",
|
|
144
|
+
{
|
|
145
|
+
ref: moreRef,
|
|
146
|
+
type: "button",
|
|
147
|
+
className: "bl-crumbs__more",
|
|
148
|
+
"aria-label": `${moreLabel} (${hidden})`,
|
|
149
|
+
"aria-haspopup": "menu",
|
|
150
|
+
"aria-expanded": open,
|
|
151
|
+
"aria-controls": open ? `${uid}-menu` : void 0,
|
|
152
|
+
onClick: () => setOpen((o) => !o),
|
|
153
|
+
onKeyDown: (event) => {
|
|
154
|
+
if (event.key === "ArrowDown") {
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
setOpen(true);
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
children: "\u2026"
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsx("span", { className: "bl-crumbs__sep", "aria-hidden": "true", children: separator })
|
|
163
|
+
] }),
|
|
164
|
+
items.slice(1 + hidden).map((item, i) => crumb(item, i + 1 + hidden))
|
|
165
|
+
] }),
|
|
166
|
+
open && /* @__PURE__ */ jsx("ul", { ref: menuRef, id: `${uid}-menu`, role: "menu", "aria-label": moreLabel, className: "bl-crumbs__menu", children: folded.map((item, i) => /* @__PURE__ */ jsx("li", { role: "none", children: link(item, i + 1, { role: "menuitem", tabIndex: -1, style: { "--i": i } }) }, `${i}-${item.label}`)) }),
|
|
167
|
+
/* @__PURE__ */ jsx("div", { className: "bl-crumbs__clip", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("div", { ref: measureRef, className: "bl-crumbs__list bl-crumbs__measure", children: [
|
|
168
|
+
items.map((item, index) => /* @__PURE__ */ jsxs("span", { className: "bl-crumbs__item", style: { animation: "none" }, children: [
|
|
169
|
+
/* @__PURE__ */ jsx("span", { className: index === items.length - 1 ? "bl-crumbs__current" : "bl-crumbs__link", children: content(item) }),
|
|
170
|
+
index < items.length - 1 && /* @__PURE__ */ jsx("span", { className: "bl-crumbs__sep", children: separator })
|
|
171
|
+
] }, `${index}-${item.label}`)),
|
|
172
|
+
/* @__PURE__ */ jsxs("span", { className: "bl-crumbs__item", style: { animation: "none" }, children: [
|
|
173
|
+
/* @__PURE__ */ jsx("span", { className: "bl-crumbs__more", children: "\u2026" }),
|
|
174
|
+
/* @__PURE__ */ jsx("span", { className: "bl-crumbs__sep", children: separator })
|
|
175
|
+
] })
|
|
176
|
+
] }) })
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
export {
|
|
180
|
+
BreadcrumbTrail as default
|
|
181
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface CRTPowerProps {
|
|
3
|
+
/** What's on the screen. It's inert and hidden from screen readers while off. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Controlled power state. */
|
|
6
|
+
on?: boolean;
|
|
7
|
+
/** Starting state when uncontrolled. */
|
|
8
|
+
defaultOn?: boolean;
|
|
9
|
+
/** Called with the new state when the power button is pressed. */
|
|
10
|
+
onChange?: (on: boolean) => void;
|
|
11
|
+
/** Power-on length, in ms (power-off is a little shorter). */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Screen height: a number in px or any CSS length. */
|
|
14
|
+
height?: number | string;
|
|
15
|
+
radius?: number;
|
|
16
|
+
background?: string;
|
|
17
|
+
bezelColor?: string;
|
|
18
|
+
/** Color of the power-on line and the fading dot. */
|
|
19
|
+
glowColor?: string;
|
|
20
|
+
scanlines?: boolean;
|
|
21
|
+
vignette?: boolean;
|
|
22
|
+
/** Show the built-in power button. */
|
|
23
|
+
showButton?: boolean;
|
|
24
|
+
/** Play the power-on animation when the component mounts. */
|
|
25
|
+
powerOnAtMount?: boolean;
|
|
26
|
+
fontFamily?: string;
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: CSSProperties;
|
|
29
|
+
}
|
|
30
|
+
export default function CRTPower({ children, on, defaultOn, onChange, duration, height, radius, background, bezelColor, glowColor, scanlines, vignette, showButton, powerOnAtMount, fontFamily, className, style }: CRTPowerProps): import("react").JSX.Element;
|
package/dist/CRTPower.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useInsertionEffect, useRef, useState } from "react";
|
|
4
|
+
const STYLE_ID = "bl-crt-power";
|
|
5
|
+
const CSS = `
|
|
6
|
+
.bl-crt { display: grid; gap: 14px; justify-items: center; width: 100%; }
|
|
7
|
+
.bl-crt__screen { position: relative; width: 100%; height: var(--bl-height); background: var(--bl-bg); overflow: hidden; border-radius: var(--bl-radius);
|
|
8
|
+
box-shadow: 0 0 0 4px #0b0b14, 0 0 0 10px var(--bl-bezel), 0 0 0 14px #0b0b14, 10px 14px 0 10px rgba(11, 11, 20, 0.4); }
|
|
9
|
+
.bl-crt__content { position: absolute; inset: 0; transform-origin: center; will-change: transform, filter; }
|
|
10
|
+
.bl-crt__content[data-off] { visibility: hidden; }
|
|
11
|
+
.bl-crt__scan { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,0.22) 2px 4px); }
|
|
12
|
+
.bl-crt__vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(120% 100% at 50% 50%, transparent 60%, rgba(0,0,0,0.55) 100%); }
|
|
13
|
+
.bl-crt__dot { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--bl-glow); box-shadow: 0 0 18px 6px var(--bl-glow); opacity: 0; pointer-events: none; }
|
|
14
|
+
.bl-crt__power { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; background: var(--bl-bezel); color: #f4f4f4; font: 9px/1 var(--bl-font, "Press Start 2P", ui-monospace, monospace); text-transform: uppercase; cursor: pointer;
|
|
15
|
+
box-shadow: 0 -3px 0 0 #0b0b14, 0 3px 0 0 #0b0b14, -3px 0 0 0 #0b0b14, 3px 0 0 0 #0b0b14; }
|
|
16
|
+
.bl-crt__power:focus-visible { outline: 3px solid #41a6f6; outline-offset: 5px; }
|
|
17
|
+
.bl-crt__led { width: 8px; height: 8px; background: #b13e53; box-shadow: 0 0 6px #b13e53; }
|
|
18
|
+
.bl-crt__power[aria-pressed="true"] .bl-crt__led { background: #a7f070; box-shadow: 0 0 8px #a7f070; }
|
|
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 reducedMotion = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
29
|
+
function CRTPower({
|
|
30
|
+
children,
|
|
31
|
+
on,
|
|
32
|
+
defaultOn = true,
|
|
33
|
+
onChange,
|
|
34
|
+
duration = 650,
|
|
35
|
+
height = 360,
|
|
36
|
+
radius = 18,
|
|
37
|
+
background = "#0b0b14",
|
|
38
|
+
bezelColor = "#333c57",
|
|
39
|
+
glowColor = "#e8f6ff",
|
|
40
|
+
scanlines = true,
|
|
41
|
+
vignette = true,
|
|
42
|
+
showButton = true,
|
|
43
|
+
powerOnAtMount = true,
|
|
44
|
+
fontFamily,
|
|
45
|
+
className = "",
|
|
46
|
+
style
|
|
47
|
+
}) {
|
|
48
|
+
useStyles();
|
|
49
|
+
const controlled = typeof on === "boolean";
|
|
50
|
+
const [internalOn, setInternalOn] = useState(defaultOn);
|
|
51
|
+
const isOn = controlled ? on : internalOn;
|
|
52
|
+
const [visible, setVisible] = useState(isOn && !powerOnAtMount);
|
|
53
|
+
const contentRef = useRef(null);
|
|
54
|
+
const dotRef = useRef(null);
|
|
55
|
+
const first = useRef(true);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const content = contentRef.current;
|
|
58
|
+
const dot = dotRef.current;
|
|
59
|
+
if (!content) return void 0;
|
|
60
|
+
if (first.current) {
|
|
61
|
+
first.current = false;
|
|
62
|
+
if (!(isOn && powerOnAtMount)) {
|
|
63
|
+
setVisible(isOn);
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const animations = [];
|
|
68
|
+
if (reducedMotion()) {
|
|
69
|
+
setVisible(true);
|
|
70
|
+
animations.push(content.animate([{ opacity: isOn ? 0 : 1 }, { opacity: isOn ? 1 : 0 }], { duration: 200, fill: "forwards" }));
|
|
71
|
+
animations[0].onfinish = () => setVisible(isOn);
|
|
72
|
+
return () => animations.forEach((animation) => animation.cancel());
|
|
73
|
+
}
|
|
74
|
+
if (isOn) {
|
|
75
|
+
setVisible(true);
|
|
76
|
+
animations.push(
|
|
77
|
+
content.animate(
|
|
78
|
+
[
|
|
79
|
+
{ transform: "scale(0, 0.004)", filter: "brightness(6)", opacity: 1 },
|
|
80
|
+
{ transform: "scale(1, 0.004)", filter: "brightness(5)", offset: 0.35 },
|
|
81
|
+
{ transform: "scale(1, 1.04)", filter: "brightness(2)", offset: 0.75 },
|
|
82
|
+
{ transform: "scale(1, 1)", filter: "brightness(1)", opacity: 1 }
|
|
83
|
+
],
|
|
84
|
+
{ duration, easing: "cubic-bezier(.2,.8,.2,1)" }
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
} else {
|
|
88
|
+
const off = content.animate(
|
|
89
|
+
[
|
|
90
|
+
{ transform: "scale(1, 1)", filter: "brightness(1)" },
|
|
91
|
+
{ transform: "scale(1, 0.004)", filter: "brightness(4)", offset: 0.55 },
|
|
92
|
+
{ transform: "scale(0, 0.004)", filter: "brightness(6)" }
|
|
93
|
+
],
|
|
94
|
+
{ duration: duration * 0.8, easing: "cubic-bezier(.6,0,.8,.2)", fill: "forwards" }
|
|
95
|
+
);
|
|
96
|
+
off.onfinish = () => {
|
|
97
|
+
setVisible(false);
|
|
98
|
+
off.cancel();
|
|
99
|
+
};
|
|
100
|
+
animations.push(off);
|
|
101
|
+
if (dot) {
|
|
102
|
+
animations.push(dot.animate([{ opacity: 0 }, { opacity: 1, offset: 0.1 }, { opacity: 0, transform: "scale(0.4)" }], { duration: duration * 1.4, delay: duration * 0.7 }));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return () => animations.forEach((animation) => animation.cancel());
|
|
106
|
+
}, [isOn, duration, powerOnAtMount]);
|
|
107
|
+
const toggle = () => {
|
|
108
|
+
const next = !isOn;
|
|
109
|
+
if (!controlled) setInternalOn(next);
|
|
110
|
+
onChange?.(next);
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsxs(
|
|
113
|
+
"div",
|
|
114
|
+
{
|
|
115
|
+
className: `bl-crt ${className}`,
|
|
116
|
+
style: {
|
|
117
|
+
"--bl-height": typeof height === "number" ? `${height}px` : height,
|
|
118
|
+
"--bl-radius": `${radius}px`,
|
|
119
|
+
"--bl-bg": background,
|
|
120
|
+
"--bl-bezel": bezelColor,
|
|
121
|
+
"--bl-glow": glowColor,
|
|
122
|
+
...fontFamily ? { "--bl-font": fontFamily } : null,
|
|
123
|
+
...style
|
|
124
|
+
},
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsxs("div", { className: "bl-crt__screen", children: [
|
|
127
|
+
/* @__PURE__ */ jsx("div", { ref: contentRef, className: "bl-crt__content", "data-off": !visible || void 0, inert: !isOn || void 0, "aria-hidden": !isOn || void 0, children }),
|
|
128
|
+
/* @__PURE__ */ jsx("div", { ref: dotRef, className: "bl-crt__dot", "aria-hidden": "true" }),
|
|
129
|
+
scanlines && /* @__PURE__ */ jsx("div", { className: "bl-crt__scan", "aria-hidden": "true" }),
|
|
130
|
+
vignette && /* @__PURE__ */ jsx("div", { className: "bl-crt__vignette", "aria-hidden": "true" })
|
|
131
|
+
] }),
|
|
132
|
+
showButton && /* @__PURE__ */ jsxs("button", { type: "button", className: "bl-crt__power", "aria-pressed": isOn, onClick: toggle, children: [
|
|
133
|
+
/* @__PURE__ */ jsx("span", { className: "bl-crt__led", "aria-hidden": "true" }),
|
|
134
|
+
isOn ? "Power off" : "Power on"
|
|
135
|
+
] })
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
export {
|
|
141
|
+
CRTPower as default
|
|
142
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
2
|
+
export interface CardDeckProps {
|
|
3
|
+
/** The cards, top first. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
/** Cards shown in the pile. */
|
|
8
|
+
visible?: number;
|
|
9
|
+
/** How far each card sits down-right of the one above, in px. */
|
|
10
|
+
offset?: number;
|
|
11
|
+
/** Fan angle per card, in degrees. */
|
|
12
|
+
fan?: number;
|
|
13
|
+
/** Drag distance (share of the width) before the card flies. */
|
|
14
|
+
threshold?: number;
|
|
15
|
+
loop?: boolean;
|
|
16
|
+
onChange?: (index: number) => void;
|
|
17
|
+
label?: string;
|
|
18
|
+
radius?: number;
|
|
19
|
+
cardColor?: string;
|
|
20
|
+
textColor?: string;
|
|
21
|
+
mutedColor?: string;
|
|
22
|
+
lineColor?: string;
|
|
23
|
+
chipColor?: string;
|
|
24
|
+
accentColor?: string;
|
|
25
|
+
fontFamily?: string;
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
}
|
|
29
|
+
export default function CardDeck({ children, width, height, visible, offset, fan, threshold, loop, onChange, label, radius, cardColor, textColor, mutedColor, lineColor, chipColor, accentColor, fontFamily, className, style }: CardDeckProps): import("react").JSX.Element;
|