#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CssCategory {
Layout,
BoxModel,
Flexbox,
Grid,
Typography,
Color,
Visual,
Transform,
Transition,
Animation,
Interaction,
List,
Table,
Paged,
GeneratedContent,
FlexGridGap,
Miscellaneous,
MotionPath,
ScrollDriven,
Houdini,
Svg,
Hardware,
}
impl CssCategory {
#[inline]
pub const fn name(self) -> &'static str {
match self {
CssCategory::Layout => "Layout",
CssCategory::BoxModel => "Box Model",
CssCategory::Flexbox => "Flexbox",
CssCategory::Grid => "Grid",
CssCategory::Typography => "Typography",
CssCategory::Color => "Color",
CssCategory::Visual => "Visual Effects",
CssCategory::Transform => "Transform",
CssCategory::Transition => "Transition",
CssCategory::Animation => "Animation",
CssCategory::Interaction => "Interaction",
CssCategory::List => "List",
CssCategory::Table => "Table",
CssCategory::Paged => "Paged Media",
CssCategory::GeneratedContent => "Generated Content",
CssCategory::FlexGridGap => "Flex & Grid Gap",
CssCategory::Miscellaneous => "Miscellaneous",
CssCategory::MotionPath => "Motion Path",
CssCategory::ScrollDriven => "Scroll Driven",
CssCategory::Houdini => "Houdini",
CssCategory::Svg => "SVG",
CssCategory::Hardware => "Hardware",
}
}
#[inline]
pub const fn description(self) -> &'static str {
match self {
CssCategory::Layout => "Properties that control the layout and positioning of elements",
CssCategory::BoxModel => {
"Properties related to the box model: width, height, margin, padding, border"
}
CssCategory::Flexbox => "CSS Flexible Box Layout properties",
CssCategory::Grid => "CSS Grid Layout properties",
CssCategory::Typography => "Font and text properties",
CssCategory::Color => "Color and background properties",
CssCategory::Visual => "Visual effects and filters",
CssCategory::Transform => "2D and 3D transforms",
CssCategory::Transition => "CSS transition properties",
CssCategory::Animation => "CSS animation properties",
CssCategory::Interaction => "User interaction properties",
CssCategory::List => "List and counter properties",
CssCategory::Table => "Table-specific properties",
CssCategory::Paged => "Paged media properties",
CssCategory::GeneratedContent => "Generated content properties",
CssCategory::FlexGridGap => "Gap properties for flex and grid layouts",
CssCategory::Miscellaneous => "Miscellaneous CSS properties",
CssCategory::MotionPath => "CSS Motion Path properties for animation along paths",
CssCategory::ScrollDriven => "Scroll-driven animation properties",
CssCategory::Houdini => "CSS Houdini properties for low-level rendering control",
CssCategory::Svg => "SVG-specific properties",
CssCategory::Hardware => "Hardware acceleration and optimization properties",
}
}
#[inline]
pub const fn all() -> [CssCategory; 22] {
[
CssCategory::Layout,
CssCategory::BoxModel,
CssCategory::Flexbox,
CssCategory::Grid,
CssCategory::Typography,
CssCategory::Color,
CssCategory::Visual,
CssCategory::Transform,
CssCategory::Transition,
CssCategory::Animation,
CssCategory::Interaction,
CssCategory::List,
CssCategory::Table,
CssCategory::Paged,
CssCategory::GeneratedContent,
CssCategory::FlexGridGap,
CssCategory::Miscellaneous,
CssCategory::MotionPath,
CssCategory::ScrollDriven,
CssCategory::Houdini,
CssCategory::Svg,
CssCategory::Hardware,
]
}
}
impl std::fmt::Display for CssCategory {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_category_names() {
assert_eq!(CssCategory::Layout.name(), "Layout");
assert_eq!(CssCategory::Flexbox.name(), "Flexbox");
assert_eq!(CssCategory::Typography.name(), "Typography");
}
#[test]
fn test_category_descriptions() {
assert!(!CssCategory::Layout.description().is_empty());
assert!(!CssCategory::BoxModel.description().is_empty());
}
#[test]
fn test_all_categories() {
let categories = CssCategory::all();
assert_eq!(categories.len(), 22);
assert!(categories.contains(&CssCategory::Layout));
assert!(categories.contains(&CssCategory::Miscellaneous));
}
#[test]
fn test_display() {
assert_eq!(CssCategory::Grid.to_string(), "Grid");
assert_eq!(CssCategory::Animation.to_string(), "Animation");
}
}