Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
Created February 18, 2017 22:50
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 j-mcnally/642c1338952943a68bb04df9e18861f9 to your computer and use it in GitHub Desktop.
Save j-mcnally/642c1338952943a68bb04df9e18861f9 to your computer and use it in GitHub Desktop.
import { Component, h, prop } from 'skatejs';
const React = { createElement: h };
const sym = Symbol();
class WaitlistedForm extends Component {
static get is(){ return 'waitlisted-form' }
static get props () {
return {
domain: prop.string({ attribute: true }),
form: prop.string({ attribute: true }),
resultUrl: prop.string({ attribute: true })
};
}
async connectedCallback () {
let resp = await fetch(`https://${this.domain}/api/v2/site.json`)
this.site = await resp.json()
super.connectedCallback();
}
disconnectedCallback () {
// Ensure we callback the parent.
super.disconnectedCallback();
}
renderCallback () {
console.log(this.site)
let nameBlock = null
if (this.site.ask_name) {
nameBlock = (<div class="wl-row wl-name">
<label>Name</label>
<input name="reservation[name]" />
</div>)
}
return (
<form action="https://{this.site.domain}/external/reservations" method="POST">
{nameBlock}
<div class="wl-row wl-email">
<label>Email</label>
<input name="reservation[email]" />
</div>
<input type="submit" value="Sign Up" />
</form>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment