Start of a client
This commit is contained in:
parent
fd83d22fd8
commit
7b9478816a
4 changed files with 5343 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
|||
**/result
|
||||
**/dist
|
||||
server/db
|
||||
**/elm-stuff
|
||||
|
|
|
|||
24
client/elm.json
Normal file
24
client/elm.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.1.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.3"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
66
client/src/Main.elm
Normal file
66
client/src/Main.elm
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
module Main exposing (..)
|
||||
import Browser
|
||||
import Html exposing (..)
|
||||
import Html.Attributes as HA
|
||||
import Html.Events as HE
|
||||
|
||||
main =
|
||||
Browser.sandbox { init = startPoll, update = update, view = view }
|
||||
|
||||
startPoll : Model
|
||||
startPoll = Creating (CreatePollInfo { title = Nothing, question = "", options = [] })
|
||||
|
||||
-- testPoll = CreatePollInfo { title = , question = "what's your favorite color?", options = ["green", "blue", "red"] }
|
||||
|
||||
type Model = Loading | Voting CreatePollInfo | ViewingResults Poll | Creating CreatePollInfo
|
||||
|
||||
type OptionHash = Int
|
||||
|
||||
type Msg = Increment | Decrement
|
||||
|
||||
type CreatePollInfo = CreatePollInfo
|
||||
{
|
||||
title : Maybe String,
|
||||
question : String,
|
||||
options : List String
|
||||
}
|
||||
type Poll = Poll
|
||||
{
|
||||
createInfo : CreatePollInfo,
|
||||
votes : List Ballot
|
||||
}
|
||||
|
||||
type Ballot = Ballot
|
||||
{
|
||||
votes : OptionHash
|
||||
}
|
||||
|
||||
update msg model = model
|
||||
-- case msg of
|
||||
-- Increment ->
|
||||
-- model + 1
|
||||
|
||||
-- Decrement ->
|
||||
-- model - 1
|
||||
--
|
||||
viewInput : String -> String -> String -> (String -> msg) -> Html msg
|
||||
viewInput t p v toMsg =
|
||||
input [ HA.type_ t, HA.placeholder p, HA.value v-- , HE.onInput toMsg
|
||||
] []
|
||||
|
||||
|
||||
view model = case model of
|
||||
(Creating (CreatePollInfo createInfo )) -> div []
|
||||
[
|
||||
input [HA.type_ "text", HA.value (Maybe.withDefault "" createInfo.title)] []
|
||||
-- input [HA.type_ "text", HA.value (Maybe.withDefault "" createInfo.title)] []
|
||||
]
|
||||
Loading -> text "loading..."
|
||||
_ -> text "uhhh"
|
||||
-- view (CreatePollInfo {options}) =
|
||||
-- div [HA.style "display" "flex", HA.style "flex-direction" "column", HA.style "max-width" "300px"]
|
||||
-- (List.map (button [] << List.singleton << text) options)
|
||||
-- -- [ div [] [ text (text model.tile) ]
|
||||
-- -- , div [] [ text (String.fromInt model) ]
|
||||
-- -- , button [ onClick Increment ] [ text "+" ]
|
||||
-- -- ]
|
||||
5252
client/src/index.html
Normal file
5252
client/src/index.html
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue