File tree Expand file tree Collapse file tree 24 files changed +353
-16
lines changed Expand file tree Collapse file tree 24 files changed +353
-16
lines changed Original file line number Diff line number Diff line change @@ -13,4 +13,4 @@ indent_size = 4
13
13
14
14
[* .html ]
15
15
ident_style = space
16
- indent_size = 4
16
+ indent_size = 2
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ use std::process::Command;
3
3
4
4
fn main ( ) {
5
5
println ! ( "cargo:rerun-if-changed=migrations" ) ;
6
- println ! ( "cargo:rerun-if-changed=src" ) ;
7
6
8
7
let output = Command :: new ( "git" )
9
8
. args ( & [ "rev-parse" , "HEAD" ] )
Original file line number Diff line number Diff line change 4
4
mod component;
5
5
pub ( crate ) use component:: { component, Component } ;
6
6
7
-
8
7
// src/components/breadcrumbs
9
8
pub mod breadcrumbs;
10
9
pub use breadcrumbs:: Breadcrumbs ;
@@ -49,6 +48,9 @@ pub use navbar::Navbar;
49
48
pub mod navbar_web_app;
50
49
pub use navbar_web_app:: NavbarWebApp ;
51
50
51
+ // src/components/navigation
52
+ pub mod navigation;
53
+
52
54
// src/components/postgres_logo
53
55
pub mod postgres_logo;
54
56
pub use postgres_logo:: PostgresLogo ;
@@ -65,6 +67,9 @@ pub use static_nav::StaticNav;
65
67
pub mod static_nav_link;
66
68
pub use static_nav_link:: StaticNavLink ;
67
69
70
+ // src/components/tables
71
+ pub mod tables;
72
+
68
73
// src/components/test_component
69
74
pub mod test_component;
70
75
pub use test_component:: TestComponent ;
Original file line number Diff line number Diff line change
1
+ // This file is automatically generated.
2
+ // You shouldn't modify it manually.
3
+
4
+ // src/components/navigation/tabs
5
+ pub mod tabs;
Original file line number Diff line number Diff line change
1
+ // This file is automatically generated.
2
+ // You shouldn't modify it manually.
3
+
4
+ // src/components/navigation/tabs/tab
5
+ pub mod tab;
6
+ pub use tab:: Tab ;
7
+
8
+ // src/components/navigation/tabs/tabs
9
+ pub mod tabs;
10
+ pub use tabs:: Tabs ;
Original file line number Diff line number Diff line change
1
+ #![ allow( unused_variables) ]
2
+ use crate :: components:: component;
3
+ use crate :: components:: component:: Component ;
4
+ use sailfish:: TemplateOnce ;
5
+
6
+ #[ derive( TemplateOnce , Default , Clone ) ]
7
+ #[ template( path = "navigation/tabs/tab/template.html" ) ]
8
+ pub struct Tab {
9
+ content : Component ,
10
+ active : bool ,
11
+ name : String ,
12
+ }
13
+
14
+ impl Tab {
15
+ pub fn new ( name : impl ToString , content : Component ) -> Tab {
16
+ Tab {
17
+ content,
18
+ active : false ,
19
+ name : name. to_string ( ) ,
20
+ }
21
+ }
22
+
23
+ pub fn button_classes ( & self ) -> String {
24
+ if self . 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
+ pub fn content_classes ( & self ) -> String {
32
+ if self . active {
33
+ "tab-pane my-4 show active" . to_string ( )
34
+ } else {
35
+ "tab-pane my-4" . to_string ( )
36
+ }
37
+ }
38
+
39
+ pub fn id ( & self ) -> String {
40
+ format ! ( "tab-{}" , self . name. to_lowercase( ) . replace( " " , "-" ) )
41
+ }
42
+
43
+ pub fn selected ( & self ) -> String {
44
+ if self . active {
45
+ "selected" . to_string ( )
46
+ } else {
47
+ "" . to_string ( )
48
+ }
49
+ }
50
+
51
+ pub fn name ( & self ) -> String {
52
+ self . name . clone ( )
53
+ }
54
+
55
+ pub fn active ( mut self ) -> Self {
56
+ self . active = true ;
57
+ self
58
+ }
59
+
60
+ pub fn inactive ( mut self ) -> Self {
61
+ self . active = false ;
62
+ self
63
+ }
64
+
65
+ pub fn is_active ( & self ) -> bool {
66
+ self . active
67
+ }
68
+ }
69
+
70
+ component ! ( Tab ) ;
Original file line number Diff line number Diff line change
1
+ < div >
2
+ < %+ content %>
3
+ </ div >
Original file line number Diff line number Diff line change
1
+ use crate :: components:: component;
2
+ use crate :: components:: navigation:: tabs:: Tab ;
3
+ use sailfish:: TemplateOnce ;
4
+
5
+ #[ derive( TemplateOnce , Default ) ]
6
+ #[ template( path = "navigation/tabs/tabs/template.html" ) ]
7
+ pub struct Tabs {
8
+ tabs : Vec < Tab > ,
9
+ }
10
+
11
+ impl Tabs {
12
+ pub fn new ( tabs : & [ Tab ] ) -> Tabs {
13
+ // Set the first tab to active if none are.
14
+ let mut 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
+ pub fn active_tab ( mut self , name : impl ToString ) -> 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 ) ;
Original file line number Diff line number Diff line change
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 : 4px solid #{$slate-tint-700 } ;
15
+ color : #{$slate-tint-700 } ;
16
+ text-shadow : none ;
17
+ }
18
+
19
+ color : #{$slate-tint-100 } ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change
1
+ < ul class ="nav nav-tabs " role ="tablist ">
2
+ < % for tab in &tabs { %>
3
+ < li class ="nav-item " role ="presentation ">
4
+ < button
5
+ class ="<%= tab.button_classes() %> "
6
+ data-bs-toggle ="tab "
7
+ data-bs-target ="#<%= tab.id() %> "
8
+ type ="button "
9
+ role ="tab "
10
+ aria-controls ="<%= tab.id() %> "
11
+ aria-selected ="<%= tab.selected() %> "
12
+ >
13
+ < %= tab.name() %>
14
+ </ button >
15
+ </ li >
16
+ < % } %>
17
+ </ ul >
18
+ < div class ="tab-content ">
19
+ < % for (i, tab) in tabs.into_iter().enumerate() { %>
20
+ < div
21
+ class ="<%= tab.content_classes() %> "
22
+ id ="<%= tab.id() %> "
23
+ role ="tabpanel "
24
+ aria-labelledby ="tab-<%= tab.id() %> "
25
+ tabindex ="<%= i %> "
26
+ >
27
+ < %+ tab %>
28
+ </ div >
29
+ < % } %>
30
+ </ div >
Original file line number Diff line number Diff line change
1
+ // This file is automatically generated.
2
+ // You shouldn't modify it manually.
3
+
4
+ // src/components/tables/large/row
5
+ pub mod row;
6
+ pub use row:: Row ;
7
+
8
+ // src/components/tables/large/table
9
+ pub mod table;
10
+ pub use table:: Table ;
Original file line number Diff line number Diff line change
1
+ use crate :: components:: component;
2
+ use crate :: components:: component:: Component ;
3
+ use sailfish:: TemplateOnce ;
4
+
5
+ #[ derive( TemplateOnce , Default , Clone ) ]
6
+ #[ template( path = "tables/large/row/template.html" ) ]
7
+ pub struct Row {
8
+ columns : Vec < Component > ,
9
+ }
10
+
11
+ impl Row {
12
+ pub fn new ( columns : & [ Component ] ) -> Row {
13
+ Row {
14
+ columns : columns. to_vec ( ) ,
15
+ }
16
+ }
17
+ }
18
+
19
+ component ! ( Row ) ;
Original file line number Diff line number Diff line change
1
+ table .table.table-lg {
2
+ tr {
3
+ & :first-of-type {
4
+ td {
5
+ padding-top : 16px ;
6
+ }
7
+ }
8
+
9
+ & :hover {
10
+ div .table-cell-content {
11
+ background : #{$gray-800 } ;
12
+ }
13
+ }
14
+
15
+ td {
16
+ vertical-align : middle ;
17
+ padding : 8px 0 ;
18
+
19
+ div .table-cell-content {
20
+ background : #{$gray-600 } ;
21
+ padding : 20px 0 ;
22
+ }
23
+
24
+ & :first-of-type {
25
+ div .table-cell-content {
26
+ padding-left : 67px ;
27
+ }
28
+ }
29
+
30
+ & :last-of-type {
31
+ div .table-cell-content {
32
+ padding-right : 67px ;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ < tr >
2
+ < % for column in columns { %>
3
+ < td >
4
+ < div class ="table-cell-content ">
5
+ < %+ column %>
6
+ </ div >
7
+ </ td >
8
+ < % } %>
9
+ </ tr >
Original file line number Diff line number Diff line change
1
+ use crate :: components:: component;
2
+ use crate :: components:: tables:: large:: Row ;
3
+ use sailfish:: TemplateOnce ;
4
+
5
+ #[ derive( TemplateOnce , Default ) ]
6
+ #[ template( path = "tables/large/table/template.html" ) ]
7
+ pub struct Table {
8
+ rows : Vec < Row > ,
9
+ headers : Vec < String > ,
10
+ }
11
+
12
+ impl Table {
13
+ pub fn new ( headers : & [ impl ToString ] , rows : & [ Row ] ) -> Table {
14
+ Table {
15
+ headers : headers. iter ( ) . map ( |h| h. to_string ( ) ) . collect ( ) ,
16
+ rows : rows. to_vec ( ) ,
17
+ }
18
+ }
19
+ }
20
+
21
+ component ! ( Table ) ;
Original file line number Diff line number Diff line change
1
+ table .table.table-lg {
2
+ * {
3
+ border-width : 0 ;
4
+ }
5
+
6
+ thead {
7
+ th {
8
+ color : #{$slate-shade-100 } ;
9
+ background : #{$gray-800 } ;
10
+ text-transform : uppercase ;
11
+ font-size : 0.75rem ;
12
+ padding : 16px 0 ;
13
+
14
+ & :first-of-type {
15
+ padding-left : 67px ;
16
+ }
17
+ }
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ < table class ="table table-lg ">
2
+ < thead >
3
+ < tr >
4
+ < % for header in headers { %>
5
+ < th > < %= header %> </ th >
6
+ < % } %>
7
+ </ tr >
8
+ </ thead >
9
+ < tbody >
10
+ < % for row in rows { %>
11
+ < %+ row %>
12
+ < % } %>
13
+ </ tbody >
14
+ </ div >
Original file line number Diff line number Diff line change
1
+ // This file is automatically generated.
2
+ // You shouldn't modify it manually.
3
+
4
+ // src/components/tables/large
5
+ pub mod large;
Original file line number Diff line number Diff line change @@ -669,7 +669,7 @@ impl<'a> Tab<'a> {
669
669
"
670
670
<li class=\" nav-item\" role=\" presentation\" >
671
671
<button
672
- class=\" nav-link {active}\"
672
+ class=\" nav-link btn btn-tertiary rounded-0 {active}\"
673
673
data-bs-toggle=\" tab\"
674
674
data-bs-target=\" #tab-{id}\"
675
675
type=\" button\"
Original file line number Diff line number Diff line change 6
6
@import " ../../src/components/left_nav_web_app/left_nav_web_app.scss" ;
7
7
@import " ../../src/components/modal/modal.scss" ;
8
8
@import " ../../src/components/navbar/navbar.scss" ;
9
+ @import " ../../src/components/navigation/tabs/tab/tab.scss" ;
10
+ @import " ../../src/components/navigation/tabs/tabs/tabs.scss" ;
9
11
@import " ../../src/components/postgres_logo/postgres_logo.scss" ;
10
12
@import " ../../src/components/static_nav/static_nav.scss" ;
13
+ @import " ../../src/components/tables/large/row/row.scss" ;
14
+ @import " ../../src/components/tables/large/table/table.scss" ;
You can’t perform that action at this time.
0 commit comments