Skip to content

Commit

Permalink
webserver/site: use border color to show if address is valid or inval…
Browse files Browse the repository at this point in the history
…id (#3040)

* webserver/site: use border color to show if address is valid or invalid
---------
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon authored Oct 30, 2024
1 parent 5e659ec commit 717fc3e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
8 changes: 8 additions & 0 deletions client/webserver/site/src/css/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ textarea {
outline: none;
}

&.border-danger {
border-color: var(--text-danger);
}

&.border-success {
border-color: var(--indicator-good);
}

&.thin {
width: 4rem;
}
Expand Down
5 changes: 1 addition & 4 deletions client/webserver/site/src/html/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,7 @@
</div>
<div>
<label for="sendAddr">[[[Address]]]</label>
<div class="d-flex">
<input type="text" class="col-1" id="sendAddr" spellcheck="false">
<span id="validAddr" class="ico-check mx-2 pt-2 d-hide"></span>
</div>
<input type="text" id="sendAddr" spellcheck="false">
</div>
<div class="d-flex align-items-stretch">
<div class="flex-grow-1 pe-3">
Expand Down
11 changes: 5 additions & 6 deletions client/webserver/site/src/js/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,12 @@ export default class WalletsPage extends BasePage {
// Validate send address on input.
Doc.bind(page.sendAddr, 'input', async () => {
const asset = app().assets[this.selectedAssetID]
Doc.hide(page.validAddr)
page.sendAddr.classList.remove('is-invalid')
page.sendAddr.classList.remove('border-danger', 'border-success')
const addr = page.sendAddr.value || ''
if (!asset || addr === '') return
const valid = await this.validateSendAddress(addr, asset.id)
if (valid) Doc.show(page.validAddr)
else page.sendAddr.classList.add('is-invalid')
if (valid) page.sendAddr.classList.add('border-success')
else page.sendAddr.classList.add('border-danger')
})

// A link on the wallet reconfiguration form to show/hide the password field.
Expand Down Expand Up @@ -2161,8 +2160,8 @@ export default class WalletsPage extends BasePage {
Doc.show(page.toggleSubtract)
}

Doc.hide(page.validAddr, page.sendErr, page.maxSendDisplay, page.sendTokenMsgBox)
page.sendAddr.classList.remove('invalid')
Doc.hide(page.sendErr, page.maxSendDisplay, page.sendTokenMsgBox)
page.sendAddr.classList.remove('border-danger', 'border-success')
page.sendAddr.value = ''
page.sendAmt.value = ''
const xcRate = app().fiatRatesMap[assetID]
Expand Down

0 comments on commit 717fc3e

Please sign in to comment.