@ilo-org/react 0.14.1 → 0.16.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/lib/cjs/components/Cards/CardGroup/CardGroup.js +7 -4
- package/lib/cjs/components/Cards/CardGroup/index.js +9 -8
- package/lib/cjs/components/Cards/DetailCard/DetailCard.js +2 -2
- package/lib/cjs/components/Cards/FactlistCard/FactListCard.js +2 -2
- package/lib/cjs/components/Cards/FeatureCard/FeatureCard.js +2 -2
- package/lib/cjs/components/Cards/MultilinkCard/MultiLinkCard.js +2 -2
- package/lib/cjs/components/Cards/PromoCard/PromoCard.js +2 -2
- package/lib/cjs/components/Cards/StatCard/StatCard.js +2 -2
- package/lib/cjs/components/Cards/TextCard/TextCard.js +2 -2
- package/lib/cjs/components/LogoGrid/LogoGrid.js +1 -1
- package/lib/cjs/components/Navigation/Navigation.js +34 -8
- package/lib/cjs/components/SocialMedia/SocialMedia.js +1 -1
- package/lib/cjs/hooks/index.js +0 -2
- package/lib/esm/components/Cards/CardGroup/CardGroup.js +7 -4
- package/lib/esm/components/Cards/CardGroup/index.js +9 -8
- package/lib/esm/components/Cards/DetailCard/DetailCard.js +2 -2
- package/lib/esm/components/Cards/FactlistCard/FactListCard.js +2 -2
- package/lib/esm/components/Cards/FeatureCard/FeatureCard.js +2 -2
- package/lib/esm/components/Cards/MultilinkCard/MultiLinkCard.js +2 -2
- package/lib/esm/components/Cards/PromoCard/PromoCard.js +2 -2
- package/lib/esm/components/Cards/StatCard/StatCard.js +2 -2
- package/lib/esm/components/Cards/TextCard/TextCard.js +2 -2
- package/lib/esm/components/LogoGrid/LogoGrid.js +1 -1
- package/lib/esm/components/Navigation/Navigation.js +35 -9
- package/lib/esm/components/SocialMedia/SocialMedia.js +1 -1
- package/lib/esm/hooks/index.js +0 -1
- package/lib/styles/components/accordion.css +1 -0
- package/lib/styles/components/breadcrumb.css +1 -0
- package/lib/styles/components/button.css +1 -0
- package/lib/styles/components/callout.css +1 -0
- package/lib/styles/components/card.css +1 -0
- package/lib/styles/components/cardgroup.css +1 -0
- package/lib/styles/components/checkbox.css +1 -0
- package/lib/styles/components/container.css +1 -0
- package/lib/styles/components/contextmenu.css +1 -0
- package/lib/styles/components/credit.css +1 -0
- package/lib/styles/components/datacard.css +1 -0
- package/lib/styles/components/datepicker.css +1 -0
- package/lib/styles/components/detailcard.css +1 -0
- package/lib/styles/components/dropdown.css +1 -0
- package/lib/styles/components/empty.css +1 -0
- package/lib/styles/components/factlistcard.css +1 -0
- package/lib/styles/components/featurecard.css +1 -0
- package/lib/styles/components/fieldset.css +1 -0
- package/lib/styles/components/file-upload.css +1 -0
- package/lib/styles/components/footer.css +1 -0
- package/lib/styles/components/form.css +1 -0
- package/lib/styles/components/formcontrol.css +1 -0
- package/lib/styles/components/heading.css +1 -0
- package/lib/styles/components/hero.css +1 -0
- package/lib/styles/components/herocard.css +1 -0
- package/lib/styles/components/icon.css +1 -0
- package/lib/styles/components/image.css +1 -0
- package/lib/styles/components/input.css +1 -0
- package/lib/styles/components/link.css +1 -0
- package/lib/styles/components/linklist.css +1 -0
- package/lib/styles/components/list.css +1 -0
- package/lib/styles/components/loading.css +1 -0
- package/lib/styles/components/logo.css +1 -0
- package/lib/styles/components/logogrid.css +1 -0
- package/lib/styles/components/modal.css +1 -0
- package/lib/styles/components/multilinkcard.css +1 -0
- package/lib/styles/components/navigation.css +1 -0
- package/lib/styles/components/notification.css +1 -0
- package/lib/styles/components/pagination.css +1 -0
- package/lib/styles/components/profile.css +1 -0
- package/lib/styles/components/promocard.css +1 -0
- package/lib/styles/components/radio.css +1 -0
- package/lib/styles/components/readmore.css +1 -0
- package/lib/styles/components/richtext.css +1 -0
- package/lib/styles/components/searchfield.css +1 -0
- package/lib/styles/components/socialmedia.css +1 -0
- package/lib/styles/components/statcard.css +1 -0
- package/lib/styles/components/table.css +1 -0
- package/lib/styles/components/tableofcontents.css +1 -0
- package/lib/styles/components/tabs.css +1 -0
- package/lib/styles/components/tag.css +1 -0
- package/lib/styles/components/textarea.css +1 -0
- package/lib/styles/components/textcard.css +1 -0
- package/lib/styles/components/textinput.css +1 -0
- package/lib/styles/components/toggle.css +1 -0
- package/lib/styles/components/tooltip.css +1 -0
- package/lib/styles/components/video.css +1 -0
- package/lib/styles/global.css +2 -0
- package/lib/styles/index.css +9 -0
- package/lib/styles/monorepo.css +9 -0
- package/lib/types/react/src/components/Cards/CardGroup/CardGroup.props.d.ts +28 -2
- package/lib/types/react/src/components/Cards/DetailCard/DetailCard.props.d.ts +5 -1
- package/lib/types/react/src/components/Cards/FactlistCard/FactListCard.props.d.ts +5 -1
- package/lib/types/react/src/components/Cards/FeatureCard/FeatureCard.props.d.ts +5 -1
- package/lib/types/react/src/components/Cards/MultilinkCard/MultilinkCard.props.d.ts +5 -1
- package/lib/types/react/src/components/Cards/PromoCard/PromoCard.props.d.ts +5 -1
- package/lib/types/react/src/components/Cards/StatCard/StatCard.props.d.ts +8 -1
- package/lib/types/react/src/components/Cards/TextCard/TextCard.props.d.ts +5 -1
- package/lib/types/react/src/hooks/index.d.ts +0 -1
- package/lib/types/react/src/types/index.d.ts +1 -0
- package/package.json +8 -5
- package/lib/cjs/hooks/useVideoPlayer.js +0 -75
- package/lib/esm/hooks/useVideoPlayer.js +0 -73
- package/lib/types/react/src/hooks/useVideoPlayer.d.ts +0 -12
|
@@ -7,15 +7,40 @@ import { FeatureCardProps } from "../FeatureCard";
|
|
|
7
7
|
import { DetailCardProps } from "../DetailCard";
|
|
8
8
|
import { FactlistCardProps } from "../FactlistCard";
|
|
9
9
|
import { DataCardProps } from "../DataCard";
|
|
10
|
+
import { HeadingTypes, CardSize, ThemeTypes, CardAlignment } from "../../../types";
|
|
10
11
|
export interface CommonCardGroupProps {
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
+
*Collapsed - Optionally collapses margins between the cards.
|
|
14
|
+
*Option keys: true, false
|
|
15
|
+
*/
|
|
16
|
+
collapsed?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
*Number of cards in the group
|
|
13
19
|
*/
|
|
14
20
|
cardCount: string;
|
|
15
21
|
/**
|
|
16
|
-
*
|
|
22
|
+
*Size - Sets the layout of the cards in the group. See the Card component for more info on this setting, which has different effects on the different types of cards.
|
|
23
|
+
*Option keys: standard, narrow, wide, fluid
|
|
24
|
+
*/
|
|
25
|
+
size: CardSize;
|
|
26
|
+
/**
|
|
27
|
+
*Alignment - Positions the image to the right or to the left of the content when the card is displayed in a wide or fluid size. Has no effect if the card is displayed in a standard or narrow size. Only used by `Multilink Card`.
|
|
28
|
+
*Option keys: left, right
|
|
29
|
+
*/
|
|
30
|
+
alignment?: CardAlignment;
|
|
31
|
+
/**
|
|
32
|
+
*Set the title level for all the cards in the group
|
|
33
|
+
*/
|
|
34
|
+
titleLevel?: HeadingTypes;
|
|
35
|
+
/**
|
|
36
|
+
*A Button to display after all the cards in the group
|
|
17
37
|
*/
|
|
18
38
|
cta?: LinkProps;
|
|
39
|
+
/**
|
|
40
|
+
*Theme - Sets all of the cards to appear as either light or dark. Used by all card groups except for Multilink Card, Data Card and Stat Card.
|
|
41
|
+
*Option keys: dark, light
|
|
42
|
+
*/
|
|
43
|
+
theme?: ThemeTypes;
|
|
19
44
|
}
|
|
20
45
|
export interface StatCardGroup extends CommonCardGroupProps {
|
|
21
46
|
/**
|
|
@@ -53,6 +78,7 @@ export interface FactlistCardGroup extends CommonCardGroupProps {
|
|
|
53
78
|
}
|
|
54
79
|
export interface DataCardGroup extends CommonCardGroupProps {
|
|
55
80
|
type: "data";
|
|
81
|
+
titleLevel?: never;
|
|
56
82
|
cards: DataCardProps[];
|
|
57
83
|
}
|
|
58
84
|
export type CardGroupProps = StatCardGroup | MultilinkCardGroup | TextCardGroup | PromoCardGroup | FeatureCardGroup | DetailCardGroup | FactlistCardGroup | DataCardGroup;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardSize, EventDate } from "../../../types";
|
|
1
|
+
import { CardSize, EventDate, HeadingTypes } from "../../../types";
|
|
2
2
|
export type DetailCardProps = {
|
|
3
3
|
/**
|
|
4
4
|
* A line of text that appears as a small heading above the title of the card
|
|
@@ -8,6 +8,10 @@ export type DetailCardProps = {
|
|
|
8
8
|
* The title of the card
|
|
9
9
|
*/
|
|
10
10
|
title: string;
|
|
11
|
+
/**
|
|
12
|
+
* HTML element used for the title
|
|
13
|
+
*/
|
|
14
|
+
titleLevel?: HeadingTypes;
|
|
11
15
|
/**
|
|
12
16
|
* Introductory text in the card
|
|
13
17
|
*/
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { ThemeTypes, CardSize } from "../../../types";
|
|
1
|
+
import { ThemeTypes, CardSize, HeadingTypes } from "../../../types";
|
|
2
2
|
export type FactlistCardProps = {
|
|
3
3
|
/**
|
|
4
4
|
* The title of the card
|
|
5
5
|
*/
|
|
6
6
|
title: string;
|
|
7
|
+
/**
|
|
8
|
+
* HTML element used for the title
|
|
9
|
+
*/
|
|
10
|
+
titleLevel?: HeadingTypes;
|
|
7
11
|
/**
|
|
8
12
|
* Will render the card to appear on light or dark backgrounds
|
|
9
13
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeTypes, CardSize, EventDate } from "../../../types";
|
|
1
|
+
import { ThemeTypes, CardSize, EventDate, HeadingTypes } from "../../../types";
|
|
2
2
|
import { LinkListProps } from "../../LinkList/LinkList.props";
|
|
3
3
|
export type FeatureCardProps = {
|
|
4
4
|
isvideo?: boolean;
|
|
@@ -10,6 +10,10 @@ export type FeatureCardProps = {
|
|
|
10
10
|
* The title of the card
|
|
11
11
|
*/
|
|
12
12
|
title: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTML element used for the title
|
|
15
|
+
*/
|
|
16
|
+
titleLevel?: HeadingTypes;
|
|
13
17
|
/**
|
|
14
18
|
* Will render the card to appear on light or dark backgrounds
|
|
15
19
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CardAlignment, CardSize } from "../../../types";
|
|
1
|
+
import { CardAlignment, CardSize, HeadingTypes } from "../../../types";
|
|
2
2
|
import { LinkListProps } from "../../LinkList/LinkList.props";
|
|
3
3
|
export type MultilinkCardProps = {
|
|
4
4
|
isvideo?: boolean;
|
|
@@ -10,6 +10,10 @@ export type MultilinkCardProps = {
|
|
|
10
10
|
* The title of the card
|
|
11
11
|
*/
|
|
12
12
|
title: string;
|
|
13
|
+
/**
|
|
14
|
+
* HTML element used for the title
|
|
15
|
+
*/
|
|
16
|
+
titleLevel?: HeadingTypes;
|
|
13
17
|
/**
|
|
14
18
|
* How big should the card be
|
|
15
19
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeTypes, CardCornerType, CardSize } from "../../../types";
|
|
1
|
+
import { ThemeTypes, CardCornerType, CardSize, HeadingTypes } from "../../../types";
|
|
2
2
|
import { LinkProps } from "../../LinkList/LinkList.props";
|
|
3
3
|
export type PromoCardProps = {
|
|
4
4
|
/**
|
|
@@ -9,6 +9,10 @@ export type PromoCardProps = {
|
|
|
9
9
|
* The title of the card
|
|
10
10
|
*/
|
|
11
11
|
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* HTML element used for the title
|
|
14
|
+
*/
|
|
15
|
+
titleLevel?: HeadingTypes;
|
|
12
16
|
/**
|
|
13
17
|
* Will render the card to appear on light or dark backgrounds
|
|
14
18
|
*/
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { CardColor, CardSize } from "../../../types";
|
|
1
|
+
import { CardColor, CardSize, HeadingTypes } from "../../../types";
|
|
2
2
|
import { LinkProps } from "../../LinkList/LinkList.props";
|
|
3
3
|
export type StatCardProps = {
|
|
4
4
|
/**
|
|
5
5
|
* The title of the card
|
|
6
6
|
*/
|
|
7
7
|
title: string;
|
|
8
|
+
/**
|
|
9
|
+
* HTML element used for the title
|
|
10
|
+
*/
|
|
11
|
+
titleLevel?: HeadingTypes;
|
|
12
|
+
/**
|
|
13
|
+
* Background color of stat card
|
|
14
|
+
*/
|
|
8
15
|
color?: CardColor;
|
|
9
16
|
/**
|
|
10
17
|
* How big should the card be
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ThemeTypes, CardSize, EventDate } from "../../../types";
|
|
1
|
+
import { ThemeTypes, CardSize, EventDate, HeadingTypes } from "../../../types";
|
|
2
2
|
import { ProfileProps } from "../../Profile/Profile.props";
|
|
3
3
|
export type TextCardProps = {
|
|
4
4
|
/**
|
|
@@ -9,6 +9,10 @@ export type TextCardProps = {
|
|
|
9
9
|
* The title of the card
|
|
10
10
|
*/
|
|
11
11
|
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* HTML element used for the title
|
|
14
|
+
*/
|
|
15
|
+
titleLevel?: HeadingTypes;
|
|
12
16
|
/**
|
|
13
17
|
* Will render the card to appear on light or dark backgrounds
|
|
14
18
|
*/
|
|
@@ -29,6 +29,7 @@ export type CardSize = "wide" | "standard" | "narrow" | "fluid";
|
|
|
29
29
|
export type CardCornerType = boolean;
|
|
30
30
|
export type CardAlignment = "left" | "right";
|
|
31
31
|
export type CardTypes = "stat" | "multilink" | "text" | "promo" | "feature" | "detail" | "factlist" | "data";
|
|
32
|
+
export type HeadingTypes = "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
32
33
|
export type EventDate = {
|
|
33
34
|
unix?: string;
|
|
34
35
|
human?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ilo-org/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "React components for the ILO's Design System",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui_patterns",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"import": "./lib/esm/hooks/*.js",
|
|
55
55
|
"require": "./lib/cjs/hooks/*.js",
|
|
56
56
|
"types": "./lib/types/react/src/hooks/index.d.ts"
|
|
57
|
-
}
|
|
57
|
+
},
|
|
58
|
+
"./styles/": "./lib/styles/"
|
|
58
59
|
},
|
|
59
60
|
"typesVersions": {
|
|
60
61
|
"*": {
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
"@ilo-org/brand-assets": "0.5.1",
|
|
102
103
|
"@ilo-org/fonts": "0.2.1",
|
|
103
104
|
"@ilo-org/icons-react": "0.1.1",
|
|
104
|
-
"@ilo-org/styles": "0.
|
|
105
|
+
"@ilo-org/styles": "1.0.1",
|
|
105
106
|
"@ilo-org/themes": "0.8.1",
|
|
106
107
|
"@ilo-org/utils": "0.1.1"
|
|
107
108
|
},
|
|
@@ -132,6 +133,7 @@
|
|
|
132
133
|
"@types/react": "^17.0.11",
|
|
133
134
|
"@types/react-dom": "^17.0.20",
|
|
134
135
|
"@types/video.js": "7.3.57",
|
|
136
|
+
"glob": "^10.3.10",
|
|
135
137
|
"http-server": "^14.1.0",
|
|
136
138
|
"identity-obj-proxy": "^3.0.0",
|
|
137
139
|
"jest-environment-jsdom": "27.5.1",
|
|
@@ -155,7 +157,7 @@
|
|
|
155
157
|
"ts-dedent": "^2.2.0",
|
|
156
158
|
"ts-jest": "^29.1.1",
|
|
157
159
|
"tslib": "^2.3.1",
|
|
158
|
-
"vite": "^4.5.
|
|
160
|
+
"vite": "^4.5.3",
|
|
159
161
|
"@ilo-org/eslint-config": "0.2.1",
|
|
160
162
|
"@ilo-org/prettier-config": "0.1.1",
|
|
161
163
|
"@ilo-org/typescript-config": "0.1.1"
|
|
@@ -169,7 +171,7 @@
|
|
|
169
171
|
},
|
|
170
172
|
"scripts": {
|
|
171
173
|
"build": "pnpm build:lib",
|
|
172
|
-
"build:lib": "rollup -c",
|
|
174
|
+
"build:lib": "rollup -c && npm run copy:styles",
|
|
173
175
|
"build:docs": "storybook build",
|
|
174
176
|
"check": "tsc --noEmit --p tsconfig.build.json",
|
|
175
177
|
"dev:lib": "rollup --config --configDevelop -w",
|
|
@@ -179,6 +181,7 @@
|
|
|
179
181
|
"lint:fix": "eslint . --fix",
|
|
180
182
|
"storybook": "storybook dev -p 6006",
|
|
181
183
|
"storybook:static": "http-server ./storybook-static",
|
|
184
|
+
"copy:styles": "node copystyles.js",
|
|
182
185
|
"test": "NODE_OPTIONS=--experimental-vm-modules SKIP_PREFLIGHT_CHECK=true react-scripts test --watchAll=false --setupFilesAfterEnv ./src/setup.ts"
|
|
183
186
|
}
|
|
184
187
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var React = require('react');
|
|
4
|
-
|
|
5
|
-
const useVideoPlayer = (videoElement) => {
|
|
6
|
-
const [fullscreen, setFullscreen] = React.useState(false);
|
|
7
|
-
const [playing, setPlaying] = React.useState(false);
|
|
8
|
-
const [progress, setProgress] = React.useState(0);
|
|
9
|
-
const [showvolume, showVolume] = React.useState(false);
|
|
10
|
-
/**
|
|
11
|
-
* Fullscreen functionality
|
|
12
|
-
*/
|
|
13
|
-
const toggleFullscreen = () => {
|
|
14
|
-
setFullscreen(!fullscreen);
|
|
15
|
-
};
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
if (fullscreen) {
|
|
18
|
-
if (videoElement.requestFullscreen) {
|
|
19
|
-
videoElement.requestFullscreen();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
document.exitFullscreen();
|
|
24
|
-
}
|
|
25
|
-
}, [fullscreen, videoElement]);
|
|
26
|
-
/**
|
|
27
|
-
* Play/pause functionality
|
|
28
|
-
*/
|
|
29
|
-
const togglePlay = () => {
|
|
30
|
-
setPlaying(!playing);
|
|
31
|
-
};
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
playing ? videoElement.current.play() : videoElement.current.pause();
|
|
34
|
-
}, [playing, videoElement]);
|
|
35
|
-
/**
|
|
36
|
-
* Progress indicator
|
|
37
|
-
*/
|
|
38
|
-
const handleOnTimeUpdate = () => {
|
|
39
|
-
setProgress((videoElement.current.currentTime / videoElement.current.duration) * 100);
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Scrub functionality
|
|
43
|
-
*/
|
|
44
|
-
const handleVideoScrub = (event) => {
|
|
45
|
-
const scrubValue = Number((event.offsetX * event.target.max) / event.target.offsetWidth);
|
|
46
|
-
videoElement.current.currentTime =
|
|
47
|
-
videoElement.current.duration * scrubValue;
|
|
48
|
-
setProgress(scrubValue);
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Show volume slider
|
|
52
|
-
*/
|
|
53
|
-
const toggleVolumeSlider = () => {
|
|
54
|
-
showVolume(!showvolume);
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Volume change
|
|
58
|
-
*/
|
|
59
|
-
const handleVolumeChange = (event) => {
|
|
60
|
-
videoElement.volume = event.target.value;
|
|
61
|
-
};
|
|
62
|
-
return {
|
|
63
|
-
handleOnTimeUpdate,
|
|
64
|
-
handleVideoScrub,
|
|
65
|
-
handleVolumeChange,
|
|
66
|
-
playing,
|
|
67
|
-
progress,
|
|
68
|
-
showvolume,
|
|
69
|
-
toggleFullscreen,
|
|
70
|
-
togglePlay,
|
|
71
|
-
toggleVolumeSlider,
|
|
72
|
-
};
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
module.exports = useVideoPlayer;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
const useVideoPlayer = (videoElement) => {
|
|
4
|
-
const [fullscreen, setFullscreen] = useState(false);
|
|
5
|
-
const [playing, setPlaying] = useState(false);
|
|
6
|
-
const [progress, setProgress] = useState(0);
|
|
7
|
-
const [showvolume, showVolume] = useState(false);
|
|
8
|
-
/**
|
|
9
|
-
* Fullscreen functionality
|
|
10
|
-
*/
|
|
11
|
-
const toggleFullscreen = () => {
|
|
12
|
-
setFullscreen(!fullscreen);
|
|
13
|
-
};
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (fullscreen) {
|
|
16
|
-
if (videoElement.requestFullscreen) {
|
|
17
|
-
videoElement.requestFullscreen();
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
document.exitFullscreen();
|
|
22
|
-
}
|
|
23
|
-
}, [fullscreen, videoElement]);
|
|
24
|
-
/**
|
|
25
|
-
* Play/pause functionality
|
|
26
|
-
*/
|
|
27
|
-
const togglePlay = () => {
|
|
28
|
-
setPlaying(!playing);
|
|
29
|
-
};
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
playing ? videoElement.current.play() : videoElement.current.pause();
|
|
32
|
-
}, [playing, videoElement]);
|
|
33
|
-
/**
|
|
34
|
-
* Progress indicator
|
|
35
|
-
*/
|
|
36
|
-
const handleOnTimeUpdate = () => {
|
|
37
|
-
setProgress((videoElement.current.currentTime / videoElement.current.duration) * 100);
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Scrub functionality
|
|
41
|
-
*/
|
|
42
|
-
const handleVideoScrub = (event) => {
|
|
43
|
-
const scrubValue = Number((event.offsetX * event.target.max) / event.target.offsetWidth);
|
|
44
|
-
videoElement.current.currentTime =
|
|
45
|
-
videoElement.current.duration * scrubValue;
|
|
46
|
-
setProgress(scrubValue);
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Show volume slider
|
|
50
|
-
*/
|
|
51
|
-
const toggleVolumeSlider = () => {
|
|
52
|
-
showVolume(!showvolume);
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Volume change
|
|
56
|
-
*/
|
|
57
|
-
const handleVolumeChange = (event) => {
|
|
58
|
-
videoElement.volume = event.target.value;
|
|
59
|
-
};
|
|
60
|
-
return {
|
|
61
|
-
handleOnTimeUpdate,
|
|
62
|
-
handleVideoScrub,
|
|
63
|
-
handleVolumeChange,
|
|
64
|
-
playing,
|
|
65
|
-
progress,
|
|
66
|
-
showvolume,
|
|
67
|
-
toggleFullscreen,
|
|
68
|
-
togglePlay,
|
|
69
|
-
toggleVolumeSlider,
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { useVideoPlayer as default };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const useVideoPlayer: (videoElement: any) => {
|
|
2
|
-
handleOnTimeUpdate: () => void;
|
|
3
|
-
handleVideoScrub: (event: any) => void;
|
|
4
|
-
handleVolumeChange: (event: any) => void;
|
|
5
|
-
playing: boolean;
|
|
6
|
-
progress: number;
|
|
7
|
-
showvolume: boolean;
|
|
8
|
-
toggleFullscreen: () => void;
|
|
9
|
-
togglePlay: () => void;
|
|
10
|
-
toggleVolumeSlider: () => void;
|
|
11
|
-
};
|
|
12
|
-
export default useVideoPlayer;
|