mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
styling with CSS
This commit is contained in:
parent
5feaf1aea6
commit
f69dbb48ca
3 changed files with 18 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta name="color-scheme" content="dark">
|
||||
<link rel="css" href="style.css" data-trunk>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
|
|
|
@ -27,6 +27,8 @@ fn main() {
|
|||
_ = Executor::init_glib();
|
||||
let app = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
app.connect_startup(|_| load_css());
|
||||
|
||||
app.connect_activate(|app| {
|
||||
// Connect to "activate" signal of `app`
|
||||
let owner = Owner::new();
|
||||
|
@ -156,3 +158,18 @@ fn hstack(children: impl Render<Rndr>) -> impl Render<Rndr> {
|
|||
.child(children)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gtk")]
|
||||
fn load_css() {
|
||||
use gtk::{gdk::Display, CssProvider};
|
||||
|
||||
let provider = CssProvider::new();
|
||||
provider.load_from_path("style.css");
|
||||
|
||||
// Add the provider to the default screen
|
||||
gtk::style_context_add_provider_for_display(
|
||||
&Display::default().expect("Could not connect to a display."),
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
|
|
0
examples/gtk/style.css
Normal file
0
examples/gtk/style.css
Normal file
Loading…
Reference in a new issue