use super::MatchSelectorElement;
use bevy::prelude::{
Component,
Deref,
Reflect, ReflectComponent
};
use std::borrow::Cow;
#[derive(Debug, Reflect, Component, Default, Clone, Deref)]
#[reflect(Component)]
pub struct Class(Cow<'static, str>);
impl Class
{
pub fn new(
class: impl Into<Cow<'static, str>>
) -> Self {
Self(class.into())
}
fn matches(
&self,
class: &str
) -> bool {
self.0.split_ascii_whitespace().any(|c| c == class)
}
}
impl MatchSelectorElement
for Class
{
fn matches(
&self,
element: &str
) -> bool {
self.matches(element)
}
}