mithril.js icon indicating copy to clipboard operation
mithril.js copied to clipboard

Reusable components.

Open vivekimsit opened this issue 11 years ago • 225 comments

Hi,

What about creating a repo which contains a set of reusable UI components? something like Angular-UI or Khan Acacdemy

I am ready to contribute.

Cheers!

vivekimsit avatar Jan 14 '15 03:01 vivekimsit

We all thought about this, finally one is speaking it out ;)

I think there are a few problems to solve. Everyone has opinions about how thinks has to be solved so these components should be flexible enough.

This is normally done with configuration. But if you do this, the components tend to get quite complex and large.

On the other hand, with mithril things got quite simple to implement. So in most cases it is easier to reimplement your component specific to your usecase.

Other questions that arise:

  • What module system (plain/AMD/CommonJS/ES6)
  • Dependencies between components and to utilities (e. G. lodash)
  • 1-repo-per-component (ampersand) or 1 repo for all components or something between
  • ...

This shouldn't keep us away from doing it. Maybe open-source-evolution will figure this out.

StephanHoyer avatar Jan 14 '15 06:01 StephanHoyer

Yes,

From this project we will learn:

  1. How awesome mithril is.
  2. How to creates components which are easy to compose.
  3. Mithril best practices which others can follow.

Would like to listen from others too :)

Thanks!

vivekimsit avatar Jan 14 '15 07:01 vivekimsit

just found https://github.com/mithril-ui

Seems monolithic and outdated. Also it's bound bootstrap what I personally don't like.

There is also https://github.com/ng-vu/mithril-bootstrap from the same person (@ng-vu)

StephanHoyer avatar Jan 14 '15 08:01 StephanHoyer

Satyam and I wrote one of the earliest component repos https://github.com/eddyystop/mithril-components. We thought then a standard set of Mithril components was important to acceptance, and I still think so now.

The problem has always been the lack of a canonical component design that turtles all the way down, and allows some components to expose some of their state to others. You'd want components from different authors to play nice with one another.

Like other people, I've rolled my own components, including some sophisticated ones, yet they can't be shared.

eddyystop avatar Jan 14 '15 17:01 eddyystop

Hi guys,

I created mithril-bootstrap just for experience how to structure projects and components in Mithril. For now, I agree that it's easier to reimplement components for our specific usecases or wrap other libraries in Mithril-style than force everyone to follow a single style.

JavaScript is evolving rapidly. Yesterday I used RequireJs, today Browserify and tomorrow maybe ES6 Modules. It's up to people to organize their projects and requirements.

iOliverNguyen avatar Jan 16 '15 02:01 iOliverNguyen

Ya, it would not be that trivial but I think its a good project to start with. After all it can show the real power of mithril.

WDYT?

vivekimsit avatar Jan 16 '15 02:01 vivekimsit

@ng-vu Totally agree.

Thats why I also think the web-components movement is a dead-end. Easy-to-implement custom tailored components are the way to go. That's why mithril rocks ;).

So conclusion of this issue would maybe to create a list of possible patterns for mithril components where anyone can get inspired and inspire others.

Don't quite know how to achieve this. Maybe a wiki, but this tends to outdate.

Any ideas?

StephanHoyer avatar Jan 16 '15 10:01 StephanHoyer

Hello,

I believe a component store would be very nice but I also understand that a reusable component is very complexe to implement because of the required flexibility.

What about a component snippet store ? You would be able to share your components without to search for flexibility. Others can reuse and adapt them to their own needs and maybe can share their new version with different features.

For Boostrap related stuff, there is http://bootsnipp.com/ which offers exactly this kind of stuff. You find code snippets which are ready to use ; but most of the time you adapt them to your own needs.

Damien

Le 16/01/2015 11:50, Stephan Hoyer a écrit :

@ng-vu https://github.com/ng-vu Totally agree.

Thats why I also think the web-components movement is a dead-end. Easy-to-implement custom tailored components are the way to go. That's why mithril rocks ;).

So conclusion of this issue would maybe to create a list of possible patterns for mithril components where anyone can get inspired and inspire others.

Don't quite know how to achieve this. Maybe a wiki, but this tends to outdate.

Any ideas?

— Reply to this email directly or view it on GitHub https://github.com/lhorie/mithril.js/issues/413#issuecomment-70237406.

ghost avatar Jan 16 '15 14:01 ghost

@tracim, I find the idea of a snippet store interesting. In addition to what you mention, it sidesteps the issue of what CSS to decorate the tags with e.g. custom classes (m-dropdown-component) vs Bootstrap classes.

eddyystop avatar Jan 16 '15 16:01 eddyystop

:+1:

I think this is a great idea. Too many people want stuff that just plug and plays, but the truth is you can't write terse and elegant plugins that accounts for everybody's intended usage and caters for all their desired configuration with totally plug-and-play code. People have tried to do this in the past and ended up with the huge bloated nightmares that are jQuery UI and Angular.

If anything, Mithril's philosophy is that functional code should be kept short and sweet and obvious, that way users can learn a little by looking into it and customise it to fit their situation.

Plus, this encourages development and configuration over dumb copy+pasting, which has got to be good for the community.

barneycarroll avatar Jan 16 '15 17:01 barneycarroll

:+1:

Snippet store seems interesting idea. That will be a kind of cookbook.

vivekimsit avatar Jan 16 '15 18:01 vivekimsit

A Mithril Cookbook would be a great resource, given the way people seem to recommend developing with Mithril (solving your own problems effectively and not writing a mini-framework about it). Having several recipes for solving a focused task can be useful when you're learning. Depending on your coding approach (functional, prototypal, class-based), there might be several idiomatic implementations for the same recipe. One concrete example of how this could work is ActiveState's language-specific cookbook recipes; several of the subsites have even been turned into O'Reilly books. Collecting recipes for solving common tasks would be a good start.

jdnier avatar Jan 16 '15 18:01 jdnier

If anyone wants to take a stab at organizing the wiki, feel free.

lhorie avatar Jan 16 '15 19:01 lhorie

I agree that Cookbook or a collection of snippets would be a perfect way to learn Mithril and to help people make their own custom components. But Mithril needs to gain popularity and I think if a newbie will see just a list of recipes, and he won't be able to npm-install then to quickly test - he will be disappointed and will go back to React with their react-components repo. I personally find Mithril much more solid and useful than React. But I still have to use React because of its Material Design components, and because I can't assure my colleagues to use Mithril since nobody ever heard of it. So recipes are important to learn Mithril. But pluggable components are important to start quickly use Mithril and to help it become popular.

zserge avatar Jan 19 '15 12:01 zserge

@zserge are you referring to https://github.com/callemall/material-ui ?

eddyystop avatar Jan 19 '15 16:01 eddyystop

@eddyystop Yes, subjectively it seems to be the most usable set of Material components to write mobile HTML5 apps (I've also checked Bootstrap Material, Angular Material and Polymer Project).

zserge avatar Jan 19 '15 16:01 zserge

Totally agree with @zserge

In fact to develop a strong community we need a strong POCs

cheers!

vivekimsit avatar Jan 19 '15 17:01 vivekimsit

I would think callemall/material-ui custom less CSS would concern some people, as opposed to, say, Bootstrap 3. Any information on this?

I guess one idea is to keep someone's material UI less and redo the JS in Mithril.

eddyystop avatar Jan 19 '15 17:01 eddyystop

@eddyystop You mean they're using different element classes than Bootstrap? I don't see a problem here, since these two are very different:

  • As I see Bootstrap is handy to style individual elements on the web page. It's handy when you make a web page with content, or maybe with some simple forms.
  • Material UI is useful when you want to make a full mobile application, so you get the building blocks - actionbar, side navigation, pickers, sliders etc. That's why the bootstrap material style is very fragile and barely works in mobile browsers. So ideally Mithril should have plugins for both, bootstrap and material UI.

And I totally agree that "borrowing" LESS styles from the material-ui would simplify things a lot. Or maybe from the Polymer, which also looks nice on mobile.

zserge avatar Jan 19 '15 17:01 zserge

@zserge "Polymer is based on a set of future technologies, including Shadow DOM, Custom Elements and Model Driven Views." So its further removed from the Mithril philosophy than Material-UI or Bootstrap.

The Material-UI and Bootstrap CSS can force the HTML to be structured differently. So you'd need a separate library for each, though they would be similar.

eddyystop avatar Jan 19 '15 18:01 eddyystop