Skip to content

Commit 60f0c86

Browse files
authored
Merge pull request #1 from MailOnline/feat/mock
Feat/mock
2 parents 29c604a + 7ae00a3 commit 60f0c86

File tree

152 files changed

+4893
-1
lines changed

Some content is hidden

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

152 files changed

+4893
-1
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea
2+
/node_modules/
3+
/.idea/
4+
/.nyc_output/
5+
/coverage/
6+
package-lock.json
7+
yarn.lock
8+
/lib/
9+
/.vscode/
10+
.DS_Store

.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.idea
2+
/node_modules/
3+
/.idea/
4+
/.nyc_output/
5+
/coverage/
6+
package-lock.json
7+
yarn.lock
8+
*.test.ts
9+
*.spec.ts
10+
*.test.js
11+
*.spec.js
12+
/typings/
13+
/test/
14+
/.vscode/
15+
.DS_Store

.npmrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@mol-fe:registry="http://sinopia.devhsk.mol.dmgt.net:4873/"
2+
@mol-ads:registry="http://sinopia.devhsk.mol.dmgt.net:4873/"
3+
unsafe-perm=true
4+
init-author-name="MailOnline"
5+
init-author-email="fe@mailonline.co.uk"
6+
init-author-url="http://www.dailymail.co.uk"
7+
init-license="UNLICENSED"
8+
init-version="0.0.0"

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
8

.storybook/ShowDocs.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import {createElement as h} from 'react';
2+
3+
const ShowDocs = ({name}) => {
4+
return h('div', {},
5+
h('div', {
6+
style: {
7+
padding: '0 20px'
8+
},
9+
dangerouslySetInnerHTML: {
10+
__html: require(`../docs/${name}.md`)
11+
}
12+
}),
13+
h('style', {
14+
dangerouslySetInnerHTML: {
15+
__html: `
16+
@import url(http://fonts.googleapis.com/css?family=Merriweather:300italic,300);
17+
18+
html {
19+
font-size: 18px;
20+
max-width: 800px;
21+
}
22+
23+
body {
24+
color: #444;
25+
font-family: 'Merriweather', Georgia, serif;
26+
margin: 0;
27+
max-width: 800px;
28+
}
29+
30+
/* === A bit of a gross hack so we can have bleeding divs/blockquotes. */
31+
32+
div {
33+
width: 100%;
34+
}
35+
36+
div img {
37+
width: 100%;
38+
}
39+
40+
blockquote p {
41+
font-size: 1.5rem;
42+
font-style: italic;
43+
margin: 1rem auto 1rem;
44+
max-width: 48rem;
45+
}
46+
47+
li {
48+
margin-left: 2rem;
49+
}
50+
51+
/* Counteract the specificity of the gross *:not() chain. */
52+
h1 {
53+
padding: 1m 0 !important;
54+
}
55+
/* === End gross hack */
56+
57+
p {
58+
color: #555;
59+
height: auto;
60+
line-height: 1.45;
61+
}
62+
63+
pre, code {
64+
font-family: Menlo, Monaco, "Courier New", monospace
65+
}
66+
67+
pre {
68+
background-color: #fafafa;
69+
font-size: .8rem;
70+
overflow-x: scroll;
71+
padding: 1.125em;
72+
}
73+
74+
a,
75+
a:visited {
76+
color: #3498db;
77+
}
78+
79+
a:hover,
80+
a:focus,
81+
a:active {
82+
color: #2980b9;
83+
}
84+
`
85+
}
86+
})
87+
);
88+
};
89+
90+
export default ShowDocs;

.storybook/addons.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import '@storybook/addon-actions/register';
2+
import '@storybook/addon-links/register';

.storybook/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {configure} from '@storybook/react';
2+
3+
const req = require.context('../src/', true, /.*(stories|story)\.(js|jsx|ts|tsx)?$/);
4+
5+
const loadStories = () => {
6+
req.keys().forEach((filename) => req(filename));
7+
};
8+
9+
configure(loadStories, module);

.storybook/webpack.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const path = require('path');
2+
3+
const SRC_PATH = path.join(__dirname, '../src');
4+
5+
module.exports = {
6+
module: {
7+
rules: [
8+
{
9+
test: /\.tsx?$/,
10+
loader: 'ts-loader',
11+
include: [
12+
SRC_PATH,
13+
]
14+
}
15+
]
16+
},
17+
18+
resolve: {
19+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
20+
enforceExtension: false
21+
}
22+
};

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
11
# mol-fe-react
22

3-
React.js utility belt.
3+
React utility belt.
4+
5+
- Collection of React goodies
6+
- Isomorphic - all components work in browser and Node
7+
- [See demos and docs](https://mailonline.github.io/mol-fe-react/)
8+
9+
## Installation
10+
11+
```shell
12+
npm install mol-fe-react --save
13+
```
14+
15+
## Usage
16+
17+
Import each utility individually to decrease your bundle size
18+
19+
```js
20+
import {mock} from 'mol-fe-react/lib/mock';
21+
22+
const MyComponent = mock();
23+
```
24+
25+
## Reference
26+
27+
- Dummies
28+
- [`mock()`](./docs/mock.md)
29+
- [`loadable()`](./docs/loadable.md)
30+
- [`lazy()`](./docs/lazy.md)
31+
- [`delayed()`](./docs/delayed.md)
32+
- [`invert()`](./docs/invert.md)
33+
- Sensors
34+
- [`<SizeSensor>`](./docs/SizeSensor.md)
35+
- [`<WidthSensor>`](./docs/WidthSensor.md)
36+
- [`<ScrollSensor>`](./docs/ScrollSensor.md)
37+
- [`<MediaSensor>`](./docs/MediaSensor.md)
38+
- [`<WindowSizeSensor>`](./docs/WindowSizeSensor.md)
39+
- [`<WindowScrollSensor>`](./docs/WindowScrollSensor.md)
40+
- [`<NetworkSensor>`](./docs/NetworkSensor.md) and [`withNetwork()`](./docs/NetworkSensor.md#withnetwork)
41+
- [`<BatterySensor>`](./docs/BatterySensor.md)
42+
- [`<LightSensor>`](./docs/LightSensor.md)
43+
- [`<MediaDeviceSensor>`](./docs/MediaDeviceSensor.md)
44+
- Generators
45+
- [`<Speak>`](./docs/Speak.md)
46+
- [`<Vibrate>`](./docs/Vibrate.md)
47+
- [`<LocalStorage>`](./docs/LocalStorage.md)
48+
- [`<Audio>`](./docs/Audio.md)
49+
- Context
50+
- [`<Provider>`](./docs/context.md#provider), [`<Consumer>`](./docs/context.md#consumer), and [`withContext()`](./docs/context.md#withcontext)
51+
- [`<Theme>`](./docs/theme.md#theme), [`<Themed>`](./docs/theme.md#themed), and [`withTheme()`](./docs/theme.md#withtheme)
52+
- `<CssVars>`
53+
- CSS resets
54+
- [`<CssResetEricMeyer>`](./docs/reset/CssResetEricMeyer.md)
55+
- [`<CssResetEricMeyerCondensed>`](./docs/reset/CssResetEricMeyerCondensed.md)
56+
- [`<CssResetMinimalistic>`](./docs/reset/CssResetMinimalistic.md)
57+
- [`<CssResetMinimalistic2>`](./docs/reset/CssResetMinimalistic2.md)
58+
- [`<CssResetMinimalistic3>`](./docs/reset/CssResetMinimalistic3.md)
59+
- [`<CssResetPoorMan>`](./docs/reset/CssResetPoorMan.md)
60+
- [`<CssResetShaunInman>`](./docs/reset/CssResetShaunInman.md)
61+
- [`<CssResetSiolon>`](./docs/reset/CssResetSiolon.md)
62+
- [`<CssResetTantek>`](./docs/reset/CssResetTantek.md)
63+
- [`<CssResetUniversal>`](./docs/reset/CssResetUniversal.md)
64+
- [`<CssResetYahoo>`](./docs/reset/CssResetYahoo.md)
65+
- Other
66+
- [`<Resolve>`](./docs/Resolve.md)

docs/Audio.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# `<Audio>`
2+
3+
FaCC that creates an `<audio>` element to play audio tracks, re-renders on audio state changes.
4+
5+
## Usage
6+
7+
```jsx
8+
import {Audio} from 'mol-fe-react/lib/Audio';
9+
10+
<Audio autoPlay src='https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3'>{(control, state) => {
11+
JSON.stringify(state, null, 4)
12+
}}</Audio>
13+
```
14+
15+
## Props
16+
17+
In addition to props below also accepts all [React's media events](https://reactjs.org/docs/events.html#media-events).
18+
19+
```tsx
20+
export interface IAudioProps {
21+
src: string;
22+
autoPlay?: boolean;
23+
loop?: boolean;
24+
muted?: boolean;
25+
preload?: 'none' | 'metadata' | 'auto';
26+
volume?: number;
27+
noJs?: React.ReactElement<any>;
28+
}
29+
```
30+
31+
- `src` - required, string, audio source file URL.
32+
- `autoPlay` - optional, boolean, whether to autoplay audio, defaults to `false`.
33+
- `loop` - optional, boolean, whether to repeat the track when it ends, defaults to `false`.
34+
- `muted` - optional, boolean, whether to mute the audio, defaults to `false`.
35+
- `preload` - optional, string, `<audio>` element preload attribute.
36+
- `volume` - optional, number, audio volume in `[0..1]` range, defaults to `1`.
37+
- `noJs` - optional, React element(s) to render insided the `<audio>` tag.
38+
39+
## Example
40+
41+
Play a sample audio track with control buttons.
42+
43+
```jsx
44+
<Audio src='https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3'>{(audio, state) =>
45+
<div>
46+
<button onClick={audio.play}>Play</button>
47+
<button onClick={audio.pause}>Pause</button>
48+
<button onClick={() => audio.seek(state.time - 5)}>Seek -</button>
49+
<button onClick={() => audio.seek(state.time + 5)}>Seek +</button>
50+
<button onClick={() => audio.volume(state.volume - 0.05)}>Volume -</button>
51+
<button onClick={() => audio.volume(state.volume + 0.05)}>Volume +</button>
52+
<button onClick={audio.mute}>Mute</button>
53+
<button onClick={audio.unmute}>Unmute</button>
54+
</div>
55+
}</Audio>
56+
```

0 commit comments

Comments
 (0)