Skip to content

Commit

Permalink
edit layout
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedakef committed Jan 8, 2025
1 parent 2b881cf commit ac17874
Show file tree
Hide file tree
Showing 8 changed files with 2,308 additions and 605 deletions.
File renamed without changes.
1,428 changes: 1,142 additions & 286 deletions frontend/example/steps.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ view model =
"Go tutor"

body =
div [ css [ Styles.container, Styles.flexCenter, Css.minHeight (Css.vh 100) ] ]
div [ css [ Css.displayFlex, Css.flexDirection Css.column, Css.minHeight (Css.vh 100) ] ]
[ Styles.globalStyles
, inlineCss Styles.requiredShStyles
, navigation
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/Steps/Steps.elm
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ update msg state =
( Success { successState | steps = steps }, Cmd.none )

Err err ->
( Failure ("error while getting program execution steps: " ++ HttpHelper.errorToString err), Cmd.none )
( Failure ("Error while getting program execution steps: " ++ HttpHelper.errorToString err), Cmd.none )

GotSourceCode sourceCodeResult ->
case sourceCodeResult of
Ok sourceCode ->
( Success { successState | sourceCode = sourceCode }, Cmd.none )

Err err ->
( Failure ("error while reading program source code: " ++ HttpHelper.errorToString err), Cmd.none )
( Failure ("Error while reading program source code: " ++ HttpHelper.errorToString err), Cmd.none )

Next ->
if successState.position + 1 > List.length successState.steps then
Expand Down Expand Up @@ -116,15 +116,15 @@ update msg state =
( Success (StepsState steps 0 "" Nothing), getSourceCode )

Err err ->
( Failure ("error while getting program execution steps: " ++ HttpHelper.errorToString err), Cmd.none )
( Failure ("Error while getting program execution steps: " ++ HttpHelper.errorToString err), Cmd.none )

GotSourceCode sourceCodeResult ->
case sourceCodeResult of
Ok sourceCode ->
( Success (StepsState [] 0 sourceCode Nothing), Cmd.none )

Err err ->
( Failure ("error while reading program source code: " ++ HttpHelper.errorToString err), Cmd.none )
( Failure ("Error while reading program source code: " ++ HttpHelper.errorToString err), Cmd.none )

Next ->
( state, Cmd.none )
Expand Down
37 changes: 18 additions & 19 deletions frontend/src/Steps/View.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,16 @@ import SyntaxHighlight as SH

view : State -> Html Msg
view state =
main_ [ css [ Styles.container, Css.flexWrap Css.wrap, Css.alignItems Css.center, Css.flex (Css.num 1) ] ]
(case state of
Success stepsState ->
let
visualizeState =
stateToVisualize stepsState
in
[ div [ css [ Styles.container ] ]
[ div [ css [ Styles.flexColumn ] ]
[ h1 [] [ text "Visualize your Go Program:" ]
]
]
case state of
Success stepsState ->
let
visualizeState =
stateToVisualize stepsState
in
main_ [ css [ Css.flex (Css.num 1) ] ]
[ div [ css [ Css.paddingLeft (Css.px 10) ] ] [ h1 [] [ text "Visualize your Go Program:" ] ]
, div [ css [ Styles.container ] ]
[ div [ css [ Css.displayFlex, Styles.flexColumn, Styles.flexCenter ] ]
[ div [ css [ Css.displayFlex, Css.flex (Css.num 1), Styles.flexCenter ] ]
[ codeView visualizeState
, div [ css [ Css.displayFlex, Styles.flexCenter, Css.margin2 (Css.px 20) (Css.px 0) ] ]
[ div []
Expand All @@ -51,16 +47,19 @@ view state =
]
]
]
, div [ css [ Css.displayFlex, Styles.flexColumn, Styles.flexCenter ] ] [ programVisualizer visualizeState ]
, div [ css [ Css.displayFlex, Css.flex (Css.num 1), Styles.flexCenter ] ] [ programVisualizer visualizeState ]
]
]

Failure error ->
[ pre [ css [ Css.color (Css.hex "#d65287"), Css.fontSize (Css.px 20) ] ] [ text error ] ]
Failure error ->
main_ [ css [ Css.flex (Css.num 1), Styles.container, Css.justifyContent Css.center, Css.alignItems Css.center ] ]
[ pre [ css [ Css.color (Css.hex "#d65287"), Css.fontSize (Css.px 20) ] ] [ text error ]
]

Loading ->
[ pre [ css [ Css.fontSize (Css.px 20) ] ] [ text "Loading..." ] ]
)
Loading ->
main_ [ css [ Css.flex (Css.num 1), Styles.container, Css.justifyContent Css.center, Css.alignItems Css.center ] ]
[ pre [ css [ Css.fontSize (Css.px 20) ] ] [ text "Loading..." ]
]


type alias VisualizeState =
Expand Down
8 changes: 0 additions & 8 deletions frontend/src/Styles.elm
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ container =
]


flexColumn : Css.Style
flexColumn =
Css.batch
[ flex (num 1)
, padding (px 10)
]


flexCenter : Css.Style
flexCenter =
Css.batch
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ updateExample:
jq . steps.json > steps_formatted.json
mv steps_formatted.json steps.json
cp steps.json frontend/example
cp example/main.go frontend/example
cp example/main.go frontend/example.txt
Loading

0 comments on commit ac17874

Please sign in to comment.