Expose a theme preview keybinding function (#23237)

Danilo Leal and Agus Zubiaga created

This is useful if we want to pass random strings as keybindings for any
component that takes one, so we can display them on the debug theme
preview pane.

Release Notes:

- N/A

Co-authored-by: Agus Zubiaga <hi@aguz.me>

Change summary

crates/ui/src/traits/component_preview.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

Detailed changes

crates/ui/src/traits/component_preview.rs 🔗

@@ -1,5 +1,5 @@
 #![allow(missing_docs)]
-use crate::prelude::*;
+use crate::{prelude::*, KeyBinding};
 use gpui::{AnyElement, SharedString};
 
 /// Which side of the preview to show labels on
@@ -198,3 +198,7 @@ pub fn example_group_with_title<T>(
 ) -> ComponentExampleGroup<T> {
     ComponentExampleGroup::with_title(title, examples)
 }
+
+pub fn theme_preview_keybinding(keystrokes: &str) -> KeyBinding {
+    KeyBinding::new(gpui::KeyBinding::new(keystrokes, gpui::NoAction {}, None))
+}