mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-16 12:25:12 -05:00
feat: arg expansions working, lez go ma nigga
This commit is contained in:
parent
45ca7a9718
commit
1196617af5
6 changed files with 167 additions and 104 deletions
|
@ -17,6 +17,7 @@ import Html.Attributes exposing (form, id)
|
|||
import Layouts
|
||||
import List.Extra exposing (..)
|
||||
import Maybe exposing (withDefault)
|
||||
import Maybe.Extra exposing (isNothing)
|
||||
import Page exposing (Page)
|
||||
import Route exposing (Route)
|
||||
import Shared
|
||||
|
@ -35,47 +36,57 @@ import View exposing (View)
|
|||
-- )
|
||||
|
||||
|
||||
argumentMaker : (Int -> msg) -> List Int -> Argument -> Int -> Element msg
|
||||
argumentMaker onClickMsg argHeights argument indexExpand =
|
||||
let
|
||||
isArgumentExpanded : Int
|
||||
isArgumentExpanded =
|
||||
withDefault 0 <| getAt indexExpand argHeights
|
||||
in
|
||||
type alias ArgMakerInput msg =
|
||||
{ arg : Argument
|
||||
, index : Int
|
||||
, isExpanded : Bool
|
||||
, maybeHeight : Maybe Int
|
||||
, titleClickMsg : msg
|
||||
}
|
||||
|
||||
|
||||
argumentMaker : ArgMakerInput msg -> Element msg
|
||||
argumentMaker argMakerInput =
|
||||
column
|
||||
[ B.color colourTheme.cardBackground
|
||||
, rounded 10
|
||||
, E.width <| px 700
|
||||
, E.htmlAttribute (id <| "arg" ++ String.fromInt indexExpand)
|
||||
]
|
||||
[ titleMaker onClickMsg indexExpand argument.argumentTitle isArgumentExpanded
|
||||
(if isNothing argMakerInput.maybeHeight then
|
||||
[ E.htmlAttribute (id <| "arg" ++ String.fromInt argMakerInput.index) ]
|
||||
|
||||
else
|
||||
[]
|
||||
)
|
||||
[ titleMaker argMakerInput
|
||||
, column
|
||||
([ E.width <| px 600, centerX, transitionStyle, spacing 10 ]
|
||||
-- ++ (if not isArgumentExpanded then
|
||||
-- [ transitionStyle
|
||||
-- -- , height <| px 0
|
||||
-- , roundEach { topLeft = 0, topRight = 0, bottomRight = 10, bottomLeft = 10 }
|
||||
-- , clip
|
||||
-- ]
|
||||
-- else
|
||||
-- [ transitionStyle
|
||||
-- , height <| px 300
|
||||
-- , clip
|
||||
-- ]
|
||||
-- )
|
||||
(case argMakerInput.maybeHeight of
|
||||
Just h ->
|
||||
[ B.color colourTheme.cardBackground
|
||||
, clip
|
||||
, transitionStyle
|
||||
, height <|
|
||||
px <|
|
||||
if argMakerInput.isExpanded then
|
||||
h
|
||||
|
||||
else
|
||||
0
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
[ transparent True ]
|
||||
)
|
||||
[ propositionMaker argument isArgumentExpanded
|
||||
, reductioMaker argument isArgumentExpanded
|
||||
, summaryMaker argument isArgumentExpanded
|
||||
, strengthMaker argument isArgumentExpanded
|
||||
, tableMaker argument isArgumentExpanded
|
||||
, proofTreeMaker argument isArgumentExpanded
|
||||
]
|
||||
<|
|
||||
List.map (\x -> x argMakerInput)
|
||||
[ propositionMaker
|
||||
, reductioMaker
|
||||
, summaryMaker
|
||||
, strengthMaker
|
||||
, tableMaker
|
||||
, proofTreeMaker
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
titleMaker : (Int -> msg) -> Int -> String -> Int -> Element msg
|
||||
titleMaker onClickMsg indexExpand title argHeight =
|
||||
titleMaker : ArgMakerInput msg -> Element msg
|
||||
titleMaker argMakerInput =
|
||||
paragraph
|
||||
(paragraphBoldFormat
|
||||
++ [ F.size 20
|
||||
|
@ -93,21 +104,21 @@ titleMaker onClickMsg indexExpand title argHeight =
|
|||
, F.color colourTheme.nonHighlightedText
|
||||
, D.color colourTheme.highlightTextHover
|
||||
]
|
||||
, V.onClick <| onClickMsg indexExpand
|
||||
, V.onClick <| argMakerInput.titleClickMsg
|
||||
]
|
||||
++ (if argHeight == 30 then
|
||||
[ rounded 10 ]
|
||||
++ (case argMakerInput.maybeHeight of
|
||||
Nothing ->
|
||||
[ transparent True ]
|
||||
|
||||
else
|
||||
[ roundEach { topLeft = 10, topRight = 10, bottomRight = 0, bottomLeft = 0 } ]
|
||||
Just _ ->
|
||||
[ roundEach { topLeft = 10, topRight = 10, bottomRight = 0, bottomLeft = 0 } ]
|
||||
)
|
||||
)
|
||||
[ text title
|
||||
]
|
||||
[ text argMakerInput.arg.argumentTitle ]
|
||||
|
||||
|
||||
propositionMaker : Argument -> Int -> Element msg
|
||||
propositionMaker argument argHeight =
|
||||
propositionMaker : ArgMakerInput msg -> Element msg
|
||||
propositionMaker argMakerInput =
|
||||
row
|
||||
[ paddingEach { top = 10, right = 0, bottom = 0, left = 0 }
|
||||
]
|
||||
|
@ -124,7 +135,7 @@ propositionMaker argument argHeight =
|
|||
, column
|
||||
[ E.width fill, E.alignLeft ]
|
||||
[ paragraph (paragraphBoldFormat ++ [ F.size 18 ])
|
||||
[ text argument.propositionTitle
|
||||
[ text argMakerInput.arg.propositionTitle
|
||||
|> el
|
||||
[ F.color colourTheme.nonHighlightedText
|
||||
, F.regular
|
||||
|
@ -135,9 +146,9 @@ propositionMaker argument argHeight =
|
|||
]
|
||||
|
||||
|
||||
reductioMaker : Argument -> Int -> Element msg
|
||||
reductioMaker argument argHeight =
|
||||
case argument.propositionReductio of
|
||||
reductioMaker : ArgMakerInput msg -> Element msg
|
||||
reductioMaker argMakerInput =
|
||||
case argMakerInput.arg.propositionReductio of
|
||||
"" ->
|
||||
none
|
||||
|
||||
|
@ -156,8 +167,8 @@ reductioMaker argument argHeight =
|
|||
]
|
||||
|
||||
|
||||
summaryMaker : Argument -> Int -> Element msg
|
||||
summaryMaker argument argHeight =
|
||||
summaryMaker : ArgMakerInput msg -> Element msg
|
||||
summaryMaker argMakerInput =
|
||||
row []
|
||||
[ column
|
||||
[ E.alignTop, E.alignLeft ]
|
||||
|
@ -173,7 +184,7 @@ summaryMaker argument argHeight =
|
|||
, spacing 3
|
||||
]
|
||||
)
|
||||
[ text argument.propositionSummary
|
||||
[ text argMakerInput.arg.propositionSummary
|
||||
|> el
|
||||
[ F.color colourTheme.nonHighlightedText
|
||||
, F.regular
|
||||
|
@ -184,8 +195,8 @@ summaryMaker argument argHeight =
|
|||
]
|
||||
|
||||
|
||||
strengthMaker : Argument -> Int -> Element msg
|
||||
strengthMaker argument argHeight =
|
||||
strengthMaker : ArgMakerInput msg -> Element msg
|
||||
strengthMaker argMakerInput =
|
||||
let
|
||||
barMaker : Int -> Element msg
|
||||
barMaker num =
|
||||
|
@ -254,12 +265,12 @@ strengthMaker argument argHeight =
|
|||
]
|
||||
, column
|
||||
[ E.width fill, E.alignLeft, centerY ]
|
||||
[ barMaker argument.argumentCertainty ]
|
||||
[ barMaker argMakerInput.arg.argumentCertainty ]
|
||||
]
|
||||
|
||||
|
||||
tableMaker : Argument -> Int -> Element msg
|
||||
tableMaker argument argHeight =
|
||||
tableMaker : ArgMakerInput msg -> Element msg
|
||||
tableMaker argMakerInput =
|
||||
let
|
||||
formalizationMaker : List (Element msg)
|
||||
formalizationMaker =
|
||||
|
@ -300,7 +311,7 @@ tableMaker argument argHeight =
|
|||
]
|
||||
)
|
||||
)
|
||||
argument.argumentFormalization
|
||||
argMakerInput.arg.argumentFormalization
|
||||
in
|
||||
column [ centerX, E.width <| px 600 ]
|
||||
[ wrappedRow (paragraphBoldFormat ++ [ E.alignLeft, E.width fill ])
|
||||
|
@ -311,7 +322,7 @@ tableMaker argument argHeight =
|
|||
, D.color colourTheme.nonHighlightedDarkText
|
||||
, clip
|
||||
]
|
||||
{ data = argument.definitionTable
|
||||
{ data = argMakerInput.arg.definitionTable
|
||||
, columns =
|
||||
[ { header =
|
||||
el
|
||||
|
@ -368,8 +379,8 @@ tableMaker argument argHeight =
|
|||
]
|
||||
|
||||
|
||||
proofTreeMaker : Argument -> Int -> Element msg
|
||||
proofTreeMaker argument argHeight =
|
||||
proofTreeMaker : ArgMakerInput msg -> Element msg
|
||||
proofTreeMaker argMakerInput =
|
||||
row [ paddingEach { top = 10, right = 0, bottom = 10, left = 0 }, centerX, E.width fill ]
|
||||
[ column [ E.alignRight ]
|
||||
[ newTabLink
|
||||
|
@ -391,7 +402,7 @@ proofTreeMaker argument argHeight =
|
|||
]
|
||||
]
|
||||
)
|
||||
{ url = argument.proofLink
|
||||
{ url = argMakerInput.arg.proofLink
|
||||
, label = text "Proof Tree"
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue