34 lines
790 B
Elm
34 lines
790 B
Elm
module Stickers exposing (Sticker, StickerContent(..), viewSticker)
|
|
|
|
import String exposing (fromInt)
|
|
import Svg exposing (Svg, text, text_)
|
|
import Svg.Attributes exposing (fill, fontSize, textAnchor, x, y)
|
|
|
|
type alias Sticker =
|
|
{ content: StickerContent
|
|
, tooltip: String
|
|
, x: Int
|
|
, y: Int
|
|
--, scale: Int
|
|
--, isHovered: Bool
|
|
}
|
|
|
|
type StickerContent
|
|
= TextSticker String {- Color -} String {- Text -}
|
|
|
|
viewSticker : Sticker -> Svg msg
|
|
viewSticker sticker =
|
|
let
|
|
attributes =
|
|
[ x <| fromInt sticker.x
|
|
, y <| fromInt (sticker.y + 13)
|
|
]
|
|
in case sticker.content of
|
|
TextSticker color textContent ->
|
|
text_
|
|
( fill color
|
|
:: fontSize "30px"
|
|
:: textAnchor "middle"
|
|
:: attributes
|
|
)
|
|
[ text textContent ] |