mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-01 18:00:26 +00:00
63 lines
1.1 KiB
TypeScript
63 lines
1.1 KiB
TypeScript
import React, { FC } from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
interface Props {
|
|
placeholder?: string;
|
|
type: 'text' | 'email';
|
|
variant: 'small' | 'big';
|
|
name: string;
|
|
value: string;
|
|
required?: boolean;
|
|
onChange?: (event: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
|
}
|
|
|
|
const SmallField = styled.input`
|
|
border: none;
|
|
padding: 1rem;
|
|
background: var(--secondary-background);
|
|
color: var(--text);
|
|
`;
|
|
|
|
const BigField = styled.textarea`
|
|
resize: none;
|
|
border: none;
|
|
padding: 1rem;
|
|
background: var(--secondary-background);
|
|
color: var(--text);
|
|
`;
|
|
|
|
const Input: FC<Props & { className?: string }> = ({
|
|
type = 'text',
|
|
variant = 'small',
|
|
name,
|
|
value,
|
|
required,
|
|
placeholder,
|
|
className,
|
|
onChange
|
|
}) => {
|
|
return variant === 'small' ? (
|
|
<SmallField
|
|
type={type}
|
|
name={name}
|
|
value={value}
|
|
required={required}
|
|
placeholder={placeholder}
|
|
className={className}
|
|
onChange={onChange}
|
|
/>
|
|
) : (
|
|
<BigField
|
|
name={name}
|
|
value={value}
|
|
required={required}
|
|
placeholder={placeholder}
|
|
className={className}
|
|
onChange={onChange}
|
|
rows={3}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default Input;
|