//! A module that handles `bar` partial for the `search_bar` partial and the home/index/main page in the `crabbysearch` frontend.

use maud::{html, Markup, PreEscaped};

/// A functions that handles the html code for the bar for the `search_bar` partial and the
/// home/index/main page in the search engine frontend.
///
/// # Arguments
///
/// * `query` - It takes the current search query provided by user as an argument.
///
/// # Returns
///
/// It returns the compiled html code for the search bar as a result.
pub fn bar(query: &str) -> Markup {
    html!(
        .search_container {
            (PreEscaped("<div class=\"search_bar\">"))
            form action="/search" method="get" {
                input type="search" name="query" value=(query) placeholder="Type to search";
                input type="hidden" name="page" value="0";
                button type="submit"  {
                    img src="./images/magnifying_glass.svg" alt="Info icon for error box";
                }
            }
        }
    )
}
