Permalink
Browse files

DRYed the code some more by extracting the <button> and the associate…

…d CSS style logic into a separate new widget <ButtonWidget>.
  • Loading branch information...
maratbn committed Jun 30, 2018
1 parent 85dd785 commit 08a33ec32356c200dc1b2957782a9f95a34ae870
Showing with 12 additions and 4 deletions.
  1. +12 −4 webpack_in/entry.jsx
@@ -21,6 +21,14 @@ const objStyleContent = {
};
class ButtonWidget extends React.Component {
render() {
return (
<button style={{ margin: '1em'}}>{ this.props.caption }</button>
);
}
}
class HelloWidget extends React.Component {
render() {
return (
@@ -36,7 +44,7 @@ class TextWidget extends React.Component {
return (
<div style={ objStyleCommon }>
<div style={ objStyleContent }>Some text here....</div>
<button style={{ margin: '1em'}}>Change text...</button>
<ButtonWidget caption="Change text..." />
</div>
);
}
@@ -54,9 +62,9 @@ class ListWidget extends React.Component {
</ul>
</div>
<div>
<button style={{ margin: '1em'}}>Add new item...</button>
<button style={{ margin: '1em'}}>Edit item...</button>
<button style={{ margin: '1em'}}>Remove item...</button>
<ButtonWidget caption="Add new item..." />
<ButtonWidget caption="Edit item..." />
<ButtonWidget caption="Remove item..." />
</div>
</div>
);

0 comments on commit 08a33ec

Please sign in to comment.