Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
Fix searchbar (#98)
Browse files Browse the repository at this point in the history
* fix: searchbar filter and adjust height items

* remove some clones
  • Loading branch information
b-avb authored Apr 11, 2024
1 parent 9afdbbf commit 9241cbe
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
20 changes: 19 additions & 1 deletion public/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ ul {
gap: 0;
height: fit-content;
min-height: 78px;
overflow: hidden;
}

.list {
Expand Down Expand Up @@ -847,6 +848,12 @@ ul {
line-height: 24px;
}

.header__title--sticky {
position: sticky;
top: 0;
background: var(--background);
}

.header__cta {
cursor: pointer;
background: transparent;
Expand Down Expand Up @@ -1282,6 +1289,17 @@ ul {
height: calc(100vh - 80px);
}

.chat-list__rooms__content {
overflow: auto;
}

.chat-list__item {
display: flex;
height: fit-content;
flex-direction: column;
margin-bottom: 12px;
}

.chat-list__active-room {
display: flex;
gap: 12px;
Expand Down Expand Up @@ -1648,4 +1666,4 @@ ul {
.menu {
width: 100vw;
}
}
}
33 changes: 20 additions & 13 deletions src/pages/chat/chat_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,35 +261,42 @@ pub fn ChatList() -> Element {
error: None,
on_input: move |event: FormEvent| {
pattern.set(event.value().clone());
let default_rooms = all_rooms().iter().cloned().collect::<Vec<_>>();
if !event.value().is_empty() {
let x = default_rooms
let filter = all_rooms()
.iter()
.filter(|r| {
r.name.to_lowercase().contains(&event.value().to_lowercase())
})
.cloned()
.collect::<Vec<_>>();
rooms_filtered.set(x);
rooms_filtered.set(filter);
} else {
rooms_filtered.set(rooms_list.get_joined().clone())
rooms_filtered.set(rooms_list.get_joined())
}
},
on_keypress: move |_| {},
on_click: move |_| { on_scroll_chat_list_wrapper(ScrollToPosition::Right) }
}
if !rooms_list.get_invited().is_empty() {
h2 { class: "header__title", {translate!(i18, "chat.list.invitate")} }
div {
class: "chat-list__rooms__content",
if !rooms_list.get_invited().is_empty() {
div {
class: "chat-list__item",
h2 { class: "header__title header__title--sticky", {translate!(i18, "chat.list.invitate")} }
RoomsList {
rooms: rooms_list.get_invited(),
is_loading: is_loading(),
on_submit: on_click_invitation
}
}
}

RoomsList {
rooms: rooms_list.get_invited().clone(),
is_loading: is_loading(),
on_submit: on_click_invitation
div {
class: "chat-list__item",
h2 { class: "header__title header__title--sticky", {translate!(i18, "chat.list.rooms")} }
RoomsList { rooms: rooms_filtered(), is_loading: is_loading(), on_submit: on_click_room }
}
}

h2 { class: "header__title", {translate!(i18, "chat.list.rooms")} }
RoomsList { rooms: rooms_list.get_joined(), is_loading: is_loading(), on_submit: on_click_room }
}
div {
class: "chat-list__content",
Expand Down

0 comments on commit 9241cbe

Please sign in to comment.