Skip to content

Commit

Permalink
better differentiate incoming/outgoing txs, improve fee slider
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jan 3, 2024
1 parent 6ade738 commit a309c7c
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/assets/app/static/theme/deepoceanduck.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

--error: #ff0000;
--warning: var(--foreground);

--outgoingTxForeground: #b76a6a;
--incomingTxForeground: #6d8b6d;
}

#liquidwallet #container .asset .cover {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/app/static/theme/minimalsats.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

--error: #ff0000;
--warning: #ff9800;

--outgoingTxForeground: #b76a6a;
--incomingTxForeground: #6d8b6d;
}

#liquidwallet #logo {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/app/static/theme/satoshilegacy.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

--error: #ff0000;
--warning: var(--foreground);

--outgoingTxForeground: #b76a6a;
--incomingTxForeground: #6d8b6d;
}
#liquidwallet #container .asset .cover {
filter: blur(20px) grayscale(0.4) brightness(0.6);
Expand Down
3 changes: 3 additions & 0 deletions src/assets/app/static/theme/spacequack.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

--error: #ff0000;
--warning: var(--foreground);

--outgoingTxForeground: #b76a6a;
--incomingTxForeground: #6d8b6d;
}
#liquidwallet #container .asset .cover {
filter: blur(20px) grayscale(0.4) brightness(0.6);
Expand Down
4 changes: 2 additions & 2 deletions src/js/AssetProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,13 @@ export default class AssetProvider {
return price;
}

async floatToStringValue(v, assetHash) {
async floatToStringValue(v, assetHash, useSpecialSymbols = false) {
const info = await this.getAssetInfo(assetHash);
let symbol = info.ticker;
const precision = info.precision;
let symbolBeforeValue = false;

if (this.specialSymbols[symbol]) {
if (useSpecialSymbols && this.specialSymbols[symbol]) {
symbolBeforeValue = true;
symbol = this.specialSymbols[symbol];
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/LiquidWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1443,15 +1443,15 @@ export default class LiquidWallet {
* @param {string} targetAssetHash if unset means to use the base asset
* @returns
*/
human: async (targetAssetHash) => {
human: async (targetAssetHash, special = true) => {
await this.check();
if (!targetAssetHash) targetAssetHash = assetHash;

let amount = inAmount;
amount = await this.assetProvider.getPrice(amount, assetHash, targetAssetHash);
amount = await this.assetProvider.intToFloat(amount, targetAssetHash);

amount = await this.assetProvider.floatToStringValue(amount, targetAssetHash);
amount = await this.assetProvider.floatToStringValue(amount, targetAssetHash, special);
return amount;
},

Expand Down
13 changes: 12 additions & 1 deletion src/js/ui/Html.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,12 +1003,23 @@ class Html {
el.classList.add("clickable");
const sliderEl = this.$(el, "slider", ["slider"], "input");
sliderEl.classList.add("clickable");
const max = 100;
const max = 10;
sliderEl.type = "range";
sliderEl.min = 0;
sliderEl.max = max;
sliderEl.value = 0;

el.setLabel = (pos, label) => {
const posSel = pos.toString().replace(".", "_");
if (!label) {
this.$0(el, "#label" + posSel);
return;
}
const labelEl = this.$text(el, ["label"], "label" + posSel).setValue(label);
labelEl.style.left = `${pos * 100}%`;
return el;
};

const debounce = Constants.DEBOUNCE_CALLBACK_TIME;
let lastValue = 0;

Expand Down
5 changes: 4 additions & 1 deletion src/js/ui/stages/SendStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ export default class SendStage extends UIStage {
const availableBalanceValueEl = $text(availableBalanceEl);
const useAllEl = $button(availableBalanceEl, ["small"]).setValue("SEND ALL");

$title(c01El).setValue("Priority");
$title(c01El).setValue("Fee");
const prioritySlideEl = $inputSlide(c01El);
prioritySlideEl.setLabel(0, "Low (slow)");
prioritySlideEl.setLabel(0.5, "Medium");
prioritySlideEl.setLabel(1, "High (fast)");

const feeRowEl = $hlist(c01El, ["sub"]);
$hsep(feeRowEl).grow(100);
Expand Down
6 changes: 4 additions & 2 deletions src/js/ui/stages/WalletStage.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class WalletPage extends UIStage {
const balanceSecondaryEl = $text(balanceAltCntEl, ["sub"]);

lq.v(balance.value, balance.asset)
.human()
.human(balance.asset, false)
.then((value) => {
balanceEl.setValue(value);
});
Expand Down Expand Up @@ -201,9 +201,11 @@ export default class WalletPage extends UIStage {
txElCnt.hide();
} else {
if (txData.info.isIncoming) {
txElCnt.classList.add("incoming");
txDirectionEl.setValue("arrow_downward");
txDirectionEl.classList.add("incoming");
} else {
txElCnt.classList.add("outgoing");
txDirectionEl.setValue("arrow_upward");
txDirectionEl.classList.add("outgoing");
}
Expand Down Expand Up @@ -245,7 +247,7 @@ export default class WalletPage extends UIStage {
txSymbolEl.setValue(info.ticker);
});
lq.v(txData.info.outAmount, txData.info.outAsset)
.human()
.human(txData.info.outAsset, false)
.then((value) => {
txAmountEl.setValue(value);
});
Expand Down
19 changes: 19 additions & 0 deletions src/less/stages/wallet.less
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
/* filter: grayscale(40%); */
}

#liquidwallet #container.wallet.stage #history {
.tx.incoming {
.txAmount {
color: var(--incomingTxForeground);
}
.txAmount::before {
content: "+ ";
}
}
.tx.outgoing {
.txAmount {
color: var(--outgoingTxForeground);
}
.txAmount::before {
content: "- ";
}
}
}

#liquidwallet #container.wallet.stage .asset.h {
width: 100%;
}
Expand Down
22 changes: 22 additions & 0 deletions src/less/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

--error: #ff0000;
--warning: var(--elementsBackground);

--outgoingTxForeground: #b76a6a;
--incomingTxForeground: #6d8b6d;
}

#liquidwallet {
Expand Down Expand Up @@ -148,7 +151,26 @@
align-items: center;
justify-content: space-between;
width: 100%;
padding-bottom: 1rem;

.label {
position: absolute;
color: var(--foreground);
font-size: 0.8rem;
text-align: center;
bottom: 0;

white-space: nowrap;
transform: translateX(-50%);
}

.label:first-of-type {
transform: translateX(0%);
}

.label:last-of-type {
transform: translateX(-100%);
}
.slider {
flex-grow: 1;
padding: 0;
Expand Down

0 comments on commit a309c7c

Please sign in to comment.