jiro-ui
Version:
A Mithril.js UI library based from construct-ui
48 lines (45 loc) • 1.02 kB
text/typescript
import m from 'mithril';
import { Example } from '@shared/examples';
import { CustomSelect, ListItem, Icon, Icons, IOption } from '@/';
const EXAMPLE_SRC = 'components/custom-select/examples/itemRender.ts';
const options = [
{
label: 'First',
value: '1'
},
{
label: 'Second',
value: '2',
disabled: true
},
{
label: 'Third',
value: '3'
},
{
label: 'Fourth',
value: '4'
}
];
export class CustomSelectRenderExample {
public view() {
return m(Example, { src: EXAMPLE_SRC }, [
m(CustomSelect, {
triggerAttrs: {
align: 'left',
style: 'width: 300px'
},
defaultValue: '3',
itemRender: (item, isSelected, index) => m(ListItem, {
contentLeft: m(Icon, {
name: index % 2 ? Icons.FILE_PLUS : Icons.USERS
}),
style: index % 2 ? 'color: red' : undefined,
label: (item as IOption).label,
selected: isSelected
}),
options
})
]);
}
}