Added input component
This commit is contained in:
parent
4774e8b51f
commit
69818aaf6d
2 changed files with 30 additions and 0 deletions
3
fwt/components/Input/Input.sass
Normal file
3
fwt/components/Input/Input.sass
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
.input
|
||||||
|
font-size: 1rem
|
||||||
|
padding: 0.5rem 1rem
|
||||||
27
fwt/components/Input/Input.tsx
Normal file
27
fwt/components/Input/Input.tsx
Normal 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} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue