module Config.Helpers.Headers.Helpers exposing (headerMaker)

import Config.Helpers.Cards.Inner.Text exposing (divider)
import Config.Helpers.Converters exposing (formatName)
import Config.Helpers.Headers.Types as C exposing (Headerable(..))
import Config.Helpers.Response exposing (contentContainer)
import Config.Style.Colour.Helpers exposing (colourTheme)
import Config.Style.Fonts
    exposing
        ( defaultFontSize
        , headerFontSizeBig
        )
import Element as E
    exposing
        ( Element
        , centerX
        , column
        , el
        , fill
        , maximum
        , minimum
        , padding
        , paddingEach
        , paragraph
        , spacing
        , text
        , width
        )
import Element.Font as F
    exposing
        ( bold
        , center
        )


headerMaker : Headerable msg -> Element msg
headerMaker headerable =
    let
        headerTitleMaker : String -> Element msg
        headerTitleMaker title =
            el
                [ headerFontSizeBig
                , F.bold
                , width fill
                , F.center
                ]
            <|
                paragraph [] [ text title ]

        headerHelper : String -> List (Element msg) -> Element msg
        headerHelper title body =
            el
                [ width (fill |> minimum 100)
                , width (fill |> maximum 725)
                , padding 10
                , centerX
                ]
            <|
                column
                    [ width fill
                    ]
                    [ headerTitleMaker title
                    , divider
                    , el
                        [ E.height fill
                        , E.width fill
                        , centerX
                        , spacing 8
                        , paddingEach
                            { top = 10
                            , bottom = 0
                            , left = 0
                            , right = 0
                            }
                        ]
                      <|
                        el
                            [ paddingEach
                                { top = 0
                                , bottom = 0
                                , left = 15
                                , right = 15
                                }
                            , spacing 8
                            , width fill
                            ]
                        <|
                            paragraph
                                [ width fill
                                , defaultFontSize
                                , F.center
                                ]
                            <|
                                body
                    ]
    in
    case headerable of
        C.Arguments argument ->
            headerHelper argument.headerTitle argument.headerBody

        C.BlogPage blog ->
            headerHelper blog.headerTitle blog.headerBody

        C.CuckList cuck ->
            headerHelper cuck.headerTitle cuck.headerBody

        C.Debate debate ->
            headerHelper debate.headerTitle debate.headerBody

        C.Donate donate ->
            headerHelper donate.headerTitle donate.headerBody

        C.Gibberish gibberish ->
            headerHelper gibberish.headerTitle gibberish.headerBody

        C.Services service ->
            headerHelper service.headerTitle service.headerBody

        C.Interviews interview ->
            headerHelper interview.headerTitle interview.headerBody

        C.NutriDex nutriDex ->
            headerHelper nutriDex.headerTitle nutriDex.headerBody

        C.Contact contact ->
            headerHelper contact.headerTitle contact.headerBody

        C.Journal journal ->
            headerHelper journal.headerTitle journal.headerBody


cardContentMaker : List (Element msg) -> Element msg
cardContentMaker content =
    column
        [ spacing 8
        , width fill
        ]
        content


cardStuff : Element msg -> Element msg
cardStuff content =
    el
        [ E.height fill
        , E.width fill
        , centerX
        , spacing 8
        ]
    <|
        el
            [ paddingEach
                { top = 0
                , bottom = 0
                , left = 15
                , right = 15
                }
            , spacing 8
            , width fill
            ]
            content
