Code Monkey home page Code Monkey logo

paack-ui's Introduction

Paack UI

The paack-ui package provides ready-to-use components using Elm UI, based on the design sketches elaborated for Paack's apps.

The components' API strikes to be strict. That means it pragmatically stops the developer from performing undesired options combinations. Thus, producing unexpected behaviors or non-planned visuals artifacts.

The purpose of using Elm UI is mostly to keep components accessible.

The usage of this library is mostly internal, but we are open to suggestions and feedback.

Example

Here's an example of this package in action:

module Pages.Login.View exposing (container)

import Element exposing (Element, fill, maximum, minimum, shrink)
import UI.Button as Button
import UI.Document as Nav
import UI.RenderConfig as RenderConfig exposing (RenderConfig)
import UI.Text as Text
import UI.TextField as TextField
-- and others


container : AppConfig -> Model -> Nav.Page Msg
container appConfig model =
  viewBody appConfig model
    |> Nav.bodySingle
    |> Nav.page (pageTitle appConfig.locale model)


loginForm : Locale -> RenderConfig -> Model -> Element Msg
loginForm ({ terms } as locale) renderCfg model =
    Element.column
        [ Element.centerY
        , Element.centerX
        , Element.spacingXY 8 24
        , Element.padding 32
        ]
        [ TextField.username SetEmail  -- UI.TextField
            terms.pages.login.username
            model.email
            |> TextField.withPlaceholder "[email protected]"
            |> TextField.setLabelVisible True
            |> TextField.withWidth TextField.widthFull
            |> TextField.renderElement renderCfg
        , TextField.currentPassword SetPassword -- UI.TextField
            terms.pages.login.password
            model.password
            |> TextField.withPlaceholder "********"
            |> TextField.setLabelVisible True
            |> TextField.withWidth TextField.widthFull
            |> TextField.withOnEnterPressed GetCredentials
            |> TextField.renderElement renderCfg -- UI.TextField
        , Button.fromLabel (terms.pages.login.login) -- UI.Button
            |> Button.cmd GetCredentials Button.primary
            |> Button.renderElement renderCfg
        ]


loginTitle : Locale -> RenderConfig -> Element Msg
loginTitle { terms } renderCfg =
    terms.pages.login.description
        |> String.split "\n"
        |> Text.multiline Text.heading5 -- UI.Text
        |> Text.withColor (Palette.color tonePrimary brightnessMiddle)
        |> Text.renderElement renderCfg
        |> Element.el
            [ Element.paddingXY 0 20
            , Element.width fill
            ]

Showcase

This module's repository includes a showcase that itself is not an example of the module's usage but demonstrates the components and their appearance.

A published version of the showcase is available at paackeng.github.io/paack-ui.

Assets

An external repository holds static assets used within this API.

For including these assets, we recommend using parcel. First, add paack-ui-assets using npm install. Secondly, add import 'paack-ui-assets/js/paackSvgIconSprite.js'; to index.js

Also, you have to import or provide the "Fira Sans" font family, with the following weights: 400, 500, 600 and 700. Here's an example for you:

<link
  href="https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&display=swap"
  rel="stylesheet"
/>

Where to begin?

See the UI.Document module documentation for the top-level component.

There is a showcase demo available. Run npm showcase and navigate to the pointed link. In this demo, you can see all different components in actions with some code samples.

paack-ui's People

Contributors

pedrohlc avatar dependabot[bot] avatar jouderianjr avatar renanpvaz avatar chrisfls avatar segmentationfaulter avatar sufiyanyusuf avatar dependabot-preview[bot] avatar niqt avatar

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.