website/frontend/src/Pages/Propositions.elm
2024-11-11 21:57:27 -06:00

200 lines
5.2 KiB
Elm

module Pages.Propositions exposing (Model, Msg, page)
import Config.Colour as T exposing (..)
import Config.Format as O exposing (..)
import Config.Identity as I exposing (..)
import Effect exposing (Effect)
import Element exposing (..)
import Element.Font as F
import Html
import Html.Attributes as H exposing (style)
import Layouts
import Page exposing (Page)
import Route exposing (Route)
import Shared
import View exposing (View)
page : Shared.Model -> Route () -> Page Model Msg
page shared route =
Page.new
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
|> Page.withLayout toLayout
toLayout : Model -> Layouts.Layout Msg
toLayout model =
Layouts.Navbar {}
-- INIT
type alias Model =
{}
init : () -> ( Model, Effect Msg )
init () =
( {}
, Effect.none
)
-- UPDATE
type Msg
= NoOp
update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
NoOp ->
( model
, Effect.none
)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Model -> View Msg
view model =
{ title = propositionsName
, attributes = []
, element = propositionsContainer
}
propositionsContainer : Element msg
propositionsContainer =
topLevelContainer propositionsList
propositionsList : Element msg
propositionsList =
column
pageList
propositions
type alias MakeRowInput =
{ propositionTitle : String
, propositionSummary : String
, definitionTable : List Definition
, argumentFormalization : List ArgumentEntry
}
type alias ArgumentEntry =
{ premises : List String
, conclusion : String
}
type alias Definition =
{ definiendum : String
, definiens : String
}
makeRow : MakeRowInput -> Element msg
makeRow makeRowInput =
let
argRows : List (Element msg)
argRows =
List.indexedMap
(\index argumentEntry ->
column paragraphFormat
(List.indexedMap
(\premiseIndex premise ->
row paragraphHightlightedBoldText
[ text ("P" ++ String.fromInt (premiseIndex + 1) ++ ")")
, text premise |> el [ F.color colourTheme.nonHighlightedText, F.regular ]
]
)
argumentEntry.premises
++ [ row paragraphHightlightedBoldText
[ text ("C" ++ String.fromInt (index + 1) ++ ")")
, text argumentEntry.conclusion |> el [ F.color colourTheme.nonHighlightedText, F.regular ]
]
]
)
)
makeRowInput.argumentFormalization
in
column
[ paragraphWidth, alignLeft, spacing 8 ]
[ row paragraphBoldFormat
[ text "Proposition:" |> el [ F.color colourTheme.highlightText ]
, text makeRowInput.propositionTitle |> el [ F.color colourTheme.nonHighlightedText, F.regular ]
]
, row paragraphBoldFormat
[ text "Summary:" |> el [ F.color colourTheme.highlightText ]
, text makeRowInput.propositionSummary |> el [ F.color colourTheme.nonHighlightedText, F.regular ]
]
, row (paragraphBoldFormat ++ [ alignLeft ])
[ Element.table [ spacing 8 ]
{ data = makeRowInput.definitionTable
, columns =
[ { header = el [ F.bold ] (text "Definiendum" |> el [ F.color colourTheme.highlightText ])
, width = fill
, view =
\definition ->
text definition.definiendum |> el [ F.color colourTheme.nonHighlightedText, F.regular]
}
, { header = el [ F.bold ] (text "Definiens" |> el [ F.color colourTheme.highlightText ])
, width = fill
, view =
\definition ->
text definition.definiens |> el [ F.color colourTheme.nonHighlightedText, F.regular]
}
]
}
]
, column [ centerX, paragraphSpacing ] argRows
]
propositions =
List.map makeRow
[ { propositionTitle = "String"
, propositionSummary = "String"
, definitionTable =
[ { definiendum = "Term 1"
, definiens = "Definition 1"
}
, { definiendum = "Term 2"
, definiens = "Definition 2"
}
]
, argumentFormalization =
[ { premises =
[ "First premise"
, "Second premise"
, "Third premise"
, "Fourth premise"
]
, conclusion = "Conclusion"
}
]
}
]