Skip to content

Commit

Permalink
hide email filter
Browse files Browse the repository at this point in the history
  • Loading branch information
wassson committed Mar 22, 2024
1 parent 97a8ed2 commit d15cd7a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 31 deletions.
13 changes: 7 additions & 6 deletions app/controllers/email_threads_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class EmailThreadsController < ApplicationController
layout "email_thread", only: [ :new, :show ]

before_action :authenticate_user!
before_action :initialize_filters
# before_action :initialize_filters

layout "email_thread", only: [ :new, :show ]

# TODO: Add filter for inbox, reply later, all
def inbox
Expand All @@ -19,9 +20,9 @@ def show
@messages = @thread.messages.includes(:user)
end

private
# private

def initialize_filters
@filters = [ "Inbox", "Reply later", "All" ]
end
# def initialize_filters
# @filters = [ "Inbox", "Reply later", "All" ]
# end
end
30 changes: 15 additions & 15 deletions app/javascript/controllers/root_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export default class extends Controller {
this.commandPaletteOpen =
this.userSettingsModalOpen = false

this.filterIndex =
// this.filterIndex =
this.listItemIndex =
this.paletteItemIndex = 0

this.highlightFilter()
// this.highlightFilter()
this.highlightListItem()
}

Expand Down Expand Up @@ -42,26 +42,26 @@ export default class extends Controller {
this.userSettingsModalOpen = state
}

highlightFilter() {
this.filterTargets.forEach((filter, index) => {
filter.classList.toggle("text-white", index === this.filterIndex)
filter.classList.toggle("bg-neutral-700/50", index === this.filterIndex)
})
}
// highlightFilter() {
// this.filterTargets.forEach((filter, index) => {
// filter.classList.toggle("text-white", index === this.filterIndex)
// filter.classList.toggle("bg-neutral-700/50", index === this.filterIndex)
// })
// }

highlightListItem() {
this.listItemTargets.forEach((listItem, index) => {
listItem.classList.toggle("bg-neutral-700/50", index === this.listItemIndex)
})
}

nextFilter() {
this.filterIndex++
if (this.filterIndex >= this.filterTargets.length) {
this.filterIndex = 0
}
this.highlightFilter()
}
// nextFilter() {
// this.filterIndex++
// if (this.filterIndex >= this.filterTargets.length) {
// this.filterIndex = 0
// }
// this.highlightFilter()
// }

nextListItem() {
this.listItemIndex++
Expand Down
14 changes: 4 additions & 10 deletions app/views/shared/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@
</div>
<%= render 'shared/navigation/user' %>
</div>
<% @filters.each do |filter| %>
<div data-root-target="filter"
class="flex items-center h-8 px-3 hover:bg-neutral-200 hover:text-white hover:bg-neutral-700/50 backdrop-filter backdrop-blur rounded-lg">
<% if filter == 'Inbox' %>
<p class="text-xs font-medium"><%= filter %><span class="ml-1 text-sky-500"><%= @email_threads.count if filter == 'Inbox' %></span></p>
<% else %>
<p class="text-xs font-medium"><%= filter %></p>
<% end %>
</div>
<% end %>
<div data-root-target="filter"
class="flex items-center">
<p class="text-xs font-medium">Inbox<span class="ml-1 text-amber-500"><%= @email_threads.count %></span></p>
</div>
</div>
</nav>

0 comments on commit d15cd7a

Please sign in to comment.