Skip to content

Commit c1977c0

Browse files
author
Nicholas Newberry
committed
highlight currently selected list items
1 parent cff02c7 commit c1977c0

6 files changed

Lines changed: 21 additions & 6 deletions

File tree

app/views/collections/index.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="flex">
22
<%= turbo_stream_from "collections" %>
33

4-
<%= render "shared/collection_list", collections: @collections %>
4+
<% selected = @collection || @document&.collection || @chunk&.document&.collection %>
5+
<%= render "shared/collection_list", collections: @collections, selected: %>
56

67
<%= render "shared/collection_area" do %>
78
<%= render "shared/notice" %>

app/views/conversations/_conversation_list.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<%= button_to "New conversation", conversations_path, class: "rounded-lg py-1 px-3 mb-4 my-2 text-center text-secondary-950 dark:text-secondary-950 block font-medium bg-primary-600 dark:bg-primary-400", data: { turbo: false } %>
55
<div class="overflow-y-scroll flex-1 no-scrollbar">
66
<% conversations.order(created_at: :desc).each do |conversation| %>
7-
<%= render "conversation_list_item", conversation: %>
7+
<%= render "conversation_list_item", conversation:, selected: %>
88
<% end %>
99
</div>
1010
<div class="w-full text-sm font-bold text-center my-1">

app/views/conversations/_conversation_list_item.html.erb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<div id="<%= dom_id(conversation) %>">
2-
<div class="container flex hover:bg-secondary-300 dark:hover:bg-secondary-700 rounded-md p-1">
2+
<%
3+
bg_class = if selected.id == conversation.id
4+
"bg-secondary-200 dark:bg-secondary-600 hover:bg-secondary-200 dark:hover:bg-secondary-500"
5+
else
6+
"hover:bg-secondary-300 dark:hover:bg-secondary-700"
7+
end
8+
%>
9+
<div class="container flex rounded-md p-1 <%= bg_class %>">
310
<%= link_to conversation, class: "flex-1" do %>
411
<div class="px-2 py-1 text-sm">
512
<%= conversation.title %>

app/views/conversations/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="flex">
2-
<%= render "conversation_list", conversations: @conversations %>
2+
<%= render "conversation_list", conversations: @conversations, selected: @conversation %>
33

44
<div class="overflow-y-scroll flex-1 p-5 h-screen w-100 bg-secondary-100 dark:bg-secondary-950 flextext-gray-700 dark:text-secondary-200">
55
<div class="container flex justify-center w-full align-center">

app/views/shared/_collection_list.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<%= button_to "New collection", collections_path, class: "rounded-lg py-1 mb-4 px-3 my-2 text-center text-secondary-100 dark:text-secondary-950 block font-medium bg-tertiary-600 dark:bg-tertiary-400", data: { turbo: false } %>
77
<div class="container overflow-y-scroll flex-1 no-scrollbar">
88
<% collections.order(created_at: :desc).each do |collection| %>
9-
<%= render "shared/collection_list_item", collection: %>
9+
<%= render "shared/collection_list_item", collection:, selected: %>
1010
<% end %>
1111
</div>
1212
<div class="w-full text-sm font-bold text-center my-1">

app/views/shared/_collection_list_item.html.erb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
<div id="<%= "#{dom_id(collection)}_list_item" %>">
2-
<div class="container flex hover:bg-secondary-300 dark:hover:bg-secondary-700 rounded-md p-1">
2+
<%
3+
bg_class = if selected.id == collection.id
4+
"bg-secondary-200 dark:bg-secondary-600 hover:bg-secondary-200 dark:hover:bg-secondary-500"
5+
else
6+
"hover:bg-secondary-300 dark:hover:bg-secondary-700"
7+
end
8+
%>
9+
<div class="container flex rounded-md p-1 <%= bg_class %>">
310
<%= link_to collection, class: "flex-1" do %>
411
<div class="px-2 py-1 text-sm">
512
<%= collection.name %>

0 commit comments

Comments
 (0)