@micromag/element-closed-captions 0.3.488 → 0.3.491

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.
@@ -1 +1 @@
1
- .micromag-element-closed-captions-container{position:relative;text-align:center}.micromag-element-closed-captions-container .micromag-element-closed-captions-captions{background-color:#1c1c1c;color:#fff;display:inline-block;padding:10px;word-break:break-word}
1
+ .micromag-element-closed-captions-container{position:relative;text-align:center}.micromag-element-closed-captions-container .micromag-element-closed-captions-captions{background-color:#1c1c1c;color:#fff;display:inline-block;padding:5px;word-break:break-word}
package/es/index.js CHANGED
@@ -6,7 +6,8 @@ import parseSRT from 'parse-srt';
6
6
  import PropTypes$1 from 'prop-types';
7
7
  import React, { useState, useEffect, useCallback } from 'react';
8
8
  import { PropTypes } from '@micromag/core';
9
- import { getSecondsFromTime } from '@micromag/core/utils';
9
+ import { getSecondsFromTime, getStyleFromBox } from '@micromag/core/utils';
10
+ import TextElement from '@micromag/element-text';
10
11
 
11
12
  var styles = {"container":"micromag-element-closed-captions-container","captions":"micromag-element-closed-captions-captions"};
12
13
 
@@ -16,18 +17,24 @@ var propTypes = {
16
17
  // in seconds
17
18
  timeOffset: PropTypes$1.string,
18
19
  // in srt time format (10:00:01,034)
20
+ textStyle: PropTypes.textStyle,
21
+ boxStyle: PropTypes.boxStyle,
19
22
  className: PropTypes$1.string
20
23
  };
21
24
  var defaultProps = {
22
25
  media: null,
23
26
  currentTime: 0,
24
27
  timeOffset: null,
28
+ textStyle: null,
29
+ boxStyle: null,
25
30
  className: null
26
31
  };
27
32
  var ClosedCaptions = function ClosedCaptions(_ref) {
28
33
  var currentTime = _ref.currentTime,
29
34
  timeOffset = _ref.timeOffset,
30
35
  media = _ref.media,
36
+ textStyle = _ref.textStyle,
37
+ boxStyle = _ref.boxStyle,
31
38
  className = _ref.className;
32
39
  var _ref2 = media || {},
33
40
  _ref2$url = _ref2.url,
@@ -74,14 +81,16 @@ var ClosedCaptions = function ClosedCaptions(_ref) {
74
81
  }, [currentTime, lines, getLineIndexFromTime, setLineIndex]);
75
82
  var line = lineIndex !== -1 ? lines[lineIndex] : null;
76
83
  var active = line !== null;
84
+ var finalBoxStyles = boxStyle !== null ? getStyleFromBox(boxStyle) : null;
77
85
  return /*#__PURE__*/React.createElement("div", {
78
86
  className: classNames([styles.container, _defineProperty({}, className, className !== null)])
79
87
  }, active ? /*#__PURE__*/React.createElement("div", {
80
88
  className: styles.captions,
81
- dangerouslySetInnerHTML: active ? {
82
- __html: line.text
83
- } : null
84
- }) : null);
89
+ style: finalBoxStyles
90
+ }, /*#__PURE__*/React.createElement(TextElement, {
91
+ textStyle: textStyle,
92
+ body: line.text
93
+ })) : null);
85
94
  };
86
95
  ClosedCaptions.propTypes = propTypes;
87
96
  ClosedCaptions.defaultProps = defaultProps;
package/lib/index.js CHANGED
@@ -9,6 +9,7 @@ var PropTypes = require('prop-types');
9
9
  var React = require('react');
10
10
  var core = require('@micromag/core');
11
11
  var utils = require('@micromag/core/utils');
12
+ var TextElement = require('@micromag/element-text');
12
13
 
13
14
  var styles = {"container":"micromag-element-closed-captions-container","captions":"micromag-element-closed-captions-captions"};
14
15
 
@@ -18,18 +19,24 @@ var propTypes = {
18
19
  // in seconds
19
20
  timeOffset: PropTypes.string,
20
21
  // in srt time format (10:00:01,034)
22
+ textStyle: core.PropTypes.textStyle,
23
+ boxStyle: core.PropTypes.boxStyle,
21
24
  className: PropTypes.string
22
25
  };
23
26
  var defaultProps = {
24
27
  media: null,
25
28
  currentTime: 0,
26
29
  timeOffset: null,
30
+ textStyle: null,
31
+ boxStyle: null,
27
32
  className: null
28
33
  };
29
34
  var ClosedCaptions = function ClosedCaptions(_ref) {
30
35
  var currentTime = _ref.currentTime,
31
36
  timeOffset = _ref.timeOffset,
32
37
  media = _ref.media,
38
+ textStyle = _ref.textStyle,
39
+ boxStyle = _ref.boxStyle,
33
40
  className = _ref.className;
34
41
  var _ref2 = media || {},
35
42
  _ref2$url = _ref2.url,
@@ -76,14 +83,16 @@ var ClosedCaptions = function ClosedCaptions(_ref) {
76
83
  }, [currentTime, lines, getLineIndexFromTime, setLineIndex]);
77
84
  var line = lineIndex !== -1 ? lines[lineIndex] : null;
78
85
  var active = line !== null;
86
+ var finalBoxStyles = boxStyle !== null ? utils.getStyleFromBox(boxStyle) : null;
79
87
  return /*#__PURE__*/React.createElement("div", {
80
88
  className: classNames([styles.container, _defineProperty({}, className, className !== null)])
81
89
  }, active ? /*#__PURE__*/React.createElement("div", {
82
90
  className: styles.captions,
83
- dangerouslySetInnerHTML: active ? {
84
- __html: line.text
85
- } : null
86
- }) : null);
91
+ style: finalBoxStyles
92
+ }, /*#__PURE__*/React.createElement(TextElement, {
93
+ textStyle: textStyle,
94
+ body: line.text
95
+ })) : null);
87
96
  };
88
97
  ClosedCaptions.propTypes = propTypes;
89
98
  ClosedCaptions.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-closed-captions",
3
- "version": "0.3.488",
3
+ "version": "0.3.491",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -60,7 +60,8 @@
60
60
  },
61
61
  "dependencies": {
62
62
  "@babel/runtime": "^7.13.10",
63
- "@micromag/core": "^0.3.488",
63
+ "@micromag/core": "^0.3.491",
64
+ "@micromag/element-text": "^0.3.491",
64
65
  "classnames": "^2.2.6",
65
66
  "node-fetch": "^2.6.1",
66
67
  "parse-srt": "^1.0.0-alpha",
@@ -72,5 +73,5 @@
72
73
  "access": "public",
73
74
  "registry": "https://registry.npmjs.org/"
74
75
  },
75
- "gitHead": "36ecbf590ebb8eabac17e47fc48ffb8bf8c8178c"
76
+ "gitHead": "d4af8a992fad6d8d50e41e347a4b92e6e025b984"
76
77
  }