website/frontend/src/Interviews/Helpers.elm

289 lines
7.3 KiB
Elm
Raw Normal View History

2024-11-27 01:42:58 -06:00
module Interviews.Helpers exposing (..)
import Config.CardFormat exposing (..)
2024-11-27 01:42:58 -06:00
import Config.Colour exposing (..)
import Config.Format exposing (..)
import Config.StrengthBar exposing (..)
2024-11-28 00:33:22 -06:00
import Config.ToolTip exposing (..)
2024-11-27 01:42:58 -06:00
import Cuckery.Types exposing (..)
import Effect exposing (Effect)
import Element as E exposing (..)
import Element.Background as B exposing (..)
import Element.Border as D
import Element.Font as F
import Html.Attributes as H exposing (style)
import Interviews.Types exposing (..)
import Layouts
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)
interviewMaker : Interview -> Element msg
interviewMaker interview =
row
topLevelBox
[ cardImageMaker (interviewImage interview)
, cardMaker
[ cardTitleMaker (interviewTitle interview)
, cardFormatter
[ cardContentSpacing
[ column
2024-11-28 19:28:24 -06:00
fieldSpacer
[ socialMaker interview
, appearanceTitle interview
, appearanceMaker interview
]
]
2024-11-27 01:42:58 -06:00
]
]
]
interviewImage : Interview -> { src : String, description : String }
interviewImage interview =
{ src = "interviews/" ++ interview.interviewImage ++ ".png"
, description = interview.interviewImage
}
interviewTitle : Interview -> String
interviewTitle interview =
interview.interviewName
socialMaker : Interview -> Element msg
socialMaker interview =
row
(paragraphBoldFormat
++ [ F.size 18
, spacing 5
]
)
[ text "Social:"
, paragraphLinkFormat
{ url = interview.interviewSocial
, label = transitionHighlightedLinkHover <| text (formatInterviewSocial interview.interviewSocial)
}
]
appearanceTitle : Interview -> Element msg
appearanceTitle interview =
row
(paragraphBoldFormat
++ [ F.size 18
]
)
[ text "Appearances:" ]
appearanceMaker : Interview -> Element msg
appearanceMaker interview =
column [ spacing 15, width fill ] <|
List.map2 (\x y -> makeAppearance x y)
interview.interviewAppearances
(List.range 1 (List.length interview.interviewAppearances))
makeAppearance : Appearance -> Int -> Element msg
makeAppearance appearanceEntry index =
column
(paragraphAlignLeft
++ [ spacing 8
, width fill
]
)
[ row
2024-11-28 00:33:22 -06:00
(paragraphFormat
++ [ F.size 18
, E.width fill
, paddingEach
{ top = 0
, bottom = 0
, left = 35
, right = 0
}
]
)
[ column
(paragraphFormat
++ [ F.size 18
, alignTop
, alignRight
, F.alignRight
]
)
[ text (String.fromInt index ++ ". ") ]
, column
[ spacing 8
, width fill
]
2024-11-28 00:33:22 -06:00
[ episodeMaker appearanceEntry
, experienceMaker appearanceEntry
, dateMaker appearanceEntry
, subjectMaker appearanceEntry
, subjectList appearanceEntry
]
]
]
2024-11-28 00:33:22 -06:00
episodeMaker : Appearance -> Element msg
episodeMaker appearanceEntry =
paragraphLinkFormat
{ url = appearanceEntry.appearanceLink
, label =
row
[ F.size 18
]
[ text ("#" ++ appearanceEntry.appearanceEpisode ++ ": " ++ appearanceEntry.appearanceTitle)
|> el
[ F.color colourTheme.textLightOrange
, mouseOver [ F.color colourTheme.textDarkOrange ]
2024-11-28 00:33:22 -06:00
, transitionStyle
]
]
}
experienceMaker : Appearance -> Element msg
experienceMaker appearanceEntry =
row
[ width fill
, height fill
]
[ column
2024-11-28 00:33:22 -06:00
[ E.alignTop
, E.alignLeft
]
2024-11-28 19:28:24 -06:00
[ paragraph
(paragraphBoldFormat
++ [ F.size 18
, E.width fill
]
)
2024-11-28 00:33:22 -06:00
[ el
[ tooltip
"This represents how pleasant it was to interact with the host(s)."
]
(text "Pleasantness:")
]
]
2024-11-28 19:28:24 -06:00
, barPadding
[ barMaker getExperienceTooltip appearanceEntry.appearanceExperience ]
]
getExperienceTooltip : Int -> String
getExperienceTooltip num =
case num of
0 ->
"Nightmare. Deliberately malicious."
1 ->
"Toxic. Utter fucking twat(s)."
2 ->
"Hostile. Consistently disruptive."
3 ->
"Belligerent. Consistently disrespectful."
4 ->
"Uncivil. Frequently dismissive."
5 ->
"Neutral. Unremarkable social interaction."
6 ->
"Civil. Slightly considerate."
7 ->
"Pleasant. Genuinely respectful."
8 ->
"Very kind. Consistently supportive."
9 ->
"Compassionate. Went out of their way."
10 ->
"Absolute angel. Perfectly empathetic."
_ ->
"Behavior level out of expected range."
dateMaker : Appearance -> Element msg
dateMaker appearanceEntry =
row paragraphBoldFormat
[ column
[ alignTop
]
[ text "Published:"
]
, column
[ alignTop
, width fill
]
[ paragraph
[ F.regular
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = 3
}
]
[ text appearanceEntry.appearanceYear ]
]
]
subjectMaker : Appearance -> Element msg
subjectMaker appearanceEntry =
row paragraphBoldFormat
[ column
[ alignTop
]
[ text "Subjects:"
]
]
subjectList : Appearance -> Element msg
subjectList appearanceEntry =
column
[ spacing 8
, width fill
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = 25
}
]
<|
List.map2 (\x y -> makeSubject x)
appearanceEntry.appearanceSubjects
(List.range 1 (List.length appearanceEntry.appearanceSubjects))
makeSubject : Subjects -> Element msg
makeSubject subjects =
column
[ E.width fill
, alignLeft
, paddingEach
{ top = 0
, right = 0
, bottom = 0
, left = 8
}
]
[ paragraph [ F.regular ]
[ text (" " ++ subjects.subject) ]
]