Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wire up Elm lang and Semantic UI

How easy is it to use ready-made jQuery plugins in Elm? I'm just starting to learn Elm lang and I'm curious if it's possible to use Semantic UI's dropdowns in my application. How should one approach such task? Without libraries like Semantic UI it's pretty hard to make proper dropdowns for mobile, for example, and writing all that code from scratch seems like reinventing the wheel.

like image 472
Victor Marchuk Avatar asked Aug 11 '15 13:08

Victor Marchuk


People also ask

What is semantic UI used for?

What is Semantic UI? Semantic UI is a front-end development framework similar to bootstrap designed for theming. It contains pre-built semantic components that helps create beautiful and responsive layouts using human-friendly HTML.

What is Elm UI?

elm-ui is a language for layout and interface design. This is a novel iteration on declarative styling where you can use Elm types and functions to define your UI in a declarative way. The novel part is that it does not require you to know CSS to be used. The API is very simple and can be learned quickly!

Is Semantic a UI?

Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website looks more amazing. It uses a class to add CSS to the elements.


2 Answers

It's not a good idea. Elm is pure. That means for any given state, we can generate the UI. And to programatically change the UI, the state must change.
The entire reason for using Elm is because of the belief that impurity is difficult to reason about, and purity is preferred.

jQuery makes it possible for an action to directly read & modify the UI without changing the application state. It's impure.

Thus Elm and jQuery are fundamentally at odds and you will likely get into a mess trying to get the two to work together.

Probably the easiest way to proceed is find a CSS library that doesn't require JS, that gives you a reasonable set of components to work with (e.g. http://purecss.io/) and use Elm in conjunction with that.

like image 182
Mark Bolusmjak Avatar answered Sep 21 '22 22:09

Mark Bolusmjak


I don't know about jQuery specifically, but Elm has a Ports / Interop System specifically for using existing Javascript libraries and avoiding re-inventing too many wheels. I haven't use it but it might fit your needs.

like image 32
brightball Avatar answered Sep 24 '22 22:09

brightball