@boyernick/standard-ui-react 0.1.1-canary.9 → 0.2.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/package.json +5 -3
- package/src/accordion.tsx +5 -2
- package/src/alert-dialog.tsx +1 -1
- package/src/attachment.tsx +5 -2
- package/src/autocomplete.tsx +4 -3
- package/src/block-editor.tsx +1747 -0
- package/src/brand.tsx +2 -2
- package/src/breadcrumb.tsx +14 -7
- package/src/button.tsx +22 -11
- package/src/calendar.tsx +6 -3
- package/src/carousel.tsx +220 -53
- package/src/checkbox.tsx +3 -2
- package/src/code-block.tsx +66 -5
- package/src/collapsible.tsx +4 -2
- package/src/combobox.tsx +4 -3
- package/src/command.tsx +27 -12
- package/src/dialog.tsx +33 -10
- package/src/empty.tsx +4 -4
- package/src/field.tsx +4 -3
- package/src/filter-group.tsx +143 -0
- package/src/icons.tsx +28 -1
- package/src/illustrations.tsx +219 -141
- package/src/index.ts +238 -18
- package/src/input.tsx +8 -5
- package/src/kbd.tsx +10 -4
- package/src/lib/focus.ts +41 -0
- package/src/lib/popup.ts +1 -1
- package/src/lifeline/company-icon.tsx +71 -0
- package/src/lifeline/index.ts +42 -0
- package/src/lifeline/lifeline-data.ts +97 -0
- package/src/lifeline/lifeline-desktop.tsx +204 -0
- package/src/lifeline/lifeline-event.tsx +108 -0
- package/src/lifeline/lifeline-fireworks.tsx +302 -0
- package/src/lifeline/lifeline-hover-image.tsx +269 -0
- package/src/lifeline/lifeline-icons.tsx +39 -0
- package/src/lifeline/lifeline-intro-timing.ts +105 -0
- package/src/lifeline/lifeline-labels.tsx +24 -0
- package/src/lifeline/lifeline-layout.ts +1 -0
- package/src/lifeline/lifeline-legend.tsx +31 -0
- package/src/lifeline/lifeline-lightbox.tsx +309 -0
- package/src/lifeline/lifeline-marker.tsx +183 -0
- package/src/lifeline/lifeline-people.tsx +99 -0
- package/src/lifeline/lifeline-photos.tsx +366 -0
- package/src/lifeline/lifeline-shell.tsx +135 -0
- package/src/lifeline/lifeline-utils.ts +83 -0
- package/src/lifeline/lifeline-vertical.tsx +482 -0
- package/src/lifeline/lifeline.tsx +69 -0
- package/src/lifeline/types.ts +112 -0
- package/src/lifeline/use-lifeline-intro.ts +130 -0
- package/src/lifeline/use-lifeline-scroll.ts +1011 -0
- package/src/lifeline/use-lifeline-vertical-scroll.ts +271 -0
- package/src/menubar.tsx +9 -2
- package/src/minimap.tsx +296 -0
- package/src/modal.tsx +608 -0
- package/src/navigation-menu.tsx +338 -67
- package/src/number-field.tsx +336 -61
- package/src/otp-field.tsx +4 -3
- package/src/pagination.tsx +262 -42
- package/src/password-protection.tsx +345 -0
- package/src/popover.tsx +1 -1
- package/src/progress.tsx +5 -0
- package/src/questionnaire.tsx +284 -0
- package/src/radio.tsx +4 -2
- package/src/scroll-area.tsx +4 -1
- package/src/select.tsx +5 -2
- package/src/sidebar.tsx +113 -28
- package/src/slider.tsx +66 -6
- package/src/sounds.tsx +6 -10
- package/src/spinner.tsx +105 -32
- package/src/switch.tsx +4 -1
- package/src/table.tsx +82 -15
- package/src/tabs.tsx +189 -38
- package/src/text-animate.tsx +71 -28
- package/src/textarea.tsx +6 -1
- package/src/timeline.tsx +378 -0
- package/src/toast.tsx +214 -35
- package/src/toggle.tsx +4 -2
- package/src/toolbar.tsx +12 -7
- package/src/tooltip.tsx +43 -3
- package/src/video-player.tsx +396 -127
- package/src/image-modal.tsx +0 -110
- package/src/markdown-editor.tsx +0 -302
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
4
|
+
import {
|
|
5
|
+
getTransitionMarkerFadeDuration,
|
|
6
|
+
LIFELINE_FAST_MARKER_FADE_MS,
|
|
7
|
+
timeAtTrackProgress,
|
|
8
|
+
trackProgressAtTime,
|
|
9
|
+
} from "./lifeline-intro-timing"
|
|
10
|
+
|
|
11
|
+
/** Tweak these */
|
|
12
|
+
export const LIFELINE_LABELS_MS = 600
|
|
13
|
+
export const LIFELINE_RAIL_MS = 3200
|
|
14
|
+
/**
|
|
15
|
+
* Track length (px on desktop, tall lifelines on mobile) the base rail
|
|
16
|
+
* duration was tuned for — roughly a 40-year personal lifeline. Longer
|
|
17
|
+
* tracks slow the sweep sublinearly so dense timelines stay readable,
|
|
18
|
+
* capped so a 250-year nation doesn't become a screensaver.
|
|
19
|
+
*/
|
|
20
|
+
export const LIFELINE_REFERENCE_TRACK = 9000
|
|
21
|
+
export const LIFELINE_RAIL_MAX_MS = 7200
|
|
22
|
+
export const LIFELINE_RAIL_SCALE_POWER = 0.45
|
|
23
|
+
/**
|
|
24
|
+
* Keep fade stretching subtle — long fades lag behind the sweeping
|
|
25
|
+
* line and read as out of sync.
|
|
26
|
+
*/
|
|
27
|
+
export const LIFELINE_FADE_SCALE_MAX = 1.5
|
|
28
|
+
|
|
29
|
+
export function useLifelineIntro(markerWidths: number[]) {
|
|
30
|
+
// Skip straight to the settled end state for users who prefer reduced motion.
|
|
31
|
+
const [shouldPlay] = useState(
|
|
32
|
+
() =>
|
|
33
|
+
typeof window === "undefined" ||
|
|
34
|
+
!window.matchMedia("(prefers-reduced-motion: reduce)").matches,
|
|
35
|
+
)
|
|
36
|
+
const [isPlaying, setIsPlaying] = useState(true)
|
|
37
|
+
const [isComplete, setIsComplete] = useState(false)
|
|
38
|
+
const introTimeoutRef = useRef(0)
|
|
39
|
+
|
|
40
|
+
const totalMarkersWidth = useMemo(
|
|
41
|
+
() => markerWidths.reduce((sum, width) => sum + width, 0),
|
|
42
|
+
[markerWidths],
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const railDuration = useMemo(() => {
|
|
46
|
+
if (totalMarkersWidth <= LIFELINE_REFERENCE_TRACK) return LIFELINE_RAIL_MS
|
|
47
|
+
|
|
48
|
+
const scale = Math.pow(
|
|
49
|
+
totalMarkersWidth / LIFELINE_REFERENCE_TRACK,
|
|
50
|
+
LIFELINE_RAIL_SCALE_POWER,
|
|
51
|
+
)
|
|
52
|
+
return Math.min(LIFELINE_RAIL_MAX_MS, Math.round(LIFELINE_RAIL_MS * scale))
|
|
53
|
+
}, [totalMarkersWidth])
|
|
54
|
+
|
|
55
|
+
// Stretch each marker's fade with the sweep so dense timelines bloom
|
|
56
|
+
// in a trailing wave instead of flickering past.
|
|
57
|
+
const fadeScale = Math.min(
|
|
58
|
+
LIFELINE_FADE_SCALE_MAX,
|
|
59
|
+
railDuration / LIFELINE_RAIL_MS,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
const introDuration =
|
|
63
|
+
railDuration + Math.round(LIFELINE_FAST_MARKER_FADE_MS * fadeScale)
|
|
64
|
+
|
|
65
|
+
const getTrackProgressAtTime = useCallback(
|
|
66
|
+
(elapsedMs: number) => {
|
|
67
|
+
if (!shouldPlay || totalMarkersWidth <= 0) {
|
|
68
|
+
return Math.min(elapsedMs / railDuration, 1)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return trackProgressAtTime(elapsedMs, markerWidths, railDuration)
|
|
72
|
+
},
|
|
73
|
+
[markerWidths, railDuration, shouldPlay, totalMarkersWidth],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const getMarkerDelay = useCallback(
|
|
77
|
+
(index: number) => {
|
|
78
|
+
if (!shouldPlay || totalMarkersWidth <= 0) return 0
|
|
79
|
+
|
|
80
|
+
const offset = markerWidths
|
|
81
|
+
.slice(0, index)
|
|
82
|
+
.reduce((sum, width) => sum + width, 0)
|
|
83
|
+
|
|
84
|
+
return timeAtTrackProgress(
|
|
85
|
+
offset / totalMarkersWidth,
|
|
86
|
+
markerWidths,
|
|
87
|
+
railDuration,
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
[markerWidths, railDuration, shouldPlay, totalMarkersWidth],
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
const getMarkerFadeDuration = useCallback(
|
|
94
|
+
(index: number) => {
|
|
95
|
+
return Math.round(getTransitionMarkerFadeDuration(index) * fadeScale)
|
|
96
|
+
},
|
|
97
|
+
[fadeScale],
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
const completeIntro = useCallback(() => {
|
|
101
|
+
setIsComplete(true)
|
|
102
|
+
}, [])
|
|
103
|
+
|
|
104
|
+
const startIntroTimer = useCallback(() => {
|
|
105
|
+
window.clearTimeout(introTimeoutRef.current)
|
|
106
|
+
setIsPlaying(true)
|
|
107
|
+
setIsComplete(false)
|
|
108
|
+
|
|
109
|
+
introTimeoutRef.current = window.setTimeout(() => {
|
|
110
|
+
setIsPlaying(false)
|
|
111
|
+
}, introDuration)
|
|
112
|
+
}, [introDuration])
|
|
113
|
+
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
return () => window.clearTimeout(introTimeoutRef.current)
|
|
116
|
+
}, [])
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
shouldPlay,
|
|
120
|
+
isPlaying,
|
|
121
|
+
isComplete,
|
|
122
|
+
labelsDuration: LIFELINE_LABELS_MS,
|
|
123
|
+
railDuration,
|
|
124
|
+
getTrackProgressAtTime,
|
|
125
|
+
getMarkerDelay,
|
|
126
|
+
getMarkerFadeDuration,
|
|
127
|
+
startIntroTimer,
|
|
128
|
+
completeIntro,
|
|
129
|
+
}
|
|
130
|
+
}
|