Skip to content

Commit 0ac4ecc

Browse files
committed
rusty-app v0.0.1: external css for components
* external css for each component
1 parent c522182 commit 0ac4ecc

6 files changed

Lines changed: 95 additions & 87 deletions

File tree

src/css/mailbox.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.mailbox {
2+
background-color: #23272e;
3+
}
4+
.mailbox-list {
5+
background-color: #23272e;
6+
}
7+
.mailbox-row {
8+
background: none;
9+
color: #f5f6fa;
10+
font-size: 1rem;
11+
font-weight: 500;
12+
border-radius: 6px;
13+
padding: 4px 8px;
14+
}
15+
.mailbox-row:hover {
16+
background: #353b45;
17+
}
18+
.mailbox-row:selected {
19+
background: #353b45;
20+
}
21+
.mailbox-label {
22+
color: #f5f6fa;
23+
}

src/css/main.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
window,
2+
.main-bg {
3+
background-color: #23272e;
4+
color: #f5f6fa;
5+
}
6+
.status-bar {
7+
background-color: #2d323b;
8+
color: #f5f6fa;
9+
border: 1px solid #353b45;
10+
}
11+
.menu-bar {
12+
background-color: #23272e;
13+
color: #f5f6fa;
14+
border: 1px solid #353b45;
15+
}
16+
.mailbox {
17+
background-color: #23272e;
18+
border: 1px solid #353b45;
19+
}
20+
.content-area {
21+
background-color: #23272e;
22+
border: 1px solid #353b45;
23+
}
24+
.column-border {
25+
border: 1px solid #353b45;
26+
}
27+
button.flat {
28+
background: none;
29+
border: none;
30+
color: #f5f6fa;
31+
}
32+
button.flat:hover {
33+
background: #353b45;
34+
}
35+
list {
36+
background-color: #23272e;
37+
}
38+
list row:selected {
39+
background-color: #353b45;
40+
}

src/css/menu.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.menu-bar {
2+
background-color: #23272e;
3+
}
4+
.menu-btn {
5+
background: none;
6+
border: none;
7+
color: #f5f6fa;
8+
padding: 8px 18px;
9+
border-radius: 8px;
10+
font-size: 1rem;
11+
font-weight: 500;
12+
transition: background 0.2s;
13+
}
14+
.menu-btn:hover {
15+
background: #353b45;
16+
color: #ffffff;
17+
}
18+
.menu-btn image {
19+
color: #f5f6fa;
20+
}

src/mailbox.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,9 @@ pub struct Mailbox {
1919
impl Mailbox {
2020
pub fn new(folders: &[Folder]) -> Self {
2121
// --- CSS for dark mailbox styling ---
22-
let css = "
23-
.mailbox {
24-
background-color: #23272e;
25-
}
26-
.mailbox-list {
27-
background-color: #23272e;
28-
}
29-
.mailbox-row {
30-
background: none;
31-
color: #f5f6fa;
32-
font-size: 1rem;
33-
font-weight: 500;
34-
border-radius: 6px;
35-
padding: 4px 8px;
36-
}
37-
.mailbox-row:hover {
38-
background: #353b45;
39-
}
40-
.mailbox-row:selected {
41-
background: #353b45;
42-
}
43-
.mailbox-label {
44-
color: #f5f6fa;
45-
}
46-
";
4722
let provider = CssProvider::new();
48-
provider.load_from_data(css);
23+
provider.load_from_path("src/css/mailbox.css");
24+
4925
let display = Display::default().expect("Failed to get default display");
5026
gtk4::style_context_add_provider_for_display(
5127
&display,

src/main.rs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// src/main.rs
2-
32
mod mailbox;
43
mod menu;
54

@@ -23,44 +22,9 @@ fn main() {
2322
}
2423

2524
fn build_ui(app: &Application) {
26-
// --- CSS for dark theme ---
27-
let css = "
28-
window, .main-bg {
29-
background-color: #23272e;
30-
color: #f5f6fa;
31-
}
32-
.status-bar {
33-
background-color: #2d323b;
34-
color: #f5f6fa;
35-
}
36-
.menu-bar {
37-
background-color: #23272e;
38-
color: #f5f6fa;
39-
}
40-
.mailbox {
41-
background-color: #23272e;
42-
}
43-
.content-area {
44-
background-color: #23272e;
45-
}
46-
button.flat {
47-
background: none;
48-
border: none;
49-
color: #f5f6fa;
50-
}
51-
button.flat:hover {
52-
background: #353b45;
53-
}
54-
list {
55-
background-color: #23272e;
56-
}
57-
list row:selected {
58-
background-color: #353b45;
59-
}
60-
";
61-
25+
// Load CSS from external file
6226
let provider = CssProvider::new();
63-
provider.load_from_data(css);
27+
provider.load_from_path("src/css/main.css");
6428

6529
let display = Display::default().expect("Failed to get default display");
6630
gtk4::style_context_add_provider_for_display(
@@ -118,6 +82,9 @@ fn build_ui(app: &Application) {
11882
let message_list_area = GtkBox::new(Orientation::Vertical, 10);
11983
message_list_area.set_hexpand(true);
12084
message_list_area.set_vexpand(true);
85+
message_list_area.add_css_class("column-border");
86+
87+
// <-- New class added
12188
let message_list_label = Label::new(Some("Message List"));
12289
message_list_label.set_halign(Align::Center);
12390
message_list_label.set_valign(Align::Start);
@@ -128,6 +95,9 @@ fn build_ui(app: &Application) {
12895
content_display_area.set_hexpand(false);
12996
content_display_area.set_vexpand(true);
13097
content_display_area.set_width_request(90);
98+
content_display_area.add_css_class("column-border");
99+
100+
// <-- New class added
131101
let content_display_label = Label::new(Some("Content Display"));
132102
content_display_label.set_halign(Align::Center);
133103
content_display_label.set_valign(Align::Start);

src/menu.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,9 @@ pub struct MenuBar {
1414
impl MenuBar {
1515
pub fn new() -> Self {
1616
// --- CSS for dark menu styling ---
17-
let css = "
18-
.menu-bar {
19-
background-color: #23272e;
20-
}
21-
.menu-btn {
22-
background: none;
23-
border: none;
24-
color: #f5f6fa;
25-
padding: 8px 18px;
26-
border-radius: 8px;
27-
font-size: 1rem;
28-
font-weight: 500;
29-
transition: background 0.2s;
30-
}
31-
.menu-btn:hover {
32-
background: #353b45;
33-
color: #ffffff;
34-
}
35-
.menu-btn image {
36-
color: #f5f6fa;
37-
}
38-
";
3917
let provider = CssProvider::new();
40-
provider.load_from_data(css);
18+
provider.load_from_path("src/css/menu.css");
19+
4120
let display = Display::default().expect("Failed to get default display");
4221
gtk4::style_context_add_provider_for_display(
4322
&display,

0 commit comments

Comments
 (0)