From a0abd876b4e32b64391a08862dcc99cc8c297c46 Mon Sep 17 00:00:00 2001 From: Patrick Opie Date: Sun, 9 Apr 2017 11:42:10 -0700 Subject: [PATCH] Vue --- app/app.js | 19 ++++ app/components/BankCard/bank-card.css | 77 +++++++++++++++ app/components/BankCard/bank-card.vue | 95 +++++++++++++++++++ .../BankCardPayment/bank-card-payment.vue | 59 ++++++++++++ .../models/currency-validator.js | 60 ++++++++++++ app/components/app.vue | 24 +++++ app/components/home.vue | 30 ++++++ app/components/test.vue | 25 +++++ app/router/router.js | 17 ++++ app/store/store.js | 3 + 10 files changed, 409 insertions(+) create mode 100644 app/app.js create mode 100644 app/components/BankCard/bank-card.css create mode 100644 app/components/BankCard/bank-card.vue create mode 100644 app/components/BankCardPayment/bank-card-payment.vue create mode 100644 app/components/BankCardPayment/models/currency-validator.js create mode 100644 app/components/app.vue create mode 100644 app/components/home.vue create mode 100644 app/components/test.vue create mode 100644 app/router/router.js create mode 100644 app/store/store.js diff --git a/app/app.js b/app/app.js new file mode 100644 index 0000000..d621589 --- /dev/null +++ b/app/app.js @@ -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} +}); diff --git a/app/components/BankCard/bank-card.css b/app/components/BankCard/bank-card.css new file mode 100644 index 0000000..e70893d --- /dev/null +++ b/app/components/BankCard/bank-card.css @@ -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; +} diff --git a/app/components/BankCard/bank-card.vue b/app/components/BankCard/bank-card.vue new file mode 100644 index 0000000..dfaa369 --- /dev/null +++ b/app/components/BankCard/bank-card.vue @@ -0,0 +1,95 @@ + + + + + diff --git a/app/components/BankCardPayment/bank-card-payment.vue b/app/components/BankCardPayment/bank-card-payment.vue new file mode 100644 index 0000000..c0bc9fc --- /dev/null +++ b/app/components/BankCardPayment/bank-card-payment.vue @@ -0,0 +1,59 @@ + + + + diff --git a/app/components/BankCardPayment/models/currency-validator.js b/app/components/BankCardPayment/models/currency-validator.js new file mode 100644 index 0000000..bb239f3 --- /dev/null +++ b/app/components/BankCardPayment/models/currency-validator.js @@ -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 + ) + } + } +} + diff --git a/app/components/app.vue b/app/components/app.vue new file mode 100644 index 0000000..e816fa5 --- /dev/null +++ b/app/components/app.vue @@ -0,0 +1,24 @@ + + + + + diff --git a/app/components/home.vue b/app/components/home.vue new file mode 100644 index 0000000..f3992ff --- /dev/null +++ b/app/components/home.vue @@ -0,0 +1,30 @@ + + + diff --git a/app/components/test.vue b/app/components/test.vue new file mode 100644 index 0000000..951acb6 --- /dev/null +++ b/app/components/test.vue @@ -0,0 +1,25 @@ + + + diff --git a/app/router/router.js b/app/router/router.js new file mode 100644 index 0000000..c80a433 --- /dev/null +++ b/app/router/router.js @@ -0,0 +1,17 @@ +import Home from '../components/home.vue'; +import Test from '../components/test.vue'; + +export default { + routes: [ + { + path: '/', + name: 'home', + component: Home + }, + { + path: '/test', + name: 'test', + component: Test + } + ] +} diff --git a/app/store/store.js b/app/store/store.js new file mode 100644 index 0000000..89ce5b6 --- /dev/null +++ b/app/store/store.js @@ -0,0 +1,3 @@ +export default { + message: 'Hello world!' +}