@@ -29,6 +29,8 @@ export const CrowdNodeCard = (() => {
29
29
depositAlt : `Deposit to Crowdnode` ,
30
30
#Txt : '#' ,
31
31
#Alt : `# for Crowdnode` ,
32
+ fundTxt : 'Fund Wallet' ,
33
+ fundAlt : `Fund Wallet for Crowdnode` ,
32
34
placement : 'center' ,
33
35
rendered : null ,
34
36
responsive : true ,
@@ -42,7 +44,7 @@ export const CrowdNodeCard = (() => {
42
44
...config ,
43
45
}
44
46
45
- this . appElement = document . body
47
+ // this.appElement = document.body
46
48
47
49
this . api = createSignal ( { } )
48
50
@@ -60,57 +62,76 @@ export const CrowdNodeCard = (() => {
60
62
...config . elements ,
61
63
}
62
64
65
+ this . stage = [ ]
66
+
67
+ Object . defineProperties ( this , {
68
+ stage : {
69
+ get : ( ) => [
70
+ ! this . api . value ?. acceptedToS , // Stage 0
71
+ this . api . value ?. acceptedToS , // Stage 1
72
+ this . api . value ?. balance <= 0 , // Stage 2
73
+ this . api . value ?. balance > 0 , // Stage 3
74
+ ] ,
75
+ } ,
76
+ } ) ;
77
+
63
78
this . markup = { }
64
- this . markup . content = ( ) => html `
65
- < header >
66
- < a href ="https://app.crowdnode.io/ " target ="_blank " rel ="noreferrer ">
67
- < svg class ="crowdnode-logo lock " width ="26 " height ="26 " viewBox ="0 0 240 240 ">
68
- < use xlink:href ="#icon-crowdnode-logo "> </ use >
69
- </ svg >
70
- < span > CrowdNode</ span >
71
- </ a >
72
- </ header >
79
+ // # & Accept
80
+ this . markup . stageOne = ( ) => this . stage [ 0 ] && ! this . stage [ 1 ] && html `
81
+ < section class ="flex col jc-between ">
82
+ Start earning interest by staking your Dash at CrowdNode
83
+ </ section >
73
84
85
+ < footer class ="flex ">
86
+ < button
87
+ class ="rounded outline flex-fill "
88
+ type ="submit "
89
+ name ="intent "
90
+ value ="# "
91
+ title ="${ this . state . #Alt } "
92
+ >
93
+ ${ this . state . #Txt }
94
+ </ button >
95
+ </ footer >
96
+ `
97
+ this . markup . stageTwo = ( ) => this . stage [ 1 ] && this . stage [ 2 ] && html `
74
98
< section class ="flex col jc-between ">
75
- ${ ! this . api . value ?. acceptedToS && html `
76
- Start earning interest by staking your Dash at CrowdNode
77
- ` }
78
- ${ this . api . value ?. acceptedToS && html `
79
- < p class ="my-0 "> < em >
80
- Balance: Ð ${ this . api . value ?. balance }
81
- </ em > </ p >
82
- ` }
83
- ${ this . api . value ?. acceptedToS && html `
84
- < p class ="my-0 "> < em >
85
- Earned: Ð ${ this . api . value ?. earned }
86
- </ em > </ p >
87
- ` }
99
+ Finish funding your account to start earning interest
88
100
</ section >
89
101
90
102
< footer class ="flex ">
91
- ${ ! this . api . value ?. acceptedToS && html `
92
- < button
93
- class ="rounded outline flex-fill "
94
- type ="submit "
95
- name ="intent "
96
- value ="# "
97
- title ="${ this . state . #Alt } "
98
- >
99
- ${ this . state . #Txt }
100
- </ button >
101
- ` }
102
- ${ this . api . value ?. acceptedToS && html `
103
- < button
104
- class ="rounded outline flex-fill "
105
- type ="submit "
106
- name ="intent "
107
- value ="deposit "
108
- title ="${ this . state . depositAlt } "
109
- >
110
- ${ this . state . depositTxt }
111
- </ button >
112
- ` }
113
- ${ this . api . value ?. acceptedToS && this . api . value ?. balance > 0 && html `
103
+ < button
104
+ class ="rounded outline flex-fill "
105
+ type ="submit "
106
+ name ="intent "
107
+ value ="fund "
108
+ title ="${ this . state . fundAlt } "
109
+ >
110
+ ${ this . state . fundTxt }
111
+ </ button >
112
+ </ footer >
113
+ `
114
+ this . markup . stageThree = ( ) => this . stage [ 1 ] && this . stage [ 3 ] && html `
115
+ < section class ="flex col jc-between ">
116
+ < p class ="my-0 "> < em >
117
+ Balance: Ð ${ this . api . value ?. balance }
118
+ </ em > </ p >
119
+ < p class ="my-0 "> < em >
120
+ Earned: Ð ${ this . api . value ?. earned }
121
+ </ em > </ p >
122
+ </ section >
123
+
124
+ < footer class ="flex ">
125
+ < button
126
+ class ="rounded outline flex-fill "
127
+ type ="submit "
128
+ name ="intent "
129
+ value ="deposit "
130
+ title ="${ this . state . depositAlt } "
131
+ >
132
+ ${ this . state . depositTxt }
133
+ </ button >
134
+ ${ this . stage [ 3 ] && html `
114
135
< button
115
136
class ="rounded outline flex-fill "
116
137
type ="submit "
@@ -123,6 +144,20 @@ export const CrowdNodeCard = (() => {
123
144
` }
124
145
</ footer >
125
146
`
147
+ this . markup . content = ( ) => html `
148
+ < header >
149
+ < a href ="https://app.crowdnode.io/ " target ="_blank " rel ="noreferrer ">
150
+ < svg class ="crowdnode-logo lock " width ="26 " height ="26 " viewBox ="0 0 240 240 ">
151
+ < use xlink:href ="#icon-crowdnode-logo "> </ use >
152
+ </ svg >
153
+ < span > CrowdNode</ span >
154
+ </ a >
155
+ </ header >
156
+
157
+ ${ this . markup . stageOne ( ) }
158
+ ${ this . markup . stageTwo ( ) }
159
+ ${ this . markup . stageThree ( ) }
160
+ `
126
161
this . markup = {
127
162
...this . markup ,
128
163
...config . markup ,
@@ -202,14 +237,16 @@ export const CrowdNodeCard = (() => {
202
237
this . elements . form . name = this . slugs . form
203
238
this . elements . form . innerHTML = this . markup . content ( )
204
239
240
+ console . log ( 'CN Card render' , this . stage , this . elements . form . innerHTML )
241
+
205
242
this . elements . form . addEventListener (
206
243
'submit' ,
207
244
this . events . submit ,
208
245
)
209
246
210
247
console . log ( 'CARD RENDER' , this , cfg )
211
248
212
- if ( ! this . state . rendered ) {
249
+ if ( ! this . state . rendered && el ) {
213
250
el . insertAdjacentElement ( position , this . elements . form )
214
251
this . state . rendered = this . elements . form
215
252
}
0 commit comments