Skip to content

Commit 03a08d6

Browse files
committed
use jsx in vue
1 parent cc833c4 commit 03a08d6

20 files changed

+434
-652
lines changed

babel.conf.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ module.exports = function (vendor) {
88
}]
99
]
1010

11-
const plugins = ['@babel/plugin-transform-runtime', '@babel/plugin-transform-react-jsx']
11+
if (vendor === 'vue') {
12+
presets.push('@vue/babel-preset-jsx')
13+
}
14+
15+
const plugins = ['@babel/plugin-transform-runtime']
16+
17+
if (vendor === 'react') {
18+
plugins.push('@babel/plugin-transform-react-jsx')
19+
}
1220

1321
return { presets, plugins }
1422
}

demo/README.md

Lines changed: 0 additions & 17 deletions
This file was deleted.

demo/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

demo/transfer/vue/app.js

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import Vue from 'vue'
2+
import { NumericKeyboard, NumericInput, Keys } from 'numeric-keyboard'
3+
import '../styles.styl'
4+
5+
const PasswordLayout = [
6+
[
7+
{
8+
key: Keys.ONE
9+
},
10+
{
11+
key: Keys.TWO
12+
},
13+
{
14+
key: Keys.THREE
15+
},
16+
],
17+
[
18+
{
19+
key: Keys.FOUR
20+
},
21+
{
22+
key: Keys.FIVE
23+
},
24+
{
25+
key: Keys.SIX
26+
},
27+
],
28+
[
29+
{
30+
key: Keys.SEVEN
31+
},
32+
{
33+
key: Keys.EIGHT
34+
},
35+
{
36+
key: Keys.NINE
37+
},
38+
],
39+
[
40+
{
41+
key: Keys.BLANK
42+
},
43+
{
44+
key: Keys.ZERO
45+
},
46+
{
47+
key: Keys.DEL
48+
},
49+
],
50+
]
51+
52+
const Password = Vue.extend({
53+
components: {
54+
'v-numeric-keyboard': NumericKeyboard
55+
},
56+
57+
data() {
58+
return {
59+
PasswordLayout,
60+
password: ''
61+
}
62+
},
63+
64+
methods: {
65+
press(key) {
66+
if (key === Keys.DEL) {
67+
this.password = this.password.slice(0, -1)
68+
}
69+
else {
70+
this.password = this.password + key
71+
if (this.password.length === 6) {
72+
setTimeout(() => this.$emit('confirm', this.password), 100)
73+
}
74+
}
75+
}
76+
},
77+
78+
template: `
79+
<section class="password">
80+
<div class="dialog">
81+
<h2>Conform password</h2>
82+
<div class="input">
83+
<span v-for="n in 6" :key="n" :class="{ fill: n <= password.length }"></span>
84+
</div>
85+
<v-numeric-keyboard :layout="PasswordLayout" @press="press" />
86+
</div>
87+
</section>
88+
`
89+
90+
})
91+
92+
export default Vue.extend({
93+
components: {
94+
'v-numeric-input': NumericInput,
95+
'v-password': Password
96+
},
97+
98+
data() {
99+
return {
100+
amount: '',
101+
shouldOpenPassword: false
102+
}
103+
},
104+
105+
methods: {
106+
confirmAmount() {
107+
if (this.amount) {
108+
this.shouldOpenPassword = true
109+
}
110+
},
111+
112+
confirmPassword(password) {
113+
this.shouldOpenPassword = false
114+
setTimeout(() => alert(`Amount: ${this.amount}\nPassword: ${password}`), 200)
115+
}
116+
},
117+
118+
template: `
119+
<main className="app">
120+
<header>
121+
<h1>Transfer to Arthur</h1>
122+
</header>
123+
<form @submit.prevent="confirmAmount">
124+
<label>Amount</label>
125+
<div class="input">
126+
<v-numeric-input type="number" autofocus entertext="Confirm" format="^(?:\\d+(?:\\.\\d{0,2})?)?$" v-model="amount" @enterpress="confirmAmount" />
127+
</div>
128+
<input type="submit" value="Confirm" :disabled="!amount" />
129+
</form>
130+
<footer>
131+
<p>Power by Numeric Keyboard</p>
132+
</footer>
133+
<v-password v-if="shouldOpenPassword" @confirm="confirmPassword" />
134+
</main>
135+
`
136+
})

demo/vue/app.js renamed to demo/transfer/vue/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Vue from 'vue'
2-
import App from './app.vue'
2+
import App from './app.js'
33

44
new Vue({
55
el: '#app',

demo/vue/app.styl

Lines changed: 0 additions & 110 deletions
This file was deleted.

demo/vue/app.vue

Lines changed: 0 additions & 49 deletions
This file was deleted.

demo/vue/index.template.html

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)