mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-22 08:17:40 +03:00
31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
app "hello-gui"
|
|
packages { pf: "platform" }
|
|
imports []# [ pf.Action.{ Action }, pf.Elem.{ button, text, row, col } ]
|
|
provides [ program ] to pf
|
|
|
|
program = { render }
|
|
|
|
render = \state ->
|
|
div0 = \numerator, denominator -> (numerator / denominator) |> Result.withDefault 0
|
|
|
|
rgba = \r, g, b, a -> { r: div0 r 255, g: div0 g 255, b: div0 b 255, a }
|
|
|
|
styles = { bgColor: rgba 100 50 50 1, borderColor: rgba 10 20 30 1, borderWidth: 10, textColor: rgba 220 220 250 1 }
|
|
|
|
height = Num.toStr state.height
|
|
width = Num.toStr state.width
|
|
|
|
Col
|
|
[
|
|
Row
|
|
[
|
|
Button (Text "Corner ") styles,
|
|
Button (Text "Top Mid ") { styles & bgColor: rgba 100 100 50 1 },
|
|
Button (Text "Top Right ") { styles & bgColor: rgba 50 50 150 1 },
|
|
],
|
|
Button (Text "Mid Left ") { styles & bgColor: rgba 150 100 100 1 },
|
|
Button (Text "Bottom Left") { styles & bgColor: rgba 150 50 50 1 },
|
|
Button (Text "height: \(height)") { styles & bgColor: rgba 50 150 50 1 },
|
|
Button (Text "width: \(width)") { styles & bgColor: rgba 50 100 50 1 },
|
|
]
|