@therealtinhtute/baroiplayer 1.2.1 → 2.0.0-beta.1
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/README.md +90 -71
- package/dist/components/icons/index.d.ts +36 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
- package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +750 -5640
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +110 -114
- package/src/components/variants/gradient/gradient-audio.tsx +47 -0
- package/src/components/variants/gradient/gradient-controls.tsx +254 -0
- package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
- package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
- package/src/components/variants/gradient/gradient-skin.css +211 -0
- package/src/components/variants/gradient/gradient-video.tsx +70 -0
- package/src/index.ts +5 -198
- package/src/test/accessibility-utils.ts +0 -59
- package/dist/context/media.js +0 -1
- package/dist/context/media.mjs +0 -3
- package/dist/context/store.js +0 -1
- package/dist/context/store.mjs +0 -3
- package/dist/context-Bzd5QCKM.cjs +0 -7
- package/dist/context-Bzd5QCKM.cjs.map +0 -1
- package/dist/context-DD_SH4tT.js +0 -1053
- package/dist/context-DD_SH4tT.js.map +0 -1
- package/dist/core-events-BRnLMB7s.cjs +0 -2
- package/dist/core-events-BRnLMB7s.cjs.map +0 -1
- package/dist/core-events-v_mKdj5p.js +0 -417
- package/dist/core-events-v_mKdj5p.js.map +0 -1
- package/dist/core-plugins-CMBv-yVh.cjs +0 -2
- package/dist/core-plugins-CMBv-yVh.cjs.map +0 -1
- package/dist/core-plugins-CqCxLkbd.js +0 -754
- package/dist/core-plugins-CqCxLkbd.js.map +0 -1
- package/dist/core.js +0 -15
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -960
- package/dist/core.mjs.map +0 -1
- package/dist/enhanced-components-BwjBqSA1.js +0 -2858
- package/dist/enhanced-components-BwjBqSA1.js.map +0 -1
- package/dist/enhanced-components-C-ka-XLp.cjs +0 -2
- package/dist/enhanced-components-C-ka-XLp.cjs.map +0 -1
- package/dist/hooks-B-IIWPJr.js +0 -1842
- package/dist/hooks-B-IIWPJr.js.map +0 -1
- package/dist/hooks-DcHzmBwA.cjs +0 -4
- package/dist/hooks-DcHzmBwA.cjs.map +0 -1
- package/dist/minimal-components-BYsMQde5.js +0 -1610
- package/dist/minimal-components-BYsMQde5.js.map +0 -1
- package/dist/minimal-components-CsxQbDp7.cjs +0 -2
- package/dist/minimal-components-CsxQbDp7.cjs.map +0 -1
- package/dist/minimal-components.css +0 -1
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-DCSijLJg.js +0 -312
- package/dist/performance-monitor-DCSijLJg.js.map +0 -1
- package/dist/performance-monitor-wNFKmqMr.cjs +0 -2
- package/dist/performance-monitor-wNFKmqMr.cjs.map +0 -1
- package/dist/rolldown-runtime-BmowowmI.js +0 -14
- package/dist/rolldown-runtime-mLOUI7ql.cjs +0 -1
- package/dist/utils-D2gQ7c2R.js +0 -64
- package/dist/utils-D2gQ7c2R.js.map +0 -1
- package/dist/utils-DJaAwiZ9.cjs +0 -2
- package/dist/utils-DJaAwiZ9.cjs.map +0 -1
- package/dist/utils.js +0 -1
- package/dist/utils.mjs +0 -3
- package/src/adapters/videojs-adapter.tsx +0 -470
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +0 -111
- package/src/components/LoadingState.tsx +0 -239
- package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
- package/src/components/__tests__/media-player-react19.test.tsx +0 -457
- package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
- package/src/components/audio-player.tsx +0 -85
- package/src/components/basic/index.ts +0 -37
- package/src/components/enhanced/advanced-features.tsx +0 -311
- package/src/components/enhanced/debug-panel.tsx +0 -448
- package/src/components/enhanced/enhanced-controls.tsx +0 -597
- package/src/components/enhanced/enhanced-media-player.tsx +0 -566
- package/src/components/enhanced/error-handling.tsx +0 -338
- package/src/components/enhanced/index.ts +0 -39
- package/src/components/enhanced/media-player-enhanced.tsx +0 -383
- package/src/components/examples/basic-video-player.tsx +0 -50
- package/src/components/examples/custom-controls-example.tsx +0 -63
- package/src/components/examples/enhanced-controls-example.tsx +0 -100
- package/src/components/examples/enhanced-media-player-example.tsx +0 -302
- package/src/components/examples/loading-states-demo.tsx +0 -141
- package/src/components/examples/react-19-demo.tsx +0 -349
- package/src/components/examples/volume-orientation-demo.tsx +0 -105
- package/src/components/icon-demo.tsx +0 -196
- package/src/components/legacy.tsx +0 -87
- package/src/components/media-metadata-display.tsx +0 -99
- package/src/components/media-player-audio.tsx +0 -39
- package/src/components/media-player-controls.tsx +0 -223
- package/src/components/media-player-error.tsx +0 -163
- package/src/components/media-player-fullscreen.tsx +0 -109
- package/src/components/media-player-hls.tsx +0 -111
- package/src/components/media-player-loading.tsx +0 -76
- package/src/components/media-player-play.tsx +0 -75
- package/src/components/media-player-root.tsx +0 -338
- package/src/components/media-player-seek.tsx +0 -168
- package/src/components/media-player-time.tsx +0 -99
- package/src/components/media-player-tooltip.tsx +0 -58
- package/src/components/media-player-video.tsx +0 -54
- package/src/components/media-player-volume.tsx +0 -155
- package/src/components/media-player.tsx +0 -292
- package/src/components/media-suspense.tsx +0 -344
- package/src/components/player-settings-form.tsx +0 -158
- package/src/components/react-player-wrapper.tsx +0 -651
- package/src/components/simple-video-player.tsx +0 -62
- package/src/components/ui/blur-poster.tsx +0 -96
- package/src/components/ui/empty-state.tsx +0 -91
- package/src/components/ui/enhanced-seek-bar.tsx +0 -254
- package/src/components/ui/error-state.tsx +0 -124
- package/src/components/ui/fullscreen-button.tsx +0 -81
- package/src/components/ui/loading-skeleton.tsx +0 -107
- package/src/components/ui/media-resource-preloader.tsx +0 -458
- package/src/components/ui/offline-message.tsx +0 -98
- package/src/components/ui/play-button.tsx +0 -99
- package/src/components/ui/seek-bar.tsx +0 -191
- package/src/components/ui/time-display.tsx +0 -61
- package/src/components/ui/volume-control.tsx +0 -190
- package/src/components/unified/base-media-player.tsx +0 -252
- package/src/components/unified/media-player.tsx +0 -75
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
- package/src/components/variants/minimal/MinimalControls.tsx +0 -124
- package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
- package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
- package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
- package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
- package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
- package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
- package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
- package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
- package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
- package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
- package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
- package/src/components/variants/minimal/components/RightControls.tsx +0 -164
- package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
- package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
- package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
- package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
- package/src/components/variants/minimal/components/VideoElement.tsx +0 -35
- package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
- package/src/components/variants/minimal/index.ts +0 -23
- package/src/components/video-player.tsx +0 -100
- package/src/context/__tests__/media-store.test.ts +0 -509
- package/src/context/error-handling.ts +0 -398
- package/src/context/media-context.tsx +0 -254
- package/src/context/media-provider.tsx +0 -264
- package/src/context/media-store.ts +0 -387
- package/src/context/persistence.ts +0 -462
- package/src/core/events/event-system.ts +0 -448
- package/src/core/events/hooks.ts +0 -325
- package/src/core/events/index.ts +0 -22
- package/src/core/events/middleware.ts +0 -286
- package/src/core/index.ts +0 -22
- package/src/core/optimization/bundle-optimizer.tsx +0 -312
- package/src/core/performance/cicd.ts +0 -98
- package/src/core/performance/index.ts +0 -38
- package/src/core/performance/media-loading-optimizer.ts +0 -545
- package/src/core/performance/performance-budgets.ts +0 -437
- package/src/core/performance/performance-monitor.tsx +0 -488
- package/src/core/performance/performance-testing.ts +0 -461
- package/src/core/plugins/__tests__/registry.test.ts +0 -595
- package/src/core/plugins/base-plugin.ts +0 -225
- package/src/core/plugins/enhanced-plugin-system.ts +0 -435
- package/src/core/plugins/examples/analytics-plugin.ts +0 -241
- package/src/core/plugins/index.ts +0 -39
- package/src/core/plugins/registry.ts +0 -546
- package/src/core/plugins/types.ts +0 -169
- package/src/core/plugins/utils.ts +0 -317
- package/src/core/progressive-loading.tsx +0 -331
- package/src/core/providers/enhanced-hls-provider.ts +0 -307
- package/src/core/providers/lazy-provider.tsx +0 -14
- package/src/core/providers/service-provider.tsx +0 -164
- package/src/core/utils.tsx +0 -34
- package/src/features/media-session/media-session-manager.ts +0 -411
- package/src/features/picture-in-picture/pip-manager.ts +0 -428
- package/src/features/playlist/playlist-manager.ts +0 -626
- package/src/features/subtitles/subtitle-manager.ts +0 -435
- package/src/features/subtitles/subtitle-parser.ts +0 -284
- package/src/features/thumbnails/thumbnail-generator.ts +0 -528
- package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
- package/src/hooks/__tests__/use-media-player.test.ts +0 -712
- package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
- package/src/hooks/accessibility/index.ts +0 -27
- package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
- package/src/hooks/accessibility/use-focus-management.ts +0 -183
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
- package/src/hooks/accessibility/use-screen-reader.ts +0 -212
- package/src/hooks/core/index.ts +0 -47
- package/src/hooks/legacy.ts +0 -21
- package/src/hooks/use-buffer-health.ts +0 -218
- package/src/hooks/use-enhanced-media-player.ts +0 -575
- package/src/hooks/use-focus-trap.tsx +0 -162
- package/src/hooks/use-intelligent-preloading.ts +0 -387
- package/src/hooks/use-keyboard-controls.ts +0 -115
- package/src/hooks/use-keyboard-shortcuts.ts +0 -255
- package/src/hooks/use-media-actions.ts +0 -184
- package/src/hooks/use-media-metadata.ts +0 -91
- package/src/hooks/use-media-optimistic.ts +0 -264
- package/src/hooks/use-media-player.ts +0 -343
- package/src/hooks/use-media-state.ts +0 -194
- package/src/hooks/use-memory-optimization.ts +0 -360
- package/src/hooks/use-network-status.ts +0 -124
- package/src/hooks/use-optimistic-controls.ts +0 -95
- package/src/hooks/use-optimized-media.ts +0 -283
- package/src/hooks/use-smart-preload.ts +0 -229
- package/src/hooks/use-touch-gestures.ts +0 -461
- package/src/hooks/useEnhancedSubtitles.ts +0 -258
- package/src/hooks/useKeyboardShortcuts.ts +0 -106
- package/src/hooks/useMediaControls.ts +0 -52
- package/src/hooks/useScreenshot.ts +0 -77
- package/src/hooks/useSubtitles.ts +0 -91
- package/src/hooks/useVideoPlayer.ts +0 -278
- package/src/icons/components/FullscreenIcon.tsx +0 -36
- package/src/icons/components/SettingsIcon.tsx +0 -37
- package/src/icons/components/animated/LoadingIcon.tsx +0 -27
- package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
- package/src/icons/components/media/PauseIcon.tsx +0 -38
- package/src/icons/components/media/PlayIcon.tsx +0 -37
- package/src/icons/components/volume/VolumeIcon.tsx +0 -38
- package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
- package/src/icons/index.ts +0 -56
- package/src/icons/provider.tsx +0 -58
- package/src/icons/types.ts +0 -60
- package/src/index-enhanced.ts +0 -35
- package/src/index-legacy.ts +0 -324
- package/src/index.css +0 -102
- package/src/lib/__tests__/async-utils.test.ts +0 -291
- package/src/lib/async-utils.ts +0 -194
- package/src/lib/deprecation.ts +0 -51
- package/src/lib/format-time.ts +0 -37
- package/src/lib/index.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -462
- package/src/styles/minimal-player.css +0 -621
- package/src/styles/pixel-art.css +0 -41
- package/src/styles/videojs.css +0 -100
- package/src/types/assets.d.ts +0 -29
- package/src/types/events.ts +0 -47
- package/src/types/formats.ts +0 -79
- package/src/types/index.ts +0 -203
- package/src/types/videojs-plugins.d.ts +0 -14
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { memo } from "react"
|
|
2
|
-
import { cn } from "../../lib/utils"
|
|
3
|
-
|
|
4
|
-
interface BlurPosterProps {
|
|
5
|
-
src: string
|
|
6
|
-
alt: string
|
|
7
|
-
className?: string
|
|
8
|
-
intensity?: "low" | "medium" | "high"
|
|
9
|
-
transitionDuration?: number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const intensityBlurPx = {
|
|
13
|
-
low: "8px",
|
|
14
|
-
medium: "16px",
|
|
15
|
-
high: "32px"
|
|
16
|
-
} as const
|
|
17
|
-
|
|
18
|
-
const BlurPosterComponent = memo(function BlurPoster({
|
|
19
|
-
src,
|
|
20
|
-
alt,
|
|
21
|
-
className,
|
|
22
|
-
intensity = "medium",
|
|
23
|
-
transitionDuration = 300
|
|
24
|
-
}: BlurPosterProps) {
|
|
25
|
-
return (
|
|
26
|
-
<div
|
|
27
|
-
className={cn("relative overflow-hidden bg-black/20", className)}
|
|
28
|
-
aria-label={alt}
|
|
29
|
-
role="img">
|
|
30
|
-
<div
|
|
31
|
-
className="absolute inset-0 bg-center bg-cover opacity-100"
|
|
32
|
-
style={{
|
|
33
|
-
backgroundImage: `url('${src}')`,
|
|
34
|
-
filter: `blur(${intensityBlurPx[intensity]})`
|
|
35
|
-
}}
|
|
36
|
-
/>
|
|
37
|
-
<div
|
|
38
|
-
className="absolute inset-0 bg-gradient-to-t from-black/60 via-transparent to-black/20"
|
|
39
|
-
style={{ transitionDuration: `${transitionDuration}ms` }}
|
|
40
|
-
/>
|
|
41
|
-
</div>
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
interface BlurPosterWithPlaceholderProps {
|
|
46
|
-
src: string
|
|
47
|
-
placeholderSrc?: string
|
|
48
|
-
alt: string
|
|
49
|
-
className?: string
|
|
50
|
-
intensity?: "low" | "medium" | "high"
|
|
51
|
-
isLoading?: boolean
|
|
52
|
-
children?: React.ReactNode
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const BlurPosterWithPlaceholder = memo(function BlurPosterWithPlaceholder({
|
|
56
|
-
src,
|
|
57
|
-
placeholderSrc,
|
|
58
|
-
alt,
|
|
59
|
-
className,
|
|
60
|
-
intensity = "medium",
|
|
61
|
-
isLoading = true,
|
|
62
|
-
children
|
|
63
|
-
}: BlurPosterWithPlaceholderProps) {
|
|
64
|
-
return (
|
|
65
|
-
<div className={cn("relative overflow-hidden", className)}>
|
|
66
|
-
{isLoading ? (
|
|
67
|
-
<>
|
|
68
|
-
{placeholderSrc && (
|
|
69
|
-
<img
|
|
70
|
-
src={placeholderSrc}
|
|
71
|
-
alt=""
|
|
72
|
-
className={cn("absolute inset-0 h-full w-full object-cover", `scale-105 blur-md`)}
|
|
73
|
-
aria-hidden="true"
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
76
|
-
<div
|
|
77
|
-
className={cn(
|
|
78
|
-
"absolute inset-0 bg-center bg-cover opacity-0 transition-opacity duration-500",
|
|
79
|
-
!isLoading && "opacity-100"
|
|
80
|
-
)}
|
|
81
|
-
style={{
|
|
82
|
-
backgroundImage: `url('${src}')`,
|
|
83
|
-
filter: `blur(${intensityBlurPx[intensity]})`
|
|
84
|
-
}}
|
|
85
|
-
aria-hidden="true"
|
|
86
|
-
/>
|
|
87
|
-
</>
|
|
88
|
-
) : (
|
|
89
|
-
<img src={src} alt={alt} className="absolute inset-0 h-full w-full object-cover" />
|
|
90
|
-
)}
|
|
91
|
-
{children}
|
|
92
|
-
</div>
|
|
93
|
-
)
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
export const BlurPoster = BlurPosterComponent
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { Film, FolderOpen, Music, Play, Search } from "lucide-react"
|
|
2
|
-
import { type ReactNode, memo } from "react"
|
|
3
|
-
import { cn } from "../../lib/utils"
|
|
4
|
-
|
|
5
|
-
export interface EmptyStateProps {
|
|
6
|
-
title?: string
|
|
7
|
-
description?: string
|
|
8
|
-
icon?: ReactNode
|
|
9
|
-
action?: ReactNode
|
|
10
|
-
className?: string
|
|
11
|
-
variant?: "default" | "media" | "playlist" | "search" | "folder"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const variantIcons = {
|
|
15
|
-
default: null,
|
|
16
|
-
media: <Film size={48} className="text-[color:var(--media-text-secondary)]" />,
|
|
17
|
-
playlist: <Play size={48} className="text-[color:var(--media-text-secondary)]" />,
|
|
18
|
-
search: <Search size={48} className="text-[color:var(--media-text-secondary)]" />,
|
|
19
|
-
folder: <FolderOpen size={48} className="text-[color:var(--media-text-secondary)]" />
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const EmptyStateComponent = memo(function EmptyState({
|
|
23
|
-
title = "No content here",
|
|
24
|
-
description,
|
|
25
|
-
icon,
|
|
26
|
-
action,
|
|
27
|
-
className,
|
|
28
|
-
variant = "default"
|
|
29
|
-
}: EmptyStateProps) {
|
|
30
|
-
const displayIcon = icon ?? variantIcons[variant]
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<div
|
|
34
|
-
className={cn(
|
|
35
|
-
"flex flex-col items-center justify-center p-8 text-center",
|
|
36
|
-
"rounded-lg bg-[color:var(--media-bg)]",
|
|
37
|
-
className
|
|
38
|
-
)}
|
|
39
|
-
role="status"
|
|
40
|
-
aria-live="polite">
|
|
41
|
-
{displayIcon && (
|
|
42
|
-
<div className="mb-4" aria-hidden="true">
|
|
43
|
-
{displayIcon}
|
|
44
|
-
</div>
|
|
45
|
-
)}
|
|
46
|
-
<h3 className="mb-2 font-semibold text-[color:var(--media-text)] text-lg">{title}</h3>
|
|
47
|
-
{description && (
|
|
48
|
-
<p className="mb-4 max-w-sm text-[color:var(--media-text-secondary)] text-sm">
|
|
49
|
-
{description}
|
|
50
|
-
</p>
|
|
51
|
-
)}
|
|
52
|
-
{action && <div>{action}</div>}
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
interface MediaEmptyStateProps {
|
|
58
|
-
type?: "video" | "audio" | "playlist"
|
|
59
|
-
action?: ReactNode
|
|
60
|
-
className?: string
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const MediaEmptyState = memo(function MediaEmptyState({
|
|
64
|
-
type = "video",
|
|
65
|
-
action,
|
|
66
|
-
className
|
|
67
|
-
}: MediaEmptyStateProps) {
|
|
68
|
-
const titles = {
|
|
69
|
-
video: "No video available",
|
|
70
|
-
audio: "No audio tracks",
|
|
71
|
-
playlist: "Playlist is empty"
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const descriptions = {
|
|
75
|
-
video: "Select a video to start watching",
|
|
76
|
-
audio: "Add audio files to your library",
|
|
77
|
-
playlist: "Add videos to your playlist to see them here"
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<EmptyStateComponent
|
|
82
|
-
title={titles[type]}
|
|
83
|
-
description={descriptions[type]}
|
|
84
|
-
variant={type === "video" ? "media" : type === "audio" ? "media" : "playlist"}
|
|
85
|
-
action={action}
|
|
86
|
-
className={className}
|
|
87
|
-
/>
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
export { EmptyStateComponent as EmptyState }
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as Slider from "@radix-ui/react-slider"
|
|
4
|
-
import * as Tooltip from "@radix-ui/react-tooltip"
|
|
5
|
-
import {
|
|
6
|
-
forwardRef,
|
|
7
|
-
useCallback,
|
|
8
|
-
useDeferredValue,
|
|
9
|
-
useMemo,
|
|
10
|
-
useRef,
|
|
11
|
-
useState,
|
|
12
|
-
useTransition
|
|
13
|
-
} from "react"
|
|
14
|
-
import { formatTime } from "../../lib/format-time"
|
|
15
|
-
import { cn } from "../../lib/utils"
|
|
16
|
-
import type { SeekBarProps } from "../../types/index"
|
|
17
|
-
|
|
18
|
-
export const EnhancedSeekBar = forwardRef<HTMLDivElement, SeekBarProps>(
|
|
19
|
-
({ currentTime, duration, buffered, onSeek, size = "sm", className }, ref) => {
|
|
20
|
-
// React 19 concurrent features
|
|
21
|
-
const [isPending, startTransition] = useTransition()
|
|
22
|
-
const [isDragging, setIsDragging] = useState(false)
|
|
23
|
-
const [previewTime, setPreviewTime] = useState(0)
|
|
24
|
-
const [isHovering, setIsHovering] = useState(false)
|
|
25
|
-
|
|
26
|
-
// Defer non-critical updates for better performance
|
|
27
|
-
const deferredHovering = useDeferredValue(isHovering)
|
|
28
|
-
const deferredPreviewTime = useDeferredValue(previewTime)
|
|
29
|
-
|
|
30
|
-
// Throttling refs
|
|
31
|
-
const seekTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined)
|
|
32
|
-
const lastSeekTime = useRef<number>(0)
|
|
33
|
-
const rafId = useRef<number | undefined>(undefined)
|
|
34
|
-
|
|
35
|
-
// Memoize expensive calculations
|
|
36
|
-
const progress = useMemo(
|
|
37
|
-
() => (duration > 0 ? (currentTime / duration) * 100 : 0),
|
|
38
|
-
[currentTime, duration]
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
// Calculate buffered ranges with memoization
|
|
42
|
-
const bufferedRanges = useMemo(() => {
|
|
43
|
-
const ranges = []
|
|
44
|
-
if (buffered && duration > 0) {
|
|
45
|
-
for (let i = 0; i < buffered.length; i++) {
|
|
46
|
-
const start = (buffered.start(i) / duration) * 100
|
|
47
|
-
const end = (buffered.end(i) / duration) * 100
|
|
48
|
-
ranges.push({ start, end })
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return ranges
|
|
52
|
-
}, [buffered, duration])
|
|
53
|
-
|
|
54
|
-
// Optimized value change handler with throttling and RAF
|
|
55
|
-
const handleValueChange = useCallback(
|
|
56
|
-
([value]: number[]) => {
|
|
57
|
-
const time = ((value ?? 0) / 100) * duration
|
|
58
|
-
|
|
59
|
-
setPreviewTime(time)
|
|
60
|
-
|
|
61
|
-
// Cancel any pending RAF
|
|
62
|
-
if (rafId.current) {
|
|
63
|
-
cancelAnimationFrame(rafId.current)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (isDragging) {
|
|
67
|
-
// Clear previous timeout
|
|
68
|
-
if (seekTimeoutRef.current) {
|
|
69
|
-
clearTimeout(seekTimeoutRef.current)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Use RAF for smooth updates during dragging
|
|
73
|
-
rafId.current = requestAnimationFrame(() => {
|
|
74
|
-
const now = performance.now()
|
|
75
|
-
const timeDiff = now - lastSeekTime.current
|
|
76
|
-
const timeJump = Math.abs(time - currentTime)
|
|
77
|
-
|
|
78
|
-
// Only seek if enough time has passed or if this is a large jump
|
|
79
|
-
if (timeDiff > 16 || timeJump > 0.5) {
|
|
80
|
-
// 60fps = 16ms per frame
|
|
81
|
-
startTransition(() => {
|
|
82
|
-
onSeek(time)
|
|
83
|
-
})
|
|
84
|
-
lastSeekTime.current = now
|
|
85
|
-
} else {
|
|
86
|
-
// Defer the seek
|
|
87
|
-
seekTimeoutRef.current = setTimeout(() => {
|
|
88
|
-
startTransition(() => {
|
|
89
|
-
onSeek(time)
|
|
90
|
-
})
|
|
91
|
-
lastSeekTime.current = performance.now()
|
|
92
|
-
}, 16)
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
[duration, isDragging, onSeek, currentTime, startTransition]
|
|
98
|
-
)
|
|
99
|
-
|
|
100
|
-
const handleValueCommit = useCallback(
|
|
101
|
-
([value]: number[]) => {
|
|
102
|
-
const time = ((value ?? 0) / 100) * duration
|
|
103
|
-
|
|
104
|
-
// Cancel any pending RAF
|
|
105
|
-
if (rafId.current) {
|
|
106
|
-
cancelAnimationFrame(rafId.current)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Clear any pending seeks
|
|
110
|
-
if (seekTimeoutRef.current) {
|
|
111
|
-
clearTimeout(seekTimeoutRef.current)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
startTransition(() => {
|
|
115
|
-
onSeek(time)
|
|
116
|
-
})
|
|
117
|
-
setIsDragging(false)
|
|
118
|
-
},
|
|
119
|
-
[duration, onSeek, startTransition]
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
const handlePointerDown = useCallback(() => {
|
|
123
|
-
setIsDragging(true)
|
|
124
|
-
lastSeekTime.current = performance.now()
|
|
125
|
-
}, [])
|
|
126
|
-
|
|
127
|
-
// Cleanup on unmount
|
|
128
|
-
useMemo(() => {
|
|
129
|
-
return () => {
|
|
130
|
-
if (rafId.current) {
|
|
131
|
-
cancelAnimationFrame(rafId.current)
|
|
132
|
-
}
|
|
133
|
-
if (seekTimeoutRef.current) {
|
|
134
|
-
clearTimeout(seekTimeoutRef.current)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}, [])
|
|
138
|
-
|
|
139
|
-
// Memoize tooltip content to prevent re-renders
|
|
140
|
-
const tooltipContent = useMemo(() => {
|
|
141
|
-
return (
|
|
142
|
-
<div
|
|
143
|
-
className={cn(
|
|
144
|
-
"rounded bg-black/80 px-2 py-1 text-sm text-white",
|
|
145
|
-
"fade-in-0 zoom-in-95 animate-in"
|
|
146
|
-
)}>
|
|
147
|
-
{formatTime(deferredPreviewTime)}
|
|
148
|
-
</div>
|
|
149
|
-
)
|
|
150
|
-
}, [deferredPreviewTime])
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<div
|
|
154
|
-
ref={ref}
|
|
155
|
-
className={cn(
|
|
156
|
-
"media-container relative w-full text-[color:var(--media-text)]",
|
|
157
|
-
"touch-manipulation contain-layout",
|
|
158
|
-
className
|
|
159
|
-
)}
|
|
160
|
-
onMouseEnter={() => setIsHovering(true)}
|
|
161
|
-
onMouseLeave={() => setIsHovering(false)}>
|
|
162
|
-
<Tooltip.Provider>
|
|
163
|
-
<Tooltip.Root>
|
|
164
|
-
<Tooltip.Trigger asChild>
|
|
165
|
-
<div className="relative animate-enter">
|
|
166
|
-
<Slider.Root
|
|
167
|
-
className={cn(
|
|
168
|
-
"group relative flex w-full touch-none select-none items-center",
|
|
169
|
-
"media-md:h-4 media-sm:h-3 media-xs:h-2",
|
|
170
|
-
"focus-ring cursor-pointer",
|
|
171
|
-
isPending && "opacity-75"
|
|
172
|
-
)}
|
|
173
|
-
value={[progress]}
|
|
174
|
-
max={100}
|
|
175
|
-
step={0.1}
|
|
176
|
-
onValueChange={handleValueChange}
|
|
177
|
-
onValueCommit={handleValueCommit}
|
|
178
|
-
onPointerDown={handlePointerDown}
|
|
179
|
-
aria-label="Seek to position">
|
|
180
|
-
<Slider.Track
|
|
181
|
-
className={cn(
|
|
182
|
-
"relative grow overflow-hidden rounded-full",
|
|
183
|
-
"bg-[color:var(--media-control-bg)]/40 backdrop-blur-sm",
|
|
184
|
-
"border border-[color:var(--media-border)]/20",
|
|
185
|
-
"shadow-inner transition-all duration-300 ease-out",
|
|
186
|
-
"h-1 group-focus-within:h-1.5 group-hover:h-1.5",
|
|
187
|
-
"group-hover:bg-[color:var(--media-control-bg)]/60",
|
|
188
|
-
"group-hover:border-[color:var(--media-border)]/40"
|
|
189
|
-
)}>
|
|
190
|
-
{/* Buffered ranges - optimized rendering */}
|
|
191
|
-
{bufferedRanges.map((range, index) => (
|
|
192
|
-
<div
|
|
193
|
-
key={`${range.start}-${range.end}-${index}`}
|
|
194
|
-
className={cn(
|
|
195
|
-
"absolute h-full rounded-full transition-all duration-500",
|
|
196
|
-
"bg-[color:var(--color-media-buffered)] shadow-inner",
|
|
197
|
-
"opacity-60 group-hover:opacity-80"
|
|
198
|
-
)}
|
|
199
|
-
style={{
|
|
200
|
-
left: `${range.start}%`,
|
|
201
|
-
width: `${range.end - range.start}%`,
|
|
202
|
-
willChange: "width, left"
|
|
203
|
-
}}
|
|
204
|
-
/>
|
|
205
|
-
))}
|
|
206
|
-
|
|
207
|
-
{/* Progress range with gradient */}
|
|
208
|
-
<Slider.Range
|
|
209
|
-
className={cn(
|
|
210
|
-
"absolute h-full rounded-full transition-all duration-300",
|
|
211
|
-
"bg-gradient-to-r from-[color:var(--color-media-progress)] to-[color:var(--color-brand-accent)]",
|
|
212
|
-
"shadow-[color:var(--color-brand-primary)]/20 shadow-lg",
|
|
213
|
-
"group-hover:shadow-xl",
|
|
214
|
-
isDragging && "transition-none"
|
|
215
|
-
)}
|
|
216
|
-
/>
|
|
217
|
-
</Slider.Track>
|
|
218
|
-
|
|
219
|
-
<Slider.Thumb
|
|
220
|
-
className={cn(
|
|
221
|
-
"block size-4 rounded-full border-white/20 bg-white",
|
|
222
|
-
"shadow-lg hover:shadow-xl",
|
|
223
|
-
"opacity-0 group-hover:opacity-100",
|
|
224
|
-
"hover:scale-110 hover:bg-white/95 active:scale-95",
|
|
225
|
-
"focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-white/50",
|
|
226
|
-
"focus:ring-offset-2 focus:ring-offset-black/20",
|
|
227
|
-
"transition-all duration-300 ease-out",
|
|
228
|
-
isDragging && "scale-110 opacity-100",
|
|
229
|
-
isPending && "animate-pulse"
|
|
230
|
-
)}
|
|
231
|
-
aria-label="Seek"
|
|
232
|
-
/>
|
|
233
|
-
</Slider.Root>
|
|
234
|
-
</div>
|
|
235
|
-
</Tooltip.Trigger>
|
|
236
|
-
|
|
237
|
-
{(isDragging || deferredHovering) && (
|
|
238
|
-
<Tooltip.Portal>
|
|
239
|
-
<Tooltip.Content
|
|
240
|
-
sideOffset={10}
|
|
241
|
-
className="data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade">
|
|
242
|
-
{tooltipContent}
|
|
243
|
-
<Tooltip.Arrow className="fill-black/80" />
|
|
244
|
-
</Tooltip.Content>
|
|
245
|
-
</Tooltip.Portal>
|
|
246
|
-
)}
|
|
247
|
-
</Tooltip.Root>
|
|
248
|
-
</Tooltip.Provider>
|
|
249
|
-
</div>
|
|
250
|
-
)
|
|
251
|
-
}
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
EnhancedSeekBar.displayName = "EnhancedSeekBar"
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { AlertTriangle, Info, RefreshCw, XCircle } from "lucide-react"
|
|
2
|
-
import { memo } from "react"
|
|
3
|
-
import { cn } from "../../lib/utils"
|
|
4
|
-
|
|
5
|
-
export interface ErrorStateProps {
|
|
6
|
-
title?: string
|
|
7
|
-
message?: string
|
|
8
|
-
error?: Error | string
|
|
9
|
-
severity?: "error" | "warning" | "info"
|
|
10
|
-
onRetry?: () => void
|
|
11
|
-
retryLabel?: string
|
|
12
|
-
className?: string
|
|
13
|
-
showIcon?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const severityConfig = {
|
|
17
|
-
error: {
|
|
18
|
-
icon: XCircle,
|
|
19
|
-
iconColor: "text-red-500",
|
|
20
|
-
bgColor: "bg-red-500/10",
|
|
21
|
-
borderColor: "border-red-500/20"
|
|
22
|
-
},
|
|
23
|
-
warning: {
|
|
24
|
-
icon: AlertTriangle,
|
|
25
|
-
iconColor: "text-amber-500",
|
|
26
|
-
bgColor: "bg-amber-500/10",
|
|
27
|
-
borderColor: "border-amber-500/20"
|
|
28
|
-
},
|
|
29
|
-
info: {
|
|
30
|
-
icon: Info,
|
|
31
|
-
iconColor: "text-blue-500",
|
|
32
|
-
bgColor: "bg-blue-500/10",
|
|
33
|
-
borderColor: "border-blue-500/20"
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const ErrorStateComponent = memo(function ErrorState({
|
|
38
|
-
title = "Something went wrong",
|
|
39
|
-
message = "An unexpected error occurred. Please try again.",
|
|
40
|
-
error,
|
|
41
|
-
severity = "error",
|
|
42
|
-
onRetry,
|
|
43
|
-
retryLabel = "Try again",
|
|
44
|
-
className,
|
|
45
|
-
showIcon = true
|
|
46
|
-
}: ErrorStateProps) {
|
|
47
|
-
const config = severityConfig[severity]
|
|
48
|
-
const Icon = config.icon
|
|
49
|
-
const errorMessage = typeof error === "string" ? error : error?.message
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div
|
|
53
|
-
className={cn(
|
|
54
|
-
"flex flex-col items-center justify-center p-8 text-center",
|
|
55
|
-
config.bgColor,
|
|
56
|
-
config.borderColor,
|
|
57
|
-
"rounded-lg border",
|
|
58
|
-
className
|
|
59
|
-
)}
|
|
60
|
-
role="alert"
|
|
61
|
-
aria-live="assertive">
|
|
62
|
-
{showIcon && (
|
|
63
|
-
<div className={cn("mb-4 rounded-full p-3", config.bgColor)} aria-hidden="true">
|
|
64
|
-
<Icon size={48} className={config.iconColor} />
|
|
65
|
-
</div>
|
|
66
|
-
)}
|
|
67
|
-
<h3 className="mb-2 font-semibold text-[color:var(--media-text)] text-lg">{title}</h3>
|
|
68
|
-
<p className="mb-4 max-w-sm text-[color:var(--media-text-secondary)] text-sm">
|
|
69
|
-
{message}
|
|
70
|
-
{errorMessage && (
|
|
71
|
-
<code className="mt-2 block rounded bg-black/20 p-2 font-mono text-xs">
|
|
72
|
-
{errorMessage}
|
|
73
|
-
</code>
|
|
74
|
-
)}
|
|
75
|
-
</p>
|
|
76
|
-
{onRetry && (
|
|
77
|
-
<button
|
|
78
|
-
onClick={onRetry}
|
|
79
|
-
className={cn(
|
|
80
|
-
"inline-flex items-center gap-2 rounded-lg px-4 py-2",
|
|
81
|
-
"bg-[color:var(--media-primary)] text-white",
|
|
82
|
-
"transition-opacity hover:opacity-90",
|
|
83
|
-
"focus:outline-none focus:ring-2 focus:ring-[color:var(--media-primary)] focus:ring-offset-2"
|
|
84
|
-
)}
|
|
85
|
-
aria-label={retryLabel}>
|
|
86
|
-
<RefreshCw size={16} />
|
|
87
|
-
{retryLabel}
|
|
88
|
-
</button>
|
|
89
|
-
)}
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
interface MediaErrorStateProps {
|
|
95
|
-
error: Error | string
|
|
96
|
-
onRetry?: () => void
|
|
97
|
-
onBack?: () => void
|
|
98
|
-
className?: string
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const MediaErrorState = memo(function MediaErrorState({
|
|
102
|
-
error,
|
|
103
|
-
onRetry,
|
|
104
|
-
onBack,
|
|
105
|
-
className
|
|
106
|
-
}: MediaErrorStateProps) {
|
|
107
|
-
const errorMessage = typeof error === "string" ? error : error.message
|
|
108
|
-
|
|
109
|
-
return (
|
|
110
|
-
<ErrorStateComponent
|
|
111
|
-
title="Unable to play media"
|
|
112
|
-
message={
|
|
113
|
-
errorMessage ||
|
|
114
|
-
"The media could not be loaded. This could be due to a network issue or an unsupported format."
|
|
115
|
-
}
|
|
116
|
-
severity="error"
|
|
117
|
-
onRetry={onRetry}
|
|
118
|
-
retryLabel="Retry"
|
|
119
|
-
className={className}
|
|
120
|
-
/>
|
|
121
|
-
)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
export { ErrorStateComponent as ErrorState }
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as Tooltip from "@radix-ui/react-tooltip"
|
|
4
|
-
import { Maximize, Minimize } from "lucide-react"
|
|
5
|
-
import { forwardRef, memo, useMemo } from "react"
|
|
6
|
-
import { cn } from "../../lib/utils"
|
|
7
|
-
import type { FullscreenButtonProps } from "../../types/index"
|
|
8
|
-
|
|
9
|
-
const FullscreenButtonComponent = memo(
|
|
10
|
-
forwardRef<HTMLButtonElement, FullscreenButtonProps>(
|
|
11
|
-
({ isFullscreen, onToggle, disabled = false, size = "lg", className }, ref) => {
|
|
12
|
-
const buttonSizes: Record<"md" | "lg" | "xl", string> = {
|
|
13
|
-
md: "h-11 w-11",
|
|
14
|
-
lg: "h-12 w-12",
|
|
15
|
-
xl: "h-14 w-14"
|
|
16
|
-
}
|
|
17
|
-
const iconSizes: Record<"md" | "lg" | "xl", number> = {
|
|
18
|
-
md: 20,
|
|
19
|
-
lg: 24,
|
|
20
|
-
xl: 28
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const sizeConfig = useMemo(
|
|
24
|
-
() => ({
|
|
25
|
-
button: buttonSizes[size] || buttonSizes.lg,
|
|
26
|
-
icon: iconSizes[size] || iconSizes.lg
|
|
27
|
-
}),
|
|
28
|
-
[size]
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
const Icon = useMemo(() => (isFullscreen ? Minimize : Maximize), [isFullscreen])
|
|
32
|
-
const ariaLabel = useMemo(
|
|
33
|
-
() => (isFullscreen ? "Exit fullscreen" : "Enter fullscreen"),
|
|
34
|
-
[isFullscreen]
|
|
35
|
-
)
|
|
36
|
-
const tooltipText = useMemo(
|
|
37
|
-
() => (isFullscreen ? "Exit fullscreen" : "Enter fullscreen"),
|
|
38
|
-
[isFullscreen]
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Tooltip.Provider>
|
|
43
|
-
<Tooltip.Root>
|
|
44
|
-
<Tooltip.Trigger asChild>
|
|
45
|
-
<button
|
|
46
|
-
ref={ref}
|
|
47
|
-
type="button"
|
|
48
|
-
onClick={onToggle}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
className={cn(
|
|
51
|
-
"inline-flex items-center justify-center rounded-lg bg-transparent p-0 text-white transition-all hover:text-cyan-700 active:scale-95",
|
|
52
|
-
"focus:outline-none focus:ring-2 focus:ring-white/50 focus:ring-offset-2 focus:ring-offset-black/20",
|
|
53
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
54
|
-
sizeConfig.button,
|
|
55
|
-
className
|
|
56
|
-
)}
|
|
57
|
-
aria-label={ariaLabel}>
|
|
58
|
-
<Icon size={sizeConfig.icon} />
|
|
59
|
-
</button>
|
|
60
|
-
</Tooltip.Trigger>
|
|
61
|
-
<Tooltip.Portal>
|
|
62
|
-
<Tooltip.Content
|
|
63
|
-
className={cn(
|
|
64
|
-
"rounded bg-black/80 px-2 py-1 text-sm text-white",
|
|
65
|
-
"fade-in-0 zoom-in-95 animate-in"
|
|
66
|
-
)}
|
|
67
|
-
sideOffset={5}>
|
|
68
|
-
{tooltipText}
|
|
69
|
-
<Tooltip.Arrow className="fill-black/80" />
|
|
70
|
-
</Tooltip.Content>
|
|
71
|
-
</Tooltip.Portal>
|
|
72
|
-
</Tooltip.Root>
|
|
73
|
-
</Tooltip.Provider>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
FullscreenButtonComponent.displayName = "FullscreenButton"
|
|
80
|
-
|
|
81
|
-
export const FullscreenButton = FullscreenButtonComponent
|