Start working on input component

This commit is contained in:
Hazem Krimi
2021-04-14 23:08:13 +01:00
parent 3130485051
commit bf30b856bc
3 changed files with 105 additions and 5 deletions
+21 -2
View File
@@ -1,7 +1,26 @@
import { Wrapper } from './styles';
const Input = () => {
return <Wrapper></Wrapper>;
type InputProps = {
className?: string;
color?: 'client' | 'productOwner' | 'developer' | 'admin' | string;
error?: boolean;
errorMessage?: string;
value: string;
label: string;
type: 'text' | 'email' | 'password' | 'file' | 'number';
placeholder?: string;
fullWidth?: boolean;
multiline?: boolean;
iconLeft?: React.SVGProps<SVGSVGElement>;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
};
const Input = ({ type, value, ...props }: InputProps) => {
return (
<Wrapper {...props}>
<input type={type} value={value} />
</Wrapper>
);
};
export default Input;
+82 -2
View File
@@ -1,3 +1,83 @@
import styled from 'styled-components';
import styled, { css } from 'styled-components';
export const Wrapper = styled.div``;
type WrapperProps = {
color?: 'client' | 'productOwner' | 'developer' | 'admin' | string;
error?: boolean;
errorMessage?: string;
fullWidth?: boolean;
multiline?: boolean;
iconLeft?: React.SVGProps<SVGSVGElement>;
};
export const Wrapper = styled.div<WrapperProps>`
display: inline;
border-radius: 5px;
color: ${({ theme }) => theme.colors.black.main};
input {
background: none;
border: none;
color: ${({ theme }) => theme.colors.black.main};
}
${({ color, theme }) => {
if (!color)
return css`
border: 2px solid ${theme.colors.client.light};
`;
switch (color) {
case 'client':
return css`
border: 2px solid ${theme.colors.client.light};
`;
case 'productOwner':
return css`
border: 2px solid ${theme.colors.productOwner.light};
`;
case 'developer':
return css`
border: 2px solid ${theme.colors.developer.light};
`;
case 'admin':
return css`
border: 2px solid ${theme.colors.admin.light};
`;
case 'success':
return css`
border: 2px solid ${theme.colors.success.main};
`;
case 'warning':
return css`
border: 2px solid ${theme.colors.warning.main};
`;
case 'error':
return css`
border: 2px solid ${theme.colors.error.main};
`;
case 'black':
return css`
border: 2px solid ${theme.colors.black.main};
`;
case 'white':
return css`
border: 2px solid ${theme.colors.white.main};
`;
default:
return css`
border: 2px solid ${color};
`;
}
}}
${({ fullWidth }) =>
fullWidth &&
css`
width: 100%;
font-size: 1.25rem;
.icon svg {
width: 1.25rem;
height: 1.25rem;
}
`};
`;