website/frontend/src/Cuckery/Helpers.elm

176 lines
5.5 KiB
Elm
Raw Normal View History

2024-11-13 23:29:50 -06:00
module Cuckery.Helpers exposing (..)
import Config.Colour exposing (..)
import Config.Format exposing (..)
import Cuckery.Types exposing (..)
import Effect exposing (Effect)
import Element exposing (..)
import Element.Border as D
import Element.Font as F
import Html.Attributes as H exposing (style)
import Layouts
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)
2024-11-20 14:40:40 -06:00
labeledField : String -> Element msg -> Element msg
labeledField label content =
row paragraphBoldFormat
[ column [ alignTop, width (px 184) ]
[ text (label ++ ":") |> el [ paddingEach { top = 0, right = 0, bottom = 0, left = 70 } ]
]
, column [ width (px 350), alignLeft ]
[ paragraph [ F.regular ] [ content ]
]
]
formatDoxasticState : Maybe DoxasticState -> Element msg
formatDoxasticState state =
case state of
Nothing ->
text "I don't form a doxastic state."
Just Belief ->
row []
[ text "I lean more toward "
, el [ F.bold ] (text "TRUE")
, text " than false."
]
Just Disbelief ->
row []
[ text "I lean more toward "
, el [ F.bold ] (text "FALSE")
, text " than true."
]
Just Agnostic ->
text "I don't form beliefs about this proposition."
formatDodgeDescription : DodgeDescription -> String
formatDodgeDescription desc =
case desc of
NoReply ->
"Debate invitation extended with no response"
RanAway ->
"Engaged in written debate and ran away when cornered"
GhostedMe ->
"Debate invitation accepted with no follow-up"
OutrightNo ->
"Debate invitation declined"
InTooDeep ->
"Debate invitation accepted and subsequently retracted"
KillScreen ->
"All further debate invitations preemptively declined"
VagueGesture ->
"Chose to gesture vaguely instead of engaging"
formatFallacy : DodgeFallacies -> String
formatFallacy fallacy =
case fallacy of
SpecificFallacy str ->
if String.isEmpty str then
""
else
str
AppealToNature ->
"Appeal to Nature"
AppealToTradition ->
"Appeal to Tradition"
AppealToIgnorance ->
"Appeal to Ignorance"
AppealFromIncredulity ->
"Appeal from Incredulity"
RedHerring ->
"Red Herring"
BeggingTheQuestion ->
"Begging the Question"
Strawman ->
"Strawman"
Equivocation ->
"Equivocation"
GeneticFallacy ->
"Genetic Fallacy"
MotteAndBailey ->
"Motte and Bailey"
formatDoxasticReason : Evaluation -> String
formatDoxasticReason reason =
case reason of
NoProp ->
"There is no proposition to evaluate."
VagueProp ->
"The proposition is too vague to evaluate."
SpecificProp str ->
str
2024-11-13 23:29:50 -06:00
makeDodge : Dodge -> Int -> Element msg
makeDodge dodgeEntry index =
2024-11-20 14:40:40 -06:00
let
formatProposition : String -> String
formatProposition proposition =
if proposition == "N/A" then
proposition
else
"\"" ++ proposition ++ "\""
maybeFallacyField : Element msg
maybeFallacyField =
case dodgeEntry.dodgeFallacy of
Nothing ->
none
Just fallacy ->
labeledField "Fallacy" (text (formatFallacy fallacy))
in
column paragraphAlignLeft
[ row (paragraphFormat ++ [ F.size 18 ])
[ text " "
, text (String.fromInt index ++ ". ")
, paragraphLinkFormat
{ url = dodgeEntry.dodgeLink
, label = row [ F.size 18 ]
[ transitionHighlightedLinkHover <|
text (formatDodgeDescription dodgeEntry.dodgeDescription)
, text "." |> el [ F.color colourTheme.nonHighlightedText ]
]
}
]
, labeledField "Proposition" (text (formatProposition dodgeEntry.dodgeProposition))
, maybeFallacyField
, labeledField "Doxastic State" (formatDoxasticState dodgeEntry.dodgeNicksDoxasticState)
, labeledField "Reason" (text (formatDoxasticReason dodgeEntry.dodgeNicksDoxasticReason))
]
2024-11-13 23:29:50 -06:00
cuckMaker : Cuck -> Element msg
cuckMaker cuck =
2024-11-20 14:40:40 -06:00
row [ imageSpacer, alignLeft ]
[ image
[ centerX
, centerY
, alignTop
, D.rounded 100
, clip
, width <| px 72
]
{ src = "cucks/" ++ cuck.cuckImage ++ "/" ++ cuck.cuckImage ++ ".png"
, description = cuck.cuckName
}
, column
paragraphAlignLeft
[ row nonHighlightedTitleFormat [ text cuck.cuckName ]
, row (paragraphBoldFormat ++ [ F.size 18 ])
[ text "Social:"
, paragraphLinkFormat
{ url = cuck.cuckSocial
, label = transitionHighlightedLinkHover <| text (formatCuckSocial cuck.cuckSocial)
}
]
, row (paragraphBoldFormat ++ [ F.size 18 ]) [ text "Dodges:" ]
, column [ spacing 8 ] <|
List.map2 (\x y -> makeDodge x y)
cuck.cuckDodges
(List.range 1 (List.length cuck.cuckDodges))
]
]