Skip to content

Commit

Permalink
feat: denomination toggle (#398)
Browse files Browse the repository at this point in the history
  • Loading branch information
dni authored Dec 22, 2023
1 parent ddc7d50 commit 3668640
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
19 changes: 11 additions & 8 deletions src/components/Fees.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Show, createEffect } from "solid-js";

import btcSvg from "../assets/btc.svg";
import satSvg from "../assets/sat.svg";
import { fetchPairs, isMobile } from "../helper";
import { fetchPairs } from "../helper";
import t from "../i18n";
import {
asset,
Expand All @@ -22,7 +22,7 @@ import {
calculateBoltzFeeOnSend,
calculateSendAmount,
} from "../utils/calculate";
import { formatAmount } from "../utils/denomination";
import { denominations, formatAmount } from "../utils/denomination";

const Fees = () => {
createEffect(() => {
Expand All @@ -49,23 +49,26 @@ const Fees = () => {
}
});

const toggleDenomination = () => {
setDenomination(
denomination() === denominations.btc
? denominations.sat
: denominations.btc,
);
};

fetchPairs();

return (
<div class="fees-dyn">
<div class="denomination">
<Show when={!isMobile}>
<label>{t("denomination")}: </label>
</Show>
<div class="denomination" onClick={() => toggleDenomination()}>
<img
src={btcSvg}
onClick={() => setDenomination("btc")}
class={denomination() == "btc" ? "active" : ""}
alt="denominator"
/>
<img
src={satSvg}
onClick={() => setDenomination("sat")}
class={denomination() == "sat" ? "active" : ""}
alt="denominator"
/>
Expand Down
21 changes: 17 additions & 4 deletions src/style/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ hr.spacer {
padding-right: 8px;
}

.denomination {
margin-left: 5px;
}

.fees-dyn {
display: flex;
justify-content: center;
Expand Down Expand Up @@ -360,8 +356,25 @@ textarea {
background-image: url(../assets/sat.svg);
}

.denomination > :first-child {
margin-right: 5px;
}
.denomination {
cursor: pointer;
flex-grow: 0;
background: rgba(0, 0, 0, 0.3);
border-radius: 18px;
border: 1px dashed rgba(255, 255, 255, 0.3);
padding: 0 5px;
&:hover {
background: rgb(20, 40, 63);
}
}
.denomination .active {
filter: none;
border-radius: 50%;
background-color: rgb(23, 34, 46);
border: 1px solid rgba(255, 255, 255, 0.25);
}

.hidden {
Expand Down

2 comments on commit 3668640

@vercel
Copy link

@vercel vercel bot commented on 3668640 Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 3668640 Dec 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.