GithubHelp home page GithubHelp logo

ef-gud-elm's Introduction

EF GUD Elm Components

This is a representation of the EF design system implemented using Elm 0.19.

It also includes a set of "Stories" a la Storybook to explain and demonstrate example usage (probably this should be split into two projects in the end).

The project is bootstrapped using Create Elm App.

To gets things up and running locally you will need to clone the repo and make sure that you have create-elm-app installed globally:

npm install -g create-elm-app

To run a local development server run:

elm-app start

This will launch the app on http://localhost:3000 with hot reloading enabled.

To create a release build run:

elm-app build

Design Principles

These components try to offer a very thin wrapper around straight html. The intention is to make use of the GUD css as-is in order to stay in line with future updates more easily and to reduce the complexity of the implementation.

Furthermore the dsl used is designed to mirror the dsl for standard html creation within Elm. This means that in general we use the same form: a function with the name of the component we are creating which accepts a list of properties and then a list of child components (where appropriate). We add value by adding a layer of type safety to ensure that only valid properties can be added to each component and by adding types to constrain simple values within the ranges dictated by the GUD.

There are pros and cons to this approach. On the plus side it results in a very familiar pattern of usage which is very similar to the generation of standard html in Elm. On the downside it is not as type safe as it could possibly be since the properties are represented as a list rather than an algebraic type (which would allow us to exclude all invalid combinations. This seemed like a good compromise as the ADT approach does make the library less convenient to use.

Contribution

With the design considerations given above, contributions are welcome via PR. If you add a component, please also add a story and wire it up in the Main.elm module. For a roadmap of what needs doing, have a look at http://code.ef.design. If you want to add something that is not part of the GUD or you feel like it makes sense to deviate from the design principles adopted so far then it's probably worth a discussion before you begin.

ef-gud-elm's People

Contributors

julian-jelfs avatar julianjelfs avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

luminescent

ef-gud-elm's Issues

Add spacing support to main layout components

The spacing module provides helper functions for most aspects of padding and margin. For each component that wants to provide padding and margin these features need to be wrapped with the relevant component's props wrapper. This is a bit of a pain. There could be a better way, but this is possibly just Elm's curse. It is not the best when it comes to abstraction. The end result will be nice for the user though.

Further exploration of phantom types

Seems like it might be an idea to implement all possible props for all components inside a single module and type them all using a phantom type. Then have each component expose just the properties they support tagged with an opaque type representing themselves.

e.g.

type ComponentProp a msg = ComponentProp (Attribute msg)

disabled : ComponentProp Radio msg
disabled = Component.disabled

Need to be sure that we can handle the differing structure of each component before we embark on this, although even if it doesn't work for all components it might be good for those that share a lot (input, text area, select, checkbox, radio etc)

Validation of fieldsets

form, fieldset and formgroup are all groups of fields and I think the the validation can probably treat them the same. This needs to be harmonised so that the validity of each one is just the validity of all of the controls that they contain.

We may benefit from some sort of FieldContainer abstraction that can handle this for all three things.

Investigate a better way to store fields internally in the form

storing fields in a list means we have to do a lot of list iteration which sucks. It would be better to store them on a dictionary but that can't obviously be done because they are keyed on branches of a sum type. Are there packages that can help with this?

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.