Skip to content

Commit

Permalink
Basic navigation between views
Browse files Browse the repository at this point in the history
  • Loading branch information
Jskobos committed Mar 24, 2019
1 parent 796755a commit dbc0cb4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
48 changes: 31 additions & 17 deletions src/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,25 @@ type alias Flags = {}

---- MODEL ----

type ActiveView =
Welcome | Summary | Experience | Education | Contact | Links | Feedback | Language

type alias Model =
{
activeView: String
activeView: ActiveView
}


init : Flags -> ( Model, Cmd Msg )
init _ =
( {
activeView = "Welcome"
activeView = Welcome
}, Dom.focus "outermost" |> Task.attempt (always NoOp) )



---- UPDATE ----


type Msg
= HandleKeyboardEvent KeyboardEvent
| NoOp
Expand All @@ -41,20 +42,26 @@ update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
HandleKeyboardEvent event ->
( { model | activeView = getActiveView event.key }
( { model | activeView = getActiveView event.ctrlKey event.key }
, Cmd.none
)

NoOp ->
( model, Cmd.none )

getActiveView : Maybe String -> String
getActiveView event =
case event of
Just key ->
key
Nothing ->
"Welcome"
getActiveView : Bool -> Maybe String -> ActiveView
getActiveView ctrl event =
if (not ctrl) then Welcome
else
case event of
Just key ->
case key of
"s" ->
Summary
_ ->
Welcome
Nothing ->
Welcome


---- VIEW ----
Expand All @@ -74,7 +81,7 @@ view model =
]
[
div [class "h-screen w-screen"]
[ topBar, body, div [style "color" "white"] [text model.activeView]
[ topBar, body model.activeView
]
]

Expand All @@ -93,11 +100,18 @@ dot color =
("m-1", True)
] ] []

body =
div [class "terminal bg-black"] [terminalHeader, terminalContent "", terminalFooter]

terminalContent content =
div [class "terminal-content"] [text content]
body activeView =
div [class "terminal bg-black"] [terminalHeader, terminalContent activeView, terminalFooter]

terminalContent activeView =
case activeView of
Welcome ->
div [class "terminal-content"] [text "Welcome"]
Summary ->
div [class "terminal-content"] [text "Summary"]
_ ->
div [class "terminal-content"] [text "Section coming soon"]


terminalFooter =
div [class "terminal-footer"] [
Expand Down
1 change: 1 addition & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ body {

.terminal-content {
height: 85%;
color: white;
}

0 comments on commit dbc0cb4

Please sign in to comment.