Last active
August 11, 2020 01:13
-
-
Save jamesmoriarty/e8af3a3be5500142717d651232940691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
button { | |
margin-left: 5px; | |
} | |
input { | |
margin: 5px; | |
} | |
form { | |
padding-right: 10px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://fb.me/react-with-addons-0.14.0.js"></script> | |
<script src="https://fb.me/react-dom-0.14.0.js"></script> | |
<div id="view" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert the html template with https://magic.reactjs.net/htmltojsx.htm | |
var TextBox = React.createClass({ | |
render: function () { | |
return ( | |
<input className='form-control' | |
name={this.props.name} | |
type='text' | |
value={this.props.value} | |
onChange={this.props.onChange} /> | |
); | |
} | |
}); | |
var ExampleForm = React.createClass({ | |
getInitialState: function () { | |
return { | |
form: { | |
name: 'John Doe', | |
title: 'Engineer', | |
email: 'john.doe@innablr.com.au', | |
phone: '+61 435 123 456' | |
} | |
} | |
}, | |
onChange: function (event) { | |
this.state.form[event.target.name] = event.target.value; | |
this.setState({ form: this.state.form }); | |
}, | |
onSubmit: function (event) { | |
event.preventDefault(); | |
}, | |
render: function () { | |
var self = this; | |
return ( | |
<form onSubmit={this.onSubmit}> | |
<TextBox name='name' value={this.state.form.name} onChange={this.onChange} /> | |
<TextBox name='title' value={this.state.form.title} onChange={this.onChange} /> | |
<TextBox name='email' value={this.state.form.email} onChange={this.onChange} /> | |
<TextBox name='phone' value={this.state.form.phone} onChange={this.onChange} /> | |
<hr/> | |
<table cellSpacing={0} cellPadding={0} border={0}> | |
<tbody> | |
<tr> | |
<td style={{ borderRight: '2px solid #231f20', padding: '0 10px 0 5px', verticalAlign: 'middle' }} valign="middle"> | |
<a href="https://innablr.com.au" target="_blank"><img width={72} height={86} src="https://www.innablr.com.au/signature-logos/innablr.gif" alt="Innablr" style={{ maxHeight: '86px', width: 'auto !important', display: 'block', border: 'none' }} /></a> | |
</td> | |
<td style={{ verticalAlign: 'middle', paddingLeft: '10px' }}> | |
<table cellSpacing={0} cellPadding={0} border={0}> | |
<tbody> | |
<tr> | |
<td style={{ paddingBottom: '0px', fontFamily: 'Verdana', fontSize: '9pt', color: '#231f20' }}> | |
<font style={{ fontWeight: 'bold', fontFamily: 'Verdana', fontSize: '9pt', color: '#231f20' }}>{this.state.form.name}</font> | |
</td> | |
</tr> | |
<tr> | |
<td style={{ paddingBottom: '5px', fontFamily: 'Verdana', fontSize: '9pt', color: '#231f20' }}> | |
<font style={{ fontFamily: 'Verdana', fontSize: '9pt', color: '#231f20' }}>{this.state.form.title}</font> | |
</td> | |
</tr> | |
<tr> | |
<td style={{ paddingBottom: '0px', fontFamily: 'Verdana', fontSize: '9pt' }}> | |
<font style={{ color: '#333333', fontSize: '9pt', fontFamily: 'Verdana' }}><b>m.</b> <a href={'tel:' + this.state.form.phone.replace(/ /g,'')} style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank">{this.state.form.phone}</a></font> | |
</td> | |
</tr> | |
<tr> | |
<td style={{ paddingBottom: '0px', fontFamily: 'Verdana', fontSize: '9pt' }}> | |
<font style={{ color: '#333333', fontSize: '9pt', fontFamily: 'Verdana' }}><b>e.</b> <a href={'mailto:' + this.state.form.email} style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank">{this.state.form.email}</a></font> | |
</td> | |
</tr> | |
<tr> | |
<td style={{ paddingBottom: '5px', fontFamily: 'Verdana', fontSize: '9pt' }}> | |
<font style={{ color: '#333333', fontSize: '9pt', fontFamily: 'Verdana' }}><b>w.</b> <a href="https://innablr.com.au" style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank">innablr.com.au</a></font> | |
</td> | |
</tr> | |
<tr> | |
<td style={{ paddingBottom: '0px', fontFamily: 'Verdana', fontSize: '9pt' }}> | |
<table cellSpacing={0} cellPadding={0} border={0}> | |
<tbody> | |
<tr> | |
<td style={{ padding: '0 2px 0 0' }}> | |
<a href="https://www.linkedin.com/company/innablr" style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank"><img src="https://www.innablr.com.au/signature-logos/linkedin.png" alt="LinkedIn" width={12} height={12} style={{ maxHeight: '12px', width: 'auto !important', display: 'block', border: 'none' }} /></a> | |
</td> | |
<td style={{ padding: '1px 2px 0 2px' }}> | |
<a href="https://twitter.com/InnablrTech" style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank"><img src="https://www.innablr.com.au/signature-logos/twitter.png" alt="Twitter" width={13} height={11} style={{ maxHeight: '11px', width: 'auto !important', display: 'block', border: 'none' }} /></a> | |
</td> | |
<td style={{ padding: '0 2px' }}> | |
<a href="https://www.facebook.com/InnablrTech" style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank"><img src="https://www.innablr.com.au/signature-logos/facebook.png" alt="Facebook" width={6} height={12} style={{ maxHeight: '12px', width: 'auto !important', display: 'block', border: 'none' }} /></a> | |
</td> | |
<td style={{ padding: '0 2px' }}> | |
<a href="https://goo.gl/maps/GtZMJSCMsuu" style={{ color: '#6244bb', textDecoration: 'none' }} target="_blank"><img src="https://www.innablr.com.au/signature-logos/pin.png" alt="Map" width={7} height={12} style={{ maxHeight: '12px', width: 'auto !important', display: 'block', border: 'none' }} /></a> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
</form> | |
); | |
} | |
}); | |
ReactDOM.render( | |
<ExampleForm />, | |
document.getElementById('view')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://jsfiddle.net/jamesmoriarty/0mw2o71k/