Comparing version 1.0.2 to 1.0.3
71
index.js
@@ -32,21 +32,58 @@ // const telegrafResponseBuilder = require('./src/telegrafResponseBuilder'); | ||
'use strict'; | ||
class App extends React.PureComponent { | ||
state = {value: 'some\ntext', copied: false}; | ||
const e = React.createElement; | ||
onChange = ({target: {value}}) => { | ||
this.setState({value, copied: false}); | ||
}; | ||
class LikeButton extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { liked: false }; | ||
} | ||
onClick = ({target: {innerHTML}}) => { | ||
console.log(`Clicked on "${innerHTML}"!`); // eslint-disable-line | ||
}; | ||
onCopy = () => { | ||
this.setState({copied: true}); | ||
}; | ||
render() { | ||
if (this.state.liked) { | ||
return 'HEY YA ZALUPA'; | ||
} | ||
return ( | ||
<div className="app"> | ||
<h1>react-copy-to-clipboard</h1> | ||
return e( | ||
'button', | ||
{ onClick: () => this.setState({ liked: true }) }, | ||
'Like' | ||
<section className="section"> | ||
<textarea onChange={this.onChange} rows={2} cols={10} value={this.state.value} /> | ||
</section> | ||
<section className="section"> | ||
<h2>1. Button</h2> | ||
<CopyToClipboard onCopy={this.onCopy} text={this.state.value}> | ||
<button>Copy to clipboard with button</button> | ||
</CopyToClipboard> | ||
</section> | ||
<section className="section"> | ||
<h2>2. Span</h2> | ||
<CopyToClipboard onCopy={this.onCopy} text={this.state.value}> | ||
<span>Copy to clipboard with span</span> | ||
</CopyToClipboard> | ||
</section> | ||
<section className="section"> | ||
<h2>3. with onClick</h2> | ||
<CopyToClipboard | ||
onCopy={this.onCopy} | ||
options={{message: 'Whoa!'}} | ||
text={this.state.value}> | ||
<button onClick={this.onClick}>Copy to clipboard with onClick prop</button> | ||
</CopyToClipboard> | ||
</section> | ||
<section className="section"> | ||
{this.state.copied ? <span style={{color: 'red'}}>Copied.</span> : null} | ||
</section> | ||
<section className="section"> | ||
<textarea cols="22" rows="3" style={{marginTop: '1em'}} /> | ||
</section> | ||
</div> | ||
); | ||
@@ -56,3 +93,5 @@ } | ||
const domContainer = document.querySelector('#like_button_container'); | ||
ReactDOM.render(e(LikeButton), domContainer); | ||
const appRoot = document.createElement('div'); | ||
document.body.appendChild(appRoot); | ||
ReactDOM.render(<App />, appRoot); |
{ | ||
"devDependencies": { | ||
"@cfworker/web": "^1.6.3", | ||
"telegraf": "^3.38.0" | ||
}, | ||
"main": "index.js", | ||
"name": "11ff", | ||
"peerDependencies": { | ||
"@cfworker/web": "^1.6.3", | ||
"telegraf": "^3.38.0" | ||
}, | ||
"version": "1.0.2" | ||
"version": "1.0.3" | ||
} |
8469
0
0
206