Commit 75e2e602 authored by Darya Rednikina's avatar Darya Rednikina
Browse files

(#4) Added skeleton for Projects.elm

parent 2cf2ec86
......@@ -7,4 +7,4 @@ html, body {
display: flex;
height: 100%;
width: 100%;
}
\ No newline at end of file
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import Browser.Navigation as Nav
import Html exposing (Html, h3, text)
import Login exposing (Model)
import Page exposing (Page, view)
import Projects exposing (Model)
import Register exposing (Model)
import Route exposing (Route)
import Url exposing (Url)
......@@ -25,6 +26,7 @@ type Page
= NotFoundPage
| LoginPage Login.Model
| RegisterPage Register.Model
| ProjectsPage Projects.Model
......@@ -34,6 +36,7 @@ type Page
type Msg
= LoginMsg Login.Msg
| RegisterMsg Register.Msg
| ProjectsMsg Projects.Msg
| LinkClicked UrlRequest
| UrlChanged Url
......@@ -65,6 +68,18 @@ update msg model =
in
m1
( ProjectsMsg projectsMsg, ProjectsPage p ) ->
let
( updatedPageModel, updatedCmd ) =
Projects.update projectsMsg p
m1 =
( { model | page = ProjectsPage updatedPageModel }
, Cmd.map ProjectsMsg updatedCmd
)
in
m1
( LinkClicked urlReq, _ ) ->
case urlReq of
Browser.Internal url ->
......@@ -122,6 +137,9 @@ view model =
RegisterPage pageModel ->
mappedView Page.Register RegisterMsg (Register.view pageModel)
ProjectsPage pageModel ->
mappedView Page.Projects ProjectsMsg (Projects.view pageModel)
notFoundView : { title : String, content : Html msg }
notFoundView =
......@@ -179,6 +197,13 @@ initCurrentPage ( model, existingCmds ) =
Register.init
in
( RegisterPage pageModel, Cmd.map RegisterMsg pageCmds )
Route.Projects ->
let
( pageModel, pageCmds ) =
Projects.init
in
( ProjectsPage pageModel, Cmd.map ProjectsMsg pageCmds )
in
( { model | page = currPage }
, Cmd.batch [ existingCmds, mappedCmds ]
......
......@@ -20,3 +20,4 @@ type Page
= Other
| Login
| Register
| Projects
module Projects exposing (Model, Msg(..), init, update, view)
import Html exposing (Html, div)
-- MODEL
type alias Model =
{ listPage : Int
}
init : ( Model, Cmd Msg )
init =
( Model 0, Cmd.none )
-- UPDATE
type Msg
= GotProjectList
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
_ ->
( model, Cmd.none )
-- VIEW
view : Model -> { title : String, content : Html Msg }
view model =
{ title = "Projects"
, content =
div [] []
}
......@@ -10,6 +10,7 @@ type Route
= NotFound
| Register
| Login
| Projects
parseUrl : Url -> Route
......@@ -28,6 +29,7 @@ matchRoute =
[ map Login top -- эта штука на localhost:9000/
, map Register (s "register")
, map Login (s "login")
, map Projects (s "projects")
]
......@@ -50,5 +52,8 @@ routeToPieces page =
Register ->
[ "register" ]
Projects ->
[ "projects" ]
_ ->
[]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment