EmailSubscribe component

This commit is contained in:
Kristian Polso 2018-05-17 15:30:17 +03:00
parent 20b2ad2f73
commit 662e1a2dec
2 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,61 @@
<template>
<div id="email-subscribe">
<h3 class="title">Subscribe to our developer newsletter!</h3>
<input type="text" class="input" v-model="emailAddress" placeholder="your@email.com">
<a class="__button-black" href="#" v-on:click.prevent="subscribe">Subscribe</a>
<p v-if="message" class="message">{{ message }}</p>
</div>
</template>
<script>
export default {
data () {
return {
emailAddress: '',
message: ''
}
},
name: 'EmailSubscribe',
methods: {
subscribe () {
var component = this;
this.message = '';
if(!this.validateEmail(this.emailAddress)) {
this.message = 'Your email is not valid!';
} else {
this.$http.post('//api.lbry.io/list/subscribe', {email: this.emailAddress, tag: 'developer'}).then(function(response) {
component.email = '';
component.message = 'Thank you for subscribing!';
});
}
},
validateEmail (email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
}
};
</script>
<style lang="scss">
#email-subscribe {
background: #ddd;
padding: 1rem 0;
text-align: center;
.title {
margin-bottom: 0.5rem;
}
.input {
border: 1px solid black;
padding: 0.65rem;
background: white;
margin-right: 1rem;
width: 18rem;
}
.message {
margin-top: 1rem;
}
}
</style>

View file

@ -125,6 +125,10 @@
</div>
</template>
<section class="email-subscribe-container">
<EmailSubscribe></EmailSubscribe>
</section>
<section class="home alert">
<div class="inner-wrap">
<strong>This website is in beta.</strong> We are actively developing this website to showcase and teach about the LBRY protocol. All things may not work as expected!<br/>This website is open source and you can <a href="https://github.com/lbryio/lbry.tech" target="_blank">contribute to it on Github</a>.