Skip to content

Commit

Permalink
accordion add ability to have small titles
Browse files Browse the repository at this point in the history
  • Loading branch information
chillenberger committed May 22, 2024
1 parent 7df1e83 commit f6ec6be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pgml-dashboard/src/components/accordian/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct Accordian {
html_contents: Vec<String>,
html_titles: Vec<String>,
selected: usize,
small_titles: bool,
}

impl Accordian {
Expand All @@ -19,6 +20,7 @@ impl Accordian {
html_contents: Vec::new(),
html_titles: Vec::new(),
selected: 0,
small_titles: false,
}
}

Expand All @@ -31,6 +33,11 @@ impl Accordian {
self.html_titles = html_titles.into_iter().map(|s| s.to_string()).collect();
self
}

pub fn small_titles(mut self, small_titles: bool) -> Self {
self.small_titles = small_titles;
self
}
}

component!(Accordian);
4 changes: 4 additions & 0 deletions pgml-dashboard/src/components/accordian/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<div class="accordian-item">
<div class="accordian-header <% if i == selected { %> selected <% } %>" data-action="click->accordian#titleClick" data-value="accordian-body<%= i %>">
<div class="d-flex justify-content-between align-items-center w-100">
<% if small_titles {%>
<h6 class="mb-0"><%- html_titles[i] %></h6>
<% } else { %>
<h4 class="mb-0"><%- html_titles[i] %></h4>
<% } %>
<span class="add material-symbols-outlined">add</span>
<span class="remove material-symbols-outlined">remove</span>
</div>
Expand Down

0 comments on commit f6ec6be

Please sign in to comment.