Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls committed Sep 14, 2016
1 parent f1ec9ce commit 28c7900
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"env": {
"es6": true,
"browser": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"extends": "airbnb",
"rules": {
"no-console": 0,
"no-unused-vars": 1,
"no-undef": 0,
"prefer-arrow-callback": 1,
"no-nested-ternary": 0,
"max-len": 0,
"react/jsx-no-bind":0
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
node_modules/
.DS_store
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Pigs in Flight, Inc

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# bebo-react
# bebo-react

A wrap react

## Get it

```npm install bebo-react --save```

## Usage

```jsx
import React from 'react';
import BeboReact from './js/utils/bebo-react';
import App from './js/components/App';

import './style.scss';
BeboReact.render(
<App />,
document.getElementById('app'),
{
disableKeyboardDoneStrip: true
}
);
```
1 change: 1 addition & 0 deletions dist/index.js

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

44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "bebo-react",
"version": "0.1.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"build": "webpack --config ./webpack.build.config.js",
"build:dev": "webpack --config ./webpack.dev.config.js",
"clean": "rimraf dist/*",
"prepublish": "npm run clean && npm run build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bebo/bebo-react.git"
},
"keywords": [
"bebo",
"react",
"beboSDK",
"wrapper"
],
"author": "Jonas Daniels",
"license": "MIT",
"bugs": {
"url": "https://github.com/bebo/bebo-react/issues"
},
"homepage": "https://github.com/bebo/bebo-react#readme",
"peerDependencies": {
"react": "^15.3.1",
"react-dom": "^15.3.1"
},
"devDependencies": {
"react": "^15.0.0-0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"webpack": "^1.13.2",
"rimraf": "^2.5.1"
},
"dependencies": {
"hoist-non-react-statics": "^1.2.0"
}
}
48 changes: 48 additions & 0 deletions src/bebo-react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Created by jonas on 9/13/16.
*/
import React from 'react';
import ReactDOM from 'react-dom';
import hoistStatics from 'hoist-non-react-statics'

function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
}

export function withBebo(WrappedComponent) {
const WithBebo = React.createClass({
render() {
// eslint-disable-next-line
if(Bebo) {
// eslint-disable-next-line
return <WrappedComponent {...this.props} bebo={Bebo} />
}
return console.error('Bebo is not defined yet...');


}
});

WithBebo.displayName = `withBebo(${getDisplayName(WrappedComponent)})`;
WithBebo.WrappedComponent = WrappedComponent;

return hoistStatics(WithBebo, WrappedComponent)
}

export default new class BeboDOM {
constructor (){
// eslint-disable-next-line
this.bebo = Bebo;
}

render(component, element, beboOptions) {
this.bebo.onReady(() => {
const { disableKeyboardDoneStrip } = beboOptions;
if(disableKeyboardDoneStrip) {
// eslint-disable-next-line
Bebo.UI.disableKeyboardDoneStrip();
}
ReactDOM.render(component, element);
})
}
}
52 changes: 52 additions & 0 deletions webpack.build.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
var webpack = require('webpack');
var path = require('path');

var plugins = [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'__DEV__': false,
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
];
plugins.push(new webpack.optimize.UglifyJsPlugin());


module.exports = {
entry: path.resolve(__dirname, './src/bebo-react.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
libraryTarget: 'umd',
library : 'ReactSimpleFetch',
},
externals: {
'react': {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React'
},
'react-dom': {
commonjs: 'react-dom',
commonjs2: 'react-dom',
amd: 'react-dom',
root: 'ReactDOM'
}
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react']
}
},
],
},
plugins: plugins,
};
31 changes: 31 additions & 0 deletions webpack.dev.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var path = require('path');

module.exports = {
entry: path.resolve(__dirname, './src/bebo-react.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
libraryTarget: 'umd',
library: 'ReactSimpleFetch',
},
externals: {
react: {
commonjs: 'react',
commonjs2: 'react',
amd: 'react',
root: 'React',
},
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['es2015', 'react'],
},
},
],
},
};

0 comments on commit 28c7900

Please sign in to comment.