use super::{Property, PropertyValues};
use crate::prelude::BevyCssError;
pub mod style;
use bevy::{ecs::query::QueryItem, prelude::*};
#[derive(Default)]
pub(crate) struct BackgroundColorProperty;
impl Property for BackgroundColorProperty {
type Cache = Color;
type Components = Entity;
type Filters = With<BackgroundColor>;
fn name() -> &'static str {
"background-color"
}
fn parse<'a>(values: &PropertyValues) -> Result<Self::Cache, BevyCssError> {
if let Some(color) = values.color() {
Ok(color)
} else {
Err(BevyCssError::InvalidPropertyValue(Self::name().to_string()))
}
}
fn apply<'w>(
cache: &Self::Cache,
components: QueryItem<Self::Components>,
_asset_server: &AssetServer,
commands: &mut Commands,
) {
commands.entity(components).insert(BackgroundColor(*cache));
}
}