component: Component crate cleanup (#29967)

This PR further organizes and documents the component crate. It:

- Simplifies the component registry
- Gives access to `ComponentMetadata` sooner
- Enables lookup by id in preview extension implementations
(`ComponentId` -> `ComponentMetadata`)
- Should slightly improve the performance of ComponentPreview

It also brings component statuses to the Component trait:

![CleanShot 2025-05-05 at 23 27
11@2x](https://github.com/user-attachments/assets/dd95ede6-bc90-4de4-90c6-3e5e064fd676)

![CleanShot 2025-05-05 at 23 27
40@2x](https://github.com/user-attachments/assets/9520aece-04c2-418b-95e1-c11aa60a66ca)

![CleanShot 2025-05-05 at 23 27
57@2x](https://github.com/user-attachments/assets/db1713d5-9831-4d00-9b29-1fd51c25fcba)

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2025-05-05 23:41:52 -04:00 committed by GitHub
parent 377909a646
commit c5d8407df4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 627 additions and 500 deletions

View file

@ -1,5 +1,6 @@
pub use component::{
Component, ComponentScope, example_group, example_group_with_title, single_example,
Component, ComponentId, ComponentScope, ComponentStatus, example_group,
example_group_with_title, single_example,
};
pub use documented::Documented;
pub use ui_macros::RegisterComponent;

View file

@ -1,3 +1,4 @@
use crate::component_prelude::*;
use crate::prelude::*;
use gpui::IntoElement;
use smallvec::{SmallVec, smallvec};
@ -81,6 +82,10 @@ impl Component for AlertModal {
ComponentScope::Notification
}
fn status() -> ComponentStatus {
ComponentStatus::WorkInProgress
}
fn description() -> Option<&'static str> {
Some("A modal dialog that presents an alert message with primary and dismiss actions.")
}