From 5c5a938ecf8f84c1b779e8795285d7c67f1a8665 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:43:56 -0300 Subject: [PATCH] Expose a theme preview keybinding function (#23237) 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 --- crates/ui/src/traits/component_preview.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui/src/traits/component_preview.rs b/crates/ui/src/traits/component_preview.rs index aab01355a1839b9b2e33c5086d53f2f03d740ed0..590e2fc37935d85395e77f7f987f4299e84f8d49 100644 --- a/crates/ui/src/traits/component_preview.rs +++ b/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( ) -> ComponentExampleGroup { ComponentExampleGroup::with_title(title, examples) } + +pub fn theme_preview_keybinding(keystrokes: &str) -> KeyBinding { + KeyBinding::new(gpui::KeyBinding::new(keystrokes, gpui::NoAction {}, None)) +}