Skip to content

Commit b0454c6

Browse files
authored
feat: Input component (#26)
* chore: input (#13) * style: format input component * style: using figma style * feat: optional placeholder * style: update input component styles for consistency * fix: biome check * fix: biome check * style: remove unnecessary backdrop blur class from input component * moved in components/ui * fix: requested changes * fix: Biome check
1 parent 7a7cb0b commit b0454c6

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

src/components/ui/input.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import type * as React from "react"
2+
import { cn } from "@/lib/utils"
3+
import { Glass } from "../glass"
4+
5+
type InputProps = React.ComponentProps<"input"> & {
6+
icon?: React.ReactNode
7+
containerClassName?: string
8+
}
9+
10+
function Input({ icon, className, containerClassName, ...inputProps }: InputProps) {
11+
return (
12+
<Glass
13+
className={cn(
14+
"inline-flex w-full items-center gap-2.5",
15+
"border border-white/50",
16+
icon ? "px-6 py-3" : "px-4 py-2",
17+
"rounded-buttonsM",
18+
"bg-background-blur",
19+
containerClassName
20+
)}
21+
>
22+
{icon && <span className="flex h-6 w-6 items-center justify-center shrink-0 text-text-primary"> {icon} </span>}
23+
24+
<input
25+
type={inputProps.type}
26+
placeholder={inputProps.placeholder ?? undefined}
27+
data-slot="input"
28+
{...inputProps}
29+
className={cn(
30+
"w-full bg-transparent border-none outline-none",
31+
"typo-body-medium text-text-primary placeholder:text-text-secondary",
32+
className
33+
)}
34+
/>
35+
</Glass>
36+
)
37+
}
38+
39+
export { Input }

src/lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { type ClassValue, clsx } from "clsx"
2-
import { twMerge } from "tailwind-merge"
2+
import { extendTailwindMerge } from "tailwind-merge"
3+
4+
const twMerge = extendTailwindMerge({
5+
extend: {
6+
theme: {
7+
radius: ["images", "rectangles", "buttonsM", "buttonsL"], // custom rounded classes from figma
8+
},
9+
},
10+
})
311

412
export function cn(...inputs: ClassValue[]) {
513
return twMerge(clsx(inputs))

0 commit comments

Comments
 (0)