@elice/material-video 1.220803.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/README.md +3 -0
- package/cjs/components/material-video/MaterialVideo.d.ts +9 -0
- package/cjs/components/material-video/MaterialVideo.js +50 -0
- package/cjs/components/material-video/MaterialVideo.styled.d.ts +2 -0
- package/cjs/components/material-video/MaterialVideo.styled.js +16 -0
- package/cjs/components/material-video/MaterialVideoContent.d.ts +10 -0
- package/cjs/components/material-video/MaterialVideoContent.js +60 -0
- package/cjs/components/material-video/index.d.ts +2 -0
- package/cjs/components/material-video/locales.d.ts +5 -0
- package/cjs/components/material-video/locales.js +15 -0
- package/cjs/components/youtube-player/YoutubePlayer.d.ts +15 -0
- package/cjs/components/youtube-player/YoutubePlayer.js +56 -0
- package/cjs/components/youtube-player/YoutubePlayer.styled.d.ts +2 -0
- package/cjs/components/youtube-player/YoutubePlayer.styled.js +16 -0
- package/cjs/components/youtube-player/index.d.ts +2 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +9 -0
- package/cjs/utils/youtubeUrlParser.d.ts +6 -0
- package/cjs/utils/youtubeUrlParser.js +16 -0
- package/es/components/material-video/MaterialVideo.d.ts +9 -0
- package/es/components/material-video/MaterialVideo.js +44 -0
- package/es/components/material-video/MaterialVideo.styled.d.ts +2 -0
- package/es/components/material-video/MaterialVideo.styled.js +8 -0
- package/es/components/material-video/MaterialVideoContent.d.ts +10 -0
- package/es/components/material-video/MaterialVideoContent.js +54 -0
- package/es/components/material-video/index.d.ts +2 -0
- package/es/components/material-video/locales.d.ts +5 -0
- package/es/components/material-video/locales.js +10 -0
- package/es/components/youtube-player/YoutubePlayer.d.ts +15 -0
- package/es/components/youtube-player/YoutubePlayer.js +48 -0
- package/es/components/youtube-player/YoutubePlayer.styled.d.ts +2 -0
- package/es/components/youtube-player/YoutubePlayer.styled.js +8 -0
- package/es/components/youtube-player/index.d.ts +2 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/utils/youtubeUrlParser.d.ts +6 -0
- package/es/utils/youtubeUrlParser.js +12 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
3
|
+
export interface MaterialVideoProps extends YoutubePlayerSharedProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
materialVideoId: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const MaterialVideo: React.FC<MaterialVideoProps>;
|
|
9
|
+
export default MaterialVideo;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var apiClient = require('@elice/api-client');
|
|
7
|
+
var blocks = require('@elice/blocks');
|
|
8
|
+
var materialSharedUtils = require('@elice/material-shared-utils');
|
|
9
|
+
var classnames = require('classnames');
|
|
10
|
+
var locales = require('./locales.js');
|
|
11
|
+
var MaterialVideoContent = require('./MaterialVideoContent.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
17
|
+
|
|
18
|
+
const MaterialVideo = _a => {
|
|
19
|
+
var _b;
|
|
20
|
+
|
|
21
|
+
var {
|
|
22
|
+
className,
|
|
23
|
+
materialVideoId,
|
|
24
|
+
locale = 'en'
|
|
25
|
+
} = _a,
|
|
26
|
+
youtubeProps = tslib.__rest(_a, ["className", "materialVideoId", "locale"]);
|
|
27
|
+
|
|
28
|
+
const prefixCls = 'em-material-video';
|
|
29
|
+
const [materialVideo, materialVideoStatus] = materialSharedUtils.useMaterialInitFetch(apiClient.config.init, React__default["default"].useCallback(signal => apiClient.getOrgMaterialVideoGet({
|
|
30
|
+
materialVideoId
|
|
31
|
+
}, {
|
|
32
|
+
signal
|
|
33
|
+
}), [materialVideoId]));
|
|
34
|
+
return React__default["default"].createElement(blocks.Flex, {
|
|
35
|
+
className: classnames__default["default"](prefixCls, className),
|
|
36
|
+
align: "center",
|
|
37
|
+
justify: "center",
|
|
38
|
+
width: "100%",
|
|
39
|
+
height: "100%"
|
|
40
|
+
}, React__default["default"].createElement(reactIntl.IntlProvider, {
|
|
41
|
+
locale: locale,
|
|
42
|
+
defaultLocale: "en",
|
|
43
|
+
messages: locale in locales ? locales[locale] : locales.en
|
|
44
|
+
}, React__default["default"].createElement(MaterialVideoContent, Object.assign({
|
|
45
|
+
materialVideo: (_b = materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.materialVideo) !== null && _b !== void 0 ? _b : null,
|
|
46
|
+
videoGetStatus: materialVideoStatus
|
|
47
|
+
}, youtubeProps))));
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = MaterialVideo;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var blocks = require('@elice/blocks');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
|
|
12
|
+
const StyledMaterialVideoStatus = styled__default["default"](blocks.Flex).withConfig({
|
|
13
|
+
componentId: "sc-dg3csq-0"
|
|
14
|
+
})(["width:100%;height:100%;background-color:#22222c;"]);
|
|
15
|
+
|
|
16
|
+
exports.StyledMaterialVideoStatus = StyledMaterialVideoStatus;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { APIStatus } from '@elice/material-shared-types';
|
|
3
|
+
import type { GetOrgMaterialVideoGetResponses } from '@elice/types';
|
|
4
|
+
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
5
|
+
export interface MaterialVideoContentProps extends YoutubePlayerSharedProps {
|
|
6
|
+
videoGetStatus: APIStatus;
|
|
7
|
+
materialVideo: null | GetOrgMaterialVideoGetResponses['materialVideo'];
|
|
8
|
+
}
|
|
9
|
+
declare const MaterialVideoContent: React.FC<MaterialVideoContentProps>;
|
|
10
|
+
export default MaterialVideoContent;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var blocks = require('@elice/blocks');
|
|
7
|
+
var designTokens = require('@elice/design-tokens');
|
|
8
|
+
var icons = require('@elice/icons');
|
|
9
|
+
var youtubeUrlParser = require('../../utils/youtubeUrlParser.js');
|
|
10
|
+
var YoutubePlayer = require('../youtube-player/YoutubePlayer.js');
|
|
11
|
+
var MaterialVideo_styled = require('./MaterialVideo.styled.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
+
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
+
|
|
17
|
+
const MaterialVideoContent = _a => {
|
|
18
|
+
var {
|
|
19
|
+
videoGetStatus,
|
|
20
|
+
materialVideo
|
|
21
|
+
} = _a,
|
|
22
|
+
youtubeProps = tslib.__rest(_a, ["videoGetStatus", "materialVideo"]);
|
|
23
|
+
|
|
24
|
+
const intl = reactIntl.useIntl();
|
|
25
|
+
|
|
26
|
+
if (videoGetStatus === 'pending') {
|
|
27
|
+
return React__default["default"].createElement(MaterialVideo_styled.StyledMaterialVideoStatus, {
|
|
28
|
+
align: "center",
|
|
29
|
+
justify: "center"
|
|
30
|
+
}, React__default["default"].createElement(blocks.Spinner, null), React__default["default"].createElement(blocks.Hspace, {
|
|
31
|
+
width: 0.5
|
|
32
|
+
}), React__default["default"].createElement(blocks.Text, {
|
|
33
|
+
role: "white"
|
|
34
|
+
}, intl.formatMessage({
|
|
35
|
+
id: 'video.status.loading'
|
|
36
|
+
})));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!(materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.url) || videoGetStatus === 'rejected') {
|
|
40
|
+
return React__default["default"].createElement(MaterialVideo_styled.StyledMaterialVideoStatus, {
|
|
41
|
+
align: "center",
|
|
42
|
+
justify: "center"
|
|
43
|
+
}, React__default["default"].createElement(blocks.Icon, {
|
|
44
|
+
icon: icons.eilStatusWarn,
|
|
45
|
+
color: designTokens.base.color.white
|
|
46
|
+
}), React__default["default"].createElement(blocks.Hspace, {
|
|
47
|
+
width: 0.5
|
|
48
|
+
}), React__default["default"].createElement(blocks.Text, {
|
|
49
|
+
role: "white"
|
|
50
|
+
}, intl.formatMessage({
|
|
51
|
+
id: 'video.status.error'
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return React__default["default"].createElement(YoutubePlayer, Object.assign({
|
|
56
|
+
videoId: youtubeUrlParser.youtubeUrlParser(materialVideo.url)
|
|
57
|
+
}, youtubeProps));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = MaterialVideoContent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const en = {
|
|
6
|
+
'video.status.loading': 'Loading video...',
|
|
7
|
+
'video.status.error': 'Error occurred while loading video'
|
|
8
|
+
};
|
|
9
|
+
const ko = {
|
|
10
|
+
'video.status.loading': '수업 자료 로딩 중...',
|
|
11
|
+
'video.status.error': '수업 자료를 가져오는 중 문제가 발생하였습니다.'
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.en = en;
|
|
15
|
+
exports.ko = ko;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { YouTubeProps } from 'react-youtube';
|
|
3
|
+
declare type PickedYoutubeProps = Pick<YouTubeProps, 'onReady' | 'onError' | 'onPlay' | 'onPause' | 'onEnd' | 'onStateChange' | 'onPlaybackRateChange' | 'onPlaybackQualityChange'>;
|
|
4
|
+
export interface YoutubePlayerSharedProps extends PickedYoutubeProps {
|
|
5
|
+
autoPlay?: boolean;
|
|
6
|
+
disableControl?: boolean;
|
|
7
|
+
disableKeyboardEvent?: boolean;
|
|
8
|
+
disableFullscreen?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface YoutubePlayerProps extends YoutubePlayerSharedProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
videoId: string;
|
|
13
|
+
}
|
|
14
|
+
declare const YoutubePlayer: React.FC<YoutubePlayerProps>;
|
|
15
|
+
export default YoutubePlayer;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib = require('tslib');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var Youtube = require('react-youtube');
|
|
6
|
+
var classnames = require('classnames');
|
|
7
|
+
var YoutubePlayer_styled = require('./YoutubePlayer.styled.js');
|
|
8
|
+
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
|
+
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
12
|
+
var Youtube__default = /*#__PURE__*/_interopDefaultLegacy(Youtube);
|
|
13
|
+
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
14
|
+
|
|
15
|
+
const YoutubePlayer = _a => {
|
|
16
|
+
var {
|
|
17
|
+
className,
|
|
18
|
+
videoId,
|
|
19
|
+
autoPlay = false,
|
|
20
|
+
disableControl = false,
|
|
21
|
+
disableKeyboardEvent = false,
|
|
22
|
+
disableFullscreen = false
|
|
23
|
+
} = _a,
|
|
24
|
+
youtubeProps = tslib.__rest(_a, ["className", "videoId", "autoPlay", "disableControl", "disableKeyboardEvent", "disableFullscreen"]);
|
|
25
|
+
|
|
26
|
+
const prefixCls = 'em-youtube-player';
|
|
27
|
+
/**
|
|
28
|
+
* Get options for YouTube IFrame player API.
|
|
29
|
+
* ref: https://developers.google.com/youtube/player_parameters#Parameters
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const getYoutubeOptions = () => {
|
|
33
|
+
return {
|
|
34
|
+
width: '100%',
|
|
35
|
+
height: '100%',
|
|
36
|
+
playerVars: {
|
|
37
|
+
autoplay: autoPlay ? 1 : 0,
|
|
38
|
+
controls: disableControl ? 0 : 1,
|
|
39
|
+
fs: disableFullscreen ? 0 : 1,
|
|
40
|
+
disablekb: disableKeyboardEvent ? 1 : 0
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return React__default["default"].createElement(YoutubePlayer_styled.StyledYoutubePlayerWrapper, {
|
|
46
|
+
className: classnames__default["default"](prefixCls, className),
|
|
47
|
+
justify: "center",
|
|
48
|
+
align: "center"
|
|
49
|
+
}, React__default["default"].createElement(Youtube__default["default"], Object.assign({
|
|
50
|
+
videoId: videoId,
|
|
51
|
+
opts: getYoutubeOptions(),
|
|
52
|
+
containerClassName: `${prefixCls}__inner`
|
|
53
|
+
}, youtubeProps)));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = YoutubePlayer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var blocks = require('@elice/blocks');
|
|
6
|
+
var styled = require('styled-components');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
+
|
|
12
|
+
const StyledYoutubePlayerWrapper = styled__default["default"](blocks.Flex).withConfig({
|
|
13
|
+
componentId: "sc-ao5iuk-0"
|
|
14
|
+
})(["width:100%;height:100%;background-color:#22222c;& .em-youtube-player__inner{width:90%;height:90%;}"]);
|
|
15
|
+
|
|
16
|
+
exports.StyledYoutubePlayerWrapper = StyledYoutubePlayerWrapper;
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/material-video';
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get YouTube video id from url using regex
|
|
7
|
+
* @param url URL of youtube
|
|
8
|
+
* @returns id of youtube video OR null when URL is invalid
|
|
9
|
+
*/
|
|
10
|
+
const youtubeUrlParser = url => {
|
|
11
|
+
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
12
|
+
const match = regExp.exec(url);
|
|
13
|
+
return match && match[7].length === 11 ? match[7] : null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.youtubeUrlParser = youtubeUrlParser;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
3
|
+
export interface MaterialVideoProps extends YoutubePlayerSharedProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
materialVideoId: number;
|
|
6
|
+
locale?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const MaterialVideo: React.FC<MaterialVideoProps>;
|
|
9
|
+
export default MaterialVideo;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IntlProvider } from 'react-intl';
|
|
4
|
+
import { config, getOrgMaterialVideoGet } from '@elice/api-client';
|
|
5
|
+
import { Flex } from '@elice/blocks';
|
|
6
|
+
import { useMaterialInitFetch } from '@elice/material-shared-utils';
|
|
7
|
+
import classnames from 'classnames';
|
|
8
|
+
import * as locales from './locales.js';
|
|
9
|
+
import { en } from './locales.js';
|
|
10
|
+
import MaterialVideoContent from './MaterialVideoContent.js';
|
|
11
|
+
|
|
12
|
+
const MaterialVideo = _a => {
|
|
13
|
+
var _b;
|
|
14
|
+
|
|
15
|
+
var {
|
|
16
|
+
className,
|
|
17
|
+
materialVideoId,
|
|
18
|
+
locale = 'en'
|
|
19
|
+
} = _a,
|
|
20
|
+
youtubeProps = __rest(_a, ["className", "materialVideoId", "locale"]);
|
|
21
|
+
|
|
22
|
+
const prefixCls = 'em-material-video';
|
|
23
|
+
const [materialVideo, materialVideoStatus] = useMaterialInitFetch(config.init, React.useCallback(signal => getOrgMaterialVideoGet({
|
|
24
|
+
materialVideoId
|
|
25
|
+
}, {
|
|
26
|
+
signal
|
|
27
|
+
}), [materialVideoId]));
|
|
28
|
+
return React.createElement(Flex, {
|
|
29
|
+
className: classnames(prefixCls, className),
|
|
30
|
+
align: "center",
|
|
31
|
+
justify: "center",
|
|
32
|
+
width: "100%",
|
|
33
|
+
height: "100%"
|
|
34
|
+
}, React.createElement(IntlProvider, {
|
|
35
|
+
locale: locale,
|
|
36
|
+
defaultLocale: "en",
|
|
37
|
+
messages: locale in locales ? locales[locale] : en
|
|
38
|
+
}, React.createElement(MaterialVideoContent, Object.assign({
|
|
39
|
+
materialVideo: (_b = materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.materialVideo) !== null && _b !== void 0 ? _b : null,
|
|
40
|
+
videoGetStatus: materialVideoStatus
|
|
41
|
+
}, youtubeProps))));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { MaterialVideo as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Flex } from '@elice/blocks';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const StyledMaterialVideoStatus = styled(Flex).withConfig({
|
|
5
|
+
componentId: "sc-dg3csq-0"
|
|
6
|
+
})(["width:100%;height:100%;background-color:#22222c;"]);
|
|
7
|
+
|
|
8
|
+
export { StyledMaterialVideoStatus };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { APIStatus } from '@elice/material-shared-types';
|
|
3
|
+
import type { GetOrgMaterialVideoGetResponses } from '@elice/types';
|
|
4
|
+
import type { YoutubePlayerSharedProps } from '../youtube-player';
|
|
5
|
+
export interface MaterialVideoContentProps extends YoutubePlayerSharedProps {
|
|
6
|
+
videoGetStatus: APIStatus;
|
|
7
|
+
materialVideo: null | GetOrgMaterialVideoGetResponses['materialVideo'];
|
|
8
|
+
}
|
|
9
|
+
declare const MaterialVideoContent: React.FC<MaterialVideoContentProps>;
|
|
10
|
+
export default MaterialVideoContent;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { Spinner, Hspace, Text, Icon } from '@elice/blocks';
|
|
5
|
+
import { base } from '@elice/design-tokens';
|
|
6
|
+
import { eilStatusWarn } from '@elice/icons';
|
|
7
|
+
import { youtubeUrlParser } from '../../utils/youtubeUrlParser.js';
|
|
8
|
+
import YoutubePlayer from '../youtube-player/YoutubePlayer.js';
|
|
9
|
+
import { StyledMaterialVideoStatus } from './MaterialVideo.styled.js';
|
|
10
|
+
|
|
11
|
+
const MaterialVideoContent = _a => {
|
|
12
|
+
var {
|
|
13
|
+
videoGetStatus,
|
|
14
|
+
materialVideo
|
|
15
|
+
} = _a,
|
|
16
|
+
youtubeProps = __rest(_a, ["videoGetStatus", "materialVideo"]);
|
|
17
|
+
|
|
18
|
+
const intl = useIntl();
|
|
19
|
+
|
|
20
|
+
if (videoGetStatus === 'pending') {
|
|
21
|
+
return React.createElement(StyledMaterialVideoStatus, {
|
|
22
|
+
align: "center",
|
|
23
|
+
justify: "center"
|
|
24
|
+
}, React.createElement(Spinner, null), React.createElement(Hspace, {
|
|
25
|
+
width: 0.5
|
|
26
|
+
}), React.createElement(Text, {
|
|
27
|
+
role: "white"
|
|
28
|
+
}, intl.formatMessage({
|
|
29
|
+
id: 'video.status.loading'
|
|
30
|
+
})));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!(materialVideo === null || materialVideo === void 0 ? void 0 : materialVideo.url) || videoGetStatus === 'rejected') {
|
|
34
|
+
return React.createElement(StyledMaterialVideoStatus, {
|
|
35
|
+
align: "center",
|
|
36
|
+
justify: "center"
|
|
37
|
+
}, React.createElement(Icon, {
|
|
38
|
+
icon: eilStatusWarn,
|
|
39
|
+
color: base.color.white
|
|
40
|
+
}), React.createElement(Hspace, {
|
|
41
|
+
width: 0.5
|
|
42
|
+
}), React.createElement(Text, {
|
|
43
|
+
role: "white"
|
|
44
|
+
}, intl.formatMessage({
|
|
45
|
+
id: 'video.status.error'
|
|
46
|
+
})));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return React.createElement(YoutubePlayer, Object.assign({
|
|
50
|
+
videoId: youtubeUrlParser(materialVideo.url)
|
|
51
|
+
}, youtubeProps));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { MaterialVideoContent as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const en = {
|
|
2
|
+
'video.status.loading': 'Loading video...',
|
|
3
|
+
'video.status.error': 'Error occurred while loading video'
|
|
4
|
+
};
|
|
5
|
+
const ko = {
|
|
6
|
+
'video.status.loading': '수업 자료 로딩 중...',
|
|
7
|
+
'video.status.error': '수업 자료를 가져오는 중 문제가 발생하였습니다.'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { en, ko };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { YouTubeProps } from 'react-youtube';
|
|
3
|
+
declare type PickedYoutubeProps = Pick<YouTubeProps, 'onReady' | 'onError' | 'onPlay' | 'onPause' | 'onEnd' | 'onStateChange' | 'onPlaybackRateChange' | 'onPlaybackQualityChange'>;
|
|
4
|
+
export interface YoutubePlayerSharedProps extends PickedYoutubeProps {
|
|
5
|
+
autoPlay?: boolean;
|
|
6
|
+
disableControl?: boolean;
|
|
7
|
+
disableKeyboardEvent?: boolean;
|
|
8
|
+
disableFullscreen?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface YoutubePlayerProps extends YoutubePlayerSharedProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
videoId: string;
|
|
13
|
+
}
|
|
14
|
+
declare const YoutubePlayer: React.FC<YoutubePlayerProps>;
|
|
15
|
+
export default YoutubePlayer;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Youtube from 'react-youtube';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { StyledYoutubePlayerWrapper } from './YoutubePlayer.styled.js';
|
|
6
|
+
|
|
7
|
+
const YoutubePlayer = _a => {
|
|
8
|
+
var {
|
|
9
|
+
className,
|
|
10
|
+
videoId,
|
|
11
|
+
autoPlay = false,
|
|
12
|
+
disableControl = false,
|
|
13
|
+
disableKeyboardEvent = false,
|
|
14
|
+
disableFullscreen = false
|
|
15
|
+
} = _a,
|
|
16
|
+
youtubeProps = __rest(_a, ["className", "videoId", "autoPlay", "disableControl", "disableKeyboardEvent", "disableFullscreen"]);
|
|
17
|
+
|
|
18
|
+
const prefixCls = 'em-youtube-player';
|
|
19
|
+
/**
|
|
20
|
+
* Get options for YouTube IFrame player API.
|
|
21
|
+
* ref: https://developers.google.com/youtube/player_parameters#Parameters
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const getYoutubeOptions = () => {
|
|
25
|
+
return {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
playerVars: {
|
|
29
|
+
autoplay: autoPlay ? 1 : 0,
|
|
30
|
+
controls: disableControl ? 0 : 1,
|
|
31
|
+
fs: disableFullscreen ? 0 : 1,
|
|
32
|
+
disablekb: disableKeyboardEvent ? 1 : 0
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return React.createElement(StyledYoutubePlayerWrapper, {
|
|
38
|
+
className: classnames(prefixCls, className),
|
|
39
|
+
justify: "center",
|
|
40
|
+
align: "center"
|
|
41
|
+
}, React.createElement(Youtube, Object.assign({
|
|
42
|
+
videoId: videoId,
|
|
43
|
+
opts: getYoutubeOptions(),
|
|
44
|
+
containerClassName: `${prefixCls}__inner`
|
|
45
|
+
}, youtubeProps)));
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { YoutubePlayer as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Flex } from '@elice/blocks';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const StyledYoutubePlayerWrapper = styled(Flex).withConfig({
|
|
5
|
+
componentId: "sc-ao5iuk-0"
|
|
6
|
+
})(["width:100%;height:100%;background-color:#22222c;& .em-youtube-player__inner{width:90%;height:90%;}"]);
|
|
7
|
+
|
|
8
|
+
export { StyledYoutubePlayerWrapper };
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/material-video';
|
package/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MaterialVideo } from './components/material-video/MaterialVideo.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get YouTube video id from url using regex
|
|
3
|
+
* @param url URL of youtube
|
|
4
|
+
* @returns id of youtube video OR null when URL is invalid
|
|
5
|
+
*/
|
|
6
|
+
const youtubeUrlParser = url => {
|
|
7
|
+
const regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*/;
|
|
8
|
+
const match = regExp.exec(url);
|
|
9
|
+
return match && match[7].length === 11 ? match[7] : null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { youtubeUrlParser };
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@elice/material-video",
|
|
3
|
+
"version": "1.220803.0",
|
|
4
|
+
"description": "User view and editing components of Elice material video",
|
|
5
|
+
"repository": "https://git.elicer.io/elice/frontend/library/elice-material",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"main": "./cjs/index.js",
|
|
8
|
+
"module": "./es/index.js",
|
|
9
|
+
"types": "./es/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"es",
|
|
12
|
+
"cjs",
|
|
13
|
+
"package.json",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": "~16.14",
|
|
19
|
+
"yarn": ">=1.20 <2"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"start": "run-s watch",
|
|
23
|
+
"prebuild": "run-s clean",
|
|
24
|
+
"build": "run-p build:es build:cjs",
|
|
25
|
+
"build:es": "rollup -c ../../rollup.config.ts -f es",
|
|
26
|
+
"build:cjs": "rollup -c ../../rollup.config.ts -f cjs",
|
|
27
|
+
"watch": "rollup -c ../../rollup.config.ts -f es -w",
|
|
28
|
+
"lint": "eslint --ext .ts,.tsx ./src --max-warnings=0",
|
|
29
|
+
"clean": "del-cli \"es/*\" \"cjs/*\" \"dist/*\""
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@elice/api-client": "^1.220802.1",
|
|
33
|
+
"@elice/blocks": "^1.220803.0",
|
|
34
|
+
"@elice/design-tokens": "^1.220803.0",
|
|
35
|
+
"@elice/icons": "^1.220803.0",
|
|
36
|
+
"@elice/material-shared-types": "22.7.2-1",
|
|
37
|
+
"@elice/material-shared-utils": "22.7.2-1",
|
|
38
|
+
"@elice/types": "^1.220802.1",
|
|
39
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
40
|
+
"react-intl": "^5.0.0",
|
|
41
|
+
"react-use": "^17.0.0",
|
|
42
|
+
"styled-components": "^5.2.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"classnames": "^2.2.0",
|
|
46
|
+
"react-youtube": "^7.14.0",
|
|
47
|
+
"tslib": "^2.3.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@elice/api-client": "^1.220802.1",
|
|
51
|
+
"@elice/blocks": "^1.220803.0",
|
|
52
|
+
"@elice/design-tokens": "^1.220803.0",
|
|
53
|
+
"@elice/icons": "^1.220803.0",
|
|
54
|
+
"@elice/icons-legacy": "npm:@elice/icons@0.220803.1",
|
|
55
|
+
"@elice/material-shared-types": "1.220803.0",
|
|
56
|
+
"@elice/material-shared-utils": "1.220803.0",
|
|
57
|
+
"@elice/types": "^1.220802.1",
|
|
58
|
+
"@types/classnames": "^2.3.1",
|
|
59
|
+
"@types/react": "~17.0.9",
|
|
60
|
+
"@types/styled-components": "^5.1.21",
|
|
61
|
+
"react": "^17.0.2",
|
|
62
|
+
"react-intl": "^5.20.10",
|
|
63
|
+
"react-use": "^17.2.4",
|
|
64
|
+
"styled-components": "^5.3.0"
|
|
65
|
+
},
|
|
66
|
+
"gitHead": "21c6b42ae6550e7899c57bf39fa78cea0f47e64c"
|
|
67
|
+
}
|