Skip to content

Commit 7f00204

Browse files
committed
Initializing git repository
1 parent 10410c1 commit 7f00204

File tree

8 files changed

+676
-0
lines changed

8 files changed

+676
-0
lines changed

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"es2017",
5+
"react",
6+
"stage-2"
7+
]
8+
}

.gitignore

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

LICENCE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2017 Raul Rene Lepșa (raul.lepsa@gmail.com)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# React Utils Button
2+
Lightweight React Button component, serving as an utility wrapper over the HTML button element.
3+
4+
##Installation
5+
```sh
6+
npm install react-slider
7+
```
8+
9+
##Usage
10+
```javascript
11+
import Button from 'react-utils-button';
12+
13+
<Button value='Click me'
14+
className="my-extra-class"
15+
onClick={() => { console.log('clicked'); }}
16+
active={false}
17+
disabled={false}/>
18+
```
19+
20+
The library can also be loaded via require:
21+
22+
```javascript
23+
const Button = require('react-utils-button')
24+
```
25+
26+
##Options
27+
- **value** (string, required) - value to be displayed inside the button
28+
- **className** (string) - extra classes
29+
- **onClick** (function) - callback function
30+
- **active** (boolean, default: false) - force active state; adds a **utils-button--active** class
31+
- **disabled** (boolean, default: false) - disabled state for the button; once disabled the onClick callback does not fire anymore
32+
33+
### Licence
34+
The code is open-source and available under the MIT Licence. More details in the LICENCE.md file.

dist/index.js

Lines changed: 547 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"react-utils-bundle",
1717
"react-component"
1818
],
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/raulrene/react-utils-button"
22+
},
1923
"dependencies": {
2024
"prop-types": "^15.5.7"
2125
},

src/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
4+
class ReactUtilsButton extends React.Component {
5+
render() {
6+
const { value, onClick, disabled, className, active } = this.props;
7+
8+
return (
9+
<button type="button"
10+
className={`utils-button${className ? ` ${className}` : ''}${active ? ' utils-button--active' : ''}`}
11+
onClick={!disabled ? onClick : () => {}} // Only trigger onClick if component is not disabled
12+
disabled={disabled ? 'disabled' : undefined}>
13+
14+
<span className='input-button-value'>{value}</span>
15+
</button>
16+
);
17+
}
18+
}
19+
20+
ReactUtilsButton.propTypes = {
21+
value: PropTypes.string.isRequired,
22+
className: PropTypes.string,
23+
onClick: PropTypes.func,
24+
disabled: PropTypes.bool,
25+
active: PropTypes.bool
26+
};
27+
28+
export default ReactUtilsButton;

webpack.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const CleanPlugin = require('clean-webpack-plugin');
4+
5+
module.exports = {
6+
entry: {
7+
app: path.join(__dirname, 'src', 'index')
8+
},
9+
10+
output: {
11+
library: 'ReactUtilsButton',
12+
libraryTarget: 'umd',
13+
path: path.join(__dirname, 'dist'),
14+
filename: 'index.js'
15+
},
16+
17+
module: {
18+
rules: [
19+
{
20+
test: /\.jsx?$/,
21+
loaders: ['babel-loader'],
22+
exclude: /node_modules/,
23+
include: path.join(__dirname, 'src')
24+
}
25+
]
26+
},
27+
28+
resolve: {
29+
modules: ['node_modules']
30+
},
31+
32+
plugins: [
33+
new CleanPlugin('./dist')
34+
]
35+
};

0 commit comments

Comments
 (0)