Skip to content

Instantly share code, notes, and snippets.

@Blazing-Mike
Created June 17, 2022 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Blazing-Mike/3a78f77ec363144017ca72e0605f58aa to your computer and use it in GitHub Desktop.
Save Blazing-Mike/3a78f77ec363144017ca72e0605f58aa to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
const style = {
table: {
borderCollapse: 'collapse'
},
tableCell: {
border: '1px solid gray',
margin: 0,
padding: '5px 10px',
width: 'max-content',
minWidth: '150px'
},
form: {
container: {
padding: '20px',
border: '1px solid #F0F8FF',
borderRadius: '15px',
width: 'max-content',
marginBottom: '40px'
},
inputs: {
marginBottom: '5px'
},
submitBtn: {
marginTop: '10px',
padding: '10px 15px',
border:'none',
backgroundColor: 'lightseagreen',
fontSize: '14px',
borderRadius: '5px'
}
}
}
function PhoneBookForm({ addEntryToPhoneBook }) {
const [FirstName, setFirstName] = useState('Adebambo');
const [LastName, setLastName] = useState('Michael');
const [phoneNo, setPhoneNo] = useState('081+++');
return (
<form onSubmit={e => { e.preventDefault() }} style={style.form.container}>
<label>First name:</label>
<br />
<input
value ={FirstName}
style={style.form.inputs}
className='userFirstname'
name='userFirstname'
type='text'
/>
<br/>
<label>Last name:</label>
<br />
<input
value ={LastName}
style={style.form.inputs}
className='userLastname'
name='userLastname'
type='text'
/>
<br />
<label>Phone:</label>
<br />
<input
value ={phoneNo}
style={style.form.inputs}
className='userPhone'
name='userPhone'
type='text'
/>
<br/>
<input
style={style.form.submitBtn}
className='submitButton'
type='submit'
value='Add User'
/>
</form>
)
}
function InformationTable(props) {
return (
<table style={style.table} className='informationTable'>
<thead>
<tr>
<th style={style.tableCell}>First name</th>
<th style={style.tableCell}>Last name</th>
<th style={style.tableCell}>Phone</th>
</tr>
</thead>
</table>
);
}
function Application(props) {
return (
<section>
<PhoneBookForm />
<InformationTable />
</section>
);
}
ReactDOM.render(
<Application />,
document.getElementById('root')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment