Skip to content

Commit

Permalink
feat(mellow-react): work on InputBase component
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Sep 19, 2024
1 parent 31746e6 commit b9dc475
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
41 changes: 41 additions & 0 deletions templates/mellow-react/assets/js/components/InputBase.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export default function InputBase({
value,
onChange,
label,
id,
icon,
suffix,
...props
}) {
return (
<div className="relative">
{label && (
<label htmlFor={id} className="mb-1 block text-lg">
{label}
</label>
)}
<div className="relative">
{Icon && (
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400">
<Icon className="h-5 w-5" />
</span>
)}
<input
ref={ref}
id={id}
className={`block w-full rounded-lg border border-gray-300 bg-white py-2 ${
Icon ? 'pl-10' : 'pl-3'
} pr-3 shadow-sm placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 ${className}`}
value={value}
onChange={onChange}
{...props}
/>
{suffix && (
<span className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-400">
{suffix}
</span>
)}
</div>
</div>
)
}
11 changes: 0 additions & 11 deletions templates/mellow-react/assets/js/pages/example.jsx

This file was deleted.

0 comments on commit b9dc475

Please sign in to comment.