Created
August 12, 2022 20:50
-
-
Save kristoferjoseph/899ab652af3f0c5dfd6cca7f80a4ff87 to your computer and use it in GitHub Desktop.
text input prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function InputText({ html, state, utils={} }) { | |
const { attrs={} } = state | |
const { | |
description='', | |
label='', | |
name='', | |
pattern='', | |
placeholder='', | |
value='', | |
min='', | |
max='', | |
type='', | |
} = attrs | |
const booleanAttr = (attrs, attr) => Object.keys(attrs).includes(attr) ? attr : '' | |
const autofocus = booleanAttr(attrs, 'autofocus') | |
const disabled = booleanAttr(attrs, 'disabled') | |
return html` | |
<label | |
for="text" | |
class=" | |
radius1 | |
" | |
> | |
<p class="pb-2"> | |
${label} | |
</p> | |
<input | |
type="text" | |
class="p-3 mb-2" | |
name="${name}" | |
value="${value}" | |
${autofocus} | |
${disabled} | |
> | |
<p> | |
${description} | |
</p> | |
</label> | |
` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment