Implement component test page

This commit is contained in:
Mikayla
2023-08-19 16:29:24 -07:00
parent e946b0a2ec
commit bfd3e53dcd
11 changed files with 217 additions and 21 deletions
+10 -8
View File
@@ -74,8 +74,9 @@ pub mod disclosure {
}
impl<C> Disclosable<C, ()> {
pub fn with_id(self, id: usize) -> Disclosable<C, ()> {
Disclosable { id, ..self }
pub fn with_id(mut self, id: usize) -> Disclosable<C, ()> {
self.id = id;
self
}
}
@@ -181,7 +182,7 @@ pub mod action_button {
use gpui::{
elements::{Component, ContainerStyle, MouseEventHandler, SafeStylable, TooltipStyle},
platform::{CursorStyle, MouseButton},
Action, Element, TypeTag, View,
Action, Element, EventContext, TypeTag, View,
};
use schemars::JsonSchema;
use serde_derive::Deserialize;
@@ -211,14 +212,14 @@ pub mod action_button {
}
impl Button<(), ()> {
pub fn dynamic_action(action: Box<dyn Action>) -> Self {
pub fn dynamic_action(action: Box<dyn Action>) -> Button<(), ()> {
Self {
contents: (),
tag: action.type_tag(),
action,
style: Interactive::new_blank(),
tooltip: None,
id: 0,
action,
}
}
@@ -292,7 +293,7 @@ pub mod action_button {
})
.on_click(MouseButton::Left, {
let action = self.action.boxed_clone();
move |_, _, cx| {
move |_, _, cx: &mut EventContext<V>| {
let window = cx.window();
let view = cx.view_id();
let action = action.boxed_clone();
@@ -437,6 +438,7 @@ pub mod label {
use gpui::{
elements::{Component, LabelStyle, SafeStylable},
fonts::TextStyle,
Element,
};
@@ -455,14 +457,14 @@ pub mod label {
}
impl SafeStylable for Label<()> {
type Style = LabelStyle;
type Style = TextStyle;
type Output = Label<LabelStyle>;
fn with_style(self, style: Self::Style) -> Self::Output {
Label {
text: self.text,
style,
style: style.into(),
}
}
}
+9 -1
View File
@@ -3,7 +3,7 @@ mod theme_registry;
mod theme_settings;
pub mod ui;
use components::{disclosure::DisclosureStyle, ToggleIconButtonStyle};
use components::{action_button::ButtonStyle, disclosure::DisclosureStyle, ToggleIconButtonStyle};
use gpui::{
color::Color,
elements::{ContainerStyle, ImageStyle, LabelStyle, Shadow, SvgStyle, TooltipStyle},
@@ -66,6 +66,7 @@ pub struct Theme {
pub feedback: FeedbackStyle,
pub welcome: WelcomeStyle,
pub titlebar: Titlebar,
pub component_test: ComponentTest,
}
#[derive(Deserialize, Default, Clone, JsonSchema)]
@@ -260,6 +261,13 @@ pub struct CollabPanel {
pub face_overlap: f32,
}
#[derive(Deserialize, Default, JsonSchema)]
pub struct ComponentTest {
pub button: Interactive<ButtonStyle<TextStyle>>,
pub toggle: Toggleable<Interactive<ButtonStyle<TextStyle>>>,
pub disclosure: DisclosureStyle<TextStyle>,
}
#[derive(Deserialize, Default, JsonSchema)]
pub struct TabbedModal {
pub tab_button: Toggleable<Interactive<ContainedText>>,