• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
  • License
    BSD 3-Clause "New...
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

elm-ui-cookbook

This repo aims to gather knowledge from https://elmlang.slack.com #elm-ui or elsewhere.

PRs welcomed.

Examples

Centralize Input.text contents

mthiems 2:33 AM @VPagani I've seen this before, and I think this may be a bug in the current version of elm-ui. It seems the input DOM element needs a text-align: inherit style, as the text-align: center is on a parent div instead of on the input itself. Here's an Ellie illustrating one option for a workaround that makes it work: https://ellie-app.com/6GQLrcSt7hWa1

mgriffith💡 3:06 AM Ah, yeah, the current way to do that is to capture your spacing a font values in a palette file and always use those. Then you could do things like set the padding based on font size or whatever you’d like.

https://elmlang.slack.com #elm-ui

Structuring code

blackeuler 4:46 AM Is there any strategy when it comes to structing the code? I feel like I have a lot of code in the one file all mainly for the view of the page.

mgriffithbulb 4:58 AM First suggestion is to take all values and put them in one file (colors, spacing/padding values, font sizes and font families). I usually call this file UI After that, if you find a reusable part of a view, I’d put it in it’s own sub module. So, buttons go in UI.Button. Though it’s also fine to have big files.

https://elmlang.slack.com #elm-ui

Break long text without spaces

row [ width fill ]
  [ paragraph
    [ Font.color model.style.color
    , Font.size 40
	, Html.Attributes.style "word-break" "break-all" |> htmlAttribute
    ]
    [ text model.status.filename ]
  ]

'overflow-wrap: break-word' will not work when paragraph inside row so this solution https://stackoverflow.com/questions/3058866/how-to-force-a-line-break-in-a-long-word-in-a-div/3059128#3059128 is bad for flexbox.

Center wrapped flexbox

You can't

https://stackoverflow.com/questions/32802202/how-to-center-a-flex-container-but-left-align-flex-items/32811002#32811002

Custom events

Examples in source code https://github.com/mdgriffith/elm-ui/blob/1.1.5/src/Element/Events.elm#L177 but are not exported

Mouse click coordinates

Examples in source code but on exported https://github.com/mdgriffith/elm-ui/blob/1.1.5/src/Element/Events.elm#L115

colorToRgbaString

colorToRgbaString color =
    let
        floatTo256 f =
            if f >= 1 then
                255

            else
                floor (f * 256)

        rgba =
            Element.toRgb color

        floatToString f =
            String.pad 2 '0' (String.fromInt (floatTo256 f))
    in
    "rgba("
        ++ floatToString rgba.red
        ++ ", "
        ++ floatToString rgba.green
        ++ ", "
        ++ floatToString rgba.blue
        ++ ", "
        ++ floatToString rgba.alpha
        ++ ")"

colorToRgbaAttr

colorToRgbaAttr color =
    let
        { red, green, blue, alpha } =
            toRgb color

        rgb =
            [ red, green, blue ] |> List.map ((*) 255 >> String.fromFloat) |> List.intersperse ", " |> List.foldl (++) ""
    in
    Html.Attributes.style "color" ("rgba(" ++ rgb ++ "," ++ String.fromFloat alpha ++ ")")

Multiple focus bug

wrap each button in an Element.el

https://ellie-app.com/5NtSNBJ4bzFa1

mdgriffith/elm-ui#47 (comment)

em values

Sophie [Yesterday at 10:24 PM] Is there a way to specify em values in elm-ui?

jhbrown [12 hours ago] There is not. Just px and percents.

https://elmlang.slack.com #elm-ui

External css

jesse 7 minutes ago We primarily use elm-ui and also have external Sass styling too and it’s fine jesse 6 minutes ago You may need to use https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/Element#noStaticStyleSheet

https://elmlang.slack.com #news-and-links

mouseOver and Font.underline

Use Border instead:

            [ Border.color <| rgba255 255 255 255 255
            , Border.widthEach
                { bottom = 1
                , left = 0
                , top = 0
                , right = 0
                }
            , mouseOver [ Border.color <| rgb255 255 0 0 ]
            ]

"spacing" does not respect spacing to the outer edges

Spacing is the distance between contained elements. You are looking for "padding" on the container (to specify how near to the borders of the container the contained elements can be).

More Repositories

1

awesome-wgpu

A curated list of wgpu code and resources.
334
star
2

awesome-elm-gamedev

A curated list of useful Elm tutorials, libraries and software for Game Development. Inspired by awesome list. Feel free to contribute.
164
star
3

elm-games

All Elm Games (hopefully)
137
star
4

goshop

Shopping cart in Go
Go
101
star
5

react-starter-kit

React starter kit - no need for grunt/gulp/gloop/glugle/gleffy/gloran/whatever task runner comes out next week
JavaScript
40
star
6

oceanic-next-jetbrains-theme

Oceanic Next Theme (UI) for JetBrains
25
star
7

elm-navigation-example

elm-lang/navigation example without using hashes
JavaScript
15
star
8

nix-for-javascript-developers

Nix language for Javascript developers
11
star
9

react-dropzone-progress-bar

react-dropzone with progress bar
JavaScript
11
star
10

dotfiles

Emacs Lisp
9
star
11

exherbo

Shell
9
star
12

stmux

stmux is a script to create tmux session with name taken from current directory and config file .tmux_session
Shell
7
star
13

color-gradient-algorithm

Python
5
star
14

monokai-ocean

A dark theme for Visual Studio Code - Monokai + Ocean background
5
star
15

zig-postgres-template

Zig
4
star
16

rust-juniper-example

Rust
4
star
17

elm-packages-stats

Show graph of number of elm packages
HTML
3
star
18

rust-shopping-bot

Rust
3
star
19

gplafferoshop

internet shop on gpl affero 3 licence
PHP
2
star
20

elm-code-editor

Elm code editor - embeddable
Elm
2
star
21

nixos-config

Nix
2
star
22

elm-image-slider

Elm
2
star
23

rust-hackerrank

http://hackerrank.com solutions
Rust
2
star
24

awesome-zig

2
star
25

guixsd-config

Scheme
2
star
26

rustommerce

Rust
2
star
27

scrape

Showcase what can be done in vanilla.js
JavaScript
2
star
28

zig-utils

A collection of utility scripts and tools I use for zig development
Shell
2
star
29

sortbytime

Rust
1
star
30

actix-web-juniper-trying

Rust
1
star
31

terminal-text-animation

JavaScript
1
star
32

calibre-library

1
star
33

go-koans-solution

my progress in https://github.com/cdarwin/go-koans
Go
1
star
34

java-scraping-jaunt

Java
1
star
35

elm-math-kids

Elm
1
star
36

rust-json-pretty-format

Rust
1
star
37

elm-input-live-search

Elm
1
star
38

angular_tree

in java
Java
1
star
39

flexbox-wrap-border-collapse

HTML
1
star
40

luna

Go
1
star
41

rust-regex-stdin-by-line-benchmark

Rust
1
star
42

rust-projecteuler

Rust
1
star
43

angular-input-time-chrome

JavaScript
1
star
44

angular-checkbox-tree

JavaScript
1
star
45

elm-elm-mdl-ripple-slow

Elm
1
star
46

angularjs-tree

JavaScript
1
star
47

.configs

Vim Script
1
star
48

miglayout

Automatically exported from code.google.com/p/miglayout
Java
1
star
49

ajv-regexp-errormessage-example

JavaScript
1
star
50

javascript-wtf-koans

1
star
51

elm-process-sleep-example

Elm
1
star