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

refactor: externalize send form components #695

Merged
merged 19 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
127f10b
dev: switch to kristapsks backend branch
theborakompanioni Nov 21, 2023
f48a66d
dev: add directSendTxFee to feature toggles
theborakompanioni Nov 21, 2023
3208bfc
dev: add tx_fee to DirectSendRequest
theborakompanioni Nov 22, 2023
fadf42f
refactor: reusable TxFeeInputField component
theborakompanioni Nov 22, 2023
e3f802a
refactor: move validate method of tx fee input field
theborakompanioni Nov 22, 2023
d2c00c7
refactor(wip): split send form into reusable components
theborakompanioni Nov 24, 2023
0286236
refactor: pass loadNewWalletAddress to SendFrom
theborakompanioni Nov 25, 2023
46fe0a5
refactor: fix active state of custom input field in CollaboratorsSele…
theborakompanioni Nov 25, 2023
1509b1a
refactor: submit button in SendForm
theborakompanioni Nov 25, 2023
486a289
fix(styles): clean up SendForm styles
theborakompanioni Nov 25, 2023
faac479
refactor: SourceJarSelector component
theborakompanioni Nov 25, 2023
3813640
fix(ui): do not display number input as textfield on Send page
theborakompanioni Nov 25, 2023
d6be5b2
Revert "dev: switch to kristapsks backend branch"
theborakompanioni Nov 25, 2023
bd15956
fix: remove unused var
theborakompanioni Nov 25, 2023
3ff21b2
fix(style): input groups with validation in SendForm
theborakompanioni Nov 26, 2023
fd34498
fix(style): reduce custom btn colors
theborakompanioni Nov 26, 2023
a803ded
chore(fee): improve fee config modal handling
theborakompanioni Nov 30, 2023
6639f3e
build(deps): update formik from v2.2.9 to v2.4.5
theborakompanioni Nov 30, 2023
a4988c3
ui(send): show form feedback for source jar index value
theborakompanioni Nov 30, 2023
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
56 changes: 45 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@table-library/react-table-library": "^4.0.23",
"bootstrap": "^5.3.2",
"classnames": "^2.3.2",
"formik": "^2.2.9",
"formik": "^2.4.5",
"i18next": "^22.0.4",
"i18next-browser-languagedetector": "^7.0.1",
"qrcode": "^1.5.1",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Accordion = ({
<div>
<rb.Button
variant={settings.theme}
className="d-flex align-items-center bg-transparent border-0 w-100 px-0 py-2"
className="d-flex align-items-center bg-transparent border-0 rounded-0 w-100 px-0 py-2"
onClick={() => setIsOpen((current) => !current)}
disabled={disabled}
>
Expand All @@ -50,7 +50,7 @@ const Accordion = ({
</div>
<Sprite symbol={`caret-${isOpen ? 'up' : 'down'}`} className="ms-1" width="20" height="20" />
</rb.Button>
<hr className="m-0 pb-4 text-secondary" />
<div className="m-0 mb-4 border-0 border-bottom" />
<rb.Collapse in={isOpen}>
<div>{children}</div>
</rb.Collapse>
Expand Down
10 changes: 0 additions & 10 deletions src/components/Earn.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
font-size: 1.2rem;
}

.earn hr {
border-color: rgba(222, 222, 222, 1);
opacity: 100%;
}

:root[data-theme='dark'] .earn hr {
border-color: var(--bs-gray-800);
opacity: 100%;
}

.offerLoader {
height: 10rem;
border-radius: 0.25rem;
Expand Down
2 changes: 1 addition & 1 deletion src/components/MnemonicWordInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const MnemonicWordInput = ({ index, value, setValue, isValid, disabled }: Mnemon
return (
<rb.InputGroup>
<rb.InputGroup.Text className={styles.seedwordIndexBackup}>{index + 1}.</rb.InputGroup.Text>
<rb.FormControl
<rb.Form.Control
type="text"
placeholder={`${t('create_wallet.placeholder_seed_word_input')} ${index + 1}`}
value={value}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modal.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
}

.modal-footer :global .btn {
--bs-btn-border-color: var(--bs-border-color);
flex-grow: 1;
min-height: 2.8rem;
font-weight: 500;
border-color: rgba(222, 222, 222, 1);
}
25 changes: 15 additions & 10 deletions src/components/PaymentConfirmModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import * as rb from 'react-bootstrap'
import Sprite from './Sprite'
import Balance from './Balance'
import { useSettings } from '../context/SettingsContext'
import { FeeValues, useEstimatedMaxCollaboratorFee, toTxFeeValueUnit } from '../hooks/Fees'
import { FeeValues, TxFee, useEstimatedMaxCollaboratorFee } from '../hooks/Fees'
import { ConfirmModal, ConfirmModalProps } from './Modal'
import styles from './PaymentConfirmModal.module.css'
import { AmountSats } from '../libs/JmWalletApi'
import { jarInitial } from './jars/Jar'
import { isValidNumber } from '../utils'

const feeRange: (feeValues: FeeValues) => [number, number] = (feeValues) => {
const feeTargetInSatsPerVByte = feeValues.tx_fees! / 1_000
const feeRange: (txFee: TxFee, txFeeFactor: number) => [number, number] = (txFee, txFeeFactor) => {
if (txFee.unit !== 'sats/kilo-vbyte') {
throw new Error('This function can only be used with unit `sats/kilo-vbyte`')
}
const feeTargetInSatsPerVByte = txFee.value! / 1_000
const minFeeSatsPerVByte = Math.max(1, feeTargetInSatsPerVByte)
const maxFeeSatsPerVByte = feeTargetInSatsPerVByte * (1 + feeValues.tx_fees_factor!)
const maxFeeSatsPerVByte = feeTargetInSatsPerVByte * (1 + txFeeFactor)
return [minFeeSatsPerVByte, maxFeeSatsPerVByte]
}

Expand All @@ -23,15 +26,17 @@ const useMiningFeeText = ({ feeConfigValues }: { feeConfigValues?: FeeValues })

const miningFeeText = useMemo(() => {
if (!feeConfigValues) return null
if (!isValidNumber(feeConfigValues.tx_fees) || !isValidNumber(feeConfigValues.tx_fees_factor)) return null
if (!isValidNumber(feeConfigValues.tx_fees?.value) || !isValidNumber(feeConfigValues.tx_fees_factor)) return null

const unit = toTxFeeValueUnit(feeConfigValues.tx_fees)
if (!unit) {
if (!feeConfigValues.tx_fees?.unit) {
return null
} else if (unit === 'blocks') {
return t('send.confirm_send_modal.text_miner_fee_in_targeted_blocks', { count: feeConfigValues.tx_fees })
} else if (feeConfigValues.tx_fees.unit === 'blocks') {
return t('send.confirm_send_modal.text_miner_fee_in_targeted_blocks', { count: feeConfigValues.tx_fees.value })
} else {
const [minFeeSatsPerVByte, maxFeeSatsPerVByte] = feeRange(feeConfigValues)
const [minFeeSatsPerVByte, maxFeeSatsPerVByte] = feeRange(
feeConfigValues.tx_fees,
feeConfigValues.tx_fees_factor!,
)
const fractionDigits = 2

if (minFeeSatsPerVByte.toFixed(fractionDigits) === maxFeeSatsPerVByte.toFixed(fractionDigits)) {
Expand Down
11 changes: 0 additions & 11 deletions src/components/Receive.module.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
.receive hr {
border-color: rgba(222, 222, 222, 1);
opacity: 100%;
}

:root[data-theme='dark'] .receive hr {
border-color: var(--bs-gray-800);
opacity: 100%;
}

.receive button {
font-weight: 500;
border-color: rgba(222, 222, 222, 1);
}

.receive form input {
Expand Down
13 changes: 13 additions & 0 deletions src/components/Send/AmountInputField.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.inputLoader {
height: 3.5rem;
border-radius: 0.25rem;
}

.input {
height: 3.5rem;
width: 100%;
}

.button {
font-size: 0.875rem !important;
}
Loading