Download js/ui/forms.js from wuosyn/frejya: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/wuosyn/frejya/resolve/main/js/ui/forms.js
- Command line
-
hf download hf://spaces/wuosyn/frejya/js/ui/forms.js
-
curl -L -o forms.js https://huggingface.co/spaces/wuosyn/frejya/resolve/main/js/ui/forms.js
1.15 kB
| // Small form pieces shared by the sheets. | |
| import { h } from './dom.js'; | |
| export const field = (label, control, hint) => h('label', { class: 'field' }, h('span', { class: 'field__label' }, label), control, hint && h('span', { class: 'field__hint' }, hint)); | |
| export function switchRow(label, hint, checked, onChange) { | |
| const input = h('input', { type: 'checkbox', checked, onchange: () => onChange(input.checked) }); | |
| return h('label', { class: 'switch' }, input, h('span', { class: 'switch__track' }), h('span', { class: 'switch__text' }, label, hint && h('small', {}, hint))); | |
| } | |
| export function choice(name, options, current, onChange, row = false) { | |
| return h('div', { class: `choice${row ? ' choice--row' : ''}`, role: 'radiogroup' }, options.map((o) => { | |
| const input = h('input', { type: 'radio', name, value: o.value, checked: o.value === current, onchange: () => onChange(o.value) }); | |
| return h('label', { class: 'choice__item' }, input, h('span', { class: 'choice__card' }, | |
| h('span', { class: 'choice__top' }, o.title, o.tag && h('small', {}, o.tag)), | |
| o.blurb && h('span', { class: 'choice__blurb' }, o.blurb))); | |
| })); | |
| } | |