Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: improve balance spacing, coloring and grouping #691

Merged
merged 13 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ui(balance): align colors with copy
  • Loading branch information
theborakompanioni committed Nov 9, 2023
commit 348f6bc379d7eb34f818ca59fe0c696686c263a4
32 changes: 23 additions & 9 deletions src/components/Balance.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
:root {
--jam-deemphasize-opacity: 0.5;
--jam-balance-color: #212529;
--jam-balance-deemphasize-color: #9eacba;
}

[data-theme='dark'] {
--jam-deemphasize-opacity: 0.5;
:root[data-theme='dark'] {
--jam-balance-color: #ffffff;
--jam-balance-deemphasize-color: #555c62;
}

.frozen {
--jam-balance-color: #0d6efd;
--jam-balance-deemphasize-color: #7eb2ff;

font-size: 0.75rem;
}

:root[data-theme='dark'] .frozen {
--jam-balance-color: #1372ff;
--jam-balance-deemphasize-color: #1153b5;
}

.balance {
color: var(--jam-balance-color);
}

.bitcoinSymbol {
Expand All @@ -12,6 +30,7 @@

.hideSymbol {
padding-left: 0.25rem;
color: var(--jam-balance-deemphasize-color);
}

/** Integer Part **/
Expand All @@ -29,15 +48,10 @@
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-value="0"]) + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-value="0"]) + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-value="0"]) + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] + span[data-value="0"] {
opacity: var(--jam-deemphasize-opacity);
color: var(--jam-balance-deemphasize-color);
}

.bitcoinAmount .fractionalPart :nth-child(3)::before,
.bitcoinAmount .fractionalPart :nth-child(6)::before {
content: '\202F';
}

.frozen {
color: var(--bs-blue);
font-size: 0.75rem;
}
16 changes: 8 additions & 8 deletions src/components/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BitcoinAmountComponent = ({ value }: { value: number }) => {

return (
<span
className={styles.bitcoinAmount}
className={`${styles.bitcoinAmount} slashed-zeroes`}
data-testid="bitcoin-amount"
data-integer-part-is-zero={integerPartIsZero}
data-fractional-part-starts-with-zero={fractionalPartStartsWithZero}
Expand All @@ -47,22 +47,22 @@ const BitcoinAmountComponent = ({ value }: { value: number }) => {
}

const SatsAmountComponent = ({ value }: { value: number }) => {
return <>{formatSats(value)}</>
return <span className="slashed-zeroes">{formatSats(value)}</span>
}

interface BalanceComponentProps {
symbol: JSX.Element
value: string | JSX.Element
value: JSX.Element
symbolIsPrefix: boolean
frozen?: boolean
}

const BalanceComponent = ({ symbol, value, symbolIsPrefix, frozen = false }: BalanceComponentProps) => {
return (
<span className={`${frozen ? styles.frozen : ''} d-inline-flex align-items-center balance-hook`}>
<span className={`${styles.balance} ${frozen ? styles.frozen : ''} d-inline-flex align-items-center balance-hook`}>
{frozen && FROZEN_SYMBOL}
{symbolIsPrefix && symbol}
<span className="slashed-zeroes">{value}</span>
{value}
{!symbolIsPrefix && symbol}
</span>
)
Expand Down Expand Up @@ -125,7 +125,7 @@ export default function Balance({
return (
<BalanceComponent
symbol={<Sprite symbol="hide" width="1.2em" height="1.2em" className={styles.hideSymbol} />}
value={'*****'}
value={<span className="slashed-zeroes">{'*****'}</span>}
symbolIsPrefix={false}
frozen={frozen}
/>
Expand All @@ -135,7 +135,7 @@ export default function Balance({
const valueNumber = parseFloat(valueString)
if (!isValidNumber(valueNumber)) {
console.warn('<Balance /> component expects number input as string')
return <BalanceComponent symbol={<></>} value={valueString} symbolIsPrefix={false} frozen={frozen} />
return <BalanceComponent symbol={<></>} value={<>{valueString}</>} symbolIsPrefix={false} frozen={frozen} />
}

// Treat integers as sats.
Expand Down Expand Up @@ -182,7 +182,7 @@ export default function Balance({
)

console.warn('<Balance /> component cannot determine balance format')
return <BalanceComponent symbol={<></>} value={valueString} symbolIsPrefix={false} frozen={frozen} />
return <BalanceComponent symbol={<></>} value={<>{valueString}</>} symbolIsPrefix={false} frozen={frozen} />
}, [valueString, displayMode, frozen])

if (!enableVisibilityToggle) {
Expand Down