Commit 536de89a authored by Noah Zinsmeister's avatar Noah Zinsmeister Committed by GitHub

replace commas with periods (#815)

* replace commas with periods

* add pattern attribute
parent 199eb8bf
...@@ -27,7 +27,6 @@ const CurrencySelect = styled.button<{ selected: boolean }>` ...@@ -27,7 +27,6 @@ const CurrencySelect = styled.button<{ selected: boolean }>`
align-items: center; align-items: center;
height: 2.2rem; height: 2.2rem;
font-size: 20px; font-size: 20px;
font-family: 'Inter';
font-weight: 500; font-weight: 500;
background-color: ${({ selected, theme }) => (selected ? theme.bg1 : theme.primary1)}; background-color: ${({ selected, theme }) => (selected ? theme.bg1 : theme.primary1)};
color: ${({ selected, theme }) => (selected ? theme.text1 : theme.white)}; color: ${({ selected, theme }) => (selected ? theme.text1 : theme.white)};
......
...@@ -3,18 +3,15 @@ import styled from 'styled-components' ...@@ -3,18 +3,15 @@ import styled from 'styled-components'
import { escapeRegExp } from '../../utils' import { escapeRegExp } from '../../utils'
const StyledInput = styled.input<{ error?: boolean; fontSize?: string; align?: string }>` const StyledInput = styled.input<{ error?: boolean; fontSize?: string; align?: string }>`
color: ${({ error, theme }) => error && theme.red1}; color: ${({ error, theme }) => (error ? theme.red1 : theme.text1)};
color: ${({ theme }) => theme.text1};
width: 0; width: 0;
position: relative; position: relative;
font-size: 24px;
font-weight: 500; font-weight: 500;
font-family: 'Inter', sans-serif;
outline: none; outline: none;
border: none; border: none;
flex: 1 1 auto; flex: 1 1 auto;
background-color: ${({ theme }) => theme.bg1}; background-color: ${({ theme }) => theme.bg1};
font-size: ${({ fontSize }) => fontSize && fontSize}; font-size: ${({ fontSize }) => fontSize ?? '24px'};
text-align: ${({ align }) => align && align}; text-align: ${({ align }) => align && align};
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
...@@ -65,7 +62,8 @@ export const Input = React.memo(function InnerInput({ ...@@ -65,7 +62,8 @@ export const Input = React.memo(function InnerInput({
{...rest} {...rest}
value={value} value={value}
onChange={event => { onChange={event => {
enforcer(event.target.value) // replace commas with periods, because uniswap exclusively uses period as the decimal separator
enforcer(event.target.value.replace(/,/g, '.'))
}} }}
// universal input options // universal input options
inputMode="decimal" inputMode="decimal"
...@@ -74,6 +72,7 @@ export const Input = React.memo(function InnerInput({ ...@@ -74,6 +72,7 @@ export const Input = React.memo(function InnerInput({
autoCorrect="off" autoCorrect="off"
// text-specific options // text-specific options
type="text" type="text"
pattern="^[0-9]*[.,]?[0-9]*$"
placeholder={placeholder || '0.0'} placeholder={placeholder || '0.0'}
minLength={1} minLength={1}
maxLength={79} maxLength={79}
...@@ -83,3 +82,5 @@ export const Input = React.memo(function InnerInput({ ...@@ -83,3 +82,5 @@ export const Input = React.memo(function InnerInput({
}) })
export default Input export default Input
// const inputRegex = RegExp(`^\\d*(?:\\\\[.])?\\d*$`) // match escaped "." characters via in a non-capturing group
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment