module Config.Style.Fonts exposing
    ( FontScale
    , FontSizes
    , bodyFont
    , createFontScale
    , createFontSizes
    , defaultFontScale
    , headerFont
    , paragraphSpacing
    )

import Element
    exposing
        ( Attr
        , Attribute
        , spacing
        )
import Element.Font as F
    exposing
        ( size
        , typeface
        )


headerFont : F.Font
headerFont =
    F.typeface "Montez"


bodyFont : F.Font
bodyFont =
    F.typeface "Playpen Sans"


paragraphSpacing : Attribute msg
paragraphSpacing =
    spacing 0


type FontScale
    = FontScale Float


createFontScale : Float -> FontScale
createFontScale baseFontSize =
    FontScale baseFontSize


defaultFontScale : FontScale
defaultFontScale =
    FontScale 16.0


type alias FontSizes msg =
    { verySmall : Attribute msg
    , small : Attribute msg
    , normal : Attribute msg
    , medium : Attribute msg
    , large : Attribute msg
    , extraLarge : Attribute msg
    , huge : Attribute msg
    }


createFontSizes : FontScale -> FontSizes msg
createFontSizes (FontScale base) =
    let
        scaled multiplier =
            F.size (round (base * multiplier))
    in
    { -- assuming a 16px base:
      verySmall = scaled 0.75 -- 12px
    , small = scaled 0.875 -- 14px
    , normal = scaled 1.0 -- 16px
    , medium = scaled 1.125 -- 18px
    , large = scaled 1.25 -- 20px
    , extraLarge = scaled 1.5 -- 24px
    , huge = scaled 2.0 -- 32px at
    }
