pub struct Style(/* private fields */);Expand description
An inline style: a prop typed StyleProp<ViewStyle> in TypeScript (an
object, an array of them, or nothing), decoded when JS sets it as a host
element’s style is (transforms, shadow offsets, native animated
values included), and applied with Element::inline_style. Rust
makes one with the typed styles (From<StyleRefinement>: what a style
prop’s setter does with its closure, .selected_style(|s| s.bg(..))),
theme colors following the appearance and bound parts their signals,
as in .active(|s| ..); or from declarations (Style::from_decls,
Style::with).
Its native animated values are node ids, valid while the style is the
prop’s current value (JS keeps the values alive with it, as a host
element’s style does); a component that keeps an older Style
beyond that may hold ids of values JS has collected.
Implementations§
Source§impl Style
impl Style
Sourcepub fn from_decls(decls: impl IntoIterator<Item = StyleDecl>) -> Self
pub fn from_decls(decls: impl IntoIterator<Item = StyleDecl>) -> Self
A style of decls, applied in order; one that does not apply (a
value of the wrong type or format) is left out and logged, as on a
host element.
Sourcepub fn with(self, key: StyleKey, value: PropertyValue) -> Self
pub fn with(self, key: StyleKey, value: PropertyValue) -> Self
This style with property key set to value after the rest
(Style::default().with(StyleKey::Opacity, PropertyValue::Number(0.5.into()))).
Sourcepub fn then(&self, over: &Style) -> Self
pub fn then(&self, over: &Style) -> Self
This style with over after it: where both set a property,
over’s declarations and typed styles win (a state’s style over a
part’s).
Sourcepub fn background_color(&self) -> Option<AdaptiveColor>
pub fn background_color(&self) -> Option<AdaptiveColor>
The color it fills its view with in no state (backgroundColor,
Rust’s bg), if it sets one that is no gradient and not
transparent: what a part’s terminal form draws its text in (a
progress bar’s run in its indicator’s color). The typed styles’
over the declarations; their bound parts are left out.
Sourcepub fn is_typed(&self) -> bool
pub fn is_typed(&self) -> bool
Whether it has typed styles (Rust’s StyleRefinement, static or
bound): a style JS gives has none. A component that applies a style
it is given after its own bound styles reads it to bind only the
styles that need it (Element::inline_style of a closure binds
the typed styles after the element’s own).
Trait Implementations§
Source§impl From<InputPartStyle> for Style
impl From<InputPartStyle> for Style
Source§fn from(style: InputPartStyle) -> Self
fn from(style: InputPartStyle) -> Self
Source§impl From<Style> for TextPartStyle
impl From<Style> for TextPartStyle
Source§impl From<Style> for InputPartStyle
impl From<Style> for InputPartStyle
Source§impl From<StylePatch> for Style
impl From<StylePatch> for Style
Source§fn from(patch: StylePatch) -> Self
fn from(patch: StylePatch) -> Self
Source§impl From<StyleRefinement> for Style
impl From<StyleRefinement> for Style
Source§fn from(style: StyleRefinement) -> Self
fn from(style: StyleRefinement) -> Self
Source§impl From<TextPartStyle> for Style
impl From<TextPartStyle> for Style
Source§fn from(style: TextPartStyle) -> Self
fn from(style: TextPartStyle) -> Self
Source§impl IntoReactive<Style> for Style
impl IntoReactive<Style> for Style
Source§impl JsValue for Style
impl JsValue for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl !RefUnwindSafe for Style
impl !Send for Style
impl !Sync for Style
impl !UnwindSafe for Style
impl Forget for Style
impl Freeze for Stylewhere
*const RcInner<StylePatch> is !null: Freeze,
PhantomData<RcInner<StylePatch>>: Freeze,
*const RcInner<Vec<(Variant, Declaration)>> is !null: Freeze,
PhantomData<RcInner<Vec<(Variant, Declaration)>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<&'static str>: Freeze,
PhantomData<Rc<dyn Fn(&mut StyleRefinement)>>: Freeze,
impl Move for Style
impl Unpin for Style
impl UnsafeUnpin for Stylewhere
*const RcInner<StylePatch> is !null: UnsafeUnpin,
PhantomData<RcInner<StylePatch>>: UnsafeUnpin,
*const RcInner<Vec<(Variant, Declaration)>> is !null: UnsafeUnpin,
PhantomData<RcInner<Vec<(Variant, Declaration)>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
PhantomData<Rc<dyn Fn(&mut StyleRefinement)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CallbackArgs for Twhere
T: Ret,
impl<T> CallbackArgs for Twhere
T: Ret,
Source§fn ts_params(types: &mut TsTypes, names: &[&str]) -> String
fn ts_params(types: &mut TsTypes, names: &[&str]) -> String
names (name: string, amount: number), or without names value for one and a, b, … for
several.