Skip to content

Instantly share code, notes, and snippets.

@williamlagos
Created February 24, 2020 14:31
Show Gist options
  • Save williamlagos/3c5c0d5453f3eedf74b0bb6d60938093 to your computer and use it in GitHub Desktop.
Save williamlagos/3c5c0d5453f3eedf74b0bb6d60938093 to your computer and use it in GitHub Desktop.
React HTML
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
<style>
html {
height: 100%;
}
body {
min-height: 100%;
}
</style>
</head>
<body class="d-flex align-items-center">
<div class="container">
<div class="row">
<div class="col-md-6 d-flex justify-content-center align-items-center text-center order-2 order-md-1" style="background: black">
<!-- <div class="py-5"> -->
<!-- <p style="color: white">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
</p> -->
<div id="react_container"></div>
<!-- <button class="btn btn-large btn-light">Inscreva</button> -->
<!-- </div> -->
</div>
<div class="col-md-6 order-1 order-md-2" style="padding: 0">
<img class="img-fluid" src="./image.png"/>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- React CDN -->
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script>
'use strict';
const e = React.createElement;
class Container extends React.Component {
constructor(props) {
super(props);
this.state = {
date: new Date(),
content: 'Inscreva',
unavailable: false,
description: '',
name: '',
option: 0,
};
this.handleInputChange = this.handleInputChange.bind(this);
}
componentDidMount() {
this.timerID = setInterval(
() => this.setState({ date: new Date() }),
1000
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
handleInputChange(event) {
const target = event.target;
const value = target.type === 'checkbox' ? target.checked : target.value;
const name = target.type === 'select-one' ? 'option' : target.name;
this.setState({
[name]: value
});
}
render() {
return e(React.Fragment, {},
e('ul', { style: { display: 'none' } }, [1, 2, 3, 4, 5].map((i) => e('li', { style: { color: 'white' }, key: i }, `Item ${i}`))),
e(
'form',
{},
e('div', { className: 'form-group' },
e('label', { style: { color: 'white' } }, 'Nome'),
e('input', {
name: 'name',
type: 'text',
className: 'form-control',
onChange: this.handleInputChange
}),
),
e('div', { className: 'form-group' },
e('label', { style: { color: 'white' } }, 'Selecione a opção'),
e(
'select', {
value: this.state.option,
className: 'form-control',
onChange: this.handleInputChange
},
[1, 2, 3, 4, 5].map((i) => e('option', { key: i, value: i }, `Item ${i}`)))
),
e('div', { className: 'form-group' },
e('label', { style: { color: 'white' } }, 'Descrição'),
e('textarea', {
value: this.state.description,
name: 'description',
className: 'form-control',
onChange: this.handleInputChange
}),
),
),
e('h2', { style: { minWidth: '150px', color: 'white' } }, this.state.date.toLocaleTimeString()),
e(
'button',
{
className: `btn btn-large my-2 ${this.props.appearance}`,
disabled: this.state.unavailable,
onClick: () => this.setState({ unavailable: true, content: 'Inscrito' })
},
this.props.children || this.state.content
)
);
}
}
const domContainer = document.querySelector('#react_container');
ReactDOM.render(
e(Container, { appearance: 'btn-success' }),
domContainer
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment