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

follow-up(PR771): quick freeze/unfreeze #802

Merged
merged 21 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6d2ec4b
refactor(send): use util function to shorten address
theborakompanioni Jul 22, 2024
8d4868b
refactor(Send): rectify utxos fallback icon
theborakompanioni Jul 22, 2024
8236519
refactor(balance): split styles for balance color and spacing
theborakompanioni Jul 22, 2024
bcd8989
refactor(send): slashed-zeroes style for addresses
theborakompanioni Jul 22, 2024
84e01b8
refactor(send): reset amount value in InnerSendForm instead of Amount…
theborakompanioni Jul 22, 2024
1f3e5e2
refactor(send): remove unnecessary function
theborakompanioni Jul 22, 2024
54d2749
refactor(send): fix sats value display color
theborakompanioni Jul 22, 2024
4e111f9
fix(send): loading state indicator of quick freeze/unfreeze
theborakompanioni Jul 22, 2024
5f8b876
chore(send): jarIndex type as JarIndex instead of String
theborakompanioni Jul 22, 2024
67a7603
refactor(send): remove unnecessary type UtxoList
theborakompanioni Jul 22, 2024
5ae4ce0
refactor(send): Confirmations component
theborakompanioni Aug 6, 2024
a5464da
refactor(send): make onToggle in ShowUtxos mandatory
theborakompanioni Aug 7, 2024
e0ed6f8
refactor(send): provide selected utxos in confirm callback
theborakompanioni Aug 9, 2024
d6743f1
refactor(send): handle timelocked utxos
theborakompanioni Aug 11, 2024
4a5129e
refator(send): use rb.Collapse for frozen utxos in modal
theborakompanioni Aug 11, 2024
d548f87
chore(ui): externalize Divider component
theborakompanioni Aug 11, 2024
b4022e6
chore(send): prevent flickering when frozen utxos appear
theborakompanioni Aug 11, 2024
c790207
refactor(modal): custom component for quick freeze utxos modal
theborakompanioni Aug 11, 2024
6bcf8cd
refactor(send): remove showRadioButton property from UtxosList component
theborakompanioni Aug 11, 2024
5372ef0
refactor: remove id and checked prop from type Utxo
theborakompanioni Aug 11, 2024
128608c
chore: align button styles in modals
theborakompanioni Aug 13, 2024
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
2 changes: 1 addition & 1 deletion public/sprite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 18 additions & 18 deletions src/components/Balance.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
--jam-balance-deemphasize-color: #1153b5;
}

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

Expand Down Expand Up @@ -53,32 +53,32 @@
justify-content: center;
}

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

/** Integer Part **/
.bitcoinAmount[data-integer-part-is-zero="true"] .integerPart,
.bitcoinAmountColor[data-integer-part-is-zero="true"] .integerPart,
/** Decimal Point **/
.bitcoinAmount[data-integer-part-is-zero="true"] .decimalPoint,
.bitcoinAmount[data-fractional-part-starts-with-zero="true"] .decimalPoint,
.bitcoinAmountColor[data-integer-part-is-zero="true"] .decimalPoint,
.bitcoinAmountColor[data-fractional-part-starts-with-zero="true"] .decimalPoint,
/** Fractional Part **/
.bitcoinAmount[data-integer-part-is-zero="false"] .fractionalPart,
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]),
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmount[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="false"] .fractionalPart,
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]),
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
.bitcoinAmountColor[data-integer-part-is-zero="true"] .fractionalPart :nth-child(1):is(span[data-digit="0"]) + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"] + span[data-digit="0"],
/** Symbol */
.bitcoinAmount[data-raw-value="0"] + .bitcoinSymbol {
.bitcoinAmountColor[data-raw-value="0"] + .bitcoinSymbol {
color: var(--jam-balance-deemphasize-color);
}

.satsAmount[data-raw-value='0'],
.satsAmount[data-raw-value='0'] + .satsSymbol {
.satsAmountColor[data-raw-value='0'],
.satsAmountColor[data-raw-value='0'] + .satsSymbol {
color: var(--jam-balance-deemphasize-color);
}
20 changes: 10 additions & 10 deletions src/components/Balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ interface BalanceComponentProps {
symbol?: JSX.Element
showSymbol?: boolean
frozen?: boolean
isColorChange?: boolean
colored?: boolean
frozenSymbol?: boolean
}

const BalanceComponent = ({
symbol,
showSymbol = true,
frozen = false,
isColorChange = false,
colored = true,
frozenSymbol = true,
children,
}: PropsWithChildren<BalanceComponentProps>) => {
return (
<span
className={classNames('balance-hook', 'd-inline-flex align-items-center', {
[styles.frozen]: frozen,
[styles.balance]: !isColorChange,
[styles.balanceColor]: colored,
})}
>
{children}
Expand All @@ -69,7 +69,7 @@ const DECIMAL_POINT_CHAR = '.'

type BitcoinBalanceProps = Omit<BalanceComponentProps, 'symbol'> & { value: number }

const BitcoinBalance = ({ value, ...props }: BitcoinBalanceProps) => {
const BitcoinBalance = ({ value, colored = true, ...props }: BitcoinBalanceProps) => {
const numberString = formatBtc(value)
const [integerPart, fractionalPart] = numberString.split(DECIMAL_POINT_CHAR)

Expand All @@ -78,10 +78,10 @@ const BitcoinBalance = ({ value, ...props }: BitcoinBalanceProps) => {
const fractionalPartStartsWithZero = fractionPartArray[0] === '0'

return (
<BalanceComponent symbol={BTC_SYMBOL} {...props}>
<BalanceComponent symbol={BTC_SYMBOL} colored={colored} {...props}>
<span
className={classNames(`slashed-zeroes`, {
[styles.bitcoinAmount]: !props.isColorChange,
className={classNames(`slashed-zeroes`, styles.bitcoinAmount, styles.bitcoinAmountSpacing, {
[styles.bitcoinAmountColor]: colored,
})}
data-testid="bitcoin-amount"
data-integer-part-is-zero={integerPartIsZero}
Expand All @@ -105,11 +105,11 @@ const BitcoinBalance = ({ value, ...props }: BitcoinBalanceProps) => {

type SatsBalanceProps = Omit<BalanceComponentProps, 'symbol'> & { value: number }

const SatsBalance = ({ value, ...props }: SatsBalanceProps) => {
const SatsBalance = ({ value, colored = true, ...props }: SatsBalanceProps) => {
return (
<BalanceComponent symbol={SAT_SYMBOL} {...props}>
<BalanceComponent symbol={SAT_SYMBOL} colored={colored} {...props}>
<span
className={classNames(`slashed-zeroes`, { [styles.satsAmount]: !props.isColorChange })}
className={classNames(`slashed-zeroes`, { [styles.satsAmountColor]: colored })}
data-testid="sats-amount"
data-raw-value={value}
>
Expand Down
32 changes: 32 additions & 0 deletions src/components/Divider.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.dividerContainer {
display: flex;
justify-content: space-between;
align-items: center;
}

.dividerContainer .dividerLine {
margin: 0;
width: 50%;
flex-grow: 0;
flex-shrink: 1;
}

.dividerContainer .dividerButton {
display: flex;
justify-content: center;
align-items: center;
margin: 0 1rem;
flex-shrink: 0;
flex-grow: 1;
color: var(--bs-body-color);
cursor: pointer;
background-color: transparent;
border: 1px solid var(--bs-body-color);
border-radius: 50%;
width: 2rem;
height: 2rem;
}

.dividerContainer .dividerButton:disabled {
cursor: not-allowed;
}
27 changes: 27 additions & 0 deletions src/components/Divider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as rb from 'react-bootstrap'
import classNames from 'classnames'
import Sprite from './Sprite'
import styles from './Divider.module.css'

type DividerProps = rb.ColProps & {
toggled: boolean
onToggle: (current: boolean) => void
disabled?: boolean
className?: string
}

export default function Divider({ toggled, onToggle, disabled, className, ...colProps }: DividerProps) {
return (
<rb.Row className={classNames('d-flex', 'justify-content-center', className)}>
<rb.Col xs={12} {...colProps}>
<div className={styles.dividerContainer}>
<hr className={styles.dividerLine} />
<button className={styles.dividerButton} disabled={disabled} onClick={() => onToggle(toggled)}>
<Sprite symbol={toggled ? 'caret-up' : 'caret-down'} width="20" height="20" />
</button>
<hr className={styles.dividerLine} />
</div>
</rb.Col>
</rb.Row>
)
}
10 changes: 8 additions & 2 deletions src/components/JarSelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,15 @@ export default function JarSelectorModal({
</rb.Modal.Body>
<rb.Modal.Footer className={styles.modalFooter}>
<rb.Button variant="light" onClick={cancel} className="d-flex justify-content-center align-items-center">
{t('modal.confirm_button_reject')}
<Sprite symbol="cancel" width="26" height="26" />
<div>{t('modal.confirm_button_reject')}</div>
</rb.Button>
<rb.Button disabled={isConfirming || selectedJar === undefined} variant="dark" onClick={confirm}>
<rb.Button
disabled={isConfirming || selectedJar === undefined}
variant="dark"
onClick={confirm}
className="flex-1 d-flex justify-content-center align-items-center"
>
{isConfirming ? (
<>
<rb.Spinner as="span" animation="border" size="sm" role="status" />
Expand Down
33 changes: 0 additions & 33 deletions src/components/MainWalletView.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,36 +27,3 @@
width: 100%;
height: 3.5rem;
}

.jarsDividerContainer {
display: flex;
justify-content: space-between;
align-items: center;
}

.jarsDividerContainer .dividerLine {
margin: 0;
width: 50%;
flex-grow: 0;
flex-shrink: 1;
}

.jarsDividerContainer .dividerButton {
display: flex;
justify-content: center;
align-items: center;
margin: 0 1rem;
flex-shrink: 0;
flex-grow: 1;
color: var(--bs-body-color);
cursor: pointer;
background-color: transparent;
border: 1px solid var(--bs-body-color);
border-radius: 50%;
width: 2rem;
height: 2rem;
}

.jarsDividerContainer .dividerButton:disabled {
cursor: not-allowed;
}
23 changes: 8 additions & 15 deletions src/components/MainWalletView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ExtendedLink } from './ExtendedLink'
import { JarDetailsOverlay } from './jar_details/JarDetailsOverlay'
import { Jars } from './Jars'
import styles from './MainWalletView.module.css'
import Divider from './Divider'

interface WalletHeaderProps {
walletName: string
Expand Down Expand Up @@ -226,21 +227,13 @@ export default function MainWalletView({ wallet }: MainWalletViewProps) {
</div>
</rb.Row>
</rb.Collapse>
<rb.Row className="d-flex justify-content-center">
<rb.Col xs={showJars ? 12 : 10} md={showJars ? 12 : 8}>
<div className={styles.jarsDividerContainer}>
<hr className={styles.dividerLine} />
<button
className={styles.dividerButton}
disabled={serviceInfo?.rescanning}
onClick={() => setShowJars((current) => !current)}
>
<Sprite symbol={showJars ? 'caret-up' : 'caret-down'} width="20" height="20" />
</button>
<hr className={styles.dividerLine} />
</div>
</rb.Col>
</rb.Row>
<Divider
toggled={showJars}
onToggle={() => setShowJars((current) => !current)}
disabled={serviceInfo?.rescanning}
xs={showJars ? 12 : 10}
md={showJars ? 12 : 8}
/>
</div>
</div>
)
Expand Down
10 changes: 5 additions & 5 deletions src/components/Modal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,36 @@
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.25) !important;
}

.modal-header {
.modalHeader {
display: flex !important;
justify-content: center !important;
background-color: transparent !important;
border: none !important;
padding: 1.25rem 1.25rem 0 1.25rem !important;
}

.modal-title {
.modalTitle {
font-size: 1.3rem !important;
font-weight: 600 !important;
color: var(--bs-body-color) !important;
}

.modal-body {
.modalBody {
text-align: center !important;
font-size: 1rem !important;
font-weight: 400 !important;
padding: 0.25rem 1.25rem 1rem 1.25rem !important;
}

.modal-footer {
.modalFooter {
display: flex !important;
justify-content: center !important;
gap: 1rem;
background-color: transparent !important;
padding: 1rem 1.25rem 1.25rem 1.25rem !important;
}

.modal-footer :global .btn {
.modalFooter :global .btn {
--bs-btn-border-color: var(--bs-border-color);
flex-grow: 1;
min-height: 2.8rem;
Expand Down
Loading