Skip to content

Commit 99acccc

Browse files
author
Yury Shapkarin
committed
add react tip button
1 parent d28936e commit 99acccc

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

button-react.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import createButton from './src/button';
4+
5+
export default class Button extends React.Component {
6+
constructor(props) {
7+
super(props);
8+
this.button = React.createRef();
9+
this.componentDidMount = this.componentDidUpdate = () =>
10+
createButton(this.button.current, this.props);
11+
}
12+
13+
render() {
14+
return React.createElement('div', { ref: this.button });
15+
}
16+
};
17+
18+
Button.propTypes = {
19+
size: PropTypes.oneOf(['icon', 'small', 'medium', 'large']),
20+
url: PropTypes.string,
21+
account: PropTypes.string,
22+
};

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "",
55
"main": "dist/index.js",
66
"browser": "dist/index.js",
7-
"dependencies": {},
87
"files": [
98
"dist",
109
"src"
@@ -27,6 +26,10 @@
2726
"webpack": "^4.44.1",
2827
"webpack-cli": "^3.3.12"
2928
},
29+
"optionalDependencies": {
30+
"prop-types": "^15.7.2",
31+
"react": "^17.0.0"
32+
},
3033
"scripts": {
3134
"test": "echo \"Error: no test specified\" && exit 1",
3235
"start": "npm run build && serve",

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ const genConfig = (filename, { inlineCss } = {}) => ({
4040
module.exports = [
4141
genConfig('index-without-styles.js'),
4242
genConfig('index.js', { inlineCss: true }),
43+
genConfig('button-react.js'),
4344
];

0 commit comments

Comments
 (0)