Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Commit

Permalink
start migrating to elm-components. controls doesn't compile yet
Browse files Browse the repository at this point in the history
  • Loading branch information
vilterp committed Aug 1, 2015
1 parent 2bff271 commit 52c3cbd
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 698 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "elm-components"]
path = elm-components
url = [email protected]:evancz/elm-components.git
1 change: 1 addition & 0 deletions elm-components
Submodule elm-components added at 7bf413
1 change: 0 additions & 1 deletion elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"dependencies": {
"elm-lang/core": "2.0.0 <= v < 3.0.0",
"evancz/elm-html": "4.0.0 <= v < 5.0.0",
"vilterp/fancy-start-app": "1.0.0 <= v < 2.0.0",
"imeckler/empty": "1.0.0 <= v < 2.0.0",
"evancz/elm-markdown": "1.1.4 <= v < 2.0.0",
"jystic/elm-font-awesome": "1.0.0 <= v < 2.0.0"
Expand Down
39 changes: 22 additions & 17 deletions frontend/Button.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Button where

import Components exposing (..)

import Signal
import Html exposing (..)
import Html.Attributes exposing (..)
Expand All @@ -8,34 +10,37 @@ import Html.Lazy exposing (..)


type Model
= Up
| Down
| Hover
= Up
| Down
| Hover


type Action
= MouseUpdate Model
type Message a
= MouseUpdate Model
| Click a


update : Action -> Model -> Model
update action state =
case action of
update : Message a -> Model -> Transaction (Message a) (Model, Maybe a)
update msg state =
case msg of
MouseUpdate newState ->
newState
done (newState, Nothing)

Click clickMsg ->
done (state, Just clickMsg)


view : Signal.Address Action
-> Signal.Address a
view : Signal.Address (Message a)
-> a
-> Model
-> (Model -> Html)
-> Html
view buttonStateAddr actionAddr action state render =
view addr clickMsg state render =
div
[ onMouseOver buttonStateAddr (MouseUpdate Hover)
, onMouseDown buttonStateAddr (MouseUpdate Down)
, onMouseUp buttonStateAddr (MouseUpdate Hover)
, onMouseLeave buttonStateAddr (MouseUpdate Up)
, onClick actionAddr action
[ onMouseOver addr (MouseUpdate Hover)
, onMouseDown addr (MouseUpdate Down)
, onMouseUp addr (MouseUpdate Hover)
, onMouseLeave addr (MouseUpdate Up)
, onClick addr (Click clickMsg)
]
[ lazy render state ]
58 changes: 33 additions & 25 deletions frontend/Debugger.elm
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,50 @@ import String
import Color
import Debug

import FancyStartApp
import Components exposing (..)
import Empty exposing (..)
import WebSocket

import Model exposing (..)
import Styles exposing (..)
import Button
import Debugger.RuntimeApi as API
import Debugger.Model as DM
import Debugger.Service as Service
import SideBar.Controls as Controls
import SideBar.Logs as Logs
import DataUtils exposing (..)


(html, uiTasks) =
FancyStartApp.start
{ initialState = initModel
, initialTasks = (\loopback ->
[Signal.send (Service.commandsMailbox ()).address (DM.Initialize initMod)])
, externalActions =
Signal.mergeMany
[ Signal.map NewServiceState Service.state
, socketEventsMailbox.signal
]
output =
start
{ init =
request (task connectSocket) initModel
, view = view
, update = update
}


main =
html
output.html


port tasks : Signal (Task Never ())
port tasks =
output.tasks


(=>) = (,)


view : Signal.Address Action -> Model -> Html
view : Signal.Address Message -> Model -> Html
view addr state =
let
(mainVal, isPlaying) =
case state.serviceState of
DM.Active activeAttrs ->
Just activeAttrs ->
(activeAttrs.mainVal, DM.isPlaying activeAttrs)

_ ->
Nothing ->
(div [] [], False)

in
Expand Down Expand Up @@ -136,7 +134,10 @@ viewSidebar addr state =
body =
case state.serviceState of
DM.Active activeAttrs ->
[ Controls.view addr state activeAttrs
[ Controls.view
addr
state
activeAttrs
, dividerBar
, Logs.view
(Signal.forwardTo addr LogsAction)
Expand All @@ -160,6 +161,13 @@ viewSidebar addr state =
([toggleTab addr state] ++ body)


update : Message -> Model -> Transaction Message Model
update msg model =
case msg of
_ ->
done model

{-
update : FancyStartApp.UpdateFun Model Empty Action
update loopback now action state =
case Debug.log "MAIN ACTION" action of
Expand Down Expand Up @@ -219,7 +227,7 @@ update loopback now action state =
CompilationErrors errors ->
Debug.crash errors

-}

-- Socket stuff

Expand All @@ -238,8 +246,9 @@ port windowLocationHost : String

-- TASK PORTS

port connectSocket : Task x ()
port connectSocket =
-- TODO: external events in Elm Components so we can add this in
connectSocket : Task Never Message
connectSocket =
(WebSocket.create
("ws://" ++ windowLocationHost ++ "/socket?file=" ++ fileName)
(Signal.forwardTo
Expand All @@ -257,15 +266,14 @@ port connectSocket =
)
)
)
`Task.andThen` (\socket ->
Signal.send socketEventsMailbox.address (ConnectSocket <| Just socket))
|> Task.map (ConnectSocket << Just)


port uiTasksPort : Signal (Task Empty ())
port uiTasksPort =
uiTasks


port debugServiceTasks : Signal (Task Empty ())
port debugServiceTasks =
Service.tasks
--port debugServiceTasks : Signal (Task Empty ())
--port debugServiceTasks =
-- Service.tasks
165 changes: 0 additions & 165 deletions frontend/Debugger/Model.elm

This file was deleted.

7 changes: 6 additions & 1 deletion frontend/Debugger/RuntimeApi.elm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ sgShape =
Native.Debugger.RuntimeApi.sgShape


justMain : SGShape -> List NodeId
justMain shape =
[shape.mainId]


getModule : DebugSession -> ElmModule
getModule =
Native.Debugger.RuntimeApi.getModule
Expand Down Expand Up @@ -145,7 +150,7 @@ type alias ValueSet =

-- COMMANDS

{-| Swap in new module. Starts off paused.
{-| Swap in new module. Starts off playing.
Subscribes to the list of nodes returned by the given function (3rd arg),
and returns their initial values. -}
initializeFullscreen : ElmModule
Expand Down
Loading

0 comments on commit 52c3cbd

Please sign in to comment.