Skip to content

Commit

Permalink
feat: limit UI upgrade 3 (#5283)
Browse files Browse the repository at this point in the history
* feat: meditating cow bg color

* feat: full amount on trimmed amounts

---------

Co-authored-by: Leandro <[email protected]>
  • Loading branch information
fairlighteth and alfetopito authored Jan 16, 2025
1 parent 0e6646d commit 653f42f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const Input = React.memo(function InnerInput({
placeholder,
prependSymbol,
onFocus,
pattern: _pattern,
...rest
}: {
value: string | number
Expand All @@ -73,10 +74,20 @@ export const Input = React.memo(function InnerInput({
fontSize?: string
align?: 'right' | 'left'
prependSymbol?: string | undefined
pattern?: string
} & Omit<React.HTMLProps<HTMLInputElement>, 'ref' | 'onChange' | 'as'>) {
// Keep the input strictly as a string
const stringValue = typeof value === 'string' ? value : String(value)

const titleRef = React.useCallback(
(node: HTMLInputElement | null) => {
if (node) {
node.title = node.scrollWidth > node.clientWidth ? stringValue : ''
}
},
[stringValue],
)

const enforcer = (nextUserInput: string) => {
// Always allow empty input
if (nextUserInput === '') {
Expand Down Expand Up @@ -118,6 +129,7 @@ export const Input = React.memo(function InnerInput({
)}
<StyledInput
{...rest}
ref={titleRef}
value={stringValue}
readOnly={readOnly}
onFocus={(event) => {
Expand All @@ -142,8 +154,6 @@ export const Input = React.memo(function InnerInput({
autoCorrect="off"
// Keep type="text" to preserve trailing decimals
type="text"
// Remove pattern to prevent browser validation interference
pattern=""
placeholder={placeholder || '0'}
// minLength to 0 so empty strings are always valid
minLength={0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ const Content = styled.div`
position: absolute;
top: 0;
left: 0;
background: var(${UI.COLOR_PRIMARY});
opacity: 0.16;
background: var(${UI.COLOR_PAPER_DARKER});
width: var(--size);
height: var(--size);
border-radius: var(--size);
Expand Down

0 comments on commit 653f42f

Please sign in to comment.