Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7750ed2

Browse files
authored
Add tabs & table (#982)
1 parent334bdc5 commit7750ed2

File tree

24 files changed

+353
-16
lines changed

24 files changed

+353
-16
lines changed

‎pgml-dashboard/.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ indent_size = 4
1313

1414
[*.html]
1515
ident_style =space
16-
indent_size =4
16+
indent_size =2

‎pgml-dashboard/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::process::Command;
33

44
fnmain(){
55
println!("cargo:rerun-if-changed=migrations");
6-
println!("cargo:rerun-if-changed=src");
76

87
let output =Command::new("git")
98
.args(&["rev-parse","HEAD"])

‎pgml-dashboard/src/components/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
mod component;
55
pub(crate)use component::{component,Component};
66

7-
87
// src/components/breadcrumbs
98
pubmod breadcrumbs;
109
pubuse breadcrumbs::Breadcrumbs;
@@ -49,6 +48,9 @@ pub use navbar::Navbar;
4948
pubmod navbar_web_app;
5049
pubuse navbar_web_app::NavbarWebApp;
5150

51+
// src/components/navigation
52+
pubmod navigation;
53+
5254
// src/components/postgres_logo
5355
pubmod postgres_logo;
5456
pubuse postgres_logo::PostgresLogo;
@@ -65,6 +67,9 @@ pub use static_nav::StaticNav;
6567
pubmod static_nav_link;
6668
pubuse static_nav_link::StaticNavLink;
6769

70+
// src/components/tables
71+
pubmod tables;
72+
6873
// src/components/test_component
6974
pubmod test_component;
7075
pubuse test_component::TestComponent;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// This file is automatically generated.
2+
// You shouldn't modify it manually.
3+
4+
// src/components/navigation/tabs
5+
pubmod tabs;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is automatically generated.
2+
// You shouldn't modify it manually.
3+
4+
// src/components/navigation/tabs/tab
5+
pubmod tab;
6+
pubuse tab::Tab;
7+
8+
// src/components/navigation/tabs/tabs
9+
pubmod tabs;
10+
pubuse tabs::Tabs;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#![allow(unused_variables)]
2+
usecrate::components::component;
3+
usecrate::components::component::Component;
4+
use sailfish::TemplateOnce;
5+
6+
#[derive(TemplateOnce,Default,Clone)]
7+
#[template(path ="navigation/tabs/tab/template.html")]
8+
pubstructTab{
9+
content:Component,
10+
active:bool,
11+
name:String,
12+
}
13+
14+
implTab{
15+
pubfnnew(name:implToString,content:Component) ->Tab{
16+
Tab{
17+
content,
18+
active:false,
19+
name: name.to_string(),
20+
}
21+
}
22+
23+
pubfnbutton_classes(&self) ->String{
24+
ifself.active{
25+
"nav-link active btn btn-tertiary rounded-0".to_string()
26+
}else{
27+
"nav-link btn btn-tertiary rounded-0".to_string()
28+
}
29+
}
30+
31+
pubfncontent_classes(&self) ->String{
32+
ifself.active{
33+
"tab-pane my-4 show active".to_string()
34+
}else{
35+
"tab-pane my-4".to_string()
36+
}
37+
}
38+
39+
pubfnid(&self) ->String{
40+
format!("tab-{}",self.name.to_lowercase().replace(" ","-"))
41+
}
42+
43+
pubfnselected(&self) ->String{
44+
ifself.active{
45+
"selected".to_string()
46+
}else{
47+
"".to_string()
48+
}
49+
}
50+
51+
pubfnname(&self) ->String{
52+
self.name.clone()
53+
}
54+
55+
pubfnactive(mutself) ->Self{
56+
self.active =true;
57+
self
58+
}
59+
60+
pubfninactive(mutself) ->Self{
61+
self.active =false;
62+
self
63+
}
64+
65+
pubfnis_active(&self) ->bool{
66+
self.active
67+
}
68+
}
69+
70+
component!(Tab);

‎pgml-dashboard/src/components/navigation/tabs/tab/tab.scss

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div>
2+
<%+ content %>
3+
</div>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
usecrate::components::component;
2+
usecrate::components::navigation::tabs::Tab;
3+
use sailfish::TemplateOnce;
4+
5+
#[derive(TemplateOnce,Default)]
6+
#[template(path ="navigation/tabs/tabs/template.html")]
7+
pubstructTabs{
8+
tabs:Vec<Tab>,
9+
}
10+
11+
implTabs{
12+
pubfnnew(tabs:&[Tab]) ->Tabs{
13+
// Set the first tab to active if none are.
14+
letmut tabs = tabs.to_vec();
15+
if tabs.iter().all(|t| !t.is_active()){
16+
tabs = tabs
17+
.into_iter()
18+
.enumerate()
19+
.map(|(i, tab)|if i ==0{ tab.active()}else{ tab})
20+
.collect();
21+
}
22+
23+
Tabs{ tabs}
24+
}
25+
26+
pubfnactive_tab(mutself,name:implToString) ->Self{
27+
let tabs =self
28+
.tabs
29+
.into_iter()
30+
.map(|tab|{
31+
if tab.name() == name.to_string(){
32+
tab.active()
33+
}else{
34+
tab.inactive()
35+
}
36+
})
37+
.collect();
38+
39+
self.tabs = tabs;
40+
self
41+
}
42+
}
43+
44+
component!(Tabs);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.nav-tabs {
2+
// These tabs are used in docs as well, where they are
3+
// generated using Bootstrap. It wasn't obvious to me
4+
// how to replace those with this component yet, so I'm just
5+
// enforcing the font-family here so they look the same. Docs use Roboto by default.
6+
font-family:'silka','Roboto','sans-serif';
7+
8+
--bs-nav-tabs-border-width:4px;
9+
10+
.nav-link {
11+
border:none;
12+
13+
&.active,&:focus,&:active {
14+
border-bottom:4pxsolid#{$slate-tint-700};
15+
color:#{$slate-tint-700};
16+
text-shadow:none;
17+
}
18+
19+
color:#{$slate-tint-100};
20+
}
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp