Add badges to the card list
This commit is contained in:
parent
00616067c8
commit
45afe018c5
1 changed files with 66 additions and 15 deletions
|
@ -264,7 +264,10 @@ update msg model =
|
||||||
update Search { model | criteria = newCriteria }
|
update Search { model | criteria = newCriteria }
|
||||||
|
|
||||||
Search ->
|
Search ->
|
||||||
( { model | cardPage = toLoading model.cardPage }
|
( { model
|
||||||
|
| cardPage = toLoading model.cardPage
|
||||||
|
, activeCard = Nothing
|
||||||
|
}
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ Browser.Navigation.pushUrl model.navigationKey <|
|
[ Browser.Navigation.pushUrl model.navigationKey <|
|
||||||
Url.Builder.relative [] (searchQuery model.criteria)
|
Url.Builder.relative [] (searchQuery model.criteria)
|
||||||
|
@ -309,6 +312,18 @@ colors =
|
||||||
|
|
||||||
white =
|
white =
|
||||||
E.rgb255 255 255 255
|
E.rgb255 255 255 255
|
||||||
|
|
||||||
|
mythic =
|
||||||
|
E.rgb255 205 55 0
|
||||||
|
|
||||||
|
rare =
|
||||||
|
E.rgb255 218 165 32
|
||||||
|
|
||||||
|
uncommon =
|
||||||
|
E.rgb255 112 128 144
|
||||||
|
|
||||||
|
common =
|
||||||
|
E.rgb255 47 79 79
|
||||||
in
|
in
|
||||||
{ primary = blue
|
{ primary = blue
|
||||||
, background = lightGrey
|
, background = lightGrey
|
||||||
|
@ -317,6 +332,10 @@ colors =
|
||||||
, selected = darkGrey
|
, selected = darkGrey
|
||||||
, hover = grey
|
, hover = grey
|
||||||
, text = white
|
, text = white
|
||||||
|
, mythic = mythic
|
||||||
|
, rare = rare
|
||||||
|
, uncommon = uncommon
|
||||||
|
, common = common
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,11 +413,41 @@ viewCardBrowser model =
|
||||||
, description = cardModel.name
|
, description = cardModel.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
badge color text =
|
||||||
|
E.el
|
||||||
|
[ Border.rounded 5
|
||||||
|
, Border.color colors.text
|
||||||
|
, Background.color color
|
||||||
|
, E.width <| E.px 60
|
||||||
|
, E.padding 2
|
||||||
|
, Font.family [ Font.typeface "sans" ]
|
||||||
|
, Font.size 10
|
||||||
|
]
|
||||||
|
<|
|
||||||
|
E.text text
|
||||||
|
|
||||||
|
setBadge : Card.Card -> E.Element Msg
|
||||||
|
setBadge card =
|
||||||
|
let
|
||||||
|
color =
|
||||||
|
case card.rarity of
|
||||||
|
"mythic" ->
|
||||||
|
colors.mythic
|
||||||
|
|
||||||
|
"rare" ->
|
||||||
|
colors.rare
|
||||||
|
|
||||||
|
"uncommon" ->
|
||||||
|
colors.uncommon
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
colors.common
|
||||||
|
in
|
||||||
|
badge color card.setCode
|
||||||
|
|
||||||
priceBadge { currency, amount } =
|
priceBadge { currency, amount } =
|
||||||
E.el
|
E.el
|
||||||
[ Border.solid
|
[ Border.rounded 5
|
||||||
, Border.width 1
|
|
||||||
, Border.rounded 5
|
|
||||||
, Border.color colors.text
|
, Border.color colors.text
|
||||||
, E.width <| E.px 60
|
, E.width <| E.px 60
|
||||||
, E.padding 2
|
, E.padding 2
|
||||||
|
@ -414,9 +463,7 @@ viewCardBrowser model =
|
||||||
cardInfoWidth =
|
cardInfoWidth =
|
||||||
E.px 300
|
E.px 300
|
||||||
|
|
||||||
cardDetails card =
|
prices card =
|
||||||
let
|
|
||||||
prices =
|
|
||||||
Maybe.Extra.values
|
Maybe.Extra.values
|
||||||
[ Maybe.map (\usd -> { currency = "usd", amount = usd }) <|
|
[ Maybe.map (\usd -> { currency = "usd", amount = usd }) <|
|
||||||
Maybe.Extra.or card.prices.usd card.prices.usd_foil
|
Maybe.Extra.or card.prices.usd card.prices.usd_foil
|
||||||
|
@ -424,7 +471,8 @@ viewCardBrowser model =
|
||||||
Maybe.Extra.or card.prices.eur card.prices.eur_foil
|
Maybe.Extra.or card.prices.eur card.prices.eur_foil
|
||||||
, Maybe.map (\tix -> { currency = "tix", amount = tix }) card.prices.tix
|
, Maybe.map (\tix -> { currency = "tix", amount = tix }) card.prices.tix
|
||||||
]
|
]
|
||||||
in
|
|
||||||
|
cardDetails card =
|
||||||
E.column
|
E.column
|
||||||
[ E.spacing 20
|
[ E.spacing 20
|
||||||
, E.padding 10
|
, E.padding 10
|
||||||
|
@ -432,7 +480,7 @@ viewCardBrowser model =
|
||||||
<|
|
<|
|
||||||
E.el [ E.centerX ]
|
E.el [ E.centerX ]
|
||||||
(viewCard { width = 192, height = 272 } card)
|
(viewCard { width = 192, height = 272 } card)
|
||||||
:: (E.row [ E.spacing 5, E.centerX ] <| List.map priceBadge prices)
|
:: (E.row [ E.spacing 5, E.centerX ] <| List.map priceBadge (prices card))
|
||||||
:: E.paragraph [ Font.heavy, Font.size 24, Font.center ] [ E.text card.name ]
|
:: E.paragraph [ Font.heavy, Font.size 24, Font.center ] [ E.text card.name ]
|
||||||
:: List.map (\text -> E.paragraph [ Font.size 16 ] [ E.text text ])
|
:: List.map (\text -> E.paragraph [ Font.size 16 ] [ E.text text ])
|
||||||
(String.lines card.oracleText)
|
(String.lines card.oracleText)
|
||||||
|
@ -471,6 +519,9 @@ viewCardBrowser model =
|
||||||
, description = cardModel.name
|
, description = cardModel.name
|
||||||
}
|
}
|
||||||
, E.el [ E.centerY ] <| E.text cardModel.name
|
, E.el [ E.centerY ] <| E.text cardModel.name
|
||||||
|
, E.column [ E.alignRight, E.height E.fill ] <|
|
||||||
|
setBadge cardModel
|
||||||
|
:: List.map priceBadge (prices cardModel)
|
||||||
]
|
]
|
||||||
|
|
||||||
details =
|
details =
|
||||||
|
|
Loading…
Reference in a new issue