How to use the mithril.component function in mithril

To help you get started, we’ve selected a few mithril examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tivac / crucible / src / types / split.js View on Github external
view : function(ctrl, options) {
        var field  = options.field;
        
        return m("div", { class : css.container },
            field.instructions ? m.component(instructions, { field : field.instructions }) : null,
            (field.children || []).map(function(section) {
                return m("div", { class : css.section },
                    m.component(children, assign({}, options, {
                        // Don't want to repeat any incoming class that children might've passed in
                        class  : false,
                        fields : section.children
                    }))
                );
            })
        );
    }
};
github ArthurClemens / polythene / examples / src / app / icon / icon.es6.js View on Github external
}
                }),
                m.component(block, {
                    label: 'Refresh',
                    icon: {
                        svg: {
                            group: 'navigation',
                            name: 'refresh'
                        },
                        class: 'md'
                    }
                })
            ]
        }),

        m.component(titleBlock, {
            title: 'Iconset',
            info: m('p',
                m.trust('SVG icons from <a href="https://github.com/Templarian/MaterialDesign">Templarian / Material Design</a>')
            ),
            content: [
                m.component(block, {
                    label: 'Barcode',
                    icon: {
                        svg: {
                            name: 'barcode',
                            iconSet: 'mdi'
                        },
                        class: 'mdi'
                    }
                }),
                m.component(block, {
github CenterForOpenScience / osf.io / website / static / js / dashboard.js View on Github external
'Select a list below to see the projects. or click ',
                        m('i.fa.fa-bars'),
                        ' button above to toggle.'
                    ])
                ] : '',
                m.component(Collections, ctrl),
                m.component(Filters, {
                    activeFilter : ctrl.activeFilter,
                    updateFilter : ctrl.updateFilter,
                    nameFilters : ctrl.nameFilters,
                    tagFilters : ctrl.tagFilters
                })
            ]) : '',
            mobile && ctrl.showSidebar() ? '' : m('.db-main', { style : poStyle },[
                ctrl.refreshView() ? m('.spinner-div', m('i.fa.fa-refresh.fa-spin')) : '',
                ctrl.data().length === 0 ? ctrl.nonLoadTemplate() : m('.db-poOrganizer',  m.component( ProjectOrganizer, {
                        filesData : ctrl.data,
                        updateSelected : ctrl.updateSelected,
                        updateFilesData : ctrl.updateFilesData,
                        LinkObject : LinkObject,
                        wrapperSelector : args.wrapperSelector,
                        allProjects : ctrl.allProjects,
                        reload : ctrl.reload,
                        resetUi : ctrl.resetUi
                    })
                )
            ]),
            mobile ? '' : m('.db-info-toggle',{
                    onclick : function _showInfoOnclick(){
                        ctrl.showInfo(!ctrl.showInfo());
                        $osf.trackClick('dashboard', 'information-panel', 'show-hide-information-panel');
                    }
github AlexanderLindsay / dailybudgeteer / client / rates / ratecomponent.ts View on Github external
public view = (ctrl: RateController) =&gt; {
        return m("div.column", [
            m.component(this.changeDateComponent, ctrl.vm.day.clone()),
            m.component(this.listComponent, ctrl.vm),
            m.component(new modal(ctrl.vm.modalTitle(), ctrl.vm.isAddModalOpen,
                () =&gt; m.component(this.formComponent, { item: ctrl.vm.item(), editDuration: ctrl.vm.editDates() }),
                () =&gt; [
                    m("button.ui.left.floated.button[type='button']", {
                        onclick: ctrl.vm.editDuration,
                        disabled: ctrl.vm.item().id() &lt;= 0 || ctrl.vm.editDates()
                    }, "Edit Duration"),
                    m("button.ui.approve.button[type='button']", { onclick: ctrl.vm.expire, disabled: ctrl.vm.item().id() &lt;= 0 }, "Expire"),
                    m("button.ui.approve.button[type='button']", { onclick: ctrl.vm.save }, ctrl.vm.modalActionName()),
                    m("button.ui.cancel.button[type='button]", "Cancel")
                ]))
        ]);
    };
}
github catarse / catarse.js / legacy / src / root / follow-found-friends.js View on Github external
displayTabContent = () => {
                const c_opts = {
                        user
                    },
                    tabs = {
                        '#creators': m.component(userCreators, c_opts),
                        '#friends': m.component(userFriends, c_opts),
                        '#follows': m.component(userFollows, c_opts),
                        '#followers': m.component(userFollowers, c_opts)
                    };

                hash(window.location.hash);

                if (_.isEmpty(hash()) || hash() === '#_=_') {
                    return tabs['#friends'];
                }

                return tabs[hash()];
            };
github tivac / crucible / types / repeating-edit.js View on Github external
el.select();
                        }
                    })
                )
            ),
            m("li",
                m("label",
                    "Max: ",
                    m("input[type=number]", {
                        oninput : m.withAttr("value", update.bind(null, options.ref, "max")),
                        value   : details.max || ""
                    })
                )
            ),
            m.component(types.components.fields.edit, {
                details : details,
                ref     : options.ref
            })
        );
    }
};
github catarse / catarse.js / legacy / spec / components / project-posts.spec.js View on Github external
beforeAll(() => {
            spyOn(m, 'component').and.callThrough();
            projectPostDetail = ProjectPostDetailsMockery()[0];
            const project = m.prop({id: 1231});
            const component = m.component(projectPosts, {
                    project: project
                }),
                view = component.view(component.controller({
                    project: project
                }));

            $output = mq(view);
        });
github catarse / catarse.js / legacy / src / c / projects-display.js View on Github external
            return m('div', _.map(ctrl.aonAndFlex_Sub_3, (collection, index) => m.component(projectRowWithHeader, {
                    collection,
                    title: collection.title,
                    ref: `home_${(collection.hash === 'all' ? 'score' : collection.hash)}`,
                    showFriends: collection.showFriends,
                    isOdd: index & 1
                }))
            );
github catarse / catarse.js / legacy / src / root / publish.js View on Github external
view: function(ctrl, args) {
        const project = _.first(ctrl.projectDetails()),
            acceptedIndex = ctrl.acceptedIndex,
            account = _.first(ctrl.projectAccount());

        const terms = project.mode === 'flex' ? publishVM.flexTerms(project) :
          project.mode === 'aon' ? publishVM.aonTerms(project, ctrl.expiresAt()) :
                                   publishVM.subTerms(project);

        return [project && account ? [
            (project.is_owner_or_admin ? m.component(projectDashboardMenu, {
                project: m.prop(project),
                hidePublish: true
            }) : ''),
            m(`.w-section.section-product.${project.mode}`),
            m('.w-section.section', [
                m('.w-container', [
                    m('.w-row', [
                        m('.w-col.w-col-3'),
                        m('.w-col.w-col-6', [
                            m('.u-text-center', [
                                m('img.u-marginbottom-20[src=\'/assets/catarse_bootstrap/launch-icon.png\'][width=\'94\']'),
                                m('.fontsize-large.fontweight-semibold.u-marginbottom-20', 'Pronto para lançar sua campanha?'),
                                m('.fontsize-base.u-marginbottom-30', 'Preparamos uma lista com informações importantes para você checar antes de colocar seu projeto no ar!')
                            ])
                        ]),
                        m('.w-col.w-col-3')
github ArthurClemens / polythene / examples / src / app / list-tile / list-tile.es6.js View on Github external
content: m('.demo-list', [
                m.component(listTile, {
                    title: titleLineText,
                    subtitle: infoDoubleLineText
                }),
                m.component(listTile, {
                    title: titleLineText,
                    subtitle: infoDoubleLineText
                }),
                m.component(listTile, {
                    title: titleLineText,
                    subtitle: infoDoubleLineText
                })
            ])
        }),
        m.component(titleBlock, {
            title: 'Three lines',
            content: m('.demo-list', [
                m.component(listTile, {
                    title: titleLineText,
                    highSubtitle: infoDoubleLineText
                }),
                m.component(listTile, {
                    title: titleLineText,
                    highSubtitle: infoDoubleLineText
                }),
                m.component(listTile, {
                    title: titleLineText,
                    highSubtitle: infoDoubleLineText
                })
            ])
        }),