2024-12-11 02:38:42 -06:00
|
|
|
module Pages.Debate.Arguments exposing (Model, Msg, page)
|
2024-11-12 19:23:16 -06:00
|
|
|
|
2024-12-09 19:53:09 -06:00
|
|
|
import Config.Data.Identity exposing (pageNames)
|
2024-12-27 01:30:21 -06:00
|
|
|
import Config.Helpers.Cards.Inner.Helpers
|
|
|
|
exposing
|
2024-12-28 20:50:11 -06:00
|
|
|
( argumentButton
|
|
|
|
, bodyFormat
|
2024-12-27 01:30:21 -06:00
|
|
|
, detailBodyMaker
|
|
|
|
, detailFormat
|
|
|
|
, detailSpacing
|
|
|
|
, detailTitleMaker
|
|
|
|
)
|
|
|
|
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
|
|
|
|
import Config.Helpers.Cards.Outer.Types as C
|
2024-12-20 00:13:27 -06:00
|
|
|
import Config.Helpers.Converters exposing (toTitleCase)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Config.Helpers.Format
|
|
|
|
exposing
|
2024-12-23 03:15:35 -06:00
|
|
|
( headerFontSizeSmall
|
|
|
|
, paragraphFontSize
|
2024-12-15 02:31:26 -06:00
|
|
|
, paragraphSpacing
|
|
|
|
)
|
2024-12-22 04:36:03 -06:00
|
|
|
import Config.Helpers.Headers.Helpers exposing (..)
|
|
|
|
import Config.Helpers.Headers.Records exposing (argumentHeader)
|
|
|
|
import Config.Helpers.Headers.Types as R exposing (..)
|
2024-12-23 03:15:35 -06:00
|
|
|
import Config.Helpers.ImageFolders as M exposing (..)
|
2024-12-11 03:48:49 -06:00
|
|
|
import Config.Helpers.Response
|
2024-12-09 19:53:09 -06:00
|
|
|
exposing
|
2024-12-09 20:30:04 -06:00
|
|
|
( pageList
|
2024-12-09 19:53:09 -06:00
|
|
|
, topLevelContainer
|
|
|
|
)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Config.Helpers.StrengthBar
|
|
|
|
exposing
|
|
|
|
( barMaker
|
|
|
|
, barPadding
|
|
|
|
)
|
|
|
|
import Config.Helpers.ToolTip exposing (tooltip)
|
2024-12-09 19:53:09 -06:00
|
|
|
import Config.Helpers.Viewport exposing (resetViewport)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Config.Pages.Debate.Arguments.List
|
|
|
|
exposing
|
|
|
|
( argumentList
|
|
|
|
)
|
2024-12-09 19:53:09 -06:00
|
|
|
import Config.Pages.Debate.Arguments.Types exposing (..)
|
2024-12-27 01:30:21 -06:00
|
|
|
import Config.Style.Colour.Helpers
|
|
|
|
exposing
|
|
|
|
( ThemeColor(..)
|
|
|
|
, colourTheme
|
|
|
|
)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Config.Style.Glow
|
|
|
|
exposing
|
|
|
|
( glowDeepDarkGrey
|
|
|
|
, glowDeepDarkOrange
|
|
|
|
)
|
2024-12-24 03:08:39 -06:00
|
|
|
import Config.Style.Images exposing (imageSquareMaker)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Config.Style.Transitions exposing (transitionStyleSlow)
|
2024-11-12 19:23:16 -06:00
|
|
|
import Effect exposing (Effect)
|
2024-12-09 19:53:09 -06:00
|
|
|
import Element as E exposing (..)
|
2024-12-15 02:31:26 -06:00
|
|
|
import Element.Background as B
|
|
|
|
import Element.Border as D
|
|
|
|
import Element.Font as F
|
|
|
|
import Html exposing (div, hr)
|
|
|
|
import Html.Attributes as H exposing (style, title, wrap)
|
2024-11-12 19:23:16 -06:00
|
|
|
import Layouts
|
|
|
|
import Page exposing (Page)
|
|
|
|
import Route exposing (Route)
|
2024-12-28 20:50:11 -06:00
|
|
|
import Route.Path as Path
|
2024-11-12 19:23:16 -06:00
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
page : Shared.Model -> Route () -> Page Model Msg
|
|
|
|
page shared route =
|
|
|
|
Page.new
|
|
|
|
{ init = init
|
|
|
|
, update = update
|
|
|
|
, subscriptions = subscriptions
|
2024-12-06 02:13:22 -06:00
|
|
|
, view = view shared
|
2024-11-12 19:23:16 -06:00
|
|
|
}
|
|
|
|
|> Page.withLayout toLayout
|
|
|
|
|
|
|
|
|
|
|
|
toLayout : Model -> Layouts.Layout Msg
|
|
|
|
toLayout model =
|
2024-12-07 15:43:26 -06:00
|
|
|
Layouts.Navbar {}
|
2024-11-12 19:23:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- INIT
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
2024-11-27 15:11:21 -06:00
|
|
|
{}
|
2024-11-12 19:23:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
init : () -> ( Model, Effect Msg )
|
|
|
|
init () =
|
2024-11-27 15:11:21 -06:00
|
|
|
( {}
|
2024-12-03 21:17:17 -06:00
|
|
|
, Effect.batch
|
|
|
|
[ Effect.map
|
|
|
|
(\_ -> NoOp)
|
|
|
|
(Effect.sendCmd resetViewport)
|
|
|
|
, Effect.none
|
|
|
|
]
|
2024-11-12 19:23:16 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- UPDATE
|
|
|
|
|
|
|
|
|
|
|
|
type Msg
|
2024-11-27 15:11:21 -06:00
|
|
|
= NoOp
|
2024-11-12 19:23:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Effect Msg )
|
|
|
|
update msg model =
|
2024-11-27 15:11:21 -06:00
|
|
|
case msg of
|
|
|
|
NoOp ->
|
|
|
|
( model
|
|
|
|
, Effect.none
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- SUBSCRIPTIONS
|
2024-11-12 19:23:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
subscriptions : Model -> Sub Msg
|
|
|
|
subscriptions model =
|
2024-11-27 15:11:21 -06:00
|
|
|
Sub.none
|
2024-11-12 19:23:16 -06:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- VIEW
|
|
|
|
|
|
|
|
|
2024-12-06 02:13:22 -06:00
|
|
|
view : Shared.Model -> Model -> View Msg
|
|
|
|
view shared model =
|
2024-12-08 02:18:36 -06:00
|
|
|
{ title = "debate (" ++ pageNames.pageArguments ++ ")"
|
2024-11-12 19:23:16 -06:00
|
|
|
, attributes = []
|
2024-12-06 02:13:22 -06:00
|
|
|
, element = debateContainer shared.device
|
2024-11-12 19:23:16 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-12-06 02:13:22 -06:00
|
|
|
debateContainer : Device -> Element msg
|
|
|
|
debateContainer device =
|
|
|
|
topLevelContainer (debateList device)
|
|
|
|
|
|
|
|
|
|
|
|
debateList : Device -> Element msg
|
|
|
|
debateList device =
|
|
|
|
column
|
|
|
|
(case ( device.class, device.orientation ) of
|
2024-12-07 15:43:26 -06:00
|
|
|
_ ->
|
2024-12-22 19:42:23 -06:00
|
|
|
pageList device
|
2024-12-06 02:13:22 -06:00
|
|
|
)
|
|
|
|
<|
|
|
|
|
List.concat
|
2024-12-22 04:36:03 -06:00
|
|
|
[ [ headerMaker (R.Arguments argumentHeader) ]
|
|
|
|
, List.map
|
2024-12-21 23:23:59 -06:00
|
|
|
(\argument ->
|
2024-12-23 03:15:35 -06:00
|
|
|
cardMaker device (C.Argument argument) (contentList device argument)
|
2024-12-21 23:23:59 -06:00
|
|
|
)
|
2024-12-08 02:18:36 -06:00
|
|
|
argumentList
|
2024-12-06 02:13:22 -06:00
|
|
|
]
|
2024-12-15 02:31:26 -06:00
|
|
|
|
|
|
|
|
2024-12-23 03:15:35 -06:00
|
|
|
contentList : Device -> Argument -> List (Element msg)
|
|
|
|
contentList device argument =
|
2024-12-24 03:08:39 -06:00
|
|
|
let
|
|
|
|
image : String -> Element msg
|
|
|
|
image size =
|
|
|
|
el
|
|
|
|
[ alignLeft
|
|
|
|
, alignTop
|
|
|
|
, paddingEach
|
|
|
|
{ top = 0
|
2024-12-27 01:30:21 -06:00
|
|
|
, right = 10
|
2024-12-24 03:08:39 -06:00
|
|
|
, bottom = 0
|
2024-12-27 01:30:21 -06:00
|
|
|
, left = 0
|
2024-12-24 03:08:39 -06:00
|
|
|
}
|
|
|
|
]
|
|
|
|
<|
|
2024-12-27 01:30:21 -06:00
|
|
|
imageSquareMaker device (imagePathMaker M.Argument argument.argumentImage) True size
|
2024-12-24 03:08:39 -06:00
|
|
|
in
|
2024-12-23 03:15:35 -06:00
|
|
|
[ row
|
|
|
|
[ width fill
|
|
|
|
, paddingEach
|
|
|
|
{ top =
|
|
|
|
case ( device.class, device.orientation ) of
|
|
|
|
( Phone, Portrait ) ->
|
|
|
|
8
|
|
|
|
|
|
|
|
( Tablet, Portrait ) ->
|
|
|
|
8
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
0
|
|
|
|
, right = 0
|
|
|
|
, bottom = 0
|
|
|
|
, left = 0
|
|
|
|
}
|
|
|
|
]
|
2024-12-27 01:30:21 -06:00
|
|
|
[ detailFormat column
|
|
|
|
[ detailFormat paragraph
|
|
|
|
[ case ( device.class, device.orientation ) of
|
|
|
|
( Phone, Portrait ) ->
|
|
|
|
none
|
2024-12-15 02:31:26 -06:00
|
|
|
|
2024-12-27 01:30:21 -06:00
|
|
|
( Tablet, Portrait ) ->
|
|
|
|
none
|
2024-12-15 02:31:26 -06:00
|
|
|
|
2024-12-27 01:30:21 -06:00
|
|
|
_ ->
|
2024-12-27 23:24:35 -06:00
|
|
|
image "Big"
|
2024-12-27 01:30:21 -06:00
|
|
|
, el ([ height fill ] ++ bodyFormat TextLightGrey) <| text argument.propositionSummary
|
2024-12-15 02:31:26 -06:00
|
|
|
]
|
2024-12-27 01:30:21 -06:00
|
|
|
, detailFormat row
|
|
|
|
[ strengthMaker
|
|
|
|
, barMaker getConfidenceTooltip argument.argumentCertainty
|
2024-12-15 02:31:26 -06:00
|
|
|
]
|
|
|
|
]
|
|
|
|
]
|
2024-12-27 01:30:21 -06:00
|
|
|
, tableMaker device argument
|
2024-12-28 18:42:47 -06:00
|
|
|
, formalizationMaker device argument
|
2024-12-28 20:50:11 -06:00
|
|
|
, el [alignRight] <|
|
|
|
|
row [ width fill, spacing 20 ]
|
|
|
|
[ argumentButton (Path.toString Path.Contact_Criticism) "Reject Premise"
|
|
|
|
, argumentButton argument.proofLink "Proof Tree"
|
|
|
|
]
|
2024-12-27 01:30:21 -06:00
|
|
|
]
|
2024-12-15 02:31:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
strengthMaker : Element msg
|
|
|
|
strengthMaker =
|
2024-12-27 01:30:21 -06:00
|
|
|
el
|
|
|
|
[ tooltip
|
|
|
|
"This represents my confidence in the soundness of the argument."
|
2024-12-15 02:31:26 -06:00
|
|
|
]
|
2024-12-27 01:30:21 -06:00
|
|
|
<|
|
|
|
|
detailTitleMaker TextLightOrange "Confidence:"
|
2024-12-15 02:31:26 -06:00
|
|
|
|
|
|
|
|
|
|
|
getConfidenceTooltip : Int -> String
|
|
|
|
getConfidenceTooltip num =
|
|
|
|
case num of
|
|
|
|
0 ->
|
|
|
|
"Extremely low. Speculative reasoning."
|
|
|
|
|
|
|
|
1 ->
|
|
|
|
"Very low. Extremely weak reasoning."
|
|
|
|
|
|
|
|
2 ->
|
|
|
|
"Low. Weak reasoning."
|
|
|
|
|
|
|
|
3 ->
|
|
|
|
"Kinda low. Somewhat weak reasoning."
|
|
|
|
|
|
|
|
4 ->
|
|
|
|
"Below average. More weak than strong."
|
|
|
|
|
|
|
|
5 ->
|
|
|
|
"Moderate. OK reasoning."
|
|
|
|
|
|
|
|
6 ->
|
|
|
|
"Above average. More strong than weak."
|
|
|
|
|
|
|
|
7 ->
|
|
|
|
"Kinda high. Somewhat strong reasoning."
|
|
|
|
|
|
|
|
8 ->
|
|
|
|
"High. Robust reasoning."
|
|
|
|
|
|
|
|
9 ->
|
|
|
|
"Very high. Extremely robust reasoning."
|
|
|
|
|
|
|
|
10 ->
|
|
|
|
"Extremely high. Air tight reasoning."
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
"Confidence level out of expected range."
|
|
|
|
|
|
|
|
|
2024-12-23 03:15:35 -06:00
|
|
|
tableMaker : Device -> Argument -> Element msg
|
|
|
|
tableMaker device argument =
|
2024-12-22 04:36:03 -06:00
|
|
|
let
|
|
|
|
cellPadding : Attribute msg
|
|
|
|
cellPadding =
|
|
|
|
paddingXY 10 5
|
|
|
|
in
|
2024-12-15 02:31:26 -06:00
|
|
|
column
|
|
|
|
[ centerX
|
|
|
|
, E.width fill
|
|
|
|
]
|
2024-12-22 04:36:03 -06:00
|
|
|
[ el
|
2024-12-27 01:30:21 -06:00
|
|
|
[ E.width fill
|
2024-12-22 04:36:03 -06:00
|
|
|
, htmlAttribute <| H.style "position" "relative"
|
|
|
|
]
|
|
|
|
<|
|
|
|
|
E.table
|
2024-12-23 03:15:35 -06:00
|
|
|
([ D.rounded 10
|
|
|
|
, D.width 2
|
|
|
|
, D.color colourTheme.textDarkGrey
|
|
|
|
, clip
|
|
|
|
]
|
|
|
|
++ (case ( device.class, device.orientation ) of
|
|
|
|
( Phone, Portrait ) ->
|
|
|
|
[ B.color colourTheme.backgroundSpreadsheet ]
|
|
|
|
|
|
|
|
( Tablet, Portrait ) ->
|
|
|
|
[ B.color colourTheme.backgroundSpreadsheet ]
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
[]
|
|
|
|
)
|
|
|
|
)
|
2024-12-15 02:31:26 -06:00
|
|
|
{ data = argument.definitionTable
|
|
|
|
, columns =
|
|
|
|
[ { header =
|
|
|
|
el
|
|
|
|
[ F.bold
|
|
|
|
, D.widthEach
|
|
|
|
{ bottom = 1
|
|
|
|
, top = 1
|
|
|
|
, left = 1
|
|
|
|
, right = 1
|
|
|
|
}
|
|
|
|
, D.color colourTheme.textDarkGrey
|
2024-12-22 04:36:03 -06:00
|
|
|
, cellPadding
|
2024-12-15 02:31:26 -06:00
|
|
|
, E.width fill
|
|
|
|
]
|
2024-12-22 04:36:03 -06:00
|
|
|
<|
|
2024-12-27 01:30:21 -06:00
|
|
|
detailTitleMaker
|
|
|
|
TextLightOrange
|
|
|
|
"Definiendum"
|
2024-12-22 04:36:03 -06:00
|
|
|
, width = fill |> maximum 30
|
2024-12-15 02:31:26 -06:00
|
|
|
, view =
|
|
|
|
\definition ->
|
2024-12-22 04:36:03 -06:00
|
|
|
el
|
2024-12-27 01:30:21 -06:00
|
|
|
[ D.widthEach
|
2024-12-15 02:31:26 -06:00
|
|
|
{ bottom = 1
|
|
|
|
, top = 0
|
|
|
|
, left = 1
|
|
|
|
, right = 1
|
|
|
|
}
|
|
|
|
, D.color colourTheme.textDarkGrey
|
2024-12-22 04:36:03 -06:00
|
|
|
, cellPadding
|
2024-12-15 02:31:26 -06:00
|
|
|
, E.height fill
|
|
|
|
]
|
2024-12-22 04:36:03 -06:00
|
|
|
<|
|
2024-12-27 01:30:21 -06:00
|
|
|
el
|
|
|
|
[ centerX
|
|
|
|
, centerY
|
|
|
|
]
|
|
|
|
<|
|
|
|
|
paragraph [] [ detailTitleMaker TextLightOrange definition.definiendum ]
|
2024-12-15 02:31:26 -06:00
|
|
|
}
|
|
|
|
, { header =
|
|
|
|
el
|
2024-12-27 01:30:21 -06:00
|
|
|
[ D.widthEach
|
2024-12-15 02:31:26 -06:00
|
|
|
{ bottom = 1
|
|
|
|
, top = 1
|
|
|
|
, left = 0
|
|
|
|
, right = 1
|
|
|
|
}
|
|
|
|
, D.color colourTheme.textDarkGrey
|
2024-12-22 04:36:03 -06:00
|
|
|
, cellPadding
|
2024-12-15 02:31:26 -06:00
|
|
|
, E.width fill
|
|
|
|
]
|
2024-12-22 04:36:03 -06:00
|
|
|
<|
|
2024-12-27 01:30:21 -06:00
|
|
|
detailTitleMaker TextLightOrange "Definiens"
|
2024-12-15 02:31:26 -06:00
|
|
|
, width = fill
|
|
|
|
, view =
|
|
|
|
\definition ->
|
2024-12-22 04:36:03 -06:00
|
|
|
el
|
2024-12-27 01:30:21 -06:00
|
|
|
[ D.widthEach
|
2024-12-15 02:31:26 -06:00
|
|
|
{ bottom = 1
|
|
|
|
, top = 0
|
|
|
|
, left = 0
|
|
|
|
, right = 1
|
|
|
|
}
|
|
|
|
, D.color colourTheme.textDarkGrey
|
2024-12-22 04:36:03 -06:00
|
|
|
, cellPadding
|
2024-12-15 02:31:26 -06:00
|
|
|
, E.height fill
|
|
|
|
]
|
2024-12-22 04:36:03 -06:00
|
|
|
<|
|
|
|
|
el [] <|
|
2024-12-27 01:30:21 -06:00
|
|
|
paragraph [] [ detailBodyMaker TextLightGrey (text definition.definiens) ]
|
2024-12-15 02:31:26 -06:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2024-12-28 18:42:47 -06:00
|
|
|
formalizationMaker : Device -> Argument -> Element msg
|
|
|
|
formalizationMaker device argument =
|
2024-12-15 02:31:26 -06:00
|
|
|
column
|
|
|
|
[ centerX
|
|
|
|
, E.width fill
|
|
|
|
, spacing 10
|
|
|
|
]
|
|
|
|
(List.indexedMap
|
|
|
|
(\index argumentEntry ->
|
|
|
|
column
|
2024-12-28 18:42:47 -06:00
|
|
|
[ paddingXY
|
|
|
|
(case ( device.class, device.orientation ) of
|
|
|
|
( Phone, Portrait ) ->
|
|
|
|
0
|
|
|
|
|
|
|
|
( Tablet, Portrait ) ->
|
|
|
|
0
|
|
|
|
|
|
|
|
_ ->
|
2024-12-28 20:50:11 -06:00
|
|
|
40
|
2024-12-28 18:42:47 -06:00
|
|
|
)
|
|
|
|
3
|
2024-12-22 04:36:03 -06:00
|
|
|
]
|
2024-12-15 02:31:26 -06:00
|
|
|
(List.indexedMap
|
|
|
|
(\entryIndex entryWithNotation ->
|
|
|
|
column
|
|
|
|
[ centerX
|
|
|
|
, F.center
|
2024-12-27 01:30:21 -06:00
|
|
|
, detailSpacing
|
2024-12-15 02:31:26 -06:00
|
|
|
, E.width fill
|
|
|
|
]
|
|
|
|
[ paragraph
|
2024-12-27 01:30:21 -06:00
|
|
|
[ width fill ]
|
|
|
|
[ detailTitleMaker
|
|
|
|
TextLightOrange
|
2024-12-15 02:31:26 -06:00
|
|
|
(if entryIndex < List.length argumentEntry.premises then
|
|
|
|
"P" ++ String.fromInt (entryIndex + 1) ++ ") "
|
|
|
|
|
|
|
|
else
|
|
|
|
"C) "
|
|
|
|
)
|
2024-12-27 01:30:21 -06:00
|
|
|
, detailBodyMaker TextLightGrey
|
|
|
|
(text
|
|
|
|
(if entryIndex < List.length argumentEntry.premises then
|
|
|
|
entryWithNotation.premise
|
|
|
|
|
|
|
|
else
|
|
|
|
argumentEntry.conclusion
|
|
|
|
)
|
2024-12-15 02:31:26 -06:00
|
|
|
)
|
|
|
|
|> el
|
2024-12-27 01:30:21 -06:00
|
|
|
[]
|
2024-12-15 02:31:26 -06:00
|
|
|
]
|
|
|
|
, paragraph
|
2024-12-27 01:30:21 -06:00
|
|
|
[]
|
|
|
|
[ detailTitleMaker
|
|
|
|
TextLightOrange
|
2024-12-15 02:31:26 -06:00
|
|
|
(if entryIndex < List.length argumentEntry.premises then
|
|
|
|
"(" ++ entryWithNotation.notation ++ ")"
|
|
|
|
|
|
|
|
else
|
|
|
|
"(∴" ++ argumentEntry.conclusionNotation ++ ")"
|
|
|
|
)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
)
|
|
|
|
(argumentEntry.premises ++ [ { premise = argumentEntry.conclusion, notation = argumentEntry.conclusionNotation } ])
|
|
|
|
)
|
|
|
|
)
|
|
|
|
argument.argumentFormalization
|
|
|
|
)
|