Skip to content

Instantly share code, notes, and snippets.

@kristoferjoseph
Created August 12, 2022 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kristoferjoseph/899ab652af3f0c5dfd6cca7f80a4ff87 to your computer and use it in GitHub Desktop.
Save kristoferjoseph/899ab652af3f0c5dfd6cca7f80a4ff87 to your computer and use it in GitHub Desktop.
text input prototype
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