use crate::*;
impl From<String> for AttributeValue {
fn from(value: String) -> Self {
AttributeValue::Text(value)
}
}
impl From<&str> for AttributeValue {
fn from(value: &str) -> Self {
AttributeValue::Text(value.to_string())
}
}
impl From<Signal<String>> for AttributeValue {
fn from(signal: Signal<String>) -> Self {
AttributeValue::Signal(signal)
}
}
impl From<Signal<bool>> for AttributeValue {
fn from(signal: Signal<bool>) -> Self {
bool_to_attr(signal)
}
}
impl From<bool> for AttributeValue {
fn from(value: bool) -> Self {
AttributeValue::Dynamic(value.to_string())
}
}
impl From<i32> for AttributeValue {
fn from(value: i32) -> Self {
AttributeValue::Dynamic(value.to_string())
}
}
impl From<f64> for AttributeValue {
fn from(value: f64) -> Self {
AttributeValue::Dynamic(value.to_string())
}
}
impl From<Css> for AttributeValue {
fn from(css: Css) -> Self {
AttributeValue::Css(css)
}
}
impl From<&'static Css> for AttributeValue {
fn from(css: &'static Css) -> Self {
AttributeValue::Css(css.clone())
}
}
impl<F> From<F> for AttributeValue
where
F: FnMut(Event) + 'static,
{
fn from(closure: F) -> Self {
AttributeValue::Event(NativeEventHandler::create(CALLBACK_EVENT_NAME, closure))
}
}
impl From<NativeEventHandler> for AttributeValue {
fn from(handler: NativeEventHandler) -> Self {
AttrValueAdapter::new(handler).into()
}
}
impl From<Option<NativeEventHandler>> for AttributeValue {
fn from(handler: Option<NativeEventHandler>) -> Self {
match handler {
Some(event_handler) => AttrValueAdapter::new(event_handler).into(),
None => AttributeValue::Text(String::new()),
}
}
}