wip
This commit is contained in:
@@ -6,7 +6,7 @@ import Html.Attributes exposing (attribute, class, classList, href, id, placehol
|
|||||||
|
|
||||||
page =
|
page =
|
||||||
div [ class "home-page" ]
|
div [ class "home-page" ]
|
||||||
[ p [] [ text "TODO: Replace this <p> with the banner" ]
|
[ banner
|
||||||
, div [ class "container page" ]
|
, div [ class "container page" ]
|
||||||
[ div [ class "row" ]
|
[ div [ class "row" ]
|
||||||
[ div [ class "col-md-9" ] [ feed ]
|
[ div [ class "col-md-9" ] [ feed ]
|
||||||
@@ -17,22 +17,11 @@ page =
|
|||||||
|
|
||||||
|
|
||||||
banner =
|
banner =
|
||||||
{- TODO Add a logo and tagline to this banner, so its structure becomes:
|
|
||||||
|
|
||||||
<div class="banner">
|
|
||||||
<div class="container">
|
|
||||||
<h1 class="logo-font">conduit</h1>
|
|
||||||
<p>A place to share your knowledge.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
HINT 1: the <div class="row"> above is an element with 2 child nodes.
|
|
||||||
|
|
||||||
HINT 2: the <div class="feed-toggle"> below is an element with text.
|
|
||||||
-}
|
|
||||||
div [ class "banner" ]
|
div [ class "banner" ]
|
||||||
[ div [ class "container" ]
|
[ div [ class "container" ]
|
||||||
[ text "TODO: Put a <h1> here instead of this text, then add a <p> right after the <h1>" ]
|
[ h1 [ class "logo-font" ] [ text "conduit" ]
|
||||||
|
, p [] [ text "A place to share your knowledge." ]
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ view tags =
|
|||||||
, div [ class "col-md-3" ]
|
, div [ class "col-md-3" ]
|
||||||
[ div [ class "sidebar" ]
|
[ div [ class "sidebar" ]
|
||||||
[ p [] [ text "Popular Tags" ]
|
[ p [] [ text "Popular Tags" ]
|
||||||
|
, viewTags tags
|
||||||
-- TODO instead of passing [] to viewTags, pass the actual tags
|
|
||||||
, viewTags []
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@@ -26,18 +24,14 @@ view tags =
|
|||||||
viewTags tags =
|
viewTags tags =
|
||||||
let
|
let
|
||||||
renderedTags =
|
renderedTags =
|
||||||
-- TODO use `List.map` and `viewTag` to render the tags
|
-- List.map (\tag -> viewTag tag) tags
|
||||||
[]
|
List.map viewTag tags
|
||||||
in
|
in
|
||||||
div [ class "tag-list" ] renderedTags
|
div [ class "tag-list" ] renderedTags
|
||||||
|
|
||||||
|
|
||||||
viewTag tagName =
|
viewTag tagName =
|
||||||
{- TODO render something like this:
|
button [ class "tag-pill tag-default" ] [ text tagName ]
|
||||||
|
|
||||||
<button class="tag-pill tag-default">tag name goes here</button>
|
|
||||||
-}
|
|
||||||
button [] []
|
|
||||||
|
|
||||||
|
|
||||||
viewBanner =
|
viewBanner =
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import Html.Events exposing (onClick)
|
|||||||
|
|
||||||
|
|
||||||
initialModel =
|
initialModel =
|
||||||
{ tags = [ "foo", "bar", "dragons" ]
|
{ tags = [ "foo", "bar", "baz", "dragons", "tag name goes here" ]
|
||||||
, selectedTag = ""
|
, selectedTag = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,13 +23,7 @@ initialModel =
|
|||||||
|
|
||||||
update msg model =
|
update msg model =
|
||||||
if msg.operation == "SELECT_TAG" then
|
if msg.operation == "SELECT_TAG" then
|
||||||
{- TODO Return `model` with the `selectedTag` field set to `msg.data`
|
{ model | selectedTag = msg.data }
|
||||||
|
|
||||||
HINT: Record update syntax looks like this:
|
|
||||||
|
|
||||||
{ model | foo = bar }
|
|
||||||
-}
|
|
||||||
model
|
|
||||||
else
|
else
|
||||||
model
|
model
|
||||||
|
|
||||||
@@ -66,28 +60,15 @@ viewBanner =
|
|||||||
|
|
||||||
viewTag selectedTagName tagName =
|
viewTag selectedTagName tagName =
|
||||||
let
|
let
|
||||||
{- TODO Set the classname to "tag-pill tag-selected" only when the
|
|
||||||
current tagName is equal to the selected one.
|
|
||||||
-}
|
|
||||||
classname =
|
classname =
|
||||||
if False then
|
if tagName == selectedTagName then
|
||||||
"tag-pill tag-selected"
|
"tag-pill tag-selected"
|
||||||
else
|
else
|
||||||
"tag-pill tag-default"
|
"tag-pill tag-default"
|
||||||
in
|
in
|
||||||
{- TODO add an onClick handler here which selects `tagName`
|
|
||||||
|
|
||||||
HINT: Take look at `update` above, to check what it expects `msg`
|
|
||||||
to be. It will look something like this:
|
|
||||||
|
|
||||||
button
|
|
||||||
[ class classname
|
|
||||||
, onClick { operation = "SOMETHING", data = "tag name goes here" }
|
|
||||||
]
|
|
||||||
[ text tagName ]
|
|
||||||
-}
|
|
||||||
button
|
button
|
||||||
[ class classname
|
[ class classname
|
||||||
|
, onClick { operation = "SELECT_TAG", data = tagName }
|
||||||
]
|
]
|
||||||
[ text tagName ]
|
[ text tagName ]
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ type alias Model =
|
|||||||
-- MODEL --
|
-- MODEL --
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to initialModel
|
initialModel : Model
|
||||||
-}
|
|
||||||
initialModel =
|
initialModel =
|
||||||
{ tags = [ "foo", "bar", "dragons" ]
|
{ tags = [ "foo", "bar", "dragons" ]
|
||||||
, selectedTag = ""
|
, selectedTag = ""
|
||||||
@@ -49,8 +48,7 @@ viewBanner =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to view
|
view : Model -> Html Msg
|
||||||
-}
|
|
||||||
view model =
|
view model =
|
||||||
div [ class "home-page" ]
|
div [ class "home-page" ]
|
||||||
[ viewBanner
|
[ viewBanner
|
||||||
@@ -72,8 +70,7 @@ view model =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to viewTag
|
viewTag : String -> String -> Html Msg
|
||||||
-}
|
|
||||||
viewTag selectedTagName tagName =
|
viewTag selectedTagName tagName =
|
||||||
let
|
let
|
||||||
classname =
|
classname =
|
||||||
@@ -93,8 +90,7 @@ viewTag selectedTagName tagName =
|
|||||||
-- UPDATE --
|
-- UPDATE --
|
||||||
|
|
||||||
|
|
||||||
{-| TODO add a type annotation to update
|
update : Msg -> Model -> Model
|
||||||
-}
|
|
||||||
update msg model =
|
update msg model =
|
||||||
if msg.operation == "SELECT_TAG" then
|
if msg.operation == "SELECT_TAG" then
|
||||||
{ model | selectedTag = msg.data }
|
{ model | selectedTag = msg.data }
|
||||||
|
|||||||
@@ -99,18 +99,9 @@ viewForm model =
|
|||||||
Html.form [ onSubmit Save ]
|
Html.form [ onSubmit Save ]
|
||||||
[ fieldset []
|
[ fieldset []
|
||||||
[ Form.input
|
[ Form.input
|
||||||
{- TODO Sign up for an account (you can enter nonsense for all
|
|
||||||
the signup fields) and then click `New Post` in the header to
|
|
||||||
view the Article Editor.
|
|
||||||
|
|
||||||
When the user enters some input for Article Title,
|
|
||||||
we want to update the `title` field in the Model.
|
|
||||||
|
|
||||||
HINT: We'll need to add something to the definition of Msg to
|
|
||||||
do this. Look at how SetDescription is used in the next field!
|
|
||||||
-}
|
|
||||||
[ class "form-control-lg"
|
[ class "form-control-lg"
|
||||||
, placeholder "Article Title"
|
, placeholder "Article Title"
|
||||||
|
, onInput SetTitle
|
||||||
, value model.title
|
, value model.title
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
@@ -146,6 +137,7 @@ viewForm model =
|
|||||||
type Msg
|
type Msg
|
||||||
= Save
|
= Save
|
||||||
| SetDescription String
|
| SetDescription String
|
||||||
|
| SetTitle String
|
||||||
| SetBody String
|
| SetBody String
|
||||||
| SetTags String
|
| SetTags String
|
||||||
| CreateCompleted (Result Http.Error (Article Body))
|
| CreateCompleted (Result Http.Error (Article Body))
|
||||||
@@ -174,13 +166,9 @@ update user msg model =
|
|||||||
errors ->
|
errors ->
|
||||||
( { model | errors = errors }, Cmd.none )
|
( { model | errors = errors }, Cmd.none )
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
SetTitle title ->
|
||||||
-- --
|
( { model | title = title }, Cmd.none )
|
||||||
-- TODO add something here that sets the title based on user input. --
|
|
||||||
-- --
|
|
||||||
-- HINT: take a look at how SetDescription does something similar! --
|
|
||||||
-- --
|
|
||||||
------------------------------------------------------------------------
|
|
||||||
SetDescription description ->
|
SetDescription description ->
|
||||||
( { model | description = description }, Cmd.none )
|
( { model | description = description }, Cmd.none )
|
||||||
|
|
||||||
|
|||||||
@@ -75,25 +75,20 @@ view session model =
|
|||||||
loggedInUser =
|
loggedInUser =
|
||||||
session.user
|
session.user
|
||||||
|
|
||||||
{- TODO figure out if this is the loggedInUser's profile
|
|
||||||
or not, based on whether that user's username matches this
|
|
||||||
profile's username.
|
|
||||||
|
|
||||||
HINT: The type of Maybe is:
|
|
||||||
|
|
||||||
type Maybe val
|
|
||||||
= Just val
|
|
||||||
| Nothing
|
|
||||||
-}
|
|
||||||
isMyProfile =
|
isMyProfile =
|
||||||
False
|
case loggedInUser of
|
||||||
|
Just user ->
|
||||||
|
profile.username == user.username
|
||||||
|
|
||||||
|
Nothing ->
|
||||||
|
True
|
||||||
in
|
in
|
||||||
div [ class "profile-page" ]
|
div [ class "profile-page" ]
|
||||||
[ Errors.view DismissErrors model.errors
|
[ Errors.view DismissErrors model.errors
|
||||||
, div [ class "user-info" ]
|
, div [ class "user-info" ]
|
||||||
[ div [ class "container" ]
|
[ div [ class "container" ]
|
||||||
[ div [ class "row" ]
|
[ div [ class "row" ]
|
||||||
[ viewProfileInfo profile ]
|
[ viewProfileInfo isMyProfile profile ]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class "container" ]
|
, div [ class "container" ]
|
||||||
@@ -101,18 +96,8 @@ view session model =
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
viewProfileInfo : Profile -> Html Msg
|
viewProfileInfo : Bool -> Profile -> Html Msg
|
||||||
viewProfileInfo profile =
|
viewProfileInfo isMyProfile profile =
|
||||||
let
|
|
||||||
{- TODO delete this hardcoded isMyProfile declaration, and have
|
|
||||||
viewProfileInfo accept isMyProfile as an argument instead.
|
|
||||||
|
|
||||||
HINT: The module will no longer compile after this change! Follow
|
|
||||||
the compiler's error messages to resolve this.
|
|
||||||
-}
|
|
||||||
isMyProfile =
|
|
||||||
False
|
|
||||||
in
|
|
||||||
div [ class "col-xs-12 col-md-10 offset-md-1" ]
|
div [ class "col-xs-12 col-md-10 offset-md-1" ]
|
||||||
[ img [ class "user-img", UserPhoto.src profile.image ] []
|
[ img [ class "user-img", UserPhoto.src profile.image ] []
|
||||||
, h4 [] [ User.usernameToHtml profile.username ]
|
, h4 [] [ User.usernameToHtml profile.username ]
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{"title":"Elm is fun!","description":"Elm","body":"I've really been enjoying it!","tagList":["elm","fun"],"slug":"elm-is-fun--zb6nba","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523441276},"updatedAt":{"$$date":1525523441276},"_id":"AfnCDbXe6wi8Vg8C"}
|
{"title":"this is my title","description":"this is just a test","body":"Hello World!","tagList":[],"slug":"this-is-my-title-ladzo0","author":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525546112100},"updatedAt":{"$$date":1525546112100},"_id":"9kCKBGvHDiWaDSjj"}
|
||||||
{"title":"Elm is fun!","description":"Programming","body":"I've really been enjoying it!","tagList":["elm","fun"],"slug":"elm-is-fun--zb6nba","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523441276},"updatedAt":{"$$date":1525523455652},"_id":"AfnCDbXe6wi8Vg8C"}
|
{"title":"Elm is fun!","description":"Programming","body":"I've really been enjoying it!","tagList":["elm","fun"],"slug":"elm-is-fun--zb6nba","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523441276},"updatedAt":{"$$date":1525523455652},"_id":"AfnCDbXe6wi8Vg8C"}
|
||||||
{"title":"Who says undefined isn't a function anyway?","description":"Functions","body":"Quite frankly I think undefined can be anything it wants to be, if it believes in itself.","tagList":["programming"],"slug":"who-says-undefined-isnt-a-function-anyway-t39ope","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523547620},"updatedAt":{"$$date":1525523547620},"_id":"CDCDlBclmwWpWdCX"}
|
{"title":"Who says undefined isn't a function anyway?","description":"Functions","body":"Quite frankly I think undefined can be anything it wants to be, if it believes in itself.","tagList":["programming"],"slug":"who-says-undefined-isnt-a-function-anyway-t39ope","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523547620},"updatedAt":{"$$date":1525523547620},"_id":"CDCDlBclmwWpWdCX"}
|
||||||
{"title":"This compiler is pretty neat","description":"Elm","body":"It tells me about problems in my code. How neat is that?","tagList":["compilers","elm"],"slug":"this-compiler-is-pretty-neat-9ycui8","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523694805},"updatedAt":{"$$date":1525523694805},"_id":"ttAbrJu6OrOJ7jAf"}
|
|
||||||
{"title":"Are dragons real?","description":"dragons","body":"Do Komodo Dragons count? I think they should. It's right there in the name!","tagList":["dragons"],"slug":"are-dragons-real-467lsh","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523750396},"updatedAt":{"$$date":1525523750396},"_id":"I2h7s1VuXciCP5nl"}
|
{"title":"Are dragons real?","description":"dragons","body":"Do Komodo Dragons count? I think they should. It's right there in the name!","tagList":["dragons"],"slug":"are-dragons-real-467lsh","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523750396},"updatedAt":{"$$date":1525523750396},"_id":"I2h7s1VuXciCP5nl"}
|
||||||
|
{"title":"Hello World","description":"stuff","body":"this is not port 8000","tagList":[],"slug":"hello-world-dwkkns","author":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525547607765},"updatedAt":{"$$date":1525547607765},"_id":"fiusiOt77z4zbKe8"}
|
||||||
|
{"title":"This compiler is pretty neat","description":"Elm","body":"It tells me about problems in my code. How neat is that?","tagList":["compilers","elm"],"slug":"this-compiler-is-pretty-neat-9ycui8","author":"Z1YiwpVIz2GQQ13Q","createdAt":{"$$date":1525523694805},"updatedAt":{"$$date":1525523694805},"_id":"ttAbrJu6OrOJ7jAf"}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"follow":"Z1YiwpVIz2GQQ13Q","user":"gsZdyqSGbQscoIU6","createdAt":{"$$date":1525550850919},"_id":"f8Yep9EguoPa8Rwn"}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
{"username":"SamSample","email":"sam@sample.com","password":"$2a$10$6bury.WsF0p7chmqoqQc..S5HZ6qPK/KuqVfXxBjSasmDPxF3fj3W","bio":"","image":null,"createdAt":{"$$date":1525523183044},"_id":"Z1YiwpVIz2GQQ13Q"}
|
|
||||||
{"username":"SamSample","email":"sam@sample.com","password":"samsample","bio":"I'm the sample user for the workshop. Hi!","image":"https://user-images.githubusercontent.com/1094080/39663282-6459c64e-503e-11e8-8da8-a2af2c81d052.png","createdAt":{"$$date":1525523183044},"_id":"Z1YiwpVIz2GQQ13Q","updatedAt":{"$$date":1525523378471}}
|
{"username":"SamSample","email":"sam@sample.com","password":"samsample","bio":"I'm the sample user for the workshop. Hi!","image":"https://user-images.githubusercontent.com/1094080/39663282-6459c64e-503e-11e8-8da8-a2af2c81d052.png","createdAt":{"$$date":1525523183044},"_id":"Z1YiwpVIz2GQQ13Q","updatedAt":{"$$date":1525523378471}}
|
||||||
|
{"username":"wefjbsfdjkhdgrskjhsdfgjhb","email":"sdfgjhsgjhbdfgkjhsdf@sfgdhjfjhgdfgf.com","password":"$2a$10$gnFdddybmitDP.yKM3OjfubgZ1O3geK9N8LymFV4mZYaSGe9WYPby","bio":"","image":null,"createdAt":{"$$date":1525546056406},"_id":"gsZdyqSGbQscoIU6"}
|
||||||
|
|||||||
Reference in New Issue
Block a user