Skip to content

Commit c06416a

Browse files
authored
Merge pull request #183 from bbc/refactor-media-player
Refactor media player
2 parents c62f410 + 0e7a988 commit c06416a

39 files changed

+621
-727
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
],
1111
"env": {
1212
"browser": true,
13-
"jest": true
13+
"jest": true,
14+
"node": true,
1415
},
1516
"rules": {
1617
"prefer-const": 1,
@@ -43,7 +44,7 @@
4344
"no-param-reassign": [ 1 ],
4445
"no-shadow": [ 1 ],
4546
"camelcase": [ 1 ],
46-
"no-underscore-dangle" : [0, "always"],
47+
"no-underscore-dangle": [0, "always"],
4748
"keyword-spacing": ["error", { "before": true, "after": true }],
4849
"key-spacing": ["error", { "afterColon": true }],
4950
"newline-before-return": "error",

.storybook/config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ addDecorator(withA11y);
1717

1818
addParameters({
1919
options: {
20-
panelPosition: 'right',
20+
// showPanel: false,
21+
panelPosition: 'bottom',
2122
sidebarAnimations: true
2223
},
2324
});

.storybook/styles/main.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
body * {
1+
body {
22
font-family: ReithSerif, Fallback, sans-serif;
3-
// font-family: ReithSans, Helvetica, sans-serif !important;
3+
4+
}
5+
6+
p, span {
7+
font-family: ReithSans, Helvetica, sans-serif;
8+
9+
}
10+
11+
h1, h2, h3, h4, h5, h6, label * {
12+
font-family: ReithSerif;
413
}

.storybook/webpack.config.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,28 @@ module.exports = {
66
module: {
77
rules: [
88
{
9-
test: /\.module.css$/,
9+
test: /\.module.(sa|sc|c)ss$/,
1010
use: [
11+
"style-loader",
1112
{
12-
loader: "style-loader"
13+
loader: "css-loader",
14+
options: { modules: true }
1315
},
1416
{
15-
loader: "css-loader",
16-
options: {
17-
modules: true
18-
}
17+
loader: "sass-loader",
18+
options: { sourcemap: true }
1919
}
2020
]
2121
},
2222
{
23-
test: /\.scss$/,
23+
test: /\.s(a|c)ss$/,
24+
exclude: /\.module.(s(a|c)ss)$/,
2425
use: [
25-
{
26-
loader: "style-loader"
27-
},
28-
{
29-
loader: "css-loader",
30-
options: {
31-
sourceMap: true
32-
}
33-
},
26+
"style-loader",
27+
"css-loader",
3428
{
3529
loader: "sass-loader",
36-
options: {
37-
sourcemap: true
38-
}
30+
options: { sourcemap: true }
3931
}
4032
]
4133
}

demo/app.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import React from 'react';
2-
// NOTE: This slows down performance, even during development
3-
// if (process.env.NODE_ENV !== 'production') {
4-
// const { whyDidYouUpdate } = require('why-did-you-update');
5-
// whyDidYouUpdate(React, { exclude: [ /^HotKeysWrapper/ ] } );
6-
// }
2+
73
import TranscriptEditor from '../packages/components/transcript-editor';
84
import SttTypeSelect from './select-stt-json-type';
95
import ExportFormatSelect from './select-export-format';
106
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
117
import { faGithub } from '@fortawesome/free-brands-svg-icons';
128

13-
import demoTranscript from './sample-data/KateDarling-bbcKaldiTranscriptWithSpeakerSegments.json';
14-
const demoMediaUrl = 'https://download.ted.com/talks/KateDarling_2018S-950k.mp4';
15-
const demoTitle = 'Ted Talk - Kate Darling';
9+
import DEMO_TRANSCRIPT from './sample-data/KateDarling-bbcKaldiTranscriptWithSpeakerSegments.json';
10+
const DEMO_MEDIA_URL = 'https://download.ted.com/talks/KateDarling_2018S-950k.mp4';
11+
const DEMO_TITLE = 'TED Talk | Kate Darling - Why we have an emotional connection to robots';
1612

17-
import style from './index.module.css';
13+
import style from './index.module.scss';
1814

1915
class App extends React.Component {
2016
constructor(props) {
@@ -36,9 +32,9 @@ class App extends React.Component {
3632

3733
loadDemo = () => {
3834
this.setState({
39-
transcriptData: demoTranscript,
40-
mediaUrl: demoMediaUrl,
41-
title: demoTitle,
35+
transcriptData: DEMO_TRANSCRIPT,
36+
mediaUrl: DEMO_MEDIA_URL,
37+
title: DEMO_TITLE,
4238
sttType: 'bbckaldi'
4339
});
4440
}
@@ -52,7 +48,7 @@ class App extends React.Component {
5248
if (canPlay) {
5349
const fileURL = URL.createObjectURL(file);
5450
this.setState({
55-
// transcriptData: demoTranscript,
51+
// transcriptData: DEMO_TRANSCRIPT,
5652
mediaUrl: fileURL,
5753
fileName: file.name
5854
});
@@ -65,7 +61,7 @@ class App extends React.Component {
6561
const fileURL = prompt("Paste the URL you'd like to use here:");
6662

6763
this.setState({
68-
// transcriptData: demoTranscript,
64+
// transcriptData: DEMO_TRANSCRIPT,
6965
mediaUrl: fileURL
7066
});
7167
}
@@ -178,19 +174,19 @@ class App extends React.Component {
178174
</section>
179175

180176
<section className={ style.demoNavItem }>
181-
<label className={ style.sectionLabel }>Custom Media</label>
182-
<button onClick={ () => this.handleLoadMediaUrl() }>Load from URL</button>
177+
<label className={ style.sectionLabel }>Load Media</label>
178+
<button onClick={ () => this.handleLoadMediaUrl() }> From URL</button>
183179
<input
184180
type={ 'file' }
185181
id={ 'mediaFile' }
186182
onChange={ e => this.handleLoadMedia(e.target.files) }
187183
/>
188-
<label htmlFor="mediaFile" >Load local media</label>
184+
<label htmlFor="mediaFile" >From Computer</label>
189185
{this.state.fileName !== '' ? <label className={ style.fileNameLabel }>{this.state.fileName}</label> : null}
190186
</section>
191187

192188
<section className={ style.demoNavItem }>
193-
<label className={ style.sectionLabel }>Import Transcript</label>
189+
<label className={ style.sectionLabel }>Load Transcript</label>
194190
<SttTypeSelect
195191
className={ style.dropdown }
196192
name={ 'sttType' }
@@ -203,7 +199,7 @@ class App extends React.Component {
203199
id={ 'transcriptFile' }
204200
onChange={ e => this.handleLoadTranscriptJson(e.target.files) }
205201
/>
206-
<label htmlFor="transcriptFile" >Load Transcript</label>
202+
<label htmlFor="transcriptFile" >From Computer</label>
207203
{this.state.transcriptData !== null ? <label className={ style.fileNameLabel }>Transcript loaded.</label> : null}
208204

209205
</section>
@@ -254,7 +250,11 @@ class App extends React.Component {
254250
/>
255251
</div>
256252

257-
<button className={ style.warningButton } onClick={ () => this.clearLocalStorage() }>Clear Local Storage</button>
253+
<button
254+
className={ style.warningButton }
255+
onClick={ () => this.clearLocalStorage() }>
256+
Clear Local Storage
257+
</button>
258258
</section>
259259
</div>
260260

@@ -281,6 +281,4 @@ class App extends React.Component {
281281
}
282282
}
283283

284-
// render(<App />, document.getElementById('root'));
285-
286284
export default App;

demo/index.module.css

Lines changed: 0 additions & 143 deletions
This file was deleted.

0 commit comments

Comments
 (0)