| 2029 |
2029 |
|
css.push_str(&form::unit_rules(opts));
|
| 2030 |
2030 |
|
css.push_str(&form::option_detail_rules(opts));
|
| 2031 |
2031 |
|
css.push_str(&form::note_rules(opts));
|
|
2032 |
+ |
css.push_str(&leaving_rules());
|
|
2033 |
+ |
css
|
|
2034 |
+ |
}
|
|
2035 |
+ |
|
|
2036 |
+ |
/// How a transient notice goes away.
|
|
2037 |
+ |
///
|
|
2038 |
+ |
/// quasicoherent `43bdbff7`. `makeover-timing` has said since it shipped that
|
|
2039 |
+ |
/// `Intent::Dismiss` is how long a notice lives *before it starts to leave*,
|
|
2040 |
+ |
/// and that the leaving itself is `Motion::Fade`. `makeover-build` writes
|
|
2041 |
+ |
/// `--motion-fade` into every consumer's `timing.css`, and until this rule
|
|
2042 |
+ |
/// nothing in the tree read it: three renderers removed the node the moment
|
|
2043 |
+ |
/// the dismiss was up, and the crate's own test called the version that waits
|
|
2044 |
+ |
/// the correct one.
|
|
2045 |
+ |
///
|
|
2046 |
+ |
/// # Why an attribute and not a class
|
|
2047 |
+ |
///
|
|
2048 |
+ |
/// [`Emit`]'s prefix moves every class this crate writes, so a class here would
|
|
2049 |
+ |
/// have to be resolved through `class()` by whoever sets it -- and the party
|
|
2050 |
+ |
/// setting it is a script, which has no prefix to hand. `data-leaving` is
|
|
2051 |
+ |
/// outside that namespace, so a renderer can set it from JavaScript with no
|
|
2052 |
+ |
/// coordination.
|
|
2053 |
+ |
///
|
|
2054 |
+ |
/// The transition sits on the notice and the opacity on the leaving state, so
|
|
2055 |
+ |
/// the element is transitionable before the attribute arrives; a transition
|
|
2056 |
+ |
/// declared in the same rule as the value it changes has nothing to animate
|
|
2057 |
+ |
/// from.
|
|
2058 |
+ |
///
|
|
2059 |
+ |
/// # Reduced motion is handled by the token, not by a second rule here
|
|
2060 |
+ |
///
|
|
2061 |
+ |
/// `timing.css` already zeroes `--motion-fade` under `prefers-reduced-motion`.
|
|
2062 |
+ |
/// The reader who asked for less motion gets an instant change rather than a
|
|
2063 |
+ |
/// fade, and the renderer that sets the attribute must still remove the node on
|
|
2064 |
+ |
/// a timer rather than on `transitionend` -- a zero-length transition may fire
|
|
2065 |
+ |
/// no event at all, and a node waiting on one that never comes stays forever.
|
|
2066 |
+ |
///
|
|
2067 |
+ |
/// The fallback is `0ms` and not a guessed duration: a page with no timing
|
|
2068 |
+ |
/// sheet has not opted into this vocabulary, and the honest answer there is the
|
|
2069 |
+ |
/// behaviour it had before, which is the notice going away at once.
|
|
2070 |
+ |
///
|
|
2071 |
+ |
/// Added 0.69.0, and it is this crate's first `--motion-*` consumer.
|
|
2072 |
+ |
fn leaving_rules() -> String {
|
|
2073 |
+ |
let mut css = String::new();
|
|
2074 |
+ |
let _ = writeln!(
|
|
2075 |
+ |
css,
|
|
2076 |
+ |
"[data-notice] {{\n transition: opacity var(--motion-fade, 0ms) \
|
|
2077 |
+ |
ease-out;\n}}"
|
|
2078 |
+ |
);
|
|
2079 |
+ |
let _ = writeln!(css, "[data-notice][data-leaving] {{\n opacity: 0;\n}}");
|
| 2032 |
2080 |
|
css
|
| 2033 |
2081 |
|
}
|
| 2034 |
2082 |
|
|