ZIm/crates/ui/src/components
Nate Butler f6fbf662b4
Add ui::ComponentPreview (#20319)
The `ComponentPreview` trait enables rendering storybook-like previews
of components inside of Zed.


![CleanShot 2024-11-06 at 16 32
25@2x](https://github.com/user-attachments/assets/6894663f-1bbc-4a40-b420-33882e9e239a)


This initial version will work for any component that doesn't return a
view.

Example impl:

```rust
impl ComponentPreview for Checkbox {
    fn description() -> impl Into<Option<&'static str>> {
        "A checkbox lets people choose between opposing..."
    }

    fn examples() -> Vec<ComponentExampleGroup<Self>> {
        vec![
            example_group(
                "Default",
                vec![
                    single_example(
                        "Unselected",
                        Checkbox::new("checkbox_unselected", Selection::Unselected),
                    ),
                    // ... more examples
                ],
            ),
            // ... more examples
        ]
    }
}
```

Example usage:

```rust
fn render_components_page(&self, cx: &ViewContext<Self>) -> impl IntoElement {
        v_flex()
            .gap_2()
            .child(Checkbox::render_component_previews(cx))
            .child(Icon::render_component_previews(cx))
    }
}
```

Release Notes:

- N/A
2024-11-06 16:54:18 -05:00
..
avatar ui: Fix avatar indicators getting cut off (#18821) 2024-10-07 12:53:11 -04:00
button ui: Fix swapped element background colors (#19701) 2024-10-24 16:34:45 -04:00
checkbox ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
label ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
list ssh: Refine the modal UI (#19256) 2024-10-15 20:39:27 -03:00
stories Derive icon paths (#17816) 2024-09-13 21:12:29 -04:00
avatar.rs chore: Revert changes made to ui crate structure (#17516) 2024-09-06 21:38:56 +02:00
button.rs chore: Another round of style lints fixes (#17519) 2024-09-07 02:36:55 +02:00
checkbox.rs Add ui::ComponentPreview (#20319) 2024-11-06 16:54:18 -05:00
context_menu.rs Fix mouse clicks on remote-open-folder UI (#19851) 2024-10-28 12:55:55 -07:00
disclosure.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
divider.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
dropdown_menu.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
facepile.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
icon.rs Add ui::ComponentPreview (#20319) 2024-11-06 16:54:18 -05:00
image.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
indent_guides.rs outline panel: Add indent guides (#19719) 2024-10-28 09:54:18 +01:00
indicator.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
keybinding.rs Sketch in assistant edit button (#19705) 2024-10-29 13:21:10 -04:00
label.rs chore: Revert changes made to ui crate structure (#17516) 2024-09-06 21:38:56 +02:00
list.rs chore: Revert changes made to ui crate structure (#17516) 2024-09-06 21:38:56 +02:00
modal.rs ssh: Refine the modal UI (#19256) 2024-10-15 20:39:27 -03:00
navigable.rs gpui: Add scroll anchors (#19894) 2024-11-01 14:47:46 +01:00
numeric_stepper.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
popover.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
popover_menu.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
radio.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
right_click_menu.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
scrollbar.rs ui: Fix scrollbar content size calculation for non-uniform lists with single element (#20237) 2024-11-05 14:32:13 +01:00
settings_container.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
settings_group.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
stack.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
stories.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
tab.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
tab_bar.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
tool_strip.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00
tooltip.rs ui crate docs & spring cleaning (#18768) 2024-10-05 23:28:34 -04:00