Skip to content

Commit

Permalink
Add fixed border-radius
Browse files Browse the repository at this point in the history
  • Loading branch information
aditsch committed Mar 28, 2024
1 parent 5033543 commit 16acc96
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions src/components/interface/Inputs/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export interface TextInputProps extends React.InputHTMLAttributes<HTMLInputEleme
error?: string;
optional?: string;
inputSize?: 'small' | 'medium' | 'large';
borderRadius?: number;
}

const largeSize = css`
Expand Down Expand Up @@ -44,22 +43,16 @@ export const inputSizes = {
small: smallSize,
};

export const inputBorderRadius = {
large: 12,
medium: 12,
small: 10,
};

const StyledTextInput = styled.input<{ error: boolean; inputSize?: string; borderRadius?: number }>`
const StyledTextInput = styled.input<{ error: boolean; inputSize?: string }>`
${({ inputSize = 'large' }) => inputSizes[inputSize]};
${({ theme, borderRadius, error }) => `
${({ theme, error }) => `
padding: 0 16px;
gap: 10px;
background: ${theme.colors.BACKGROUND};
border: 1px solid ${error ? theme.colors.ERROR : theme.colors.BORDER};
border-radius: ${`${borderRadius}px`};
border-radius: 50px;
color: ${error ? theme.colors.ERROR : theme.colors.TEXT}};
::placeholder {
Expand Down Expand Up @@ -103,27 +96,14 @@ color: ${theme.colors.SECONDARY_TEXT};
`}
`;

const TextInput = ({
label,
error,
optional,
inputSize,
borderRadius,
...props
}: TextInputProps) => {
const _borderRadius = borderRadius >= 0 ? borderRadius : inputBorderRadius[inputSize || 'large'];
const TextInput = ({ label, error, optional, inputSize, ...props }: TextInputProps) => {
return (
<Flex flexFlow="column" fullWidth>
<Flex flexFlow="row" fullWidth>
{label ? <Label htmlFor={props.id}>{label}</Label> : null}{' '}
{optional ? <Optional>{optional}</Optional> : null}
</Flex>
<StyledTextInput
error={!!error}
inputSize={inputSize}
borderRadius={_borderRadius}
{...props}
/>
<StyledTextInput error={!!error} inputSize={inputSize} {...props} />
<ErrorMessage>
{error && (
<>
Expand Down

0 comments on commit 16acc96

Please sign in to comment.