hubl/src/components/hubl-status.js

30 lines
956 B
JavaScript
Raw Normal View History

2020-06-18 18:02:54 +00:00
import { widgetFactory } from 'https://unpkg.com/@startinblox/core@0.10/dist/widgets/widget-factory.js';
import { importCSS } from 'https://unpkg.com/@startinblox/core@0.10/dist/libs/helpers.js';
2020-05-19 16:22:00 +00:00
import SlimSelect from 'https://dev.jspm.io/slim-select@1.23';
const HublStatus = widgetFactory(
'hubl-status',
`<label>
<div>\${label}</div>
<select
data-holder
name="\${name}">
<option
value="Public"
\${value=="Public" ? 'selected' : ''}>Public</option>
<option
value="Private"
\${value=="Private" ? 'selected' : ''}>Privé</option>
</select>
</label>`,
'',
formWidget => {
let select = formWidget.querySelector('select');
if (!select) return;
const slimSelect = new SlimSelect({select: select});
importCSS('https://dev.jspm.io/slim-select/dist/slimselect.min.css');
select.addEventListener('change', () => slimSelect.render());
},
);
export { HublStatus }