diff options
author | David Gay <david@davidgay.org> | 2023-11-03 02:11:02 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2023-11-03 02:11:02 -0400 |
commit | d4c92922e393876e93ad13943ba45fb08586e6c8 (patch) | |
tree | 5460ab24695c978080133ae9af9dcbf8b4bca55c /app/views/pokedex/show.html.erb | |
parent | 13f4f6ca06a216962f4c25fa0d6041945cfb3fb5 (diff) |
Pokedex: Grey out uncaptured pokemon
Diffstat (limited to 'app/views/pokedex/show.html.erb')
-rw-r--r-- | app/views/pokedex/show.html.erb | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/app/views/pokedex/show.html.erb b/app/views/pokedex/show.html.erb index e463d58..992c7c8 100644 --- a/app/views/pokedex/show.html.erb +++ b/app/views/pokedex/show.html.erb @@ -1,11 +1,27 @@ <div class="space-y-4"> <h1>Pokédex</h1> + <div class="flex space-x-4 items-center"> + <%= form_with url: pokedex_path do |f| %> + <%= f.collection_select :user_id, User.order(:name), :id, + ->(user) { user.name || "No. #{user.id}" }, {selected: params[:user_id], include_blank: "Show full Pokédex"} + %> + <% end %> + <% if @user %> + <span>has captured <%= pluralize(@user.captured_pokemon.count, "specie") %> of pokémon.</span> + <% end %> + </div> + <div class="flex flex-wrap gap-4"> <% Pokemon.order(:pokedex_num).each do |pokemon| %> <% break if pokemon.pokedex_num.to_i > 386 # Up through gen 3. %> - <div class="flex flex-col flex-auto items-center w-[100px] bg-white - border border-orange-900 rounded shadow"> + <div class="flex flex-col flex-auto items-center p-1 w-[100px] bg-white border border-orange-900 rounded shadow + <% if @user && !@user.captured_pokemon.include?(pokemon) %> + grayscale opacity-50 + <% else %> + ring ring-orange-500 ring-opacity-50 + <% end %> + "> <div class="flex-1 text-display text-center">No. <%= pokemon.pokedex_num %></div> <div class="flex-grow flex flex-col justify-around"> <%= image_tag pokemon.sprite_path %> |