diff --git a/src/components/search.rs b/src/components/search.rs
index 52596a8..ead324f 100644
--- a/src/components/search.rs
+++ b/src/components/search.rs
@@ -32,15 +32,6 @@ pub fn Search() -> impl IntoView {
spawn_local(async move {
log!("Searching for: {:?}", search_query.get_untracked());
- // let results = search(search_query.get_untracked(), search_limit).await;
- // match results {
- // Ok((albums, artists, songs)) => {
- // search_results.set((albums, artists, songs));
- // }
- // Err(err) => {
- // log!("Error searching: {:?}", err);
- // }
- // }
let albums = search_albums(search_query.get_untracked(), search_limit).await;
let artists = search_artists(search_query.get_untracked(), search_limit).await;
let songs = search_songs(search_query.get_untracked(), search_limit).await;
@@ -98,8 +89,9 @@ pub fn Search() -> impl IntoView {
+ // Display 3 columns of search results: songs, albums, and artists
- {song_search_results.with(|songs| -> Vec> {
+ {move || song_search_results.with(|songs| -> Vec> {
let mut song_list = Vec::new();
log!("Songs: {:?}", songs);
for (song, _) in songs {
@@ -122,12 +114,11 @@ pub fn Search() -> impl IntoView {
});
}
-
song_list
})}
- {album_search_results.with(|albums| -> Vec> {
+ {move || album_search_results.with(|albums| -> Vec> {
let mut album_list = Vec::new();
log!("Albums: {:?}", albums);
for (album, _) in albums {
@@ -153,12 +144,11 @@ pub fn Search() -> impl IntoView {
});
}
-
album_list
})}
- {artist_search_results.with(|artists| -> Vec> {
+ {move || artist_search_results.with(|artists| -> Vec> {
let mut artist_list = Vec::new();
log!("Artists: {:?}", artists);
for (artist, _) in artists {
@@ -180,104 +170,9 @@ pub fn Search() -> impl IntoView {
});
}
-
artist_list
})}
- /* {
- move || search_results.with(|(albums, artists, songs)| -> (leptos::HtmlElement
, leptos::HtmlElement, leptos::HtmlElement) {
- // log the search results
- log!("Albums: {:?}", albums);
- log!("Artists: {:?}", artists);
- log!("Songs: {:?}", songs);
-
- // We need 3 uls, one for songs, one for albums, and one for artists, each in ascending order of score (distance)
- let mut song_list = Vec::new();
-
- for (song, score) in songs {
- song_list.push(view! {
-
-
-
path,
- None => "".to_string()
- } song_title=song.title.clone() song_artist="".to_string() />
-
-
-
- });
- }
-
- let mut album_list = Vec::new();
-
- for (album, score) in albums {
- album_list.push(view! {
-
-
-
- {album.title.clone()}
- {match album.release_date {
- Some(date) => format!(" ({})", date),
- None => "".to_string()
- }}
-
-
-
-
- });
- }
-
- let mut artist_list = Vec::new();
-
- for (artist, score) in artists {
- artist_list.push(view! {
-
-
-
- {artist.name.clone()}
-
-
-
-
- });
- }
-
- (view! {
-
- }, view! {
-
- }, view! {
-
- })
- }) */
- // }
}
diff --git a/style/search.scss b/style/search.scss
index 8a6c80d..3c18614 100644
--- a/style/search.scss
+++ b/style/search.scss
@@ -1,4 +1,92 @@
@import "theme.scss";
.search-container {
+ display: flex;
+ flex-direction: column;
+ gap: 1rem;
+
+ .search-bar {
+ input[type="search"] {
+ width: 100%;
+ padding: 0.5rem 1rem;
+ font-size: 1rem;
+ border: 1px solid $search-border;
+ border-radius: 4px;
+ transition: border-color 0.2s;
+
+ &:focus {
+ border-color: $accent-color;
+ outline: none;
+ }
+ }
+ }
+
+ .search-results {
+ display: flex;
+ justify-content: space-between;
+ gap: 1rem;
+
+ .search-result-list {
+ flex: 1;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+
+ .search-result {
+ display: flex;
+ flex-direction: column;
+ gap: 0.5rem;
+ padding: 0.5rem;
+ border: 1px solid $search-border;
+ border-radius: 4px;
+ background-color: $search-background;
+ transition: box-shadow 0.2s;
+ margin: 0.2rem;
+ min-height: 6rem;
+
+ .result-container {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+
+ .search-result-album,
+ .search-result-artist {
+ font-size: 1rem;
+ font-weight: bold;
+ }
+
+ .search-item-type {
+ font-size: 0.9rem;
+ color: $text-controls-color;
+ }
+
+ .right-side-result {
+ display: flex;
+ align-items: center;
+ gap: 0.5rem;
+
+ .search-result-options {
+ background: none;
+ border: none;
+ padding: 0;
+ cursor: pointer;
+
+ .search-result-options-icon {
+ fill: $text-controls-color;
+ transition: fill 0.2s;
+
+ &:hover {
+ fill: $controls-hover-color;
+ }
+
+ &:active {
+ fill: $controls-click-color;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
diff --git a/style/theme.scss b/style/theme.scss
index b0cea43..dd8f4f0 100644
--- a/style/theme.scss
+++ b/style/theme.scss
@@ -11,6 +11,8 @@ $play-bar-background-color: #212121;
$play-grad-start: #0a0533;
$play-grad-end: $accent-color;
$queue-background-color: $play-bar-background-color;
+$search-background: $play-bar-background-color;
+$search-border: #3f3f3f;
$auth-inputs: #796dd4;
$auth-containers: white;