use yew::html::{Classes, IntoPropValue};
#[cfg(feature = "macros")]
pub use stylist_macros::styled_component;
#[cfg(feature = "macros")]
pub use stylist_macros::styled_component_impl;
#[cfg(feature = "yew_use_style")]
pub use stylist_macros::use_style;
use crate::ast::Sheet;
use crate::manager::StyleManager;
use crate::{Style, StyleSource};
use yew::html::ImplicitClone;
impl ImplicitClone for StyleManager {}
mod global;
mod hooks;
mod provider;
pub use global::{Global, GlobalProps};
pub use provider::{ManagerProvider, ManagerProviderProps};
pub use hooks::*;
impl From<Style> for Classes {
fn from(style: Style) -> Self {
let mut classes = Self::new();
classes.push(style.get_class_name().to_string());
classes
}
}
impl From<StyleSource> for Classes {
fn from(style_src: StyleSource) -> Self {
let mut classes = Self::new();
#[cfg(all(debug_assertions, feature = "debug_style_locations"))]
let location = style_src.location.clone();
let style = style_src.into_style();
classes.push(style.get_class_name().to_string());
#[cfg(all(debug_assertions, feature = "debug_style_locations"))]
classes.push(location);
classes
}
}
impl IntoPropValue<Classes> for Style {
fn into_prop_value(self) -> Classes {
self.into()
}
}
impl IntoPropValue<Classes> for StyleSource {
fn into_prop_value(self) -> Classes {
self.into()
}
}
impl IntoPropValue<StyleSource> for Sheet {
fn into_prop_value(self) -> StyleSource {
self.into()
}
}
#[cfg_attr(documenting, doc(cfg(feature = "parser")))]
#[cfg(feature = "parser")]
mod feat_parser {
use std::borrow::Cow;
use super::*;
use stylist_core::ResultDisplay;
impl IntoPropValue<StyleSource> for String {
fn into_prop_value(self) -> StyleSource {
self.try_into()
.expect_display("couldn't parse style string")
}
}
impl IntoPropValue<StyleSource> for &str {
fn into_prop_value(self) -> StyleSource {
self.try_into()
.expect_display("couldn't parse style string")
}
}
impl<'a> IntoPropValue<StyleSource> for Cow<'a, str> {
fn into_prop_value(self) -> StyleSource {
self.try_into()
.expect_display("couldn't parse style string")
}
}
}