Skip to content

Commit

Permalink
feat(app-general): add input error border ui
Browse files Browse the repository at this point in the history
  • Loading branch information
albertodigioacchino committed Feb 11, 2021
1 parent 2b185f5 commit 78f0bfa
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import styled, { css } from 'styled-components';
import { color, ColorProps, variant } from 'styled-system';
import Icon from '../Icon';

export type InputVariants = 'default' | 'clear' | 'clearRound';
export type InputVariants = 'default' | 'defaultError' | 'clear' | 'clearRound';

export const StyledInput = styled.input<{ variant: InputVariants; withIcon?: boolean } & ColorProps>`
width: 100%;
height: 40px;
padding: 5px 10px;
box-sizing: border-box;
border-radius: 4px;
border-radius: 8px;
display: flex;
&:focus {
Expand All @@ -31,6 +31,7 @@ export const StyledInput = styled.input<{ variant: InputVariants; withIcon?: boo
variant({
variants: {
default: theme.input.variants.default,
defaultError: theme.input.variants.defaultError,
clear: theme.input.variants.clear,
clearRound: {
...theme.input.variants.clear,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const PasswordInput = React.forwardRef<HTMLInputElement, Props>(
</LabelContainer>
<Input
ref={ref}
variant="default"
variant={!!errorMessage ? 'defaultError' : 'default'}
iconRight={
<IconButton variant="clearSmall" onClick={toggleType}>
<StyledIcon variant="small">{type === 'password' ? <EyeIcon /> : <HideIcon />}</StyledIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import Box from '../Box';
import React from 'react';
import dropdownArrow from '../../../assets/icons/dropdown-arrow.svg';

export const Select = styled.select`
export const Select = styled.select<{ error?: boolean }>`
width: 100%;
height: 40px;
padding: 5px 10px;
box-sizing: border-box;
border-radius: 4px;
border: 1px solid #d7d2cb;
border-radius: 8px;
border: 1px solid ${props => (props.error ? 'red' : '#d7d2cb')};
&:focus {
outline: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ const SelectInput: React.FC<Props> = ({
{label}
</Typography>
<SelectLoadingWrapper>
<Select disabled={disabled || options.length === 0} name={name} id={name} value={value} onChange={onChange}>
<Select
disabled={disabled || options.length === 0}
name={name}
id={name}
value={value}
onChange={onChange}
error={!!errorMessage}
>
{emptyOption && emptyOptionLabel ? (
<option key="" value="">
{emptyOptionLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TextInput = React.forwardRef<HTMLInputElement, Props>(
) : null}
<Input
ref={ref}
variant="default"
variant={!!errorMessage ? 'defaultError' : 'default'}
disabled={disabled}
placeholder={placeholder}
type={type}
Expand Down
1 change: 1 addition & 0 deletions packages/game-app/src/customeTheme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare module 'styled-components' {
input: {
variants: {
default: object;
defaultError: object;
clear: object;
};
};
Expand Down
3 changes: 3 additions & 0 deletions packages/game-app/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const theme: DefaultTheme = {
default: {
border: '1px solid #D7D2CB',
},
defaultError: {
border: '1px solid red',
},
clear: {
border: 'none',
},
Expand Down

0 comments on commit 78f0bfa

Please sign in to comment.