leptos-use/examples/use_device_pixel_ratio/src/main.rs

27 lines
677 B
Rust
Raw Normal View History

2024-05-07 12:41:44 +01:00
use leptos::prelude::*;
2024-01-01 19:29:03 +01:00
use leptos_use::docs::demo_or_body;
use leptos_use::use_device_pixel_ratio;
#[component]
fn Demo() -> impl IntoView {
let pixel_ratio = use_device_pixel_ratio();
view! {
<pre>{move || format!("pixelRatio: {}", pixel_ratio())}</pre>
<p>
"Zoom in and out (or move the window to a screen with a different scaling factor) to see the value changes."
</p>
}
}
fn main() {
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();
let unmount_handle = leptos::mount::mount_to(demo_or_body(), || {
2024-01-01 19:29:03 +01:00
view! { <Demo/> }
});
unmount_handle.forget();
2024-01-01 19:29:03 +01:00
}