mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-16 04:25:11 -05:00
Merge branch 'main' into 'main'
feat: arg expansions working, lez go ma nigga See merge request BRBWaffles/website!2
This commit is contained in:
commit
a220b0d9c1
6 changed files with 167 additions and 104 deletions
|
@ -14,6 +14,7 @@
|
||||||
"elm/json": "1.1.3",
|
"elm/json": "1.1.3",
|
||||||
"elm/url": "1.0.0",
|
"elm/url": "1.0.0",
|
||||||
"elm-community/list-extra": "8.7.0",
|
"elm-community/list-extra": "8.7.0",
|
||||||
|
"elm-community/maybe-extra": "5.3.0",
|
||||||
"mdgriffith/elm-ui": "1.1.8"
|
"mdgriffith/elm-ui": "1.1.8"
|
||||||
},
|
},
|
||||||
"indirect": {
|
"indirect": {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Html.Attributes exposing (form, id)
|
||||||
import Layouts
|
import Layouts
|
||||||
import List.Extra exposing (..)
|
import List.Extra exposing (..)
|
||||||
import Maybe exposing (withDefault)
|
import Maybe exposing (withDefault)
|
||||||
|
import Maybe.Extra exposing (isNothing)
|
||||||
import Page exposing (Page)
|
import Page exposing (Page)
|
||||||
import Route exposing (Route)
|
import Route exposing (Route)
|
||||||
import Shared
|
import Shared
|
||||||
|
@ -35,47 +36,57 @@ import View exposing (View)
|
||||||
-- )
|
-- )
|
||||||
|
|
||||||
|
|
||||||
argumentMaker : (Int -> msg) -> List Int -> Argument -> Int -> Element msg
|
type alias ArgMakerInput msg =
|
||||||
argumentMaker onClickMsg argHeights argument indexExpand =
|
{ arg : Argument
|
||||||
let
|
, index : Int
|
||||||
isArgumentExpanded : Int
|
, isExpanded : Bool
|
||||||
isArgumentExpanded =
|
, maybeHeight : Maybe Int
|
||||||
withDefault 0 <| getAt indexExpand argHeights
|
, titleClickMsg : msg
|
||||||
in
|
}
|
||||||
|
|
||||||
|
|
||||||
|
argumentMaker : ArgMakerInput msg -> Element msg
|
||||||
|
argumentMaker argMakerInput =
|
||||||
column
|
column
|
||||||
[ B.color colourTheme.cardBackground
|
(if isNothing argMakerInput.maybeHeight then
|
||||||
, rounded 10
|
[ E.htmlAttribute (id <| "arg" ++ String.fromInt argMakerInput.index) ]
|
||||||
, E.width <| px 700
|
|
||||||
, E.htmlAttribute (id <| "arg" ++ String.fromInt indexExpand)
|
else
|
||||||
]
|
[]
|
||||||
[ titleMaker onClickMsg indexExpand argument.argumentTitle isArgumentExpanded
|
)
|
||||||
|
[ titleMaker argMakerInput
|
||||||
, column
|
, column
|
||||||
([ E.width <| px 600, centerX, transitionStyle, spacing 10 ]
|
(case argMakerInput.maybeHeight of
|
||||||
-- ++ (if not isArgumentExpanded then
|
Just h ->
|
||||||
-- [ transitionStyle
|
[ B.color colourTheme.cardBackground
|
||||||
-- -- , height <| px 0
|
, clip
|
||||||
-- , roundEach { topLeft = 0, topRight = 0, bottomRight = 10, bottomLeft = 10 }
|
, transitionStyle
|
||||||
-- , clip
|
, height <|
|
||||||
-- ]
|
px <|
|
||||||
-- else
|
if argMakerInput.isExpanded then
|
||||||
-- [ transitionStyle
|
h
|
||||||
-- , height <| px 300
|
|
||||||
-- , clip
|
else
|
||||||
-- ]
|
0
|
||||||
-- )
|
]
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
[ transparent True ]
|
||||||
)
|
)
|
||||||
[ propositionMaker argument isArgumentExpanded
|
<|
|
||||||
, reductioMaker argument isArgumentExpanded
|
List.map (\x -> x argMakerInput)
|
||||||
, summaryMaker argument isArgumentExpanded
|
[ propositionMaker
|
||||||
, strengthMaker argument isArgumentExpanded
|
, reductioMaker
|
||||||
, tableMaker argument isArgumentExpanded
|
, summaryMaker
|
||||||
, proofTreeMaker argument isArgumentExpanded
|
, strengthMaker
|
||||||
]
|
, tableMaker
|
||||||
|
, proofTreeMaker
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
titleMaker : (Int -> msg) -> Int -> String -> Int -> Element msg
|
titleMaker : ArgMakerInput msg -> Element msg
|
||||||
titleMaker onClickMsg indexExpand title argHeight =
|
titleMaker argMakerInput =
|
||||||
paragraph
|
paragraph
|
||||||
(paragraphBoldFormat
|
(paragraphBoldFormat
|
||||||
++ [ F.size 20
|
++ [ F.size 20
|
||||||
|
@ -93,21 +104,21 @@ titleMaker onClickMsg indexExpand title argHeight =
|
||||||
, F.color colourTheme.nonHighlightedText
|
, F.color colourTheme.nonHighlightedText
|
||||||
, D.color colourTheme.highlightTextHover
|
, D.color colourTheme.highlightTextHover
|
||||||
]
|
]
|
||||||
, V.onClick <| onClickMsg indexExpand
|
, V.onClick <| argMakerInput.titleClickMsg
|
||||||
]
|
]
|
||||||
++ (if argHeight == 30 then
|
++ (case argMakerInput.maybeHeight of
|
||||||
[ rounded 10 ]
|
Nothing ->
|
||||||
|
[ transparent True ]
|
||||||
|
|
||||||
else
|
Just _ ->
|
||||||
[ roundEach { topLeft = 10, topRight = 10, bottomRight = 0, bottomLeft = 0 } ]
|
[ roundEach { topLeft = 10, topRight = 10, bottomRight = 0, bottomLeft = 0 } ]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
[ text title
|
[ text argMakerInput.arg.argumentTitle ]
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
propositionMaker : Argument -> Int -> Element msg
|
propositionMaker : ArgMakerInput msg -> Element msg
|
||||||
propositionMaker argument argHeight =
|
propositionMaker argMakerInput =
|
||||||
row
|
row
|
||||||
[ paddingEach { top = 10, right = 0, bottom = 0, left = 0 }
|
[ paddingEach { top = 10, right = 0, bottom = 0, left = 0 }
|
||||||
]
|
]
|
||||||
|
@ -124,7 +135,7 @@ propositionMaker argument argHeight =
|
||||||
, column
|
, column
|
||||||
[ E.width fill, E.alignLeft ]
|
[ E.width fill, E.alignLeft ]
|
||||||
[ paragraph (paragraphBoldFormat ++ [ F.size 18 ])
|
[ paragraph (paragraphBoldFormat ++ [ F.size 18 ])
|
||||||
[ text argument.propositionTitle
|
[ text argMakerInput.arg.propositionTitle
|
||||||
|> el
|
|> el
|
||||||
[ F.color colourTheme.nonHighlightedText
|
[ F.color colourTheme.nonHighlightedText
|
||||||
, F.regular
|
, F.regular
|
||||||
|
@ -135,9 +146,9 @@ propositionMaker argument argHeight =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
reductioMaker : Argument -> Int -> Element msg
|
reductioMaker : ArgMakerInput msg -> Element msg
|
||||||
reductioMaker argument argHeight =
|
reductioMaker argMakerInput =
|
||||||
case argument.propositionReductio of
|
case argMakerInput.arg.propositionReductio of
|
||||||
"" ->
|
"" ->
|
||||||
none
|
none
|
||||||
|
|
||||||
|
@ -156,8 +167,8 @@ reductioMaker argument argHeight =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
summaryMaker : Argument -> Int -> Element msg
|
summaryMaker : ArgMakerInput msg -> Element msg
|
||||||
summaryMaker argument argHeight =
|
summaryMaker argMakerInput =
|
||||||
row []
|
row []
|
||||||
[ column
|
[ column
|
||||||
[ E.alignTop, E.alignLeft ]
|
[ E.alignTop, E.alignLeft ]
|
||||||
|
@ -173,7 +184,7 @@ summaryMaker argument argHeight =
|
||||||
, spacing 3
|
, spacing 3
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
[ text argument.propositionSummary
|
[ text argMakerInput.arg.propositionSummary
|
||||||
|> el
|
|> el
|
||||||
[ F.color colourTheme.nonHighlightedText
|
[ F.color colourTheme.nonHighlightedText
|
||||||
, F.regular
|
, F.regular
|
||||||
|
@ -184,8 +195,8 @@ summaryMaker argument argHeight =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
strengthMaker : Argument -> Int -> Element msg
|
strengthMaker : ArgMakerInput msg -> Element msg
|
||||||
strengthMaker argument argHeight =
|
strengthMaker argMakerInput =
|
||||||
let
|
let
|
||||||
barMaker : Int -> Element msg
|
barMaker : Int -> Element msg
|
||||||
barMaker num =
|
barMaker num =
|
||||||
|
@ -254,12 +265,12 @@ strengthMaker argument argHeight =
|
||||||
]
|
]
|
||||||
, column
|
, column
|
||||||
[ E.width fill, E.alignLeft, centerY ]
|
[ E.width fill, E.alignLeft, centerY ]
|
||||||
[ barMaker argument.argumentCertainty ]
|
[ barMaker argMakerInput.arg.argumentCertainty ]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
tableMaker : Argument -> Int -> Element msg
|
tableMaker : ArgMakerInput msg -> Element msg
|
||||||
tableMaker argument argHeight =
|
tableMaker argMakerInput =
|
||||||
let
|
let
|
||||||
formalizationMaker : List (Element msg)
|
formalizationMaker : List (Element msg)
|
||||||
formalizationMaker =
|
formalizationMaker =
|
||||||
|
@ -300,7 +311,7 @@ tableMaker argument argHeight =
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
argument.argumentFormalization
|
argMakerInput.arg.argumentFormalization
|
||||||
in
|
in
|
||||||
column [ centerX, E.width <| px 600 ]
|
column [ centerX, E.width <| px 600 ]
|
||||||
[ wrappedRow (paragraphBoldFormat ++ [ E.alignLeft, E.width fill ])
|
[ wrappedRow (paragraphBoldFormat ++ [ E.alignLeft, E.width fill ])
|
||||||
|
@ -311,7 +322,7 @@ tableMaker argument argHeight =
|
||||||
, D.color colourTheme.nonHighlightedDarkText
|
, D.color colourTheme.nonHighlightedDarkText
|
||||||
, clip
|
, clip
|
||||||
]
|
]
|
||||||
{ data = argument.definitionTable
|
{ data = argMakerInput.arg.definitionTable
|
||||||
, columns =
|
, columns =
|
||||||
[ { header =
|
[ { header =
|
||||||
el
|
el
|
||||||
|
@ -368,8 +379,8 @@ tableMaker argument argHeight =
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
proofTreeMaker : Argument -> Int -> Element msg
|
proofTreeMaker : ArgMakerInput msg -> Element msg
|
||||||
proofTreeMaker argument argHeight =
|
proofTreeMaker argMakerInput =
|
||||||
row [ paddingEach { top = 10, right = 0, bottom = 10, left = 0 }, centerX, E.width fill ]
|
row [ paddingEach { top = 10, right = 0, bottom = 10, left = 0 }, centerX, E.width fill ]
|
||||||
[ column [ E.alignRight ]
|
[ column [ E.alignRight ]
|
||||||
[ newTabLink
|
[ newTabLink
|
||||||
|
@ -391,7 +402,7 @@ proofTreeMaker argument argHeight =
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
{ url = argument.proofLink
|
{ url = argMakerInput.arg.proofLink
|
||||||
, label = text "Proof Tree"
|
, label = text "Proof Tree"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -64,7 +64,7 @@ import Html.Attributes as H exposing (style, title, wrap)
|
||||||
import Layouts
|
import Layouts
|
||||||
import List.Extra as L exposing (..)
|
import List.Extra as L exposing (..)
|
||||||
import Page exposing (Page)
|
import Page exposing (Page)
|
||||||
import Ports
|
import Ports exposing (gotArgHeight)
|
||||||
import Route exposing (Route)
|
import Route exposing (Route)
|
||||||
import Shared
|
import Shared
|
||||||
import View exposing (View)
|
import View exposing (View)
|
||||||
|
@ -91,12 +91,21 @@ toLayout model =
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ argHeights : List Int }
|
{ argExpansions : List Bool
|
||||||
|
, argHeights : List Int
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
init : () -> ( Model, Effect Msg )
|
init : () -> ( Model, Effect Msg )
|
||||||
init () =
|
init () =
|
||||||
( { argHeights = List.repeat (List.length argumentList) 30 }
|
let
|
||||||
|
numArgs : Int
|
||||||
|
numArgs =
|
||||||
|
List.length argumentList
|
||||||
|
in
|
||||||
|
( { argExpansions = List.repeat numArgs False
|
||||||
|
, argHeights = List.repeat numArgs 0
|
||||||
|
}
|
||||||
, Effect.none
|
, Effect.none
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -106,30 +115,36 @@ init () =
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= ToggleExpandArg Int
|
= GotArgHeight (List Int)
|
||||||
|
| ToggleExpandArg Int
|
||||||
|
|
||||||
|
|
||||||
update : Msg -> Model -> ( Model, Effect Msg )
|
update : Msg -> Model -> ( Model, Effect Msg )
|
||||||
update msg model =
|
update msg model =
|
||||||
case msg of
|
Debug.log (Debug.toString model.argHeights) <|
|
||||||
ToggleExpandArg index ->
|
case msg of
|
||||||
( case getAt index model.argHeights of
|
GotArgHeight argHeights ->
|
||||||
Nothing ->
|
( { model | argHeights = argHeights }, Effect.none )
|
||||||
model
|
|
||||||
|
|
||||||
Just elHeight ->
|
ToggleExpandArg index ->
|
||||||
{ model | argHeights = setAt index elHeight model.argHeights }
|
( case getAt index model.argExpansions of
|
||||||
, Effect.sendCmd <| Ports.getArgHeight ()
|
Nothing ->
|
||||||
)
|
model
|
||||||
|
|
||||||
|
Just isExpanded ->
|
||||||
|
{ model
|
||||||
-- SUBSCRIPTIONS
|
| argExpansions =
|
||||||
|
setAt index
|
||||||
|
(not isExpanded)
|
||||||
|
model.argExpansions
|
||||||
|
}
|
||||||
|
, Effect.sendCmd <| Ports.getArgHeight <| List.length model.argHeights
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
subscriptions : Model -> Sub Msg
|
subscriptions : Model -> Sub Msg
|
||||||
subscriptions model =
|
subscriptions model =
|
||||||
Sub.none
|
gotArgHeight GotArgHeight
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,14 +171,39 @@ debateContainer shared model =
|
||||||
|
|
||||||
debateList : Model -> Element Msg
|
debateList : Model -> Element Msg
|
||||||
debateList model =
|
debateList model =
|
||||||
column
|
let
|
||||||
pageList
|
argColumn : Bool -> Element Msg
|
||||||
|
argColumn isHidden =
|
||||||
|
column
|
||||||
|
-- (explain Debug.todo ::
|
||||||
|
[ padding 30
|
||||||
|
, spacing 10
|
||||||
|
]
|
||||||
|
<|
|
||||||
|
List.map argumentMaker <|
|
||||||
|
List.map4
|
||||||
|
(\w x y z ->
|
||||||
|
{ arg = w
|
||||||
|
, index = x
|
||||||
|
, isExpanded = y
|
||||||
|
, maybeHeight =
|
||||||
|
if isHidden then
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
else
|
||||||
|
z
|
||||||
|
, titleClickMsg = ToggleExpandArg x
|
||||||
|
}
|
||||||
|
)
|
||||||
|
argumentList
|
||||||
|
(List.range 0 <| List.length model.argHeights)
|
||||||
|
model.argExpansions
|
||||||
|
(List.map Just model.argHeights)
|
||||||
|
in
|
||||||
|
el
|
||||||
|
[ behindContent <| argColumn True ]
|
||||||
<|
|
<|
|
||||||
List.map2 (argumentMaker ToggleExpandArg model.argHeights)
|
argColumn False
|
||||||
argumentList
|
|
||||||
<|
|
|
||||||
List.range 0 <|
|
|
||||||
List.length model.argHeights
|
|
||||||
|
|
||||||
|
|
||||||
argumentList : List Argument
|
argumentList : List Argument
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
port module Ports exposing (getArgHeight)
|
port module Ports exposing (getArgHeight, gotArgHeight)
|
||||||
|
|
||||||
|
|
||||||
port getArgHeight : () -> Cmd msg
|
port getArgHeight : Int -> Cmd msg
|
||||||
|
|
||||||
|
|
||||||
port gotArgHeight : (() -> msg) -> Sub msg
|
port gotArgHeight : (List Int -> msg) -> Sub msg
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
// The value returned here will be passed as flags
|
// The value returned here will be passed as flags
|
||||||
// into your `Shared.init` function.
|
// into your `Shared.init` function.
|
||||||
export const flags = ({ env }) => {
|
export const flags = ({ env }) => {
|
||||||
return {
|
return {
|
||||||
height: window.innerHeight,
|
height: window.innerHeight,
|
||||||
width: window.innerWidth
|
width: window.innerWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is called AFTER your Elm app starts up
|
// This is called AFTER your Elm app starts up
|
||||||
|
@ -15,16 +15,20 @@ export const flags = ({ env }) => {
|
||||||
// to your Elm application, or subscribe to incoming
|
// to your Elm application, or subscribe to incoming
|
||||||
// messages from Elm
|
// messages from Elm
|
||||||
export const onReady = ({ app, env }) => {
|
export const onReady = ({ app, env }) => {
|
||||||
app.ports.getArgHeight.subscribe(() => {
|
app.ports.getArgHeight.subscribe((numArgs) => {
|
||||||
|
const heights = [];
|
||||||
|
|
||||||
setTimeout(() => {
|
for (let i = 0; i < numArgs; i++) {
|
||||||
const element = document.getElementById('arg1');
|
const element = document.getElementById(`arg${i}`);
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
const height = element.offsetHeight;
|
heights.push(element.offsetHeight);
|
||||||
console.log(`Height of the element: ${height}px`);
|
} else {
|
||||||
} else {
|
console.error(`Element with ID 'arg${i}' not found.`);
|
||||||
console.error('Element not found.');
|
heights.push(null); // Add null or any placeholder for missing elements
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 0)
|
|
||||||
})}
|
app.ports.gotArgHeight.send(heights);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
|
@ -21,6 +21,13 @@
|
||||||
elm-review
|
elm-review
|
||||||
elm-test
|
elm-test
|
||||||
;
|
;
|
||||||
|
|
||||||
|
inherit
|
||||||
|
(pkgs.nodePackages)
|
||||||
|
"@commitlint/config-conventional"
|
||||||
|
npm
|
||||||
|
typescript-language-server
|
||||||
|
;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue