funuicss 2.7.15 → 3.0.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/css/fun.css +6663 -6653
- package/index.d.ts +3 -0
- package/index.js +7 -1
- package/js/google/AnalyticsHandler.d.ts +10 -0
- package/js/google/AnalyticsHandler.js +20 -0
- package/js/google/analytics.d.ts +6 -0
- package/js/google/analytics.js +53 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/ui/flex/Flex.d.ts +3 -8
- package/ui/flex/Flex.js +15 -9
- package/ui/flex/FlexItem.d.ts +17 -0
- package/ui/flex/FlexItem.js +39 -0
- package/ui/notification/Notification.d.ts +7 -3
- package/ui/notification/Notification.js +18 -14
- package/ui/scrolltotop/ScrollToTop.d.ts +3 -0
- package/ui/scrolltotop/ScrollToTop.js +61 -0
- package/ui/video/Video.d.ts +2 -1
- package/ui/video/Video.js +10 -10
- package/ui/video/videoShortcuts.d.ts +1 -1
- package/ui/video/videoShortcuts.js +2 -2
- package/ui/view/View.d.ts +27 -38
- package/ui/view/View.js +10 -38
- package/ui/vista/Vista.d.ts +6 -1
- package/ui/vista/Vista.js +33 -4
- package/assets/colors/colors.d.ts +0 -347
- package/assets/colors/colors.js +0 -348
- package/assets/colors/colors.tsx +0 -697
- package/hooks/useHls.tsx +0 -69
- package/index.tsx +0 -57
- package/js/Cookie.tsx +0 -91
- package/js/Fun.jsx +0 -225
- package/js/Fun.tsx +0 -239
- package/tsconfig.json +0 -20
- package/types/react-easy-export.d.ts +0 -4
- package/ui/ScrollInView/ScrollInView.tsx +0 -69
- package/ui/accordion/Accordion.tsx +0 -125
- package/ui/alert/Alert.tsx +0 -106
- package/ui/aos/AOS.tsx +0 -24
- package/ui/appbar/AppBar.tsx +0 -115
- package/ui/appbar/Hamburger.tsx +0 -30
- package/ui/avatar/Avatar.tsx +0 -52
- package/ui/blob/Blob.tsx +0 -34
- package/ui/breadcrumb/BreadCrumb.tsx +0 -48
- package/ui/button/Button.tsx +0 -153
- package/ui/calendar/ActivityCard.tsx +0 -27
- package/ui/calendar/Calendar.tsx +0 -343
- package/ui/card/Card.tsx +0 -117
- package/ui/card/CardBody.tsx +0 -14
- package/ui/card/CardFab.tsx +0 -16
- package/ui/card/CardFooter.tsx +0 -14
- package/ui/card/CardHeader.tsx +0 -14
- package/ui/carousel/Carousel.tsx +0 -148
- package/ui/chart/Bar.tsx +0 -121
- package/ui/chart/Line.tsx +0 -186
- package/ui/chart/Pie.tsx +0 -127
- package/ui/container/Container.tsx +0 -38
- package/ui/datepicker/DatePicker.tsx +0 -148
- package/ui/div/Div.tsx +0 -61
- package/ui/drop/Action.tsx +0 -16
- package/ui/drop/Down.tsx +0 -18
- package/ui/drop/Dropdown.tsx +0 -117
- package/ui/drop/Item.tsx +0 -15
- package/ui/drop/Menu.tsx +0 -40
- package/ui/drop/Up.tsx +0 -18
- package/ui/flex/Flex.tsx +0 -115
- package/ui/grid/Col.tsx +0 -43
- package/ui/grid/Grid.tsx +0 -37
- package/ui/input/Iconic.tsx +0 -43
- package/ui/input/Input.tsx +0 -409
- package/ui/list/Item.tsx +0 -18
- package/ui/list/List.tsx +0 -45
- package/ui/loader/Loader.tsx +0 -47
- package/ui/modal/Action.tsx +0 -14
- package/ui/modal/Close.tsx +0 -14
- package/ui/modal/Content.tsx +0 -15
- package/ui/modal/Header.tsx +0 -19
- package/ui/modal/Modal.tsx +0 -140
- package/ui/notification/Content.tsx +0 -14
- package/ui/notification/Footer.tsx +0 -14
- package/ui/notification/Header.tsx +0 -14
- package/ui/notification/Notification.tsx +0 -62
- package/ui/page/NotFound.tsx +0 -67
- package/ui/page/UnAuthorized.tsx +0 -64
- package/ui/progress/Bar.tsx +0 -114
- package/ui/richtext/RichText.tsx +0 -156
- package/ui/sidebar/SideBar.tsx +0 -202
- package/ui/sidebar/SideContent.tsx +0 -16
- package/ui/slider/Slider.tsx +0 -75
- package/ui/snackbar/SnackBar.tsx +0 -56
- package/ui/specials/Circle.tsx +0 -49
- package/ui/specials/CircleGroup.tsx +0 -49
- package/ui/specials/FullCenteredPage.tsx +0 -25
- package/ui/specials/Hr.tsx +0 -16
- package/ui/specials/RowFlex.tsx +0 -56
- package/ui/specials/Section.tsx +0 -18
- package/ui/step/Container.tsx +0 -27
- package/ui/step/Header.tsx +0 -16
- package/ui/step/Line.tsx +0 -17
- package/ui/step/Step.tsx +0 -17
- package/ui/table/Body.tsx +0 -10
- package/ui/table/Data.tsx +0 -15
- package/ui/table/Head.tsx +0 -10
- package/ui/table/Row.tsx +0 -16
- package/ui/table/Table.tsx +0 -372
- package/ui/text/Text.tsx +0 -179
- package/ui/theme/dark.tsx +0 -45
- package/ui/theme/darkenUtils.ts +0 -15
- package/ui/theme/theme.tsx +0 -48
- package/ui/theme/themes.ts +0 -154
- package/ui/tooltip/Tip.tsx +0 -34
- package/ui/tooltip/ToolTip.tsx +0 -20
- package/ui/video/Video.tsx +0 -347
- package/ui/video/videoFunctions.tsx +0 -19
- package/ui/video/videoShortcuts.ts +0 -12
- package/ui/view/View.tsx +0 -157
- package/ui/vista/Vista.tsx +0 -165
- package/utils/Emojis.tsx +0 -59
- package/utils/Functions.tsx +0 -9
- package/utils/getCssVariable.tsx +0 -9
package/ui/theme/themes.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// components/ThemeProvider/themes.ts
|
|
2
|
-
|
|
3
|
-
export const colorVarsToDarken = [
|
|
4
|
-
'--primary50', '--primary100', '--primary200', '--primary300', '--primary400',
|
|
5
|
-
'--secondary50', '--secondary100', '--secondary200', '--secondary300', '--secondary400',
|
|
6
|
-
'--accent50', '--accent100', '--accent200', '--accent300', '--accent400',
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
export const darkerDefaults = {
|
|
10
|
-
'--success50': '#c1dbc7',
|
|
11
|
-
'--success100': '#b0d1b3',
|
|
12
|
-
'--success200': '#92bb97',
|
|
13
|
-
'--success300': '#6aa375',
|
|
14
|
-
'--success400': '#3f864e',
|
|
15
|
-
|
|
16
|
-
'--warning50': '#e6dcd4',
|
|
17
|
-
'--warning100': '#e6d1bb',
|
|
18
|
-
'--warning200': '#e2b783',
|
|
19
|
-
'--warning300': '#e09b59',
|
|
20
|
-
'--warning400': '#d57627',
|
|
21
|
-
|
|
22
|
-
'--info50': '#c1d3e6',
|
|
23
|
-
'--info100': '#b3c8e0',
|
|
24
|
-
'--info200': '#91b3d4',
|
|
25
|
-
'--info300': '#5a9bcb',
|
|
26
|
-
'--info400': '#2f85c3',
|
|
27
|
-
|
|
28
|
-
'--error50': '#e6cfcf',
|
|
29
|
-
'--error100': '#e6bebe',
|
|
30
|
-
'--error200': '#e29e9e',
|
|
31
|
-
'--error300': '#da7373',
|
|
32
|
-
'--error400': '#cc4646',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const themes = {
|
|
36
|
-
light: {
|
|
37
|
-
'--page-bg': '#FFFFFF',
|
|
38
|
-
'--text-color': '#000000',
|
|
39
|
-
},
|
|
40
|
-
dark: {
|
|
41
|
-
'--page-bg': '#1E1E1E',
|
|
42
|
-
'--text-color': '#FFFFFF',
|
|
43
|
-
'--raiseThemes': 'rgba(32, 32, 32, 0.5)',
|
|
44
|
-
'--raiseOpaque': 'rgba(32, 32, 32, 0.8)',
|
|
45
|
-
'--borderColor': '#4a4a4a',
|
|
46
|
-
'--borderRgb': '74, 74, 74',
|
|
47
|
-
'--lighter': '#2a2a2a',
|
|
48
|
-
'--linkColor': '#9ab',
|
|
49
|
-
'--cardBg': '#1e1e1e',
|
|
50
|
-
'--card': `4px 4px 6px #141414, -4px -4px 6px #272727`,
|
|
51
|
-
...darkerDefaults,
|
|
52
|
-
},
|
|
53
|
-
'dark-blue': {
|
|
54
|
-
'--page-bg': '#0d1b2a',
|
|
55
|
-
'--text-color': '#f0f4f8',
|
|
56
|
-
'--text-muted': '#a9bcd0',
|
|
57
|
-
'--raiseThemes': 'rgba(13, 27, 42, 0.5)',
|
|
58
|
-
'--raiseOpaque': 'rgba(13, 27, 42, 0.8)',
|
|
59
|
-
'--borderColor': '#1e3249',
|
|
60
|
-
'--borderRgb': '30, 50, 73',
|
|
61
|
-
'--lighter': '#1b2c3f',
|
|
62
|
-
'--linkColor': '#56ccf2',
|
|
63
|
-
'--accent': '#66d9ef',
|
|
64
|
-
'--cardBg': '#0d1b2a',
|
|
65
|
-
'--card': `4px 4px 6px #08121d, -4px -4px 6px #15273b`,
|
|
66
|
-
...darkerDefaults,
|
|
67
|
-
},
|
|
68
|
-
'light-gray': {
|
|
69
|
-
'--page-bg': '#e8e8e8',
|
|
70
|
-
'--text-color': '#2a2a2a',
|
|
71
|
-
'--text-muted': '#777777',
|
|
72
|
-
'--raiseThemes': 'rgba(255, 255, 255, 0.6)',
|
|
73
|
-
'--raiseOpaque': 'rgba(255, 255, 255, 0.94)',
|
|
74
|
-
'--borderColor': '#d0d0d0',
|
|
75
|
-
'--borderRgb': '208, 208, 208',
|
|
76
|
-
'--lighter': '#f4f4f4',
|
|
77
|
-
'--linkColor': '#202020',
|
|
78
|
-
'--accent': '#4a90e2',
|
|
79
|
-
'--cardBg': '#e8e8e8',
|
|
80
|
-
'--card': `8px 8px 16px #c5c5c5, -8px -8px 16px #ffffff`,
|
|
81
|
-
},
|
|
82
|
-
'pastel-green': {
|
|
83
|
-
'--page-bg': '#e6f5ea',
|
|
84
|
-
'--text-color': '#2f4f4f',
|
|
85
|
-
'--text-muted': '#5a7d7d',
|
|
86
|
-
'--raiseThemes': 'rgba(230, 245, 234, 0.6)',
|
|
87
|
-
'--raiseOpaque': 'rgba(230, 245, 234, 0.9)',
|
|
88
|
-
'--borderColor': '#b5d3c5',
|
|
89
|
-
'--borderRgb': '181, 211, 197',
|
|
90
|
-
'--lighter': '#f1faf3',
|
|
91
|
-
'--linkColor': '#4caf50',
|
|
92
|
-
'--accent': '#81c784',
|
|
93
|
-
'--cardBg': '#e6f5ea',
|
|
94
|
-
'--card': `6px 6px 12px #cde3d5, -6px -6px 12px #ffffff`,
|
|
95
|
-
},
|
|
96
|
-
'warm-orange': {
|
|
97
|
-
'--page-bg': '#fff3e0',
|
|
98
|
-
'--text-color': '#4e342e',
|
|
99
|
-
'--text-muted': '#8d6e63',
|
|
100
|
-
'--raiseThemes': 'rgba(255, 243, 224, 0.6)',
|
|
101
|
-
'--raiseOpaque': 'rgba(255, 243, 224, 0.94)',
|
|
102
|
-
'--borderColor': '#ffccbc',
|
|
103
|
-
'--borderRgb': '255, 204, 188',
|
|
104
|
-
'--lighter': '#ffecb3',
|
|
105
|
-
'--linkColor': '#ff7043',
|
|
106
|
-
'--accent': '#ff8a65',
|
|
107
|
-
'--cardBg': '#fff3e0',
|
|
108
|
-
'--card': `6px 6px 14px #e0c7b3, -6px -6px 14px #ffffff`,
|
|
109
|
-
},
|
|
110
|
-
'frosted-glass': {
|
|
111
|
-
'--page-bg': 'rgba(255, 255, 255, 0.75)',
|
|
112
|
-
'--text-color': '#111',
|
|
113
|
-
'--text-muted': '#666',
|
|
114
|
-
'--raiseThemes': 'rgba(255, 255, 255, 0.4)',
|
|
115
|
-
'--raiseOpaque': 'rgba(255, 255, 255, 0.9)',
|
|
116
|
-
'--borderColor': '#ccc',
|
|
117
|
-
'--borderRgb': '204, 204, 204',
|
|
118
|
-
'--lighter': '#fafafa',
|
|
119
|
-
'--linkColor': '#0099cc',
|
|
120
|
-
'--accent': '#00c2ff',
|
|
121
|
-
'--cardBg': 'rgba(255, 255, 255, 0.6)',
|
|
122
|
-
'--card': `4px 4px 10px rgba(0, 0, 0, 0.05), -4px -4px 10px rgba(255, 255, 255, 0.5)`,
|
|
123
|
-
},
|
|
124
|
-
'midnight-purple': {
|
|
125
|
-
'--page-bg': '#1a1333',
|
|
126
|
-
'--text-color': '#e0e0ff',
|
|
127
|
-
'--text-muted': '#b39ddb',
|
|
128
|
-
'--raiseThemes': 'rgba(26, 19, 51, 0.5)',
|
|
129
|
-
'--raiseOpaque': 'rgba(26, 19, 51, 0.85)',
|
|
130
|
-
'--borderColor': '#443a66',
|
|
131
|
-
'--borderRgb': '68, 58, 102',
|
|
132
|
-
'--lighter': '#241b3f',
|
|
133
|
-
'--linkColor': '#d1c4e9',
|
|
134
|
-
'--accent': '#9575cd',
|
|
135
|
-
'--cardBg': '#1a1333',
|
|
136
|
-
'--card': `4px 4px 8px #120c26, -4px -4px 8px #221a40`,
|
|
137
|
-
...darkerDefaults,
|
|
138
|
-
},
|
|
139
|
-
'cyber-metal': {
|
|
140
|
-
'--page-bg': '#0f1115',
|
|
141
|
-
'--text-color': '#d0d0d0',
|
|
142
|
-
'--text-muted': '#888',
|
|
143
|
-
'--raiseThemes': 'rgba(15, 17, 21, 0.4)',
|
|
144
|
-
'--raiseOpaque': 'rgba(15, 17, 21, 0.85)',
|
|
145
|
-
'--borderColor': '#2a2a2a',
|
|
146
|
-
'--borderRgb': '42, 42, 42',
|
|
147
|
-
'--lighter': '#1a1a1a',
|
|
148
|
-
'--linkColor': '#00ffe0',
|
|
149
|
-
'--accent': '#39ff14',
|
|
150
|
-
'--cardBg': '#0f1115',
|
|
151
|
-
'--card': `6px 6px 12px #050607, -6px -6px 12px #1c1f25`,
|
|
152
|
-
...darkerDefaults,
|
|
153
|
-
}
|
|
154
|
-
};
|
package/ui/tooltip/Tip.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
interface TipProps {
|
|
4
|
-
tip: string;
|
|
5
|
-
funcss?: string;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
content?: React.ReactNode;
|
|
8
|
-
message?: React.ReactNode;
|
|
9
|
-
animation?: string;
|
|
10
|
-
duration?: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export default function Tip({
|
|
14
|
-
tip,
|
|
15
|
-
funcss,
|
|
16
|
-
children,
|
|
17
|
-
content,
|
|
18
|
-
message,
|
|
19
|
-
animation,
|
|
20
|
-
duration,
|
|
21
|
-
...rest
|
|
22
|
-
}: TipProps) {
|
|
23
|
-
const text = message || content || children;
|
|
24
|
-
return (
|
|
25
|
-
<span
|
|
26
|
-
className={`tip-${tip} tip ${funcss ? funcss : ''}`}
|
|
27
|
-
style={{ animation: ` ${duration ? duration : 0}s ${animation ? animation : ''}`}}
|
|
28
|
-
{...rest}
|
|
29
|
-
>
|
|
30
|
-
{text}
|
|
31
|
-
|
|
32
|
-
</span>
|
|
33
|
-
);
|
|
34
|
-
}
|
package/ui/tooltip/ToolTip.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import Tip from './Tip';
|
|
3
|
-
|
|
4
|
-
interface ToolTipProps {
|
|
5
|
-
funcss?: string;
|
|
6
|
-
children?: React.ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function ToolTip({ funcss, children, ...rest }: ToolTipProps) {
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<span
|
|
13
|
-
|
|
14
|
-
className={`tooltip ${funcss ?? ''}`}
|
|
15
|
-
{...rest}
|
|
16
|
-
>
|
|
17
|
-
{children}
|
|
18
|
-
</span>
|
|
19
|
-
);
|
|
20
|
-
}
|
package/ui/video/Video.tsx
DELETED
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
'use client';
|
|
3
|
-
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
PiCornersOut,
|
|
6
|
-
PiFastForward,
|
|
7
|
-
PiPause,
|
|
8
|
-
PiPlay,
|
|
9
|
-
PiRewind,
|
|
10
|
-
PiSpeakerLow,
|
|
11
|
-
} from 'react-icons/pi';
|
|
12
|
-
import { IoCloudDownloadOutline } from 'react-icons/io5';
|
|
13
|
-
import Text from '../text/Text';
|
|
14
|
-
import RowFlex from '../specials/RowFlex';
|
|
15
|
-
import ToolTip from '../tooltip/ToolTip';
|
|
16
|
-
import Circle from '../specials/Circle';
|
|
17
|
-
import Tip from '../tooltip/Tip';
|
|
18
|
-
import Image from 'next/image';
|
|
19
|
-
|
|
20
|
-
import { formatTime, getBufferedPercent } from './videoFunctions';
|
|
21
|
-
import { handleKeyDown } from './videoShortcuts';
|
|
22
|
-
|
|
23
|
-
interface VideoProps {
|
|
24
|
-
src: string;
|
|
25
|
-
poster?: string;
|
|
26
|
-
onDuration?: (duration: number) => void;
|
|
27
|
-
isPause?: boolean;
|
|
28
|
-
className?: string;
|
|
29
|
-
autoPlay?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default function Video({ src, poster, onDuration, isPause, className, autoPlay , ...rest }: VideoProps) {
|
|
33
|
-
const videoRef = useRef<HTMLVideoElement | null>(null);
|
|
34
|
-
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
35
|
-
const animationFrameRef = useRef<number | null>(null);
|
|
36
|
-
|
|
37
|
-
const [isPlaying, setIsPlaying] = useState(false);
|
|
38
|
-
const [currentTime, setCurrentTime] = useState(0);
|
|
39
|
-
const [duration, setDuration] = useState(0);
|
|
40
|
-
const [volume, setVolume] = useState(1);
|
|
41
|
-
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
42
|
-
const [showVolume, setShowVolume] = useState(false);
|
|
43
|
-
const [isMouseMoving, setIsMouseMoving] = useState(true);
|
|
44
|
-
const [hasStarted, setHasStarted] = useState(false);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const handleVideoEnd = () => {
|
|
49
|
-
setIsPlaying(false);
|
|
50
|
-
setCurrentTime(duration); // optional
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
const video = videoRef.current;
|
|
55
|
-
if (!video) return;
|
|
56
|
-
|
|
57
|
-
video.addEventListener('ended', handleVideoEnd);
|
|
58
|
-
return () => {
|
|
59
|
-
video.removeEventListener('ended', handleVideoEnd);
|
|
60
|
-
};
|
|
61
|
-
}, [duration]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const playVideo = () => {
|
|
65
|
-
const video = videoRef.current;
|
|
66
|
-
if (video) {
|
|
67
|
-
// ✅ if video ended, reset it to start
|
|
68
|
-
if (video.currentTime === video.duration) {
|
|
69
|
-
video.currentTime = 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
video.play().then(() => {
|
|
73
|
-
setIsPlaying(true);
|
|
74
|
-
setHasStarted(true);
|
|
75
|
-
}).catch(() => {});
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const pauseVideo = () => {
|
|
80
|
-
const video = videoRef.current;
|
|
81
|
-
if (video && !video.paused) {
|
|
82
|
-
video.pause();
|
|
83
|
-
setIsPlaying(false);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
const handleKey = (e: KeyboardEvent) => handleKeyDown(e, isPlaying, playVideo, pauseVideo);
|
|
91
|
-
document.addEventListener('keydown', handleKey);
|
|
92
|
-
return () => document.removeEventListener('keydown', handleKey);
|
|
93
|
-
}, [isPlaying]);
|
|
94
|
-
|
|
95
|
-
const handlePlayPauseToggle = () => {
|
|
96
|
-
isPlaying ? pauseVideo() : playVideo();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const handleRewind = () => {
|
|
100
|
-
const video = videoRef.current;
|
|
101
|
-
if (video) video.currentTime = Math.max(video.currentTime - 10, 0);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const handleForward = () => {
|
|
105
|
-
const video = videoRef.current;
|
|
106
|
-
if (video) video.currentTime = Math.min(video.currentTime + 10, duration);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const handleToggleFullScreen = () => {
|
|
110
|
-
const element = containerRef.current;
|
|
111
|
-
if (!element) return;
|
|
112
|
-
if (!document.fullscreenElement) {
|
|
113
|
-
element.requestFullscreen?.();
|
|
114
|
-
} else {
|
|
115
|
-
document.exitFullscreen?.();
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const updateCurrentTime = useCallback(() => {
|
|
120
|
-
const video = videoRef.current;
|
|
121
|
-
if (video) {
|
|
122
|
-
setCurrentTime(video.currentTime);
|
|
123
|
-
animationFrameRef.current = requestAnimationFrame(updateCurrentTime);
|
|
124
|
-
}
|
|
125
|
-
}, []);
|
|
126
|
-
|
|
127
|
-
const handleLoadedMetadata = () => {
|
|
128
|
-
const video = videoRef.current;
|
|
129
|
-
if (video) {
|
|
130
|
-
setDuration(video.duration || 0);
|
|
131
|
-
onDuration?.(video.duration);
|
|
132
|
-
if (autoPlay) {
|
|
133
|
-
video.play().then(() => {
|
|
134
|
-
setIsPlaying(true); // ✅ update UI state
|
|
135
|
-
setHasStarted(true);
|
|
136
|
-
}).catch(() => {});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
useEffect(() => {
|
|
143
|
-
if (autoPlay && videoRef.current) {
|
|
144
|
-
videoRef.current.muted = true; // ✅ important for autoplay to work
|
|
145
|
-
videoRef.current.play().then(() => {
|
|
146
|
-
setIsPlaying(true);
|
|
147
|
-
setHasStarted(true);
|
|
148
|
-
}).catch((err) => {
|
|
149
|
-
console.warn('Autoplay failed', err);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}, [autoPlay]);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const handleProgressBarChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
156
|
-
const newTime = parseFloat(e.target.value);
|
|
157
|
-
if (videoRef.current) {
|
|
158
|
-
videoRef.current.currentTime = newTime;
|
|
159
|
-
}
|
|
160
|
-
setCurrentTime(newTime);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const handleVolumeChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
164
|
-
if(videoRef.current){
|
|
165
|
-
videoRef.current.muted = false;
|
|
166
|
-
}
|
|
167
|
-
const newVolume = parseFloat(e.target.value);
|
|
168
|
-
setVolume(newVolume);
|
|
169
|
-
if (videoRef.current) videoRef.current.volume = newVolume;
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
useEffect(() => {
|
|
173
|
-
if (autoPlay && videoRef.current) {
|
|
174
|
-
const playPromise = videoRef.current.play();
|
|
175
|
-
if (playPromise !== undefined) {
|
|
176
|
-
playPromise.catch(() => {});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}, [autoPlay]);
|
|
180
|
-
|
|
181
|
-
useEffect(() => {
|
|
182
|
-
if (videoRef.current) {
|
|
183
|
-
videoRef.current.volume = volume;
|
|
184
|
-
}
|
|
185
|
-
}, [volume]);
|
|
186
|
-
|
|
187
|
-
useEffect(() => {
|
|
188
|
-
if (isPause) pauseVideo();
|
|
189
|
-
}, [isPause]);
|
|
190
|
-
|
|
191
|
-
useEffect(() => {
|
|
192
|
-
const handleFullscreenChange = () => {
|
|
193
|
-
setIsFullScreen(!!document.fullscreenElement);
|
|
194
|
-
};
|
|
195
|
-
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
196
|
-
return () => document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
197
|
-
}, []);
|
|
198
|
-
|
|
199
|
-
useEffect(() => {
|
|
200
|
-
let timer: NodeJS.Timeout;
|
|
201
|
-
const handleMouseMove = (e: MouseEvent | TouchEvent) => {
|
|
202
|
-
if (containerRef.current?.contains(e.target as Node)) {
|
|
203
|
-
setIsMouseMoving(true);
|
|
204
|
-
clearTimeout(timer);
|
|
205
|
-
timer = setTimeout(() => setIsMouseMoving(false), 2000);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
209
|
-
document.addEventListener('touchstart', handleMouseMove);
|
|
210
|
-
return () => {
|
|
211
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
212
|
-
document.removeEventListener('touchstart', handleMouseMove);
|
|
213
|
-
clearTimeout(timer);
|
|
214
|
-
};
|
|
215
|
-
}, []);
|
|
216
|
-
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
if (isPlaying) {
|
|
219
|
-
animationFrameRef.current = requestAnimationFrame(updateCurrentTime);
|
|
220
|
-
} else if (animationFrameRef.current) {
|
|
221
|
-
cancelAnimationFrame(animationFrameRef.current);
|
|
222
|
-
}
|
|
223
|
-
return () => {
|
|
224
|
-
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
225
|
-
};
|
|
226
|
-
}, [isPlaying, updateCurrentTime]);
|
|
227
|
-
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
return () => {
|
|
230
|
-
pauseVideo();
|
|
231
|
-
};
|
|
232
|
-
}, []);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
useEffect(() => {
|
|
236
|
-
const video = videoRef.current;
|
|
237
|
-
if (!video) return;
|
|
238
|
-
|
|
239
|
-
const onEnd = () => {
|
|
240
|
-
setIsPlaying(false);
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
video.addEventListener('ended', onEnd);
|
|
244
|
-
return () => video.removeEventListener('ended', onEnd);
|
|
245
|
-
}, []);
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
return (
|
|
249
|
-
<div ref={containerRef} className={`video_container fit ${className || ''}`} id="fun_video_container">
|
|
250
|
-
{poster && !hasStarted && !isPlaying && (
|
|
251
|
-
<div
|
|
252
|
-
style={{ backgroundImage: `url(${poster})` }}
|
|
253
|
-
className="video_poster"
|
|
254
|
-
/>
|
|
255
|
-
)}
|
|
256
|
-
<video
|
|
257
|
-
ref={videoRef}
|
|
258
|
-
preload="auto"
|
|
259
|
-
src={src}
|
|
260
|
-
className="video_player fit min-w-200"
|
|
261
|
-
onClick={handlePlayPauseToggle}
|
|
262
|
-
onLoadedMetadata={handleLoadedMetadata}
|
|
263
|
-
playsInline
|
|
264
|
-
controls={false}
|
|
265
|
-
{...rest}
|
|
266
|
-
/>
|
|
267
|
-
|
|
268
|
-
<div className={`video_controls ${isMouseMoving ? 'show_controls' : 'hide_controls'}`}>
|
|
269
|
-
<div className="w-80-p center animated fade-in">
|
|
270
|
-
<RowFlex gap={0.3} funcss='mb-2' alignItems="center">
|
|
271
|
-
<div className='video_time'>
|
|
272
|
-
<Text text={formatTime(currentTime)} funcss='m-0' size="sm" />
|
|
273
|
-
</div>
|
|
274
|
-
<div className="col width-100-p">
|
|
275
|
-
<input
|
|
276
|
-
type="range"
|
|
277
|
-
min={0}
|
|
278
|
-
max={duration}
|
|
279
|
-
value={currentTime}
|
|
280
|
-
onChange={handleProgressBarChange}
|
|
281
|
-
className="width-100-p videoSlider styled-slider m-0"
|
|
282
|
-
aria-label="Progress bar"
|
|
283
|
-
style={{ '--progress': `${(currentTime / duration) * 100}` } as React.CSSProperties}
|
|
284
|
-
/>
|
|
285
|
-
</div>
|
|
286
|
-
<div className="video_time">
|
|
287
|
-
<Text text={`${formatTime(duration - currentTime)}`} funcss='m-0' size="sm" />
|
|
288
|
-
</div>
|
|
289
|
-
</RowFlex>
|
|
290
|
-
</div>
|
|
291
|
-
|
|
292
|
-
<div className="center-play-icon animated fade-in" onClick={handlePlayPauseToggle}>
|
|
293
|
-
<div className='play-button'>
|
|
294
|
-
{isPlaying ? <PiPause size={30} /> : <PiPlay size={30} />}
|
|
295
|
-
</div>
|
|
296
|
-
</div>
|
|
297
|
-
|
|
298
|
-
<RowFlex funcss='animated slide-up' gap={1} justify="center">
|
|
299
|
-
<RowFlex gap={0.5}>
|
|
300
|
-
<ToolTip>
|
|
301
|
-
<Circle bordered size={2} onClick={handleRewind}><PiRewind /></Circle>
|
|
302
|
-
<Tip tip="top" animation="ScaleUp" duration={0.5} content="10 sec Back" />
|
|
303
|
-
</ToolTip>
|
|
304
|
-
|
|
305
|
-
<ToolTip>
|
|
306
|
-
<Circle bordered size={2} onClick={handleForward}><PiFastForward /></Circle>
|
|
307
|
-
<Tip tip="top" animation="ScaleUp" duration={0.5} content="10 sec Forward" />
|
|
308
|
-
</ToolTip>
|
|
309
|
-
|
|
310
|
-
<div onMouseEnter={() => setShowVolume(true)} onMouseLeave={() => setShowVolume(false)}>
|
|
311
|
-
<RowFlex>
|
|
312
|
-
<Circle bordered size={2}><PiSpeakerLow /></Circle>
|
|
313
|
-
{showVolume && (
|
|
314
|
-
<input
|
|
315
|
-
type="range"
|
|
316
|
-
min={0}
|
|
317
|
-
max={1}
|
|
318
|
-
step={0.01}
|
|
319
|
-
value={volume}
|
|
320
|
-
onChange={handleVolumeChange}
|
|
321
|
-
className="width-100 max-w-50 animated slide-right"
|
|
322
|
-
style={{ height: '3px', marginLeft: 8 }}
|
|
323
|
-
aria-label="Volume"
|
|
324
|
-
/>
|
|
325
|
-
)}
|
|
326
|
-
</RowFlex>
|
|
327
|
-
</div>
|
|
328
|
-
</RowFlex>
|
|
329
|
-
|
|
330
|
-
<RowFlex gap={0.3}>
|
|
331
|
-
<ToolTip>
|
|
332
|
-
<Circle bordered size={2} onClick={handleToggleFullScreen}><PiCornersOut /></Circle>
|
|
333
|
-
<Tip tip="top" animation="ScaleUp" duration={0.5} content="Expand" />
|
|
334
|
-
</ToolTip>
|
|
335
|
-
|
|
336
|
-
<ToolTip>
|
|
337
|
-
<Circle bordered size={2} onClick={() => window.open(src || '', '_blank')}>
|
|
338
|
-
<IoCloudDownloadOutline />
|
|
339
|
-
</Circle>
|
|
340
|
-
<Tip tip="top" animation="ScaleUp" duration={0.5} content="Download" />
|
|
341
|
-
</ToolTip>
|
|
342
|
-
</RowFlex>
|
|
343
|
-
</RowFlex>
|
|
344
|
-
</div>
|
|
345
|
-
</div>
|
|
346
|
-
);
|
|
347
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// videoFunctions.tsx
|
|
2
|
-
import { MutableRefObject } from 'react';
|
|
3
|
-
|
|
4
|
-
export const formatTime = (time: number): string => {
|
|
5
|
-
if (isNaN(time)) return '00:00';
|
|
6
|
-
const minutes = Math.floor(time / 60);
|
|
7
|
-
const seconds = Math.floor(time % 60);
|
|
8
|
-
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const getBufferedPercent = (
|
|
12
|
-
videoRef: MutableRefObject<HTMLVideoElement | null>,
|
|
13
|
-
duration: number
|
|
14
|
-
): number => {
|
|
15
|
-
const video = videoRef.current;
|
|
16
|
-
if (!video || video.buffered.length === 0) return 0;
|
|
17
|
-
const end = video.buffered.end(video.buffered.length - 1);
|
|
18
|
-
return (end / duration) * 100;
|
|
19
|
-
};
|