Merge branch 'main' into collab_ui2
This commit is contained in:
commit
6d4276ea5f
58 changed files with 940 additions and 519 deletions
|
@ -178,6 +178,7 @@ impl<V: 'static> Button<V> {
|
|||
.text_ui()
|
||||
.rounded_md()
|
||||
.bg(self.variant.bg_color(cx))
|
||||
.cursor_pointer()
|
||||
.hover(|style| style.bg(self.variant.bg_color_hover(cx)))
|
||||
.active(|style| style.bg(self.variant.bg_color_active(cx)));
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ use gpui::{
|
|||
overlay, px, Action, AnchorCorner, AnyElement, Bounds, DispatchPhase, Div, EventEmitter,
|
||||
FocusHandle, FocusableView, LayoutId, MouseButton, MouseDownEvent, Pixels, Point, Render, View,
|
||||
};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
pub struct ContextMenu {
|
||||
items: Vec<ListItem>,
|
||||
|
@ -269,16 +268,15 @@ pub use stories::*;
|
|||
mod stories {
|
||||
use super::*;
|
||||
use crate::story::Story;
|
||||
use gpui::{action, Div, Render, VisualContext};
|
||||
use gpui::{actions, Div, Render, VisualContext};
|
||||
|
||||
#[action]
|
||||
struct PrintCurrentDate {}
|
||||
actions!(PrintCurrentDate);
|
||||
|
||||
fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<ContextMenu> {
|
||||
cx.build_view(|cx| {
|
||||
ContextMenu::new(cx).header(header).separator().entry(
|
||||
Label::new("Print current time"),
|
||||
PrintCurrentDate {}.boxed_clone(),
|
||||
PrintCurrentDate.boxed_clone(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ impl<V: 'static> IconButton<V> {
|
|||
fn render(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
|
||||
let icon_color = match (self.state, self.color) {
|
||||
(InteractionState::Disabled, _) => TextColor::Disabled,
|
||||
(InteractionState::Active, _) => TextColor::Error,
|
||||
(InteractionState::Active, _) => TextColor::Selected,
|
||||
_ => self.color,
|
||||
};
|
||||
|
||||
|
@ -110,17 +110,16 @@ impl<V: 'static> IconButton<V> {
|
|||
.rounded_md()
|
||||
.p_1()
|
||||
.bg(bg_color)
|
||||
.cursor_pointer()
|
||||
.hover(|style| style.bg(bg_hover_color))
|
||||
.active(|style| style.bg(bg_active_color))
|
||||
.child(IconElement::new(self.icon).color(icon_color));
|
||||
|
||||
if let Some(click_handler) = self.handlers.click.clone() {
|
||||
button = button
|
||||
.on_mouse_down(MouseButton::Left, move |state, event, cx| {
|
||||
cx.stop_propagation();
|
||||
click_handler(state, cx);
|
||||
})
|
||||
.cursor_pointer();
|
||||
button = button.on_mouse_down(MouseButton::Left, move |state, event, cx| {
|
||||
cx.stop_propagation();
|
||||
click_handler(state, cx);
|
||||
})
|
||||
}
|
||||
|
||||
if let Some(tooltip) = self.tooltip.take() {
|
||||
|
|
|
@ -81,13 +81,12 @@ pub use stories::*;
|
|||
mod stories {
|
||||
use super::*;
|
||||
use crate::Story;
|
||||
use gpui::{action, Div, Render};
|
||||
use gpui::{actions, Div, Render};
|
||||
use itertools::Itertools;
|
||||
|
||||
pub struct KeybindingStory;
|
||||
|
||||
#[action]
|
||||
struct NoAction {}
|
||||
actions!(NoAction);
|
||||
|
||||
pub fn binding(key: &str) -> gpui::KeyBinding {
|
||||
gpui::KeyBinding::new(key, NoAction {}, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue