From 5fac4745af34704d012f968f8bb79bfffd423034 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Wed, 24 Jul 2024 14:35:24 -0500 Subject: [PATCH] Filter index by category --- app/assets/images/remove.svg | 1 + app/assets/stylesheets/splats.css | 40 +++++++++++++++------------- app/controllers/splats_controller.rb | 7 ++++- app/views/splats/_splat.html.erb | 4 +-- app/views/splats/index.html.erb | 15 ++++++++++- 5 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 app/assets/images/remove.svg diff --git a/app/assets/images/remove.svg b/app/assets/images/remove.svg new file mode 100644 index 000000000..9e874f845 --- /dev/null +++ b/app/assets/images/remove.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/assets/stylesheets/splats.css b/app/assets/stylesheets/splats.css index 69df04e2f..1d1b2fb40 100644 --- a/app/assets/stylesheets/splats.css +++ b/app/assets/stylesheets/splats.css @@ -34,10 +34,31 @@ } } +.splat__category { + aspect-ratio: 1; + background-color: var(--color-bg); + border: 0.5em solid var(--splat-color); + border-radius: 50%; + color: var(--splat-color); + display: flex; + font-size: 5cqi; + font-weight: 800; + inset: auto auto 3cqi 3cqi; + padding: 0.5em 1em; + place-items: center; + position: absolute; + + + & { + inset: auto auto 0 24cqi; + } +} + .splat__date { aspect-ratio: 1; - background-color: var(--splat-color); + background-color: var(--color-bg); + border: 0.5em solid var(--splat-color); border-radius: 50%; + color: var(--splat-color); display: flex; font-size: 5cqi; font-weight: 800; @@ -59,23 +80,6 @@ z-index: -1; } -.splat__tag { - aspect-ratio: 1; - background-color: var(--splat-color); - border-radius: 50%; - display: flex; - font-size: 5cqi; - font-weight: 800; - inset: auto auto 3cqi 3cqi; - padding: 0.5em 1em; - place-items: center; - position: absolute; - - + & { - inset: auto auto 0 24cqi; - } -} - .splat__title { font-size: 10cqi; line-height: 1.2; diff --git a/app/controllers/splats_controller.rb b/app/controllers/splats_controller.rb index 787e98952..ae5408174 100644 --- a/app/controllers/splats_controller.rb +++ b/app/controllers/splats_controller.rb @@ -2,7 +2,12 @@ class SplatsController < ApplicationController before_action :set_splat, only: [ :show, :edit, :update ] def index - @splats = Splat.all + if params[:category_id] + @category = Category.find(params[:category_id]) + @splats = @category.splats + else + @splats = Splat.all + end end def new diff --git a/app/views/splats/_splat.html.erb b/app/views/splats/_splat.html.erb index 9a1f0c6eb..50a8587ba 100644 --- a/app/views/splats/_splat.html.erb +++ b/app/views/splats/_splat.html.erb @@ -5,7 +5,7 @@ <% end %> - <% if splat.categories.any? %> - <%= splat.categories.first.title %> + <% splat.categories.each do | category | %> + <%= link_to category.title, splats_path(category_id: category.id), class: "splat__category" %> <% end %> diff --git a/app/views/splats/index.html.erb b/app/views/splats/index.html.erb index a4737cbee..035630b3b 100644 --- a/app/views/splats/index.html.erb +++ b/app/views/splats/index.html.erb @@ -5,6 +5,19 @@ Settings +

+ Splats + + <% if @category %> + in <%= @category.title %> + + <%= link_to splats_path, class: "btn txt-small" do %> + <%= image_tag "remove.svg", aria: { hidden: true }, size: 24 %> + Clear + <% end %> + <% end %> +

+
<%= tag.button class: "btn flex-item-justify-end", popovertarget: "new-splat-panel" do %> <%= image_tag "add.svg", aria: { hidden: true }, size: 24 %> @@ -67,7 +80,7 @@ <% end %> <% splat.categories.each do |category| %> - <%= category.title %> + <%= link_to category.title, splats_path(category_id: category.id), class: "btn txt-small txt-nowrap" %> <% end %> JZ