Skip to content

Commit

Permalink
refactor(aria): move properties to aria-metdata (#4481)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos authored Nov 7, 2024
1 parent 5a35203 commit 3fe9193
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 1,035 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions crates/biome_aria/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ use std::str::FromStr;

pub mod iso;
mod macros;
pub mod properties;
pub mod roles;

pub use biome_aria_metadata::{AriaPropertiesEnum, AriaPropertyTypeEnum};
pub use properties::AriaProperties;
pub use biome_aria_metadata::{AriaAttribute, AriaValueType};
pub(crate) use roles::AriaRoleDefinition;
pub use roles::AriaRoles;

Expand All @@ -21,7 +19,7 @@ pub use roles::AriaRoles;
/// assert!(is_aria_property_valid("aria-checked"));
/// ```
pub fn is_aria_property_valid(property: &str) -> bool {
AriaPropertiesEnum::from_str(property).is_ok()
AriaAttribute::from_str(property).is_ok()
}

#[cfg(test)]
Expand Down
27 changes: 0 additions & 27 deletions crates/biome_aria/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,3 @@ macro_rules! define_role {
}
};
}

#[macro_export]
macro_rules! define_property {
( $id:ident {
PROPERTY_TYPE: $property_type:literal,
VALUES: $values:expr,
}) => {
#[derive(Debug)]
struct $id;

impl $id {
const PROPERTY_TYPE: &'static str = &$property_type;
const VALUES: &'static [&'static str] = &$values;
}

impl AriaPropertyDefinition for $id {
fn values(&self) -> Iter<&'static str> {
$id::VALUES.iter()
}

fn property_type(&self) -> $crate::AriaPropertyTypeEnum {
// SAFETY: PROPERTY_TYPE is internal and should not contain extraneous properties
$crate::AriaPropertyTypeEnum::from_str($id::PROPERTY_TYPE).unwrap()
}
}
};
}
Loading

0 comments on commit 3fe9193

Please sign in to comment.