Skip to main content

euv_ui/hook/use_media_query/
struct.rs

1use super::*;
2
3/// Reactive state for one CSS media query.
4///
5/// The handle carries the query it watches, the current match result,
6/// and the teardown that removes the `change` listener from the
7/// browser's `MediaQueryList`.
8///
9/// The match result is a `Signal<bool>`: a render closure that reads it
10/// re-renders when the query starts or stops matching, and nothing
11/// else in the tree is disturbed.
12#[derive(Clone, CustomDebug, Data)]
13pub struct UseMediaQuery {
14    /// Whether the query currently matches.
15    #[get(type(copy))]
16    pub matches: Signal<bool>,
17    /// The media query text this handle watches.
18    #[get(type(copy))]
19    pub query: &'static str,
20    /// The teardown that removes the `change` listener.
21    ///
22    /// `None` until the browser listener is attached, and `None` again
23    /// after the teardown has run.
24    #[get(pub(crate))]
25    #[debug(skip)]
26    pub(crate) teardown: Teardown,
27}