Skip to content

Commit

Permalink
chore(playground): playground application
Browse files Browse the repository at this point in the history
  • Loading branch information
romelperez committed Nov 11, 2020
1 parent 99e0bcd commit ca10818
Show file tree
Hide file tree
Showing 50 changed files with 685 additions and 320 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,3 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
indent_size = 4
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"node_modules",
"packages/*/lib",
"packages/arwes", // TODO: Remove when @arwes/arwes package has the new API.
"playground/public"
"playground/dist"
],
"extends": [
"standard",
Expand All @@ -21,6 +21,7 @@
},
"rules": {
"semi": ["error", "always"],
"brace-style": ["error", "stroustrup"]
"brace-style": ["error", "stroustrup"],
"react/prop-types": [0]
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ yarn-error.log*
.yarn-integrity

packages/*/lib
playground/public
playground/dist
21 changes: 21 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test-coverage": "jest --coverage",
"test-list": "jest --listTests",
"ci": "npm run bootstrap && npm run compile && npm run lint && npm test",
"playground-build": "NODE_ENV=production webpack --config ./playground/playground.webpack.config.js",
"playground-build": "cross-env NODE_ENV=production webpack --config ./playground/playground.webpack.config.js",
"playground-watch": "webpack serve --config ./playground/playground.webpack.config.js",
"release": "npm run ci && lerna publish",
"changelog": "auto-changelog --output ./docs/CHANGELOG.md --commit-limit false",
Expand Down Expand Up @@ -54,7 +54,9 @@
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"classnames": "^2.2.6",
"commitizen": "^4.2.2",
"cross-env": "^7.0.2",
"cz-conventional-changelog": "^3.3.0",
"documentation": "^13.1.0",
"eslint": "^7.12.1",
Expand All @@ -75,6 +77,7 @@
"markdownlint": "^0.21.1",
"markdownlint-cli": "^0.24.0",
"navigo": "^7.1.2",
"polished": "^4.0.3",
"raw-loader": "^4.0.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
/* eslint-disable react/prop-types */

import React, { createRef } from 'react';
import anime from 'animejs';
import { withEnergy } from '../withEnergy';
import { AnimationProvider } from '../AnimationProvider';
import { Stream } from './index';

const COLOR_ON = '#0f0';
const COLOR_OFF = '#f00';
```js
const COLOR_ON = '#27efb5'; // green
const COLOR_OFF = '#efb527'; // orange

const Item = withEnergy()(
class ItemBase extends React.PureComponent {
element = createRef()
constructor () {
super(...arguments);
this.element = React.createRef();
}

render () {
return (
<li ref={this.element} style={{ backgroundColor: COLOR_OFF }}>
<li ref={this.element} style={{ padding: 5, backgroundColor: COLOR_OFF }}>
<div>{this.props.energy.flow.value}</div>
</li>
);
Expand All @@ -42,8 +38,12 @@ const Item = withEnergy()(
);

class Sandbox extends React.PureComponent {
interval = null
state = { activate: true }
constructor () {
super(...arguments);
this.interval = null;
this.element = React.createRef();
this.state = { activate: true };
}

componentDidMount () {
this.interval = setInterval(() => {
Expand Down Expand Up @@ -78,4 +78,5 @@ class Sandbox extends React.PureComponent {
}
}

export default Sandbox;
render(<Sandbox />);
```
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
/* eslint-disable react/prop-types */

import React, { createRef } from 'react';
import anime from 'animejs';
import { AnimationProvider } from '../AnimationProvider';
import { withEnergy } from './withEnergy';

const COLOR_ON = '#0f0';
const COLOR_OFF = '#f00';
```js
const COLOR_ON = '#27efb5'; // green
const COLOR_OFF = '#efb527'; // orange

class ItemComponent extends React.PureComponent {
constructor () {
super(...arguments);
this.element = createRef();
this.element = React.createRef();
}

render () {
const { energy, children } = this.props;
return (
<div
ref={this.element}
style={{ backgroundColor: COLOR_OFF, marginLeft: '10px' }}
style={{
padding: 5,
backgroundColor: COLOR_OFF,
marginLeft: '10px'
}}
>
<div>{energy.flow.value}</div>
<div>{children}</div>
Expand Down Expand Up @@ -81,4 +79,5 @@ class Sandbox extends React.PureComponent {
}
}

export default Sandbox;
render(<Sandbox />);
```
35 changes: 35 additions & 0 deletions packages/sounds/src/withSounds/basic.sandbox.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
```js
const PlayerComponent = ({ players, audio, name }) => (
<button onClick={() => !audio.mute && players[name].play()}>
Play {name}
</button>
);

const Player = withSounds()(PlayerComponent);

const players = {
information: new Howl({ src: ['/sounds/information.mp3'] }),
ask: new Howl({ src: ['/sounds/ask.mp3'] }),
warning: new Howl({ src: ['/sounds/warning.mp3'] }),
error: new Howl({ src: ['/sounds/error.mp3'] })
};

function Sandbox () {
const [mute, setMute] = React.useState(false);

return (
<SoundsProvider players={players} audio={{ mute }}>
<button onClick={() => setMute(!mute)}>
{mute ? 'Unmute' : 'Mute'}
</button>
<br />
<Player name='information' />
<Player name='ask' />
<Player name='warning' />
<Player name='error' />
</SoundsProvider>
);
}

render(<Sandbox />);
```
48 changes: 0 additions & 48 deletions packages/sounds/src/withSounds/withSounds.sandbox.js

This file was deleted.

16 changes: 13 additions & 3 deletions playground/playground.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
mode: NODE_ENV || 'development',
entry: './playground/src/index.js',
output: {
path: path.join(__dirname, 'public'),
path: path.join(__dirname, 'dist'),
filename: 'playground.js'
},
module: {
Expand All @@ -20,18 +20,28 @@ module.exports = {
loader: 'babel-loader',
options: babelConfig
}
},
{
test: /\.md$/i,
use: 'raw-loader'
}
]
},
resolve: {
alias: {
repository: process.cwd(),
playground: path.join(process.cwd(), 'playground')
}
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/index.html'),
filename: path.join(__dirname, 'public/index.html')
filename: path.join(__dirname, 'dist/index.html')
})
],
devServer: {
contentBase: [
path.join(__dirname, 'public'),
path.join(__dirname, 'dist'),
path.join(__dirname, 'static')
],
watchContentBase: true,
Expand Down
Loading

0 comments on commit ca10818

Please sign in to comment.