summaryrefslogtreecommitdiff
path: root/app/views/pokedex/show.html.erb
blob: 992c7c8d9883ce40c6011d333a95a974c2fe5f59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<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 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 %>
        </div>
        <div class="flex-1"><%= pokemon.name %></div>
      </div>
    <% end %>
  </div>
</div>