mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
feat(dashboard): add a text Input matching the console select
Every text field in the console restyles a bare input by hand, each a little differently. A toolbar that mixes a text filter with the new Select needs the two at the same height, border and focus ring, so the styling lives in one place next to the Select instead of being copied. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
3b1302ba8e
commit
f500aa955a
2 files changed
+38
No files matched your search
+21
@@ -0,0 +1,21 @@
|
||||
import { describe, it, expect, vi } from "vitest"
|
||||
import { render, screen } from "@testing-library/react"
|
||||
import userEvent from "@testing-library/user-event"
|
||||
import { Input } from "./input.tsx"
|
||||
|
||||
describe("Input", () => {
|
||||
it("is a labelled text box that reports what is typed", async () => {
|
||||
const onValueChange = vi.fn()
|
||||
render(<Input aria-label="Filter" defaultValue="" onValueChange={onValueChange} />)
|
||||
|
||||
await userEvent.type(screen.getByRole("textbox", { name: "Filter" }), "x")
|
||||
|
||||
expect(onValueChange).toHaveBeenCalledWith("x", expect.anything())
|
||||
})
|
||||
|
||||
it("keeps the caller's classes next to its own", () => {
|
||||
render(<Input aria-label="Filter" className="font-mono" />)
|
||||
|
||||
expect(screen.getByRole("textbox", { name: "Filter" })).toHaveClass("font-mono", "rounded-lg")
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Input as InputPrimitive } from "@base-ui/react/input"
|
||||
import { cn } from "@cozystack/ui"
|
||||
|
||||
function Input({ className, ...props }: InputPrimitive.Props) {
|
||||
return (
|
||||
<InputPrimitive
|
||||
data-slot="input"
|
||||
className={cn(
|
||||
"h-7 w-full min-w-0 rounded-lg border border-slate-300 bg-white px-2.5 text-xs text-slate-900 shadow-xs outline-none transition-colors placeholder:text-slate-400 focus-visible:ring-2 focus-visible:ring-slate-400 focus-visible:ring-offset-2 data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Input }
|
||||
Reference in new issue
Block a user