Extend Label & Tooltip (#3322)

This PR extends the `Label` component with additional functionality,
partially for use in the `TextTooltip` component.

- [x] `Label` should take a `size` (`Default` & `Small` for now)
  - These should use `text_ui` and `text_ui_sm`
- [x] Fold `LabelColor` and `IconColor` into one enum
  - `TextColor`
- [x] `TextTooltip`'s keybinding field should take whatever we use for
keybindings instead of a string, and render the keybinding component
- [x] `TextTooltip` should use small `Label`s

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-11-14 13:56:05 -05:00 committed by GitHub
commit 5c8db996ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 271 additions and 254 deletions

View file

@ -69,7 +69,7 @@ use std::{
};
use theme2::ActiveTheme;
pub use toolbar::{ToolbarItemLocation, ToolbarItemView};
use ui::{h_stack, Button, ButtonVariant, Label, LabelColor};
use ui::{h_stack, Button, ButtonVariant, KeyBinding, Label, TextColor, TextTooltip};
use util::ResultExt;
use uuid::Uuid;
pub use workspace_settings::{AutosaveSetting, WorkspaceSettings};
@ -2472,17 +2472,50 @@ impl Workspace {
h_stack()
// TODO - Add player menu
.child(
Button::new("player")
.variant(ButtonVariant::Ghost)
.color(Some(LabelColor::Player(0))),
div()
.id("project_owner_indicator")
.child(
Button::new("player")
.variant(ButtonVariant::Ghost)
.color(Some(TextColor::Player(0))),
)
.tooltip(move |_, cx| {
cx.build_view(|cx| TextTooltip::new("Toggle following"))
}),
)
// TODO - Add project menu
.child(Button::new("project_name").variant(ButtonVariant::Ghost))
.child(
div()
.id("titlebar_project_menu_button")
.child(Button::new("project_name").variant(ButtonVariant::Ghost))
.tooltip(move |_, cx| {
cx.build_view(|cx| TextTooltip::new("Recent Projects"))
}),
)
// TODO - Add git menu
.child(
Button::new("branch_name")
.variant(ButtonVariant::Ghost)
.color(Some(LabelColor::Muted)),
div()
.id("titlebar_git_menu_button")
.child(
Button::new("branch_name")
.variant(ButtonVariant::Ghost)
.color(Some(TextColor::Muted)),
)
.tooltip(move |_, cx| {
// todo!() Replace with real action.
#[gpui::action]
struct NoAction {}
cx.build_view(|cx| {
TextTooltip::new("Recent Branches")
.key_binding(KeyBinding::new(gpui::KeyBinding::new(
"cmd-b",
NoAction {},
None,
)))
.meta("Only local branches shown")
})
}),
),
) // self.titlebar_item
.child(h_stack().child(Label::new("Right side titlebar item")))