From ccec612687137299c4c740449e9c8aa667865fbb Mon Sep 17 00:00:00 2001 From: Yehowshua Immanuel Date: Fri, 3 Jan 2025 10:58:40 -0500 Subject: [PATCH] now has text box --- Makefile | 6 ++---- frontend/src/Page/Landing.elm | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 7492640..3159b93 100644 --- a/Makefile +++ b/Makefile @@ -26,12 +26,9 @@ $(PUBLIC_DIR): $(PUBLIC_DIR)/index.html: $(FRONTEND_DIR)/index.html $(PUBLIC_DIR) cp $< $@ -$(FRONTEND_DIR)/elm.min.js: - make -C $(FRONTEND_DIR) - .PHONY: frontend backend -frontend: $(PUBLIC_DIR)/index.html $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR) +frontend: $(PUBLIC_DIR)/index.html $(PUBLIC_DIR) cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/ cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/ mkdir -p $(PUBLIC_DIR)/assets @@ -40,6 +37,7 @@ backend: $(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml serve: frontend backend + make -C $(FRONTEND_DIR) ifeq ($(DEBUG),1) RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml else ifeq ($(RELEASE),1) diff --git a/frontend/src/Page/Landing.elm b/frontend/src/Page/Landing.elm index 4ad6c19..05340d0 100644 --- a/frontend/src/Page/Landing.elm +++ b/frontend/src/Page/Landing.elm @@ -10,6 +10,8 @@ import Element exposing (Element) import Websockets import Ports import Json.Decode as Decode +import Html.Attributes exposing (placeholder) +import Element.Input type alias Model = { time : String @@ -20,6 +22,7 @@ type alias Landing = { type Msg = ToFrontend Landing | DecodeError Decode.Error + | GreetWidgetText String | NoOp init : () -> Model @@ -54,9 +57,23 @@ update msg model = ToFrontend landing -> ( {model | time = landing.time}, Cmd.none ) _ -> (model, Cmd.none) +greetWidget = + let + textInput = + Element.Input.text [] + { onChange = GreetWidgetText + , text = "text" + , placeholder = Nothing + , label = Element.Input.labelAbove [] (Element.text "Greet") + } + in + Element.row [] + [ textInput ] + view : Model -> Element Msg view model = Element.column [] - [ Element.text "Landing", - Element.text <| "Current time is : " ++ model.time + [ Element.text "Landing" + -- , Element.text <| "Current time is : " ++ model.time + , greetWidget ]