Added input component

This commit is contained in:
Patrick Alvin Alcala 2025-09-02 11:03:51 +08:00
parent 4774e8b51f
commit 69818aaf6d
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,3 @@
.input
font-size: 1rem
padding: 0.5rem 1rem

View file

@ -0,0 +1,27 @@
import './Input.sass'
import { createSignal } from 'solid-js'
interface Props {
placeholder?: string
value?: string
onChange?: (value: string) => void
}
export default (props: Props) => {
const [inputValue, setInputValue] = createSignal(props.value || '')
const handleChange = (event: Event) => {
const target = event.target as HTMLInputElement
const newValue = target.value
setInputValue(newValue)
if (props.onChange) {
props.onChange(newValue)
}
}
return (
<>
<input class="input" type="text" placeholder={props.placeholder} value={inputValue()} onInput={handleChange} />
</>
)
}