2022-03-15 17:59:45 +00:00
|
|
|
import { nanoid } from "nanoid";
|
2022-02-18 08:20:47 +00:00
|
|
|
import PropTypes from "prop-types";
|
2022-03-15 17:59:45 +00:00
|
|
|
import { useMemo } from "react";
|
|
|
|
|
|
|
|
export const TextInputBasic = ({ label, placeholder, ...props }) => {
|
|
|
|
const id = useMemo(() => `input-${nanoid()}`, []);
|
2022-02-17 11:53:32 +00:00
|
|
|
|
|
|
|
return (
|
2022-03-15 17:59:45 +00:00
|
|
|
<div className="flex flex-col w-full gap-1">
|
|
|
|
<label className="font-sans uppercase text-palette-300 text-xs" htmlFor={id}>
|
|
|
|
{label}
|
|
|
|
</label>
|
2022-02-17 11:53:32 +00:00
|
|
|
<input
|
2022-03-15 17:59:45 +00:00
|
|
|
id={id}
|
2022-02-17 11:53:32 +00:00
|
|
|
placeholder={placeholder}
|
2022-03-15 17:59:45 +00:00
|
|
|
className="w-full py-2 px-4 bg-palette-100 rounded-sm placeholder:text-palette-200 focus:outline outline-1 outline-palette-200"
|
|
|
|
{...props}
|
2022-02-17 11:53:32 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-02-18 08:20:47 +00:00
|
|
|
);
|
|
|
|
};
|
2022-02-17 11:53:32 +00:00
|
|
|
|
|
|
|
TextInputBasic.propTypes = {
|
|
|
|
/**
|
|
|
|
* Icon to place in text input
|
|
|
|
*/
|
|
|
|
label: PropTypes.string,
|
|
|
|
/**
|
|
|
|
* Input placeholder
|
|
|
|
*/
|
|
|
|
placeholder: PropTypes.string,
|
2022-02-18 08:20:47 +00:00
|
|
|
};
|