Skip to content

Commit 12d9982

Browse files
pietropjamesdools
authored andcommitted
"Monorepo" refactor spike remove lerna (#135)
* got storybook working tests not working yet * fixed tests using jest, and removed CRA dependency, updated babel config for babel 7 and stubbed css files for jest tests for css node modules * Added support for demo app in storybook * fixed eslint CRA had it's own linter internally, so added linting + dependencies * cleaned up export scripts in package.json * updated README * finalised refactor see PR description for more details * rename demo app editor to demoTranscript * bringing back style lint, and fixing lint in storybook config * updated with current master AWS adapter * linting * fix #132 playtime displaied double playtime on display is double of actual total playtime * temporary fix #73 monospace duration and current time in media player to stop moving while playing
1 parent 8062731 commit 12d9982

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+25302
-34542
lines changed

.babelrc

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

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: pietrop
88
---
99

1010
**Describe the bug**
11-
A clear and concise description of what the bug is.
11+
<!-- A clear and concise description of what the bug is. -->
1212

1313
**To Reproduce**
1414
Steps to reproduce the behavior:
@@ -18,10 +18,10 @@ Steps to reproduce the behavior:
1818
4. See error
1919

2020
**Expected behavior**
21-
A clear and concise description of what you expected to happen.
21+
<!-- A clear and concise description of what you expected to happen. -->
2222

2323
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
24+
<!-- If applicable, add screenshots to help explain your problem. -->
2525

2626
**Desktop (please complete the following information):**
2727
- OS: [e.g. iOS]
@@ -35,4 +35,4 @@ If applicable, add screenshots to help explain your problem.
3535
- Version [e.g. 22]
3636

3737
**Additional context**
38-
Add any other context about the problem here.
38+
<!-- Add any other context about the problem here. -->

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ assignees: pietrop
88
---
99

1010
**Is your feature request related to a problem? Please describe.**
11-
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
1212

1313
**Describe the solution you'd like**
14-
A clear and concise description of what you want to happen.
14+
<!-- A clear and concise description of what you want to happen. -->
1515

1616
**Describe alternatives you've considered**
17-
A clear and concise description of any alternative solutions or features you've considered.
17+
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
1818

1919
**Additional context**
20-
Add any other context or screenshots about the feature request here.
20+
<!-- Add any other context or screenshots about the feature request here. -->

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ assignees: pietrop
77

88
---
99

10-
_where applicable, please provide context and use case around your question._
10+
<!-- _where applicable, please provide context and use case around your question._ -->

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,5 @@ typings/
8888

8989
# next.js build output
9090
.next
91+
92+
stats.json

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
src
2+
demo
3+
lib
4+
packages
5+
build
6+
.babelrc
7+
.babel.config.js
8+
webpack.config.js

.storybook/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { configure } from "@storybook/react";
22

33
// automatically import all files ending in *.stories.js
44
// https://webpack.js.org/guides/dependency-management/
5-
const components = require.context("../packages/components/", true, /.stories.js$/);
6-
// const demo = require.context("../demo/", true, /.stories.js$/);
5+
const components = require.context('../packages/components/', true, /.stories.js$/);
6+
const demo = require.context('../demo/', true, /.stories.js$/);
77

88
configure(() => {
99
components.keys().forEach(filename => components(filename));
10-
// demo.keys().forEach(filename => demo(filename));
10+
demo.keys().forEach(filename => demo(filename));
1111
}, module);

.storybook/webpack.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// https://github.com/storybooks/storybook/issues/270#issuecomment-318101549
2+
// this config augments the storybook one with support for css modules
3+
// storybook does not have support for css modules out of the box
4+
// if CRA were to be present, storybook webpack augment those configs
5+
module.exports = {
6+
module: {
7+
rules: [
8+
{
9+
test: /\.module.css$/,
10+
use: [
11+
{
12+
loader: "style-loader"
13+
},
14+
{
15+
loader: "css-loader",
16+
options: {
17+
modules: true
18+
}
19+
}
20+
]
21+
}
22+
]
23+
}
24+
};

.stylelintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
"media-feature-range-operator-space-after": "always",
1616
"media-feature-colon-space-after": "always"
1717
}
18-
}
18+
}

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Travis CI configuration to run automated test when pushing to github
12
language: node_js
23
node_js:
34
- "10"
@@ -9,5 +10,5 @@ install:
910
- npm install
1011

1112
script:
12-
- npm run test-ci
13-
# could also run lit
13+
- npm run test:ci
14+
# TODO: could also run lit

CONTRIBUTING.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
This project has a [Code of Conduct](./CODE_OF_CONDUCT.md) that we expect all of our contributors to abide by, please check it out before contributing.
44

55
## Contributor license agreement
6-
76
By submitting code as an individual or as an entity you agree that your code is licensed the same as the [React Transcript Editor](./LICENCE.md).
87

9-
108
## Pull requests and branching
119

1210
1. [Feel free to start by raising an issue](https://github.com/bbc/react-transcript-editor/issues/new?template=feature_request.md) so that others can be aware of areas where there is active development, and if needed we can synchronies the effort.

PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
**Is your Pull Request request related to another [issue](https://github.com/bbc/react-transcript-editor/issues) in this repository ?**
2-
_If so please link to other issues and PRs as appropriate_
2+
<!-- _If so please link to other issues and PRs as appropriate_ -->
33

44
**Describe what the PR does**
5-
_A clear and concise description of what the PR does. Feel free to use bulletpoints and checkboxes if needed [...]_
5+
<!-- _A clear and concise description of what the PR does. Feel free to use bulletpoints and checkboxes if needed [...]_ -->
66

77

88
**State whether the PR is ready for review or whether it needs extra work**
9-
_If you are still working on it and just setting it up for later review, or if it's ready to be reviewed for merging_
9+
<!-- _If you are still working on it and just setting it up for later review, or if it's ready to be reviewed for merging_ -->
1010

1111
**Additional context**
12-
Add any other context or screenshots about the PR.
12+
<!-- Add any other context or screenshots about the PR. -->

README.md

Lines changed: 91 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ A React component to make transcribing audio and video easier and faster.
66

77
[![install size](https://packagephobia.now.sh/badge?p=@bbc/react-transcript-editor)](https://packagephobia.now.sh/result?p=@bbc/react-transcript-editor)
88

9-
The project uses [this github project board to organise and the co-ordinate development](https://github.com/bbc/react-transcript-editor/projects/1).
9+
The project uses [this github project boards to organise and the co-ordinate development](https://github.com/bbc/react-transcript-editor/projects).
1010

1111
_--> Work in progress <--_
1212

1313
<!-- _Screenshot of UI - optional_ -->
1414

15+
- [You can see a demo by clicking here ](https://bbc.github.io/react-transcript-editor/iframe.html?id=demo--default) (and then click the `load demo` button)
16+
- [And you can see a list of features here](./docs/features-list.md).
17+
1518
## Development env
1619

1720
<!-- _How to run the development environment_ -->
@@ -34,32 +37,29 @@ Fork this repository + git clone + cd into folder
3437

3538
## Usage - development
3639

37-
<!-- git clone [email protected]:bbc/react-transcript-editor.git -->
40+
Git clone this repository and cd into the folder.
3841

39-
> To start the development server (with entry point `src/index.js`), run
42+
To start the storybook run
4043

4144
```
4245
npm start
4346
```
4447

45-
Visit [http://localhost:3000](http://localhost:3000)
48+
Visit [http://localhost:6006](http://localhost:6006)
4649

4750
## Usage - production
4851

49-
<!-- npm install react-transcript-editor -->
50-
51-
<!-- exampel usage - require etc.. -->
52-
<!-- https://www.npmjs.com/package/@bbc/react-transcript-editor -->
53-
5452
Available on [npm - `@bbc/react-transcript-editor`](https://www.npmjs.com/package/@bbc/react-transcript-editor)
5553

5654
```
5755
npm install @bbc/react-transcript-editor
5856
```
5957

6058
```js
61-
import { TranscriptEditor } from '@bbc/react-transcript-editor';
59+
import TranscriptEditor from '@bbc/react-transcript-editor';
60+
```
6261

62+
```js
6363
<TranscriptEditor
6464
transcriptData=// Transcript json
6565
mediaUrl=// string url to media file - audio or video
@@ -71,7 +71,7 @@ import { TranscriptEditor } from '@bbc/react-transcript-editor';
7171
ref={ this.transcriptEditorRef } // optional - if you want to have access to internal functions such as retrieving content from the editor. eg to save to a server/db.
7272
/>
7373
```
74-
See [`./src/index.js` demo](./src/index.js) as a more detailed example usage of the component.
74+
See [`./demo/app.js` demo](./demo/app.js) as a more detailed example usage of the component.
7575

7676
_Note: `fileName` it is optional but it's needed if working with user uploaded local media in the browser, to be able to save and retrieve from local storage. For instance if you are passing a blob url to `mediaUrl` using `createObjectURL` this url is randomly re-generated on every page refresh so you wouldn't be able to restore a session, as `mediaUrl` is used as the local storage key. See demo app for more detail example of this[`./src/index.js`](./src/index.js)_
7777

@@ -84,19 +84,54 @@ If using in a parent project where [typescript](https://www.typescriptlang.org/)
8484
import { TranscriptEditor } from "@bbc/react-transcript-editor";
8585
```
8686

87-
## System Architecture
87+
#### Internal components
8888

89-
<!-- _High level overview of system architecture_ -->
89+
You can also import some of the underlying React components directly.
90+
91+
- `TranscriptEditor`
92+
- `TimedTextEditor`
93+
- `VideoPlayer`
94+
- `Settings`
95+
- `KeyboardShortcuts`
9096

91-
uses [`create-component-lib`](https://www.npmjs.com/package/create-component-lib) as explaied in this [blog post](https://hackernoon.com/creating-a-library-of-react-components-using-create-react-app-without-ejecting-d182df690c6b) to setup the environment to develop this React.
97+
```js
98+
import TimedTextEditor from '@bbc/react-transcript-editor/TimedTextEditor';
99+
```
100+
```js
101+
import { TimedTextEditor } from '@bbc/react-transcript-editor';
102+
```
103+
104+
However if you are not using `TranscriptEditor` it is recommended to follow the second option and import individual components like: `@bbc/react-transcript-editor/TimedTextEditor` rather than the entire library. Doing so pulls in only the specific components that you use, which can significantly reduce the amount of code you end up sending to the client. (Similarly to how [`react-bootstrap`](https://react-bootstrap.github.io/getting-started/introduction) works)
105+
106+
See the storybook for for each component details on optional and required attributes.
107+
108+
You can also use this node modules as standalone
109+
110+
```js
111+
import exportAdapter from '@bbc/react-transcript-editor/exportAdapter'
112+
```
113+
Converts from draftJs json format to other formats
114+
115+
```js
116+
import sttJsonAdapter from '@bbc/react-transcript-editor/sttJsonAdapter'
117+
```
118+
Converts various stt json formats to draftJs
119+
120+
```js
121+
import { secondsToTimecode, timecodeToSeconds, shortTimecode} from '@bbc/react-transcript-editor/timecodeConverter'
122+
```
123+
some modules to convert to and from timecodes
92124

93-
This uses [Create React App 2.0](https://reactjs.org/blog/2018/10/01/create-react-app-v2.html) so we are using [CSS Modules](https://github.com/css-modules/css-modules) to contain the scope of the css for this component.
94-
<!--
95-
Uses CSS grid-layout https://medium.com/samsung-internet-dev/common-responsive-layouts-with-css-grid-and-some-without-245a862f48df -->
125+
## System Architecture
96126

97-
> Place everything you want to publish to npm inside `src/lib`.
127+
<!-- _High level overview of system architecture_ -->
128+
- uses [`storybook`](https://storybook.js.org) with the setup as [explained in their docs](https://storybook.js.org/docs/guides/guide-react/) to develop this React.
129+
- This uses [CSS Modules](https://github.com/css-modules/css-modules) to contain the scope of the css for this component.
130+
- [`.storybook/webpack.config.js](./.storybook/webpack.config.js) enanches the storybook webpack config to add support for css modules.
131+
- The parts of the component are inside [`./packages`](./packages)
132+
- [babel.config.js](./babel.config.js) provides root level system config for [babel 7](https://babeljs.io/docs/en/next/config-files#project-wide-configuration).
98133

99-
> Outside `src/lib` (but inside src/), you can create example web pages to test or demonstrate the usage of your components.
134+
<!-- - for build, packaging, and deployment of the npm module, we use webpack with babel 7 -->
100135

101136
## Documentation
102137

@@ -116,22 +151,35 @@ We are using [this template for ADR](https://gist.github.com/iaincollins/92923cc
116151

117152
<!-- _How to run build_ -->
118153

119-
> To transpile `src/lib` and create a build in the dist folder, run:
154+
> To transpile `./packages` and create a build in the `./dist` folder, run:
120155
121156
```
122157
npm run build:component
123158
```
124159

125-
## Demo
160+
## Demo & storybook
161+
162+
- **Storybook** can bew viewed at [https://bbc.github.io/react-transcript-editor/](https://bbc.github.io/react-transcript-editor/)
163+
164+
- **Demo** can be viewed at [https://bbc.github.io/react-transcript-editor/iframe.html?id=demo--default](https://bbc.github.io/react-transcript-editor/iframe.html?id=demo--default)
165+
166+
167+
http://localhost:6006
126168

127-
Demo can be viewed at [https://bbc.github.io/react-transcript-editor](https://bbc.github.io/react-transcript-editor)
128169

129170
<!-- https://github.com/gitname/react-gh-pages
130171
-->
131172

132-
## Build - demo
173+
## Build - storybook
174+
To build the storybook as a static site
175+
176+
```
177+
npm run build:storybook
178+
```
179+
180+
## publish storybook & demo to github pages
133181

134-
This github repository uses [github pages](https://pages.github.com/) to host a demo of the component, in [docs/demo](./docs/demo)
182+
This github repository uses [github pages](https://pages.github.com/) to host the storybook and the demo of the component
135183

136184
```
137185
npm run deploy:ghpages
@@ -144,11 +192,16 @@ add to git, and push to origin master to update
144192
Alternatively If you simply want to build the demo locally in the `build` folder then just
145193

146194
```
147-
npm run build:example
195+
npm run build:storybook
148196
```
149197

150-
## Tests
198+
you can then run this command to serve the static site locally
151199

200+
```
201+
npm run build:storybook:serve
202+
```
203+
204+
## Tests
152205
<!-- _How to carry out tests_ -->
153206

154207
Test coverage using [`jest`](https://jestjs.io/), to run tests
@@ -157,6 +210,16 @@ Test coverage using [`jest`](https://jestjs.io/), to run tests
157210
npm run test
158211
```
159212

213+
During development you can use
214+
215+
```
216+
npm run test:watch
217+
```
218+
219+
## Travis CI
220+
221+
On commit this repo uses the [.travis.yml](./.travis.yml) config tu run the automated test on [travis CI](https://travis-ci.org/bbc/react-transcript-editor).
222+
160223
## Deployment
161224

162225
<!-- _How to deploy the code/app into test/staging/production_ -->
@@ -176,9 +239,9 @@ This runs `npm run build:component` and `npm publish --access public` under the
176239
See [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines and [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) guidelines.
177240

178241
## Licence
179-
180242
<!-- mention MIT Licence -->
243+
See [LICENCE](./LICENCE.md)
181244

182245
## Legal Disclaimer
183246

184-
Despite using React and DraftJs, the BBC is not promoting any Facebook products or other commercial interest.
247+
_Despite using React and DraftJs, the BBC is not promoting any Facebook products or other commercial interest._

__mocks__/styleMock.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// __mocks__/styleMock.js
2+
// mocking css files and other media for jest when used with react import
3+
// see also package.json under jest -> moduleNameMapper
4+
// https://jestjs.io/docs/en/webpack.html
5+
module.exports = {};

0 commit comments

Comments
 (0)