diff options
Diffstat (limited to 'frontend/src/Catalog.elm')
-rw-r--r-- | frontend/src/Catalog.elm | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/frontend/src/Catalog.elm b/frontend/src/Catalog.elm index d00cb92..5b233f2 100644 --- a/frontend/src/Catalog.elm +++ b/frontend/src/Catalog.elm | |||
@@ -2,15 +2,16 @@ module Catalog exposing (..) | |||
2 | 2 | ||
3 | import Browser | 3 | import Browser |
4 | import Browser.Navigation as Nav | 4 | import Browser.Navigation as Nav |
5 | import Html exposing (..) | 5 | import Css exposing (..) |
6 | import Html.Attributes exposing (..) | 6 | import Html |
7 | import Html.Events exposing (..) | 7 | import Html.Styled exposing (..) |
8 | import Html.Styled.Attributes exposing (..) | ||
9 | import Html.Styled.Events exposing (..) | ||
8 | import Http | 10 | import Http |
9 | import Json.Decode as D | 11 | import Json.Decode as D |
10 | import Json.Encode as Encode | 12 | import Json.Encode as Encode |
13 | import Styles exposing (..) | ||
11 | import Tuple exposing (..) | 14 | import Tuple exposing (..) |
12 | import Url | ||
13 | import Url.Parser as P exposing ((</>), Parser, int, oneOf, s, string) | ||
14 | import Utils exposing (..) | 15 | import Utils exposing (..) |
15 | 16 | ||
16 | 17 | ||
@@ -37,7 +38,7 @@ type alias Filters = | |||
37 | 38 | ||
38 | defaultFilters : Filters | 39 | defaultFilters : Filters |
39 | defaultFilters = | 40 | defaultFilters = |
40 | Filters ( -1, 10000 ) ( 0, 5 ) | 41 | Filters ( -1, 100000 ) ( 0, 5 ) |
41 | 42 | ||
42 | 43 | ||
43 | type alias Model = | 44 | type alias Model = |
@@ -199,18 +200,26 @@ viewFilters model = | |||
199 | inp = | 200 | inp = |
200 | Maybe.withDefault 0 << String.toFloat | 201 | Maybe.withDefault 0 << String.toFloat |
201 | in | 202 | in |
202 | div [] | 203 | div |
203 | [ div [] | 204 | [] |
204 | [ text "Price" | 205 | [ div |
205 | , select [ onInput (ChangePriceLower << inp) ] (viewRange 0 priceRange) | 206 | [ css |
207 | [ bigHeading | ||
208 | , paddingBottom (px 12) | ||
209 | ] | ||
210 | ] | ||
211 | [ text "Filters" ] | ||
212 | , div [] | ||
213 | [ div [] [ text "Price" ] | ||
214 | , furbySelect [ onInput (ChangePriceLower << inp), style "appearance" "none" ] (viewRange 0 priceRange) | ||
206 | , text "to" | 215 | , text "to" |
207 | , select [ onInput (ChangePriceUpper << inp) ] (viewRange 50000 priceRange) | 216 | , furbySelect [ onInput (ChangePriceUpper << inp), style "appearance" "none" ] (viewRange 50000 priceRange) |
208 | ] | 217 | ] |
209 | , div [] | 218 | , div [] |
210 | [ text "Rating" | 219 | [ div [] [ text "Rating" ] |
211 | , select [ onInput (ChangeRatingLower << inp) ] (viewRange 1 ratingRange) | 220 | , furbySelect [ onInput (ChangeRatingLower << inp), style "appearance" "none" ] (viewRange 1 ratingRange) |
212 | , text "to" | 221 | , text "to" |
213 | , select [ onInput (ChangeRatingUpper << inp) ] (viewRange 5 ratingRange) | 222 | , furbySelect [ onInput (ChangeRatingUpper << inp), style "appearance" "none" ] (viewRange 5 ratingRange) |
214 | ] | 223 | ] |
215 | ] | 224 | ] |
216 | 225 | ||
@@ -234,8 +243,25 @@ view model = | |||
234 | div [] [ text <| viewStatus Loading ] | 243 | div [] [ text <| viewStatus Loading ] |
235 | 244 | ||
236 | _ -> | 245 | _ -> |
237 | div [] | 246 | div |
238 | [ div [] [ viewFilters model ] | 247 | [ css [ padding (px 40) ] ] |
239 | , ul [] | 248 | [ div |
240 | (filterProducts model |> List.map viewProduct) | 249 | [ css |
250 | [ float left | ||
251 | , Css.width (pct 20) | ||
252 | ] | ||
253 | ] | ||
254 | [ viewFilters model ] | ||
255 | , div | ||
256 | [ css | ||
257 | [ float left | ||
258 | , Css.width (pct 80) | ||
259 | ] | ||
260 | ] | ||
261 | [ div [ css [ bigHeading ] ] [ text "Products" ] | ||
262 | , ul | ||
263 | [ css [ padding (px 0) ] | ||
264 | ] | ||
265 | (filterProducts model |> List.map viewProduct) | ||
266 | ] | ||
241 | ] | 267 | ] |