Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import app from './components/app.vue';
import router from './router/router';
import store from './store/store';

import Vue from 'vue';
import VueEvents from 'vue-events';
import VueRouter from 'vue-router';
import VueStash from 'vue-stash';

Vue.use(VueEvents);
Vue.use(VueRouter);
Vue.use(VueStash);

new Vue({
el: '#app',
render: h => h(app),
router: new VueRouter(router),
data: {store}
});
77 changes: 77 additions & 0 deletions app/components/BankCard/bank-card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.card {
max-width: 600px;
margin: auto;
border-radius: 2px;
margin-top: 3em;
color: #FFF;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
transition: all .3s ease;
padding: 0 10px;
background-color: #546e7a;
}

.title {
text-align: center;
padding: 10px 0;
}

.title i {
font-size: 2.5em;
line-height: 2em;
border-radius: 50%;
background-color: #FFF;
height: 75px;
width: 75px;
color: #546e7a;
margin-top: -6em;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
}

.status.verified {
color: rgba(255, 255, 255, 0.75);
}

.status {
text-align: right;
margin-top: -3.5em;
text-transform: uppercase;
}

.info {
margin: 10px 0;
}

.info .title {
text-align: left;
margin: 0;
padding: 5px 0;
color: rgba(255, 255, 255, 0.75);
}

.footer {
border-top: 1px solid rgba(255, 255, 255, 0.75);
padding: 20px;
text-align: right;
text-transform: uppercase;
position: relative;
}

.footer .action, .footer .confirm {
transition: all 0.3s ease;
opacity: 0;
}

.footer .reveal {
opacity: 1;
}

.footer a {
transition: color .3s ease;
color: #ffc107;
margin: 0 5px;
}

.footer a:hover {
color: #fff246;
cursor: pointer;
}
95 changes: 95 additions & 0 deletions app/components/BankCard/bank-card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<template>
<div class="container">
<div class="row card first" v-bind:style="styleObject">
<div class="title col-sm-12">
<i class="fa fa-university"></i>
</div>
<div class="status verified col-sm-12">
verified - <span class="badge badge-danger">${{state}}</span>
</div>
<div class="row content col-sm-12">
<div class="info unknownBank col-sm-12">
<p class="title">Institution</p>
Navy Federal Credit Union

</div>
<div class="info knownBank col-sm-12">
<div class="logo"></div>
</div>
<!--<bank-profile-account-info [accountNum]="12123124124" [routingNum]="12135352212" (onSubmit)="changeState($event)"></bank-profile-account-info>-->
<div id="bank-card-payment">
<bank-card-payment></bank-card-payment>
</div>
</div>
<div class="footer col-sm-12">
<div class="action" v-bind:class="{reveal: !isRevealed}" v-show="!payAnim">
<a v-on:click="togglePay(true)">Pay</a>
</div>
<div class="confirm" v-bind:class="{reveal: isRevealed}" v-show="payAnim">
<span class="message">Pay bill $100?</span>
<a v-on:click="pay()">Yes</a>
<a v-on:click="togglePay(false)">No</a>
</div>
</div>
</div>
</div>
</template>

<script>

import BankCardPayment from '../BankCardPayment/bank-card-payment.vue';
export default {
name: 'bank-card',
components: {
BankCardPayment
},
events: {

},
props: {
state: {
type: String,
default: ''
},
color: {
type: String,
default: '#546e7a'
},
paying: {
type: Boolean,
default: false
},
payAnim: {
type: Boolean,
default: false
},
money: {
type: Number,
default: 1000
}
},
data: {
isRevealed: this.paying,
styleObject: {
'background-color': this.color
}
},
mounted() {
},
methods: {
pay: function () {

},
togglePay: function (val) {
this.paying = val;
setTimeout(() => {
this.payAnim = val;
}, 300);
}
}
}
</script>

<style lang="css">
@import "./bank-card.css";
</style>
59 changes: 59 additions & 0 deletions app/components/BankCardPayment/bank-card-payment.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div>
<div class="info col-xs-6">
<p class="title">Routing Number</p>
<p class="text-sm-center">{{routingNum}}</p>
</div>
<div class="info col-xs-6">
<p class="title">Account Number</p>
<p class="text-sm-center">{{accountNum}}</p>
</div>

<p>Change Local State:</p>
<input class="form-control"
ref="input"
v-bind:value="value"
v-on:blur="formatValue()"
v-on:input="updateValue($event.target.value)">
<button class="btn btn-info" v-on:click="submit()">Submit</button>
</div>
</template>

<script>

import { CurrencyValidator } from './models/currency-validator';

export default {
name: 'bank-card-payment',
props: {
value: {
type: Number,
default: 0
},
routingNum: {
type: String,
default: ''
},
accountNum: {
type: String,
default: ''
}
},
methods: {
formatValue: function () {
this.$refs.input.value = CurrencyValidator.format(this.value);
},
updateValue: function () {
let result = CurrencyValidator.parse(value, this.value);
if (result.warning) {
this.$refs.input.value = result.value
}
this.$emit('input', result.value)
},
submit: function () {
console.log(this.value);
}
}
}
</script>

60 changes: 60 additions & 0 deletions app/components/BankCardPayment/models/currency-validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
export class CurrencyValidator {

static format(number) {
return (Math.trunc(number * 100) / 100).toFixed(2);
}

static parse(newString, oldNumber) {
let CleanParse = function (value) {
return {value: value}
};
let CurrencyWarning = function (warning, value) {
return {
warning: warning,
value: value,
attempt: newString
}
};
let NotAValidDollarAmountWarning = function (value) {
return new CurrencyWarning(newString + ' is not a valid dollar amount', value)
};
let AutomaticConversionWarning = function (value) {
return new CurrencyWarning(newString + ' was automatically converted to ' + value, value)
};

let newNumber = Number(newString);
let indexOfDot = newString.indexOf('.');
let indexOfE = newString.indexOf('e');

if (isNaN(newNumber)) {
if (
indexOfDot === -1 &&
indexOfE > 0 &&
indexOfE === newString.length - 1 &&
Number(newString.slice(0, indexOfE)) !== 0
) {
return new CleanParse(oldNumber)
} else {
return new NotAValidDollarAmountWarning(oldNumber)
}
}

let newCurrencyString = currencyValidator.format(newNumber);
let newCurrencyNumber = Number(newCurrencyString);

if (newCurrencyNumber === newNumber) {
if (indexOfE !== -1 && indexOfE === newString.length - 2) {
return new AutomaticConversionWarning(newNumber)
} else {
return new CleanParse(newNumber)
}
} else {
return new NotAValidDollarAmountWarning(
newNumber > newCurrencyNumber
? newCurrencyNumber
: oldNumber
)
}
}
}

24 changes: 24 additions & 0 deletions app/components/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div id="app">
<router-view></router-view>
<ul>
<li>
<router-link to="/">Home</router-link>
</li>
<li>
<router-link to="/test">Test</router-link>
</li>
</ul>
</div>
</template>

<script>
export default {
name: 'app'
}
</script>

<style lang="css">
@import "../../node_modules/bootstrap/dist/css/bootstrap.css";
@import "../assets/styles/app.css";
</style>
30 changes: 30 additions & 0 deletions app/components/home.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<template>
<section id="home">
<h1>Home</h1>
<h2>{{ message }}</h2>
</section>
</template>

<script>
import BankCard from './BankCard/bank-card.vue';
export default {
name: 'home',

store: ['message'],

components: {
BankCard
},

events: {
test(message) {
this.message = message
}
},

mounted() {
setTimeout(() => this.$events.fire('test', "You've received a message from home.vue"), 1500);
setTimeout(() => this.$events.fire('test', "Now you've received another message home.vue"), 3000);
}
}
</script>
25 changes: 25 additions & 0 deletions app/components/test.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<section id="test">
<h1>Test</h1>
<h2>{{ message }}</h2>
</section>
</template>

<script>
export default {
name: 'test',

store: ['message'],

events: {
test(message) {
this.message = message
}
},

mounted() {
setTimeout(() => this.$events.fire('test', "You've received a message from test.vue"), 1500);
setTimeout(() => this.$events.fire('test', "Now you've received another message test.vue"), 3000);
}
}
</script>
Loading