component: Add component and component_preview crates to power UI components (#24456)

This PR formalizes design components with the Component and
ComponentPreview traits.

You can open the preview UI with `workspace: open component preview`.

Component previews no longer need to return `Self` allowing for more
complex previews, and previews of components like `ui::Tooltip` that
supplement other components rather than are rendered by default.

`cargo-machete` incorrectly identifies `linkme` as an unused dep on
crates that have components deriving `IntoComponent`, so you may need to
add this to that crate's `Cargo.toml`:

```toml
# cargo-machete doesn't understand that linkme is used in the component macro
[package.metadata.cargo-machete]
ignored = ["linkme"]
```

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
This commit is contained in:
Nate Butler 2025-02-09 13:25:03 -05:00 committed by GitHub
parent 56cfc60875
commit 8f1ff189cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 1582 additions and 976 deletions

51
Cargo.lock generated
View file

@ -2942,6 +2942,28 @@ dependencies = [
"gpui",
]
[[package]]
name = "component"
version = "0.1.0"
dependencies = [
"collections",
"gpui",
"linkme",
"once_cell",
"parking_lot",
"theme",
]
[[package]]
name = "component_preview"
version = "0.1.0"
dependencies = [
"component",
"gpui",
"ui",
"workspace",
]
[[package]]
name = "concurrent-queue"
version = "2.5.0"
@ -7280,6 +7302,26 @@ dependencies = [
"memchr",
]
[[package]]
name = "linkme"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "566336154b9e58a4f055f6dd4cbab62c7dc0826ce3c0a04e63b2d2ecd784cdae"
dependencies = [
"linkme-impl",
]
[[package]]
name = "linkme-impl"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.90",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
@ -8693,9 +8735,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.20.2"
version = "1.20.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e"
[[package]]
name = "oo7"
@ -14320,8 +14362,10 @@ name = "ui"
version = "0.1.0"
dependencies = [
"chrono",
"component",
"gpui",
"itertools 0.14.0",
"linkme",
"menu",
"serde",
"settings",
@ -14349,6 +14393,7 @@ name = "ui_macros"
version = "0.1.0"
dependencies = [
"convert_case 0.7.1",
"linkme",
"proc-macro2",
"quote",
"syn 1.0.109",
@ -16120,6 +16165,7 @@ dependencies = [
"client",
"clock",
"collections",
"component",
"db",
"derive_more",
"env_logger 0.11.6",
@ -16554,6 +16600,7 @@ dependencies = [
"collections",
"command_palette",
"command_palette_hooks",
"component_preview",
"copilot",
"db",
"diagnostics",