-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added theme page and dark theme (#196)
Resolves #124 #197 - Dark theme preview https://github.com/user-attachments/assets/76441ab7-516b-41b1-96c9-dd18770aaece - Theme tests [video.webm](https://github.com/user-attachments/assets/bf013269-017e-4f0e-9c5b-d8d71266300f) [video.webm](https://github.com/user-attachments/assets/6b2b54c5-9cce-4897-aaf2-eeac2d59c29c) [video.webm](https://github.com/user-attachments/assets/49e9a986-7ed4-4660-b967-7cd66fd408a9) - Added permission check to all settings config pages, along with tests.
- Loading branch information
1 parent
22087f0
commit 8f0ae28
Showing
87 changed files
with
3,252 additions
and
1,886 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
instances/treasury-devdao.near/widget/components/BalanceBanner.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const { getNearBalances } = VM.require( | ||
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/lib.common" | ||
); | ||
|
||
const Container = styled.div` | ||
.low-balance-warning { | ||
background: rgba(255, 158, 0, 0.1); | ||
color: var(--other-warning); | ||
padding-inline: 0.8rem; | ||
padding-block: 0.5rem; | ||
font-weight: 500; | ||
font-size: 13px; | ||
h5 { | ||
color: var(--other-warning) !important; | ||
} | ||
} | ||
.insufficient-balance-warning { | ||
background-color: rgba(217, 92, 74, 0.08); | ||
color: var(--other-red); | ||
padding-inline: 0.8rem; | ||
padding-block: 0.5rem; | ||
font-weight: 500; | ||
font-size: 13px; | ||
h5 { | ||
color: var(--other-red) !important; | ||
} | ||
} | ||
`; | ||
|
||
function formatNearAmount(amount) { | ||
return parseFloat( | ||
Big(amount ?? "0") | ||
.div(Big(10).pow(24)) | ||
.toFixed(2) | ||
); | ||
} | ||
|
||
function BalanceBanner({ accountId, treasuryDaoID }) { | ||
if (!treasuryDaoID || typeof getNearBalances !== "function" || !accountId) { | ||
return <></>; | ||
} | ||
|
||
const nearBalances = getNearBalances(accountId); | ||
|
||
const LOW_BALANCE_LIMIT = 0.7; // 0.7N | ||
const INSUFFICIENT_BALANCE_LIMIT = 0.1; // 0.1N | ||
|
||
const profile = Social.getr(`${accountId}/profile`); | ||
const name = profile.name ?? accountId; | ||
|
||
return ( | ||
<Container> | ||
{!nearBalances || | ||
!nearBalances.availableParsed || | ||
nearBalances.availableParsed === "0.00" || | ||
parseFloat(nearBalances.availableParsed) > LOW_BALANCE_LIMIT ? ( | ||
<></> | ||
) : parseFloat(nearBalances.availableParsed) < | ||
INSUFFICIENT_BALANCE_LIMIT ? ( | ||
<div className="insufficient-balance-warning d-flex gap-3 p-3 rounded-3 m-3"> | ||
<i class="bi bi-exclamation-octagon error-icon h4 mb-0"></i> | ||
<div> | ||
<h5>Insufficient Funds</h5> | ||
Hey {name}, you don't have enough NEAR to complete actions on your | ||
treasury. You need at least {INSUFFICIENT_BALANCE_LIMIT}N. Please | ||
add more funds to your account and try again | ||
</div> | ||
</div> | ||
) : ( | ||
<div className="low-balance-warning d-flex gap-3 p-3 rounded-3 m-3"> | ||
<i class="bi bi-exclamation-triangle warning-icon h4 mb-0"></i> | ||
<div> | ||
<h5>Low Balance</h5> | ||
Hey {name}, your NEAR balance is {nearBalances.availableParsed}N, | ||
which is getting low. The minimum balance required is{" "} | ||
{INSUFFICIENT_BALANCE_LIMIT}N. Please add more NEAR to your account | ||
soon to avoid any issues completing actions on your treasury. | ||
</div> | ||
</div> | ||
)} | ||
</Container> | ||
); | ||
} | ||
|
||
return { BalanceBanner }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.