- Notifications
You must be signed in to change notification settings - Fork328
Dropdown + ellipsis fix#974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
18 commits Select commitHold shift + click to select a range
a189517
Dropdown + ellipsis fix
levkk0ec0817
lint
levkk122f289
Fix collapse
levkk67356a1
Dropdown with profile icon
levkk8185d7b
typo
levkk7ffebfb
use dropdown
levkkdb1ea2b
overflow
levkkcc4e6f7
oh
levkk41b203a
hmm
levkkc58a373
spaghetti
levkk99742f4
button
levkk80ced53
ok
levkk87ad794
oh
levkk50ee081
exact
levkkaf48386
ok
levkke95e7fc
Make sure dropdown works
levkk0355bad
Move dropdown scss into the module
levkkd012a55
editrconfig
levkkFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletionspgml-dashboard/.editorconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[*.scss] | ||
indent_style = space | ||
indent_size = 4 | ||
[*.js] | ||
indent_style = space | ||
indent_size = 2 | ||
[*.rs] | ||
indent_style = space | ||
indent_size = 4 | ||
[*.html] | ||
ident_style = space | ||
indent_size = 4 |
112 changes: 112 additions & 0 deletionspgml-dashboard/src/components/dropdown/dropdown.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.dropdown { | ||
@extend .d-flex; | ||
min-width: 100%; | ||
.dropdown-toggle { | ||
a { | ||
padding: 8px 12px; | ||
} | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
&:after { | ||
content: none; | ||
} | ||
} | ||
.dropdown-menu { | ||
width: 100%; | ||
} | ||
&.expandable { | ||
.dropdown-menu { | ||
width: auto; | ||
min-width: 100%; | ||
} | ||
} | ||
.dropdown-item { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
} | ||
.btn-dropdown { | ||
border-radius: $border-radius; | ||
background: #{$gray-700}; | ||
color: #{$gray-100}; | ||
display: flex; | ||
justify-content: space-between; | ||
font-weight: $font-weight-normal; | ||
--bs-btn-border-color: transparent; | ||
--bs-btn-border-width: 1px; | ||
--bs-btn-hover-border-color: #{$neon-shade-100}; | ||
--bs-btn-active-border-color: #{$neon-shade-100}; | ||
--bs-btn-active-bg: #{$gray-700}; | ||
--bs-btn-active-color: #{$gray-100}; | ||
--bs-btn-hover-color: #{$gray-100}; | ||
.material-symbols-outlined { | ||
color: #{$neon-shade-100}; | ||
} | ||
&:after { | ||
content: None; | ||
} | ||
&.show { | ||
.material-symbols-outlined { | ||
transform: rotate(-180deg); | ||
} | ||
} | ||
.collapase { | ||
width: 100%; | ||
} | ||
.btn-dropdown-text { | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
text-align: left; | ||
} | ||
.menu-item { | ||
a { | ||
padding: 8px 12px; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
} | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
&:after { | ||
content: None; | ||
} | ||
} | ||
} | ||
@mixin dropdown-menu($primary-color: null) { | ||
padding: 20px 0px 40px 0px; | ||
overflow-y: auto; | ||
@if ($primary-color) { | ||
background-color: #{$primary-color}; | ||
} | ||
} | ||
.dropdown-menu { | ||
@include dropdown-menu($gray-600); | ||
max-height: $dropdown-menu-height; | ||
overflow: hidden; | ||
} | ||
.sub-menu-dropdown { | ||
@include dropdown-menu(); | ||
border-radius: 0px; | ||
box-shadow: 1px 1px 8px 0px rgba(0, 0, 0, 0.30); | ||
} |
102 changes: 102 additions & 0 deletionspgml-dashboard/src/components/dropdown/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use crate::components::component; | ||
use crate::components::component::Component; | ||
use sailfish::TemplateOnce; | ||
use crate::components::StaticNavLink; | ||
pub enum DropdownValue { | ||
Icon(Component), | ||
Text(Component), | ||
} | ||
impl Default for DropdownValue { | ||
fn default() -> Self { | ||
DropdownValue::Text("Menu".into()) | ||
} | ||
} | ||
#[derive(TemplateOnce, Default)] | ||
#[template(path = "dropdown/template.html")] | ||
pub struct Dropdown { | ||
/// The currently selected value. | ||
value: DropdownValue, | ||
/// The list of dropdown links to render. | ||
links: Vec<StaticNavLink>, | ||
/// Position of the dropdown menu. | ||
offset: String, | ||
/// Whether or not the dropdown is collapsble. | ||
collapsable: bool, | ||
offset_collapsed: String, | ||
/// Where the dropdown menu should appear | ||
menu_position: String, | ||
expandable: bool, | ||
} | ||
impl Dropdown { | ||
pub fn new(links: Vec<StaticNavLink>) -> Self { | ||
let binding = links | ||
.iter() | ||
.filter(|link| link.active) | ||
.collect::<Vec<&StaticNavLink>>(); | ||
let active = binding.first(); | ||
let value = if let Some(active) = active { | ||
active.name.to_owned() | ||
} else { | ||
"Menu".to_owned() | ||
}; | ||
Dropdown { | ||
links, | ||
value: DropdownValue::Text(value.into()), | ||
offset: "0, 10".to_owned(), | ||
offset_collapsed: "68, -44".to_owned(), | ||
menu_position: "".to_owned(), | ||
..Default::default() | ||
} | ||
} | ||
pub fn text(mut self, value: Component) -> Self { | ||
self.value = DropdownValue::Text(value); | ||
self | ||
} | ||
pub fn icon(mut self, icon: Component) -> Self { | ||
self.value = DropdownValue::Icon(icon); | ||
self | ||
} | ||
pub fn collapsable(mut self) -> Self { | ||
self.collapsable = true; | ||
self | ||
} | ||
pub fn menu_end(mut self) -> Self { | ||
self.menu_position = "dropdown-menu-end".to_owned(); | ||
self | ||
} | ||
pub fn menu_start(mut self) -> Self { | ||
self.menu_position = "dropdown-menu-start".to_owned(); | ||
self | ||
} | ||
pub fn offset(mut self, offset: &str) -> Self { | ||
self.offset = offset.to_owned(); | ||
self | ||
} | ||
pub fn offset_collapsed(mut self, offset: &str) -> Self { | ||
self.offset_collapsed = offset.to_owned(); | ||
self | ||
} | ||
pub fn expandable(mut self) -> Self { | ||
self.expandable = true; | ||
self | ||
} | ||
} | ||
component!(Dropdown); |
56 changes: 56 additions & 0 deletionspgml-dashboard/src/components/dropdown/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<% use crate::components::dropdown::DropdownValue; %> | ||
<!-- Dropdown component --> | ||
<div class="dropdown <% if expandable { %>expandable<% } %>"> | ||
<% if let DropdownValue::Icon(icon) = value { %> | ||
<a | ||
class="topnav-controlls dropdown-toggle" | ||
role="button" | ||
data-bs-toggle="dropdown" | ||
data-bs-offset="<%= offset %>" | ||
href="#" | ||
aria-expanded="false"> | ||
<%+ icon %> | ||
</a> | ||
<% } else if let DropdownValue::Text(text) = value { %> | ||
<button | ||
class="horizontal-hide btn btn-dropdown dropdown-toggle <% if collapsable { %> leftnav-collapse-affect <% } %>" | ||
role="button" | ||
data-bs-toggle="dropdown" | ||
data-bs-offset="<%= offset %>" | ||
aria-expanded="false"> | ||
<span class="btn-dropdown-text"><%+ text %></span> | ||
<span class="material-symbols-outlined"> | ||
expand_more | ||
</span> | ||
</button> | ||
<% } %> | ||
<% if collapsable { %> | ||
<div | ||
class="menu-item horizontal-hide dropdown-toggle collapsed <% if collapsable { %> leftnav-collapse-affect <% } %>" | ||
role="button" | ||
data-bs-toggle="dropdown" | ||
data-bs-offset="<%= offset_collapsed %>" | ||
aria-expanded="false" | ||
> | ||
<a class="d-flex align-items-center justify-content-start gap-2"> | ||
<span class="material-symbols-outlined">grid_view</span> | ||
</a> | ||
</div> | ||
<% } %> | ||
<ul class="dropdown-menu <%= menu_position %>"> | ||
<% for link in links { %> | ||
<li class="menu-item d-flex align-items-center <% if link.disabled { %>disabled<% } %>"> | ||
<% if link.disabled { %> | ||
<a type="button" class="dropdown-item" disabled href="#"><%= link.name %></a> | ||
<% } else { %> | ||
<a type="button" class="dropdown-item" href="<%- link.href %>"><%= link.name %></a> | ||
<% } %> | ||
</li> | ||
<% } %> | ||
</ul> | ||
</div> | ||
<!-- /Dropdown component --> |
12 changes: 12 additions & 0 deletionspgml-dashboard/src/components/left_nav_web_app/left_nav_web_app.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.leftnav { | ||
@extend .navbar; | ||
max-width: 260px; | ||
border: none; | ||
align-items: start; | ||
background-color: inherit; | ||
@include media-breakpoint-down(lg) { | ||
background-color: #{$gray-900} | ||
} | ||
} |
27 changes: 4 additions & 23 deletionspgml-dashboard/src/components/left_nav_web_app/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletionspgml-dashboard/src/components/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
23 changes: 7 additions & 16 deletionspgml-dashboard/src/components/navbar_web_app/template.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.