website/frontend/src/Layouts/Navbar.elm

599 lines
13 KiB
Elm
Raw Normal View History

2024-11-11 03:57:54 -06:00
module Layouts.Navbar exposing (Model, Msg, Props, layout)
2024-12-09 22:08:35 -06:00
import Config.Data.Identity exposing (..)
2024-12-09 19:53:09 -06:00
import Config.Format.Format
exposing
( paragraphFontSize
, paragraphSpacing
)
import Config.Style.Colour exposing (colourTheme)
import Config.Style.Fonts exposing (spartanFont)
import Config.Style.Glow exposing (glowDeepDarkGrey)
import Config.Style.Svgs
exposing
( contact
, debate
, discord
, donate
, gitlab
, home
, hyperBlog
, interviews
, mastodon
, nutriDex
, services
, twitter
, upRootLarge
, upRootMedium
, upRootSmall
)
2024-12-09 22:11:15 -06:00
import Config.Style.Transitions
exposing
( hoverFontLightOrange
, transitionStyleMedium
)
2024-11-11 03:57:54 -06:00
import Effect exposing (Effect)
import Element as E exposing (..)
2024-12-09 19:53:09 -06:00
import Element.Background as B
import Element.Border as D
2024-12-08 21:16:04 -06:00
import Element.Events as Events
2024-11-11 03:57:54 -06:00
import Element.Font as F
import Element.Region exposing (description)
import Html exposing (Html)
2024-12-09 22:11:15 -06:00
import Html.Attributes as H
exposing
( class
, style
)
2024-11-11 03:57:54 -06:00
import Layout exposing (Layout)
import Route exposing (Route)
import Shared
import View exposing (View)
type alias Props =
2024-12-06 22:03:24 -06:00
{}
2024-11-11 03:57:54 -06:00
layout : Props -> Shared.Model -> Route () -> Layout () Model Msg contentMsg
layout props shared route =
Layout.new
{ init = init
, update = update
, view =
\layoutArgs ->
2024-12-08 02:18:36 -06:00
view shared
{ props = props
, content = layoutArgs.content
, model = layoutArgs.model
, toContentMsg = layoutArgs.toContentMsg
}
2024-11-11 03:57:54 -06:00
, subscriptions = subscriptions
}
-- MODEL
type alias Model =
{}
init : () -> ( Model, Effect Msg )
init _ =
( {}
, Effect.none
)
-- UPDATE
type Msg
= ReplaceMe
update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
ReplaceMe ->
( model
, Effect.none
)
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view :
2024-12-08 02:18:36 -06:00
Shared.Model
->
{ content : View contentMsg
, model : Model
, toContentMsg : Msg -> contentMsg
, props : Props
}
-> View contentMsg
2024-12-08 02:18:36 -06:00
view shared { content, model, toContentMsg, props } =
2024-12-07 15:43:26 -06:00
{ title = "uRN :: " ++ content.title
2024-11-11 03:57:54 -06:00
, attributes = [ F.family [ spartanFont ] ]
2024-12-08 02:18:36 -06:00
, element = navbarContainer shared.device content.element
}
navbarContainer : Device -> Element msg -> Element msg
navbarContainer device content =
row
[ E.width fill
, height fill
, B.color colourTheme.backgroundDarkGrey
, E.height E.fill
]
[ column
[ htmlAttribute (H.style "position" "fixed")
, htmlAttribute (H.style "left" "0")
, htmlAttribute (H.style "top" "0")
, htmlAttribute (H.style "height" "100vh")
, htmlAttribute (H.style "z-index" "10")
, htmlAttribute (H.style "transform-style" "preserve-3d")
, D.widthEach { top = 0, bottom = 0, left = 0, right = 3 }
, D.color colourTheme.textDarkOrange
, B.color colourTheme.backgroundDarkGrey
2024-12-09 19:53:09 -06:00
, glowDeepDarkGrey
2024-12-09 03:45:55 -06:00
, spacing 3
2024-12-08 02:18:36 -06:00
]
(case ( device.class, device.orientation ) of
( Phone, Portrait ) ->
2024-12-08 03:04:37 -06:00
[ mobileIconMaker, mobileNavbar, mobileFooterIcons ]
2024-12-08 02:18:36 -06:00
( Phone, Landscape ) ->
2024-12-08 03:04:37 -06:00
[ mobileIconMaker, mobileNavbar, mobileFooterIcons ]
2024-12-08 02:18:36 -06:00
( Tablet, Portrait ) ->
2024-12-08 03:04:37 -06:00
[ mobileIconMaker, mobileNavbar, mobileFooterIcons ]
2024-12-08 02:18:36 -06:00
_ ->
2024-12-08 03:04:37 -06:00
[ desktopIconMaker, desktopNavbar, desktopFooterIcons ]
2024-12-08 02:18:36 -06:00
)
, el
[ E.width fill
2024-11-11 18:57:51 -06:00
, height fill
2024-12-08 02:18:36 -06:00
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left =
case ( device.class, device.orientation ) of
( Phone, _ ) ->
mobileBarWidth
( Tablet, Portrait ) ->
mobileBarWidth
_ ->
desktopBarWidth
}
2024-11-11 18:57:51 -06:00
]
2024-12-08 02:18:36 -06:00
content
]
desktopBarWidth : Int
desktopBarWidth =
200
mobileBarWidth : Int
mobileBarWidth =
50
localhostUrl : String
localhostUrl =
url
desktopNavbar : Element msg
desktopNavbar =
column
[ alignLeft
, height fill
, F.color colourTheme.textLightGrey
2024-12-08 03:04:37 -06:00
, scrollbarY
2024-12-08 02:18:36 -06:00
]
[ column
[ padding 20, alignTop, alignLeft ]
2024-11-11 18:57:51 -06:00
[ column
2024-12-08 02:18:36 -06:00
[ F.bold
, F.color colourTheme.textLightGrey
, F.size 17
2024-12-08 21:16:04 -06:00
, spacing 10
2024-12-08 17:31:21 -06:00
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = 10
}
2024-11-11 18:57:51 -06:00
]
2024-12-08 21:16:04 -06:00
(List.map2 desktopButtonMaker
pageList
iconList
2024-12-08 02:18:36 -06:00
)
]
]
2024-12-08 03:04:37 -06:00
desktopIconMaker : Element msg
desktopIconMaker =
2024-12-08 02:18:36 -06:00
column
2024-12-08 03:04:37 -06:00
[ centerX
, E.width <| px desktopBarWidth
2024-12-08 02:18:36 -06:00
]
2024-12-08 03:04:37 -06:00
[ row
2024-12-09 19:53:09 -06:00
[ centerX
, spacing 2
, E.width <| px 140
, centerX
, paddingEach
{ top = 20
, right = 0
, bottom = 20
, left = 0
}
]
2024-12-08 21:16:04 -06:00
[ html upRootMedium
2024-12-08 03:04:37 -06:00
]
, el
[ E.width <| px 140
, alignTop
, centerX
, D.widthEach
{ bottom = 1
, top = 0
, left = 0
, right = 0
}
, D.color colourTheme.textDarkGrey
]
none
]
mobileIconMaker : Element msg
mobileIconMaker =
column
[ centerX
, E.width <| px mobileBarWidth
]
[ row
2024-12-09 19:53:09 -06:00
[ centerX
, spacing 2
, E.width <| px 35
, centerX
, paddingEach
{ top = 10
, right = 0
, bottom = 10
, left = 0
}
]
2024-12-08 21:16:04 -06:00
[ html upRootSmall
2024-12-08 03:04:37 -06:00
]
, el
[ E.width <| px 20
, alignTop
, centerX
, D.widthEach
{ bottom = 1
, top = 0
, left = 0
, right = 0
}
, D.color colourTheme.textDarkGrey
2024-11-11 18:57:51 -06:00
]
2024-12-08 03:04:37 -06:00
none
]
mobileNavbar : Element msg
mobileNavbar =
column
[ height fill
, E.width fill
, F.color colourTheme.textLightGrey
, scrollbarY
]
[ column
2024-12-08 02:18:36 -06:00
[ padding 5
2024-12-09 03:45:55 -06:00
, alignTop
2024-12-08 02:18:36 -06:00
, centerX
]
[ column
[ spacing 8
, centerX
]
2024-12-08 21:16:04 -06:00
(List.map2 mobileButtonMaker
pageList
iconList
2024-12-08 02:18:36 -06:00
)
]
]
2024-12-08 02:18:36 -06:00
desktopBackground : Element msg -> Element msg
desktopBackground =
el
[ E.width fill
, height fill
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = desktopBarWidth
}
]
2024-12-08 02:18:36 -06:00
mobileBackground : Element msg -> Element msg
mobileBackground =
el
[ E.width fill
, height fill
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = mobileBarWidth
}
]
2024-12-08 21:16:04 -06:00
desktopButtonMaker : String -> Html msg -> Element msg
desktopButtonMaker name icon =
2024-12-08 02:18:36 -06:00
link
[ E.width fill ]
2024-12-08 21:16:04 -06:00
{ url =
if name == "Home" then
localhostUrl
else
localhostUrl ++ String.toLower name
2024-12-08 02:18:36 -06:00
, label =
row
2024-12-08 21:16:04 -06:00
[ spacing 0, height <| px 30 ]
[ column
[ E.width <| px 35
, paddingEach
{ top = 0
, right = 10
, bottom = 0
, left = 0
2024-12-08 02:18:36 -06:00
}
]
2024-12-08 21:16:04 -06:00
[ html icon
]
2024-12-08 02:18:36 -06:00
, column
2024-12-09 22:08:35 -06:00
[ hoverFontLightOrange
2024-12-08 21:16:04 -06:00
, F.color colourTheme.textLightGrey
2024-12-09 19:53:09 -06:00
, transitionStyleMedium
2024-12-08 21:16:04 -06:00
, alignBottom
]
[ text (String.toUpper name)
2024-12-08 02:18:36 -06:00
]
]
}
2024-12-08 21:16:04 -06:00
mobileButtonMaker : String -> Html msg -> Element msg
mobileButtonMaker name icon =
2024-12-08 02:18:36 -06:00
link
[]
{ url = localhostUrl ++ String.toLower name
, label =
row
[ spacing 10 ]
2024-12-08 21:16:04 -06:00
[ column
[ E.width <| px 20
]
[ html icon
2024-12-08 02:18:36 -06:00
]
]
}
2024-12-08 21:16:04 -06:00
iconList : List (Html msg)
iconList =
2024-12-09 19:53:09 -06:00
[ home
, services
, hyperBlog
, debate
, nutriDex
, interviews
, donate
, contact
2024-12-08 21:16:04 -06:00
]
pageList : List String
pageList =
[ "Home"
, "Services"
, "HyperBlog"
, "Debate"
, "NutriDex"
, "Interviews"
, "Donate"
, "Contact"
]
2024-12-08 02:18:36 -06:00
desktopFooterIcons : Element msg
desktopFooterIcons =
2024-12-08 03:04:37 -06:00
column
[ E.width <| px 140
, alignTop
, centerX
, D.widthEach
{ bottom = 0
, top = 1
, left = 0
, right = 0
}
, D.color colourTheme.textDarkGrey
]
[ row
2024-12-08 03:04:37 -06:00
[ alignBottom
, E.width fill
2024-12-08 03:04:37 -06:00
, centerX
]
2024-12-08 03:04:37 -06:00
[ row
[ centerX
, centerY
, E.width fill
, E.height fill
, spacing 20
, paddingEach
{ top = 25
2024-12-08 17:31:21 -06:00
, bottom = 25
2024-12-08 03:04:37 -06:00
, left = 0
, right = 0
}
2024-12-08 02:18:36 -06:00
]
2024-12-08 21:16:04 -06:00
(List.map2
desktopFooterImageMaker
2024-12-08 03:04:37 -06:00
[ gitlabDetails
, twitterDetails
, mastodonDetails
, discordDetails
]
2024-12-08 21:16:04 -06:00
footerIconList
2024-12-08 03:04:37 -06:00
)
]
]
2024-12-08 02:18:36 -06:00
mobileFooterIcons : Element msg
mobileFooterIcons =
column
2024-12-08 03:04:37 -06:00
[ E.width <| px 20
, alignTop
, centerX
, D.widthEach
{ bottom = 0
, top = 1
, left = 0
, right = 0
}
, D.color colourTheme.textDarkGrey
]
2024-12-08 02:18:36 -06:00
[ column
2024-12-08 03:04:37 -06:00
[ alignBottom
2024-12-08 02:18:36 -06:00
, E.width fill
]
2024-12-08 03:04:37 -06:00
[ column
[ centerX
, centerY
, E.width fill
, E.height fill
, spacing 10
, paddingEach
{ top = 10
, bottom = 10
, left = 0
, right = 0
}
2024-12-08 02:18:36 -06:00
]
2024-12-08 21:16:04 -06:00
(List.map2
mobileFooterImageMaker
2024-12-08 03:04:37 -06:00
[ gitlabDetails
, twitterDetails
, mastodonDetails
, discordDetails
]
2024-12-08 21:16:04 -06:00
footerIconList
2024-12-08 03:04:37 -06:00
)
]
2024-12-08 02:18:36 -06:00
]
2024-12-08 21:16:04 -06:00
desktopFooterImageMaker :
2024-12-08 02:18:36 -06:00
{ name : String
, url : String
}
2024-12-08 21:16:04 -06:00
-> Html msg
2024-12-08 02:18:36 -06:00
-> Element msg
2024-12-08 21:16:04 -06:00
desktopFooterImageMaker config icon =
2024-12-08 02:18:36 -06:00
column [ centerX ]
2024-12-08 17:31:21 -06:00
[ newTabLink []
2024-12-08 02:18:36 -06:00
{ url = config.url
, label =
2024-12-08 21:16:04 -06:00
row
[ E.width <| px 20 ]
[ html icon
]
}
]
mobileFooterImageMaker :
{ name : String
, url : String
}
-> Html msg
-> Element msg
mobileFooterImageMaker config icon =
column [ centerX ]
[ newTabLink []
{ url = config.url
, label =
row
[ E.width <| px 15 ]
[ html icon
2024-12-08 02:18:36 -06:00
]
}
]
2024-12-07 15:43:26 -06:00
2024-12-08 02:18:36 -06:00
gitlabDetails : { name : String, url : String }
gitlabDetails =
{ name = "gitlab"
, url = "https://gitlab.com/BRBWaffles/website"
}
twitterDetails : { name : String, url : String }
twitterDetails =
{ name = "twitter"
, url = "https://x.com/upRootNutrition"
}
2024-12-07 15:43:26 -06:00
2024-12-08 02:18:36 -06:00
mastodonDetails : { name : String, url : String }
mastodonDetails =
{ name = "mastodon"
, url = "https://social.uprootnutrition.com/@nick"
}
discordDetails : { name : String, url : String }
discordDetails =
{ name = "discord"
, url = "https://discord.com/invite/YrcEvgRTqy"
}
2024-12-08 21:16:04 -06:00
footerIconList =
2024-12-09 19:53:09 -06:00
[ gitlab
, twitter
, mastodon
, discord
2024-12-08 21:16:04 -06:00
]