Git Product home page Git Product logo

elm-bulma-classes's Introduction

Description

A simple library for using the Bulma CSS library classes. It's simply a module exposing all classes at top level, putting the burden of not making typos on the compiler. Nothing fancy.

Usage

Example usage:

import Html
import Html.Attributes as Attributes
import Bulma.Classes as Bulma

view =
    Html.div
        [ Attributes.class Bulma.columns ]
        [ Html.div
            [ Attributes.class Bulma.column ]
            [ Html.text "column 1" ]
        , Html.div
            [ Attributes.class Bulma.column ]
            [ Html.text "column 2" ]
        ]

Why?

"Why? There's already a bunch of Bulma libraries" you might say, and that is a valid question. Well, as of writing there are three other Elm libraries with bulma in their name - surprisetalk/elm-bulma, jmackie4/elm-bulma, and danielnarey/elm-bulma-classes.

jmackie4/elm-bulma says it's a WIP in the readme, and the GitHub repo no longer exists, so we can safely disregard that.

surprisetalk/elm-bulma seems both active and useful, but ultimately tries to achieve a different goal than this library by providing an entire framework for using Bulma (check it out, seems pretty darn cool).

The one that's most like (and an inspiration for) this library is danielnarey/elm-bulma-classes. The core difference is that danielnarey/elm-bulma-classes exposes a single record containing a nested structure that ultimately branches out into all available classes. This structure (probably) works pretty well if you've got a (semi-)sophisticated code completion setup, but since I don't, I had to constantly look up which branches in the source code to get the class name I knew I wanted; with this library, I'm replacing some of the safety of grouping related classes with ease-of-use by exposing them all at the top level, essentially just letting the Elm compiler check my typos. Also, unfortunately, Daniel's library has been deprecated and not been updated since Bulma 0.4.2. This flatter structure should hopefully make it a lot easier to keep up-to-date.

elm-bulma-classes's People

Contributors

ahstro avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

aiclouds

elm-bulma-classes's Issues

Css does not load on elm reactor

Hi @ahstro,
I'm trying to implement your package because I'm a huge fan of Bulma but I'm running into some trouble.
That's my elm.json file:

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.0",
    "dependencies": {
        "direct": {
            "ahstro/elm-bulma-classes": "3.1.0",
            "elm/browser": "1.0.1",
            "elm/core": "1.0.2",
            "elm/html": "1.0.0"
        },
        "indirect": {
            "elm/json": "1.1.3",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

When I launch the elm reactor command and try to visit the localhost, I can see the HTML structure but without all the styles from Bulma.
I can't understand if I miss something so I hope you can help me.

Thank you.

Consider changing classes from `String` to `Html.Attribute`

Hello!

I thought I'd continue the conversation from the other issue.

Let's take a look at the library as Strings:

stringExample = div [ class box ] []

If we want to add another class, we have a few obvious options:

stringsExample1 = div [ class box, class hasTextCentered ] []
stringsExample2 = div [ class <| box ++ " " ++ hasTextCentered ] []
stringsExample3 = div [ classList [ box, hasTextCentered ] ] []

And if we want to vary the alignment, we're looking at something like this:

empty = ""

stringsExample4 alignment
  = div [ class box
        , case alignment of
            Left   -> class empty
            Center -> class hasTextCentered
            Right  -> class hasTextRight
        ]
  [
  ]

By moving to Html.Attribute, we get something like this:

attrExample = div [ box ] []

Already much cleaner!

If we want to add another class, we have one straightforward path:

attrsExample = div [ box, hasTextCentered ] []

And to vary the alignment, we get something like this:

empty = class ""

stringsExample4 alignment
  = div [ box
        , case alignment of
            Left   -> empty
            Center -> hasTextCentered
            Right  -> hasTextRight
        ]
  [
  ]

For more on multiple class attributes, check out this issue.

So here's the tradeoff: moving to Html.Attribute will make most code much cleaner, but may make compound classes more difficult. Consider the following:

centeredBox = Html.Attribute
centeredBox = classList [ box, hasTextCentered ]

stringExample = div [ style [], centeredBox ] []

There's no way to transform multiple Html.Attributes into a single one, so we're stuck with the following:

centeredBox = List Html.Attribute
centeredBox = [ box, hasTextCentered ]

attrExample = div ( style [] :: centeredBox ) []

For me, this tradeoff is totally worth it -- which is why I've opened this issue!

Are there any problems that I'm overlooking?

Upgrading Bulma version

Can you upgrade the Bulma version?

I don't know how to run the generate.js script. I suppose that will upgrade Bulma version automatically, right?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.