-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
355 - Purchase Confirmation Services (#558)
* various changes * main-container-header mixin * did everything outside of the purchaseConfirmationService page * flip focus and hover color for DropdownMenuButton * added the select input * added the checkbox logic * fixed a bug where if you're switching banks, the page did not go back to 1 * keep track on the indices of the selectedValidators, so that you can order them later by that * PaginatedTable * Updated the PurchaseConfirmationServicesModal * Testing connection in the beginning * Some style changes * fetch bankConfig at the beginning for both BulkPurchaseConfirmationServicesModal and PurchaseConfirmationServicesModal * disable amount input for PVs and validators without daily_rates (at least until the BE is updated) * done everything except handleSubmit * disable submit button when entered amount exceeds available balance * finished handleSubmit * remove 'active' from primaryValidator * use getBankTxFee for the bulk purchase modal * bankConfig change * fixed a bug where bank tx's fee was wrong if the selectedBank was the activeBank
- Loading branch information
Showing
144 changed files
with
2,281 additions
and
948 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
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
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
2 changes: 1 addition & 1 deletion
2
.../components/FormElements/Radio/Radio.scss → ...ements/CheckableInput/CheckableInput.scss
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.Radio { | ||
.CheckableInput { | ||
color: var(--color-gray-700); | ||
display: inline-flex; | ||
|
||
|
103 changes: 103 additions & 0 deletions
103
src/renderer/components/FormElements/CheckableInput/index.tsx
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,103 @@ | ||
import React, {FC, useEffect, useMemo, useRef} from 'react'; | ||
import clsx from 'clsx'; | ||
|
||
import Icon, {IconType} from '@renderer/components/Icon'; | ||
import {getCustomClassNames} from '@renderer/utils/components'; | ||
|
||
import './CheckableInput.scss'; | ||
|
||
export interface BaseCheckableInputProps { | ||
checked: boolean; | ||
className?: string; | ||
disabled?: boolean; | ||
error?: boolean; | ||
focused?: boolean; | ||
name?: string; | ||
onClick?(e?: React.MouseEvent<HTMLDivElement, MouseEvent>): void; | ||
onKeyDown?(e?: React.KeyboardEvent<HTMLDivElement>): void; | ||
size?: number; | ||
totalSize?: number; | ||
unfocusable?: boolean; | ||
value: string; | ||
} | ||
|
||
export interface CheckableInputType { | ||
type: 'checkbox' | 'radio'; | ||
} | ||
|
||
const CheckableInput: FC<BaseCheckableInputProps & CheckableInputType> = ({ | ||
checked, | ||
className, | ||
disabled = false, | ||
error = false, | ||
focused = false, | ||
name, | ||
onClick, | ||
onKeyDown, | ||
size, | ||
totalSize = size, | ||
unfocusable = false, | ||
type, | ||
value, | ||
}) => { | ||
const iconRef = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
if (focused) { | ||
iconRef.current?.focus(); | ||
} | ||
}, [focused, iconRef]); | ||
|
||
const checkedIcon = useMemo(() => { | ||
if (type === 'radio') return IconType.radioboxMarked; | ||
return IconType.checkboxMarked; | ||
}, [type]); | ||
|
||
const uncheckedIcon = useMemo(() => { | ||
if (type === 'radio') return IconType.radioboxBlank; | ||
return IconType.checkboxBlankOutline; | ||
}, [type]); | ||
|
||
const handleClick = onClick | ||
? (e?: React.MouseEvent<HTMLDivElement, MouseEvent>): void => { | ||
// blur if clicked. Don't blur if you pressed Enter on it. | ||
if (e?.detail === 1) { | ||
iconRef.current?.blur(); | ||
} | ||
onClick(e); | ||
} | ||
: undefined; | ||
|
||
return ( | ||
<> | ||
<Icon | ||
className={clsx('CheckableInput', className, { | ||
'CheckableInput--checked': checked, | ||
'CheckableInput--error': error, | ||
...getCustomClassNames(className, '--checked', checked), | ||
...getCustomClassNames(className, '--error', error), | ||
})} | ||
disabled={disabled} | ||
icon={checked ? checkedIcon : uncheckedIcon} | ||
onClick={handleClick} | ||
onKeyDown={onKeyDown} | ||
ref={iconRef} | ||
size={size} | ||
totalSize={totalSize} | ||
unfocusable={unfocusable} | ||
/> | ||
<input | ||
className="CheckableInput__input" | ||
checked={checked} | ||
disabled={disabled} | ||
id={name || value} | ||
name={name || value} | ||
readOnly | ||
type={type} | ||
value={value} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default CheckableInput; |
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,22 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
|
||
import React, {FC} from 'react'; | ||
import clsx from 'clsx'; | ||
|
||
import CheckableInput, {BaseCheckableInputProps} from '../CheckableInput'; | ||
|
||
export type BaseCheckboxProps = BaseCheckableInputProps; | ||
|
||
const Checkbox: FC<BaseCheckboxProps> = ({className, size = 22, ...props}) => { | ||
return ( | ||
<CheckableInput | ||
{...props} | ||
className={clsx('Checkbox', className)} | ||
size={size} | ||
totalSize={size + 2} | ||
type="checkbox" | ||
/> | ||
); | ||
}; | ||
|
||
export default Checkbox; |
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 |
---|---|---|
@@ -1,76 +1,14 @@ | ||
import React, {FC, useEffect, useRef} from 'react'; | ||
import clsx from 'clsx'; | ||
|
||
import Icon, {IconType} from '@renderer/components/Icon'; | ||
import {getCustomClassNames} from '@renderer/utils/components'; | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
|
||
import './Radio.scss'; | ||
|
||
export interface BaseRadioProps { | ||
checked: boolean; | ||
className?: string; | ||
disabled?: boolean; | ||
error?: boolean; | ||
focused?: boolean; | ||
name?: string; | ||
onClick?(e?: React.MouseEvent<HTMLDivElement, MouseEvent>): void; | ||
onKeyDown?(e?: React.KeyboardEvent<HTMLDivElement>): void; | ||
size?: number; | ||
unfocusable?: boolean; | ||
value: string; | ||
} | ||
import React, {FC} from 'react'; | ||
import clsx from 'clsx'; | ||
|
||
const Radio: FC<BaseRadioProps> = ({ | ||
checked, | ||
className, | ||
disabled = false, | ||
error = false, | ||
focused = false, | ||
name, | ||
onClick, | ||
onKeyDown, | ||
size = 24, | ||
unfocusable = false, | ||
value, | ||
}) => { | ||
const radioRef = useRef<HTMLDivElement>(null); | ||
import CheckableInput, {BaseCheckableInputProps} from '../CheckableInput'; | ||
|
||
useEffect(() => { | ||
if (focused) { | ||
radioRef.current?.focus(); | ||
} | ||
}, [focused, radioRef]); | ||
export type BaseRadioProps = BaseCheckableInputProps; | ||
|
||
return ( | ||
<> | ||
<Icon | ||
className={clsx('Radio', className, { | ||
'Radio--checked': checked, | ||
'Radio--error': error, | ||
...getCustomClassNames(className, '--checked', checked), | ||
...getCustomClassNames(className, '--error', error), | ||
})} | ||
disabled={disabled} | ||
icon={checked ? IconType.radioboxMarked : IconType.radioboxBlank} | ||
onClick={onClick} | ||
onKeyDown={onKeyDown} | ||
ref={radioRef} | ||
size={size} | ||
totalSize={size} | ||
unfocusable={unfocusable} | ||
/> | ||
<input | ||
className="Radio__input" | ||
checked={checked} | ||
disabled={disabled} | ||
id={name || value} | ||
name={name || value} | ||
readOnly | ||
type="radio" | ||
value={value} | ||
/> | ||
</> | ||
); | ||
const Radio: FC<BaseRadioProps> = ({className, size = 24, ...props}) => { | ||
return <CheckableInput {...props} className={clsx('Radio', className)} size={size} type="radio" />; | ||
}; | ||
|
||
export default Radio; |
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.