Skip to content

Commit

Permalink
DRYed the code some more by extracting the <button> and the associate…
Browse files Browse the repository at this point in the history
…d CSS style logic into a separate new widget <ButtonWidget>.
  • Loading branch information
maratbn committed Aug 5, 2018
1 parent 85dd785 commit 08a33ec
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions webpack_in/entry.jsx
Expand Up @@ -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 (
Expand All @@ -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>
);
}
Expand All @@ -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>
);
Expand Down

0 comments on commit 08a33ec

Please sign in to comment.