diff options
Diffstat (limited to 'app/views')
-rw-r--r-- | app/views/layouts/application.html.erb | 2 | ||||
-rw-r--r-- | app/views/pokedex/show.html.erb | 20 | ||||
-rw-r--r-- | app/views/users/show.html.erb | 2 |
3 files changed, 20 insertions, 4 deletions
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2332cd5..073a2f7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,7 @@ </div> <div class="space-x-8 nav-links"> <% if user_signed_in? %> - <%= link_to "Pokédex", pokedex_path %> + <%= link_to "Pokédex", pokedex_path(user_id: current_user.id) %> <%= link_to "Trainer", user_path(current_user) %> <%= link_to "Sign out", destroy_user_session_path %> <% else %> 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 %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index f11b01f..9d253ec 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -6,7 +6,7 @@ </div> <div> <p class="text-lg">NAME: <%= @user.name || "???" %> - <p>POKéDEX: <%= @user.pokedex_captured_count %></p> + <p><%= link_to "POKéDEX: #{@user.captured_pokemon.count}", pokedex_path(user_id: @user.id) %></p> <p>TIME: <%= distance_of_time_in_words_to_now(@user.created_at) %></p> </div> <% if @user == current_user %> |