Merge branch 'pre-merge' into clean-up-doc-elements

This commit is contained in:
Nathan Sobo
2024-01-01 12:21:33 -07:00
88 changed files with 237 additions and 478 deletions
+3 -5
View File
@@ -3,8 +3,8 @@ use crate::{
ListSeparator, ListSubHeader,
};
use gpui::{
px, Action, AnyElement, AppContext, DismissEvent, Div, EventEmitter, FocusHandle,
FocusableView, IntoElement, Render, Subscription, View, VisualContext,
px, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusHandle, FocusableView,
IntoElement, Render, Subscription, View, VisualContext,
};
use menu::{SelectFirst, SelectLast, SelectNext, SelectPrev};
use std::{rc::Rc, time::Duration};
@@ -232,9 +232,7 @@ impl ContextMenuItem {
}
impl Render for ContextMenu {
type Output = Div;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
div().elevation_2(cx).flex().flex_row().child(
v_stack()
.min_w(px(200.))
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::prelude::*;
@@ -7,9 +7,7 @@ use crate::Avatar;
pub struct AvatarStory;
impl Render for AvatarStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Avatar>())
.child(Story::label("Default"))
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, Icon};
@@ -7,9 +7,7 @@ use crate::{Button, ButtonStyle};
pub struct ButtonStory;
impl Render for ButtonStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Button>())
.child(Story::label("Default"))
@@ -1,4 +1,4 @@
use gpui::{Div, Render, ViewContext};
use gpui::{Render, ViewContext};
use story::Story;
use crate::prelude::*;
@@ -7,9 +7,7 @@ use crate::{h_stack, Checkbox};
pub struct CheckboxStory;
impl Render for CheckboxStory {
type Output = Div;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Checkbox>())
.child(Story::label("Default"))
@@ -1,4 +1,4 @@
use gpui::{actions, AnchorCorner, Div, Render, View};
use gpui::{actions, AnchorCorner, Render, View};
use story::Story;
use crate::prelude::*;
@@ -20,9 +20,7 @@ fn build_menu(cx: &mut WindowContext, header: impl Into<SharedString>) -> View<C
pub struct ContextMenuStory;
impl Render for ContextMenuStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.on_action(|_: &PrintCurrentDate, _| {
println!("printing unix time!");
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::prelude::*;
@@ -7,9 +7,7 @@ use crate::Disclosure;
pub struct DisclosureStory;
impl Render for DisclosureStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Disclosure>())
.child(Story::label("Toggled"))
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use strum::IntoEnumIterator;
@@ -8,9 +8,7 @@ use crate::{Icon, IconElement};
pub struct IconStory;
impl Render for IconStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
let icons = Icon::iter();
Story::container()
@@ -1,4 +1,4 @@
use gpui::{Component, Render};
use gpui::Render;
use story::{StoryContainer, StoryItem, StorySection};
use crate::{prelude::*, Tooltip};
@@ -7,9 +7,7 @@ use crate::{Icon, IconButton};
pub struct IconButtonStory;
impl Render for IconButtonStory {
type Output = Component<StoryContainer>;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
let default_button = StoryItem::new(
"Default",
IconButton::new("default_icon_button", Icon::Hash),
@@ -1,5 +1,5 @@
use gpui::NoAction;
use gpui::{Div, Render};
use gpui::Render;
use itertools::Itertools;
use story::Story;
@@ -13,9 +13,7 @@ pub fn binding(key: &str) -> gpui::KeyBinding {
}
impl Render for KeybindingStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
let all_modifier_permutations = ["ctrl", "alt", "cmd", "shift"].into_iter().permutations(2);
Story::container()
+3 -7
View File
@@ -1,15 +1,11 @@
use gpui::{Div, Render};
use crate::{prelude::*, HighlightedLabel, Label};
use gpui::Render;
use story::Story;
use crate::prelude::*;
use crate::{HighlightedLabel, Label};
pub struct LabelStory;
impl Render for LabelStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Label>())
.child(Story::label("Default"))
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, ListHeader, ListSeparator, ListSubHeader};
@@ -7,9 +7,7 @@ use crate::{List, ListItem};
pub struct ListStory;
impl Render for ListStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<List>())
.child(Story::label("Default"))
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, IconButton};
@@ -7,9 +7,7 @@ use crate::{Icon, ListHeader};
pub struct ListHeaderStory;
impl Render for ListHeaderStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<ListHeader>())
.child(Story::label("Default"))
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, Avatar};
@@ -7,9 +7,7 @@ use crate::{Icon, ListItem};
pub struct ListItemStory;
impl Render for ListItemStory {
type Output = Div;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.bg(cx.theme().colors().background)
.child(Story::title_for::<ListItem>())
+2 -4
View File
@@ -1,6 +1,6 @@
use std::cmp::Ordering;
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, TabPosition};
@@ -9,9 +9,7 @@ use crate::{Indicator, Tab};
pub struct TabStory;
impl Render for TabStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
Story::container()
.child(Story::title_for::<Tab>())
.child(Story::label("Default"))
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{Div, Render};
use gpui::Render;
use story::Story;
use crate::{prelude::*, Tab, TabBar, TabPosition};
@@ -6,9 +6,7 @@ use crate::{prelude::*, Tab, TabBar, TabPosition};
pub struct TabBarStory;
impl Render for TabBarStory {
type Output = Div;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
let tab_count = 20;
let selected_tab_index = 3;
@@ -1,4 +1,4 @@
use gpui::{Component, Render};
use gpui::Render;
use story::{StoryContainer, StoryItem, StorySection};
use crate::{prelude::*, ToggleButton};
@@ -6,9 +6,7 @@ use crate::{prelude::*, ToggleButton};
pub struct ToggleButtonStory;
impl Render for ToggleButtonStory {
type Output = Component<StoryContainer>;
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl Element {
StoryContainer::new(
"Toggle Button",
"crates/ui2/src/components/stories/toggle_button.rs",
+2 -4
View File
@@ -1,4 +1,4 @@
use gpui::{overlay, Action, AnyView, IntoElement, Overlay, Render, VisualContext};
use gpui::{overlay, Action, AnyView, IntoElement, Render, VisualContext};
use settings::Settings;
use theme::ThemeSettings;
@@ -68,9 +68,7 @@ impl Tooltip {
}
impl Render for Tooltip {
type Output = Overlay;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element {
let ui_font = ThemeSettings::get_global(cx).ui_font.family.clone();
overlay().child(
// padding to avoid mouse cursor