feat: enhance search input
This commit is contained in:
parent
d56e33ece0
commit
f860fed456
@ -9,7 +9,6 @@ import axios from "axios"
|
|||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
import { useSession } from "next-auth/react"
|
import { useSession } from "next-auth/react"
|
||||||
import { DropdownMenu } from "radix-ui"
|
import { DropdownMenu } from "radix-ui"
|
||||||
import Link from "next/link"
|
|
||||||
import { icons } from "#/assets/icons"
|
import { icons } from "#/assets/icons"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import Form from "#/components/form/form"
|
import Form from "#/components/form/form"
|
||||||
@ -423,7 +422,11 @@ export default function Admins (){
|
|||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FloatingLabelInput name="search" placeholder="Effectuer une recherche" type="text" onChange={(value) => table.setGlobalFilter(value)} />
|
<FloatingLabelInput name="search" placeholder="Effectuer une recherche" type="search" onChange={(value) => table.setGlobalFilter(value)}
|
||||||
|
button={
|
||||||
|
<Image alt="" src={icons.filterIcon} className="cursor-pointer" />
|
||||||
|
}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -57,9 +57,16 @@ body {
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-floating {
|
.btn-floating-right {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 12px;
|
right: 8px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-floating-left {
|
||||||
|
position: absolute;
|
||||||
|
left: 8px;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export default function FloatingLabelInput({
|
|||||||
<option key={index} value={option}>{option}</option>
|
<option key={index} value={option}>{option}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{button && <div className="btn-floating">{button}</div>}
|
{button && <div className="btn-floating-right">{button}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ export default function FloatingLabelInput({
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => setShowPassword(!showPassword)}
|
onClick={() => setShowPassword(!showPassword)}
|
||||||
className="btn-floating text-gray-500 hover:text-gray-700 focus:outline-none"
|
className="btn-floating-right text-gray-500 hover:text-gray-700 focus:outline-none"
|
||||||
>
|
>
|
||||||
{showPassword ? (
|
{showPassword ? (
|
||||||
<Image
|
<Image
|
||||||
@ -80,7 +80,26 @@ export default function FloatingLabelInput({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
case 'search':
|
||||||
|
return (
|
||||||
|
<div className="relative w-full">
|
||||||
|
<div className='btn-floating-left'>
|
||||||
|
<Image alt='' src={icons.searchIcon} />
|
||||||
|
</div>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder={placeholder}
|
||||||
|
className="focus:ring-2 focus:ring-blue-500 outline-none px-10 py-3 w-full text-black border border-[#d1d5dc] rounded-full"
|
||||||
|
name={name}
|
||||||
|
defaultValue={defaultValue}
|
||||||
|
onChange={handleChange}
|
||||||
|
/>
|
||||||
|
{button && <div className="btn-floating-right">{button}</div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (
|
return (
|
||||||
<div className="relative w-full">
|
<div className="relative w-full">
|
||||||
@ -92,7 +111,7 @@ export default function FloatingLabelInput({
|
|||||||
defaultValue={defaultValue}
|
defaultValue={defaultValue}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
/>
|
/>
|
||||||
{button && <div className="absolute right-0 top-1/2 transform -translate-y-1/2">{button}</div>}
|
{button && <div className="btn-floating-right">{button}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { ZodSchema } from "zod";
|
|||||||
export interface FloatingLabelInputProps {
|
export interface FloatingLabelInputProps {
|
||||||
label?: string;
|
label?: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
type: 'text' | 'password' | 'select' | 'email' | 'number' | 'hidden';
|
type: 'text' | 'password' | 'select' | 'email' | 'number' | 'hidden' | 'search';
|
||||||
options?: string[];
|
options?: string[];
|
||||||
button?: React.ReactNode;
|
button?: React.ReactNode;
|
||||||
showPasswordToggle?: boolean;
|
showPasswordToggle?: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user