History

Bring UI crate up to date (#3013)

Merges various in-progress gpui2 component branches with the new `ui` crate.

Nate Butler committed 3 years ago

Commit a5e055f2 parents 5083ab7 30b105a25 files · +1090 −210Browse files

Unified · Split

25 files
  1. crates/ui/doc/elevation.md +57 −0
  2. crates/ui/src/components.rs +4 −0
  3. crates/ui/src/components/list_item.rs +48 −24
  4. crates/ui/src/components/list_section_header.rs +88 −0
  5. crates/ui/src/components/palette_item.rs +63 −0
  6. crates/ui/src/elements/icon.rs +23 −22
  7. crates/ui/src/elements/label.rs +30 −4
  8. crates/ui/src/lib.rs +7 −0
  9. crates/ui/src/modules.rs +4 −10
  10. crates/ui/src/modules/list.rs +64 −0
  11. crates/ui/src/modules/palette.rs +124 −0
  12. crates/ui/src/modules/project_panel.rs +0 −94
  13. crates/ui/src/prelude.rs +15 −0
  14. crates/ui/src/static_data.rs +166 −0
  15. crates/ui/src/templates.rs +17 −0
  16. crates/ui/src/templates/chat_panel.rs +4 −4
  17. crates/ui/src/templates/collab_panel.rs +177 −0
  18. crates/ui/src/templates/command_palette.rs +31 −0
  19. crates/ui/src/templates/project_panel.rs +62 −0
  20. crates/ui/src/templates/status_bar.rs +3 −4
  21. crates/ui/src/templates/tab_bar.rs +5 −5
  22. crates/ui/src/templates/title_bar.rs +0 −0
  23. crates/ui/src/templates/workspace.rs +80 −0
  24. crates/ui/src/tokens.rs +18 −0
  25. docs/ui/states.md +0 −43
crates/ui/doc/elevation.md+57−0
@@ -0,0 +1,57 @@
1+# Elevation
2+
3+Elevation in Zed applies to all surfaces and components. Elevation is categorized into levels.
4+
5+Elevation accomplishes the following:
6+- Allows surfaces to move in front of or behind others, such as content scrolling beneath app top bars.
7+- Reflects spatial relationships, for instance, how a floating action button’s shadow intimates its disconnection from a collection of cards.
8+- Directs attention to structures at the highest elevation, like a temporary dialog arising in front of other surfaces.
9+
10+Elevations are the initial elevation values assigned to components by default.
11+
12+Components may transition to a higher elevation in some cases, like user interations.
13+
14+On such occasions, components transition to predetermined dynamic elevation offsets. These are the typical elevations to which components move when they are not at rest.
15+
16+## Understanding Elevation
17+
18+Elevation can be thought of as the physical closeness of an element to the user. Elements with lower elevations are physically further away from the user on the z-axis and appear to be underneath elements with higher elevations.
19+
20+Material Design 3 has a some great visualizations of elevation that may be helpful to understanding the mental modal of elevation. [Material Design – Elevation](https://m3.material.io/styles/elevation/overview)
21+
22+## Elevation Levels
23+
24+Zed integrates six unique elevation levels in its design system. The elevation of a surface is expressed as a whole number ranging from 0 to 5, both numbers inclusive. A component’s elevation is ascertained by combining the component’s resting elevation with any dynamic elevation offsets.
25+
26+The levels are detailed as follows:
27+
28+0. App Background
29+1. UI Surface
30+2. Elevated Elements
31+3. Wash
32+4. Focused Element
33+5. Dragged Element
34+
35+### 0. App Background
36+
37+The app background constitutes the lowest elevation layer, appearing behind all other surfaces and components. It is predominantly used for the background color of the app.
38+
39+### 1. UI Surface
40+
41+The UI Surface is the standard elevation for components and is placed above the app background. It is generally used for the background color of the app bar, card, and sheet.
42+
43+### 2. Elevated Elements
44+
45+Elevated elements appear above the UI surface layer surfaces and components. Elevated elements are predominantly used for creating popovers, context menus, and tooltips.
46+
47+### 3. Wash
48+
49+Wash denotes a distinct elevation reserved to isolate app UI layers from high elevation components such as modals, notifications, and overlaid panels. The wash may not consistently be visible when these components are active. This layer is often referred to as a scrim or overlay and the background color of the wash is typically deployed in its design.
50+
51+### 4. Focused Element
52+
53+Focused elements obtain a higher elevation above surfaces and components at wash elevation. They are often used for modals, notifications, and overlaid panels and indicate that they are the sole element the user is interacting with at the moment.
54+
55+### 5. Dragged Element
56+
57+Dragged elements gain the highest elevation, thus appearing above surfaces and components at the elevation of focused elements. These are typically used for elements that are being dragged, following the cursor
crates/ui/src/components.rs+4−0
@@ -1,12 +1,16 @@
11 mod facepile;
22 mod follow_group;
33 mod list_item;
4+mod list_section_header;
5+mod palette_item;
46 mod tab;
57 mod traffic_lights;
68
79 pub use facepile::*;
810 pub use follow_group::*;
911 pub use list_item::*;
12+pub use list_section_header::*;
13+pub use palette_item::*;
1014 pub use tab::*;
1115 pub use traffic_lights::*;
1216
crates/ui/src/components/list_item.rs+48−24
@@ -1,17 +1,18 @@
1−use gpui2::elements::div;
2−use gpui2::geometry::rems;
1+use crate::prelude::{DisclosureControlVisibility, InteractionState, ToggleState};
2+use crate::theme::theme;
3+use crate::tokens::token;
4+use crate::{icon, IconAsset, Label};
35 use gpui2::style::{StyleHelpers, Styleable};
4−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
6+use gpui2::{elements::div, IntoElement};
7+use gpui2::{Element, ParentElement, ViewContext};
58
6−use crate::prelude::*;
7−use crate::{icon, theme, IconAsset, Label};
8−
9−#[derive(Element)]
9+#[derive(Element, Clone)]
1010 pub struct ListItem {
1111 label: Label,
1212 left_icon: Option<IconAsset>,
1313 indent_level: u32,
1414 state: InteractionState,
15+ disclosure_control_style: DisclosureControlVisibility,
1516 toggle: Option<ToggleState>,
1617 }
1718
@@ -20,6 +21,7 @@ pub fn list_item(label: Label) -> ListItem { · 2 unmodified lines
2021 label,
2122 indent_level: 0,
2223 left_icon: None,
24+ disclosure_control_style: DisclosureControlVisibility::default(),
2325 state: InteractionState::default(),
2426 toggle: None,
2527 }
@@ -46,8 +48,30 @@ impl ListItem { · 20 unmodified lines
4648 self
4749 }
4850
51+ pub fn disclosure_control_style(
52+ mut self,
53+ disclosure_control_style: DisclosureControlVisibility,
54+ ) -> Self {
55+ self.disclosure_control_style = disclosure_control_style;
56+ self
57+ }
58+
4959 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
5060 let theme = theme(cx);
61+ let token = token();
62+ let mut disclosure_control = match self.toggle {
63+ Some(ToggleState::NotToggled) => Some(div().child(icon(IconAsset::ChevronRight))),
64+ Some(ToggleState::Toggled) => Some(div().child(icon(IconAsset::ChevronDown))),
65+ None => Some(div()),
66+ };
67+
68+ match self.disclosure_control_style {
69+ DisclosureControlVisibility::OnHover => {
70+ disclosure_control =
71+ disclosure_control.map(|c| div().absolute().neg_left_5().child(c));
72+ }
73+ DisclosureControlVisibility::Always => {}
74+ }
5175
5276 div()
5377 .fill(theme.middle.base.default.background)
@@ -56,31 +80,31 @@ impl ListItem { · 2 unmodified lines
5680 .active()
5781 .fill(theme.middle.base.pressed.background)
5882 .relative()
83+ .py_1()
5984 .child(
6085 div()
61− .h_7()
86+ .h_6()
6287 .px_2()
6388 // .ml(rems(0.75 * self.indent_level as f32))
6489 .children((0..self.indent_level).map(|_| {
65− div().w(rems(0.75)).h_full().flex().justify_center().child(
66− div()
67− .w_px()
68− .h_full()
69− .fill(theme.middle.base.default.border)
70− .hover()
71− .fill(theme.middle.warning.default.border)
72− .active()
73− .fill(theme.middle.negative.default.border),
74− )
90+ div()
91+ .w(token.list_indent_depth)
92+ .h_full()
93+ .flex()
94+ .justify_center()
95+ .child(
96+ div()
97+ .ml_px()
98+ .w_px()
99+ .h_full()
100+ .fill(theme.middle.base.default.border),
101+ )
75102 }))
76103 .flex()
77− .gap_2()
104+ .gap_1()
78105 .items_center()
79− .children(match self.toggle {
80− Some(ToggleState::NotToggled) => Some(icon(IconAsset::ChevronRight)),
81− Some(ToggleState::Toggled) => Some(icon(IconAsset::ChevronDown)),
82− None => None,
83− })
106+ .relative()
107+ .children(disclosure_control)
84108 .children(self.left_icon.map(|i| icon(i)))
85109 .child(self.label.clone()),
86110 )
crates/ui/src/components/list_section_header.rs+88−0
@@ -0,0 +1,88 @@
1+use crate::prelude::{InteractionState, ToggleState};
2+use crate::theme::theme;
3+use crate::tokens::token;
4+use crate::{icon, label, IconAsset, LabelColor, LabelSize};
5+use gpui2::style::{StyleHelpers, Styleable};
6+use gpui2::{elements::div, IntoElement};
7+use gpui2::{Element, ParentElement, ViewContext};
8+
9+#[derive(Element, Clone, Copy)]
10+pub struct ListSectionHeader {
11+ label: &'static str,
12+ left_icon: Option<IconAsset>,
13+ state: InteractionState,
14+ toggle: Option<ToggleState>,
15+}
16+
17+pub fn list_section_header(label: &'static str) -> ListSectionHeader {
18+ ListSectionHeader {
19+ label,
20+ left_icon: None,
21+ state: InteractionState::default(),
22+ toggle: None,
23+ }
24+}
25+
26+impl ListSectionHeader {
27+ pub fn set_toggle(mut self, toggle: ToggleState) -> Self {
28+ self.toggle = Some(toggle);
29+ self
30+ }
31+
32+ pub fn left_icon(mut self, left_icon: Option<IconAsset>) -> Self {
33+ self.left_icon = left_icon;
34+ self
35+ }
36+
37+ pub fn state(mut self, state: InteractionState) -> Self {
38+ self.state = state;
39+ self
40+ }
41+
42+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
43+ let theme = theme(cx);
44+ let token = token();
45+
46+ let disclosure_control = match self.toggle {
47+ Some(ToggleState::NotToggled) => Some(div().child(icon(IconAsset::ChevronRight))),
48+ Some(ToggleState::Toggled) => Some(div().child(icon(IconAsset::ChevronDown))),
49+ None => Some(div()),
50+ };
51+
52+ div()
53+ .flex()
54+ .flex_1()
55+ .w_full()
56+ .fill(theme.middle.base.default.background)
57+ .hover()
58+ .fill(theme.middle.base.hovered.background)
59+ .active()
60+ .fill(theme.middle.base.pressed.background)
61+ .relative()
62+ .py_1()
63+ .child(
64+ div()
65+ .h_6()
66+ .px_2()
67+ .flex()
68+ .flex_1()
69+ .w_full()
70+ .gap_1()
71+ .items_center()
72+ .justify_between()
73+ .child(
74+ div()
75+ .flex()
76+ .gap_1()
77+ .items_center()
78+ .children(self.left_icon.map(|i| icon(i)))
79+ .child(
80+ label(self.label.clone())
81+ .color(LabelColor::Muted)
82+ .size(LabelSize::Small),
83+ ),
84+ )
85+ .children(disclosure_control),
86+ )
87+ }
88+}
crates/ui/src/components/palette_item.rs+63−0
@@ -0,0 +1,63 @@
1+use crate::theme::theme;
2+use crate::{label, LabelColor, LabelSize};
3+use gpui2::elements::div;
4+use gpui2::style::StyleHelpers;
5+use gpui2::{Element, IntoElement};
6+use gpui2::{ParentElement, ViewContext};
7+
8+#[derive(Element)]
9+pub struct PaletteItem {
10+ pub label: &'static str,
11+ pub keybinding: Option<&'static str>,
12+}
13+
14+pub fn palette_item(label: &'static str, keybinding: Option<&'static str>) -> PaletteItem {
15+ PaletteItem { label, keybinding }
16+}
17+
18+impl PaletteItem {
19+ pub fn label(mut self, label: &'static str) -> Self {
20+ self.label = label;
21+ self
22+ }
23+
24+ pub fn keybinding(mut self, keybinding: Option<&'static str>) -> Self {
25+ self.keybinding = keybinding;
26+ self
27+ }
28+
29+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
30+ let theme = theme(cx);
31+
32+ let keybinding_label = match self.keybinding {
33+ Some(keybind) => label(keybind)
34+ .color(LabelColor::Muted)
35+ .size(LabelSize::Small),
36+ None => label(""),
37+ };
38+
39+ div()
40+ .flex()
41+ .flex_row()
42+ .grow()
43+ .justify_between()
44+ .child(label(self.label))
45+ .child(
46+ self.keybinding
47+ .map(|_| {
48+ div()
49+ .flex()
50+ .items_center()
51+ .justify_center()
52+ .px_1()
53+ .py_0()
54+ .my_0p5()
55+ .rounded_md()
56+ .text_sm()
57+ .fill(theme.lowest.on.default.background)
58+ .child(keybinding_label)
59+ })
60+ .unwrap_or_else(|| div()),
61+ )
62+ }
63+}
crates/ui/src/elements/icon.rs+23−22
@@ -1,29 +1,30 @@
1+use crate::theme::theme;
12 use gpui2::elements::svg;
23 use gpui2::style::StyleHelpers;
3−use gpui2::{Element, IntoElement, ViewContext};
4−
5−use crate::theme;
6−
7−// Icon::Hash
8−// icon(IconAsset::Hash).color(IconColor::Warning)
9−// Icon::new(IconAsset::Hash).color(IconColor::Warning)
4+use gpui2::IntoElement;
5+use gpui2::{Element, ViewContext};
106
117 #[derive(Default, PartialEq, Copy, Clone)]
128 pub enum IconAsset {
139 Ai,
1410 ArrowLeft,
1511 ArrowRight,
16− #[default]
1712 ArrowUpRight,
1813 Bolt,
19− Hash,
20− File,
21− Folder,
22− FolderOpen,
2314 ChevronDown,
24− ChevronUp,
2515 ChevronLeft,
2616 ChevronRight,
17+ ChevronUp,
18+ #[default]
19+ File,
20+ FileDoc,
21+ FileGit,
22+ FileLock,
23+ FileRust,
24+ FileToml,
25+ Folder,
26+ FolderOpen,
27+ Hash,
2728 }
2829
2930 impl IconAsset {
@@ -34,14 +35,19 @@ impl IconAsset { · 4 unmodified lines
3435 IconAsset::ArrowRight => "icons/arrow_right.svg",
3536 IconAsset::ArrowUpRight => "icons/arrow_up_right.svg",
3637 IconAsset::Bolt => "icons/bolt.svg",
37− IconAsset::Hash => "icons/hash.svg",
3838 IconAsset::ChevronDown => "icons/chevron_down.svg",
39− IconAsset::ChevronUp => "icons/chevron_up.svg",
4039 IconAsset::ChevronLeft => "icons/chevron_left.svg",
4140 IconAsset::ChevronRight => "icons/chevron_right.svg",
41+ IconAsset::ChevronUp => "icons/chevron_up.svg",
4242 IconAsset::File => "icons/file_icons/file.svg",
43+ IconAsset::FileDoc => "icons/file_icons/book.svg",
44+ IconAsset::FileGit => "icons/file_icons/git.svg",
45+ IconAsset::FileLock => "icons/file_icons/lock.svg",
46+ IconAsset::FileRust => "icons/file_icons/rust.svg",
47+ IconAsset::FileToml => "icons/file_icons/toml.svg",
4348 IconAsset::Folder => "icons/file_icons/folder.svg",
4449 IconAsset::FolderOpen => "icons/file_icons/folder_open.svg",
50+ IconAsset::Hash => "icons/hash.svg",
4551 }
4652 }
4753 }
@@ -55,19 +61,14 @@ pub fn icon(asset: IconAsset) -> Icon { · 7 unmodified lines
5561 Icon { asset }
5662 }
5763
58−// impl Icon {
59−// pub fn new(asset: IconAsset) -> Icon {
60−// Icon { asset }
61−// }
62−// }
63−
6464 impl Icon {
6565 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
6666 let theme = theme(cx);
6767
6868 svg()
69+ .flex_none()
6970 .path(self.asset.path())
7071 .size_4()
71− .fill(theme.lowest.base.default.foreground)
72+ .fill(theme.lowest.variant.default.foreground)
7273 }
7374 }
crates/ui/src/elements/label.rs+30−4
@@ -1,29 +1,40 @@
1+use crate::theme::theme;
12 use gpui2::elements::div;
23 use gpui2::style::StyleHelpers;
3−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
4−
5−use crate::theme;
4+use gpui2::{Element, ViewContext};
5+use gpui2::{IntoElement, ParentElement};
66
77 #[derive(Default, PartialEq, Copy, Clone)]
88 pub enum LabelColor {
99 #[default]
1010 Default,
11+ Muted,
1112 Created,
1213 Modified,
1314 Deleted,
1415 Hidden,
16+ Placeholder,
17+}
18+
19+#[derive(Default, PartialEq, Copy, Clone)]
20+pub enum LabelSize {
21+ #[default]
22+ Default,
23+ Small,
1524 }
1625
1726 #[derive(Element, Clone)]
1827 pub struct Label {
1928 label: &'static str,
2029 color: LabelColor,
30+ size: LabelSize,
2131 }
2232
2333 pub fn label(label: &'static str) -> Label {
2434 Label {
2535 label,
2636 color: LabelColor::Default,
37+ size: LabelSize::Default,
2738 }
2839 }
2940
@@ -33,17 +44,32 @@ impl Label { · 3 unmodified lines
3344 self
3445 }
3546
47+ pub fn size(mut self, size: LabelSize) -> Self {
48+ self.size = size;
49+ self
50+ }
51+
3652 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
3753 let theme = theme(cx);
3854
3955 let color = match self.color {
4056 LabelColor::Default => theme.lowest.base.default.foreground,
57+ LabelColor::Muted => theme.lowest.variant.default.foreground,
4158 LabelColor::Created => theme.lowest.positive.default.foreground,
4259 LabelColor::Modified => theme.lowest.warning.default.foreground,
4360 LabelColor::Deleted => theme.lowest.negative.default.foreground,
4461 LabelColor::Hidden => theme.lowest.variant.default.foreground,
62+ LabelColor::Placeholder => theme.lowest.base.disabled.foreground,
4563 };
4664
47− div().text_sm().text_color(color).child(self.label.clone())
65+ let mut div = div();
66+
67+ if self.size == LabelSize::Small {
68+ div = div.text_xs();
69+ } else {
70+ div = div.text_sm();
71+ }
72+
73+ div.text_color(color).child(self.label.clone())
4874 }
4975 }
crates/ui/src/lib.rs+7−0
@@ -5,10 +5,17 @@ mod element_ext; · 4 unmodified lines
55 mod elements;
66 mod modules;
77 pub mod prelude;
8+mod static_data;
9+mod templates;
810 mod theme;
11+mod tokens;
912
1013 pub use crate::theme::*;
1114 pub use components::*;
1215 pub use element_ext::*;
1316 pub use elements::*;
1417 pub use modules::*;
18+pub use prelude::*;
19+pub use static_data::*;
20+pub use templates::*;
21+pub use tokens::*;
crates/ui/src/modules.rs+4−10
@@ -1,11 +1,5 @@
1−mod chat_panel;
2−mod project_panel;
3−mod status_bar;
4−mod tab_bar;
5−mod title_bar;
1+mod list;
2+mod palette;
63
7−pub use chat_panel::*;
8−pub use project_panel::*;
9−pub use status_bar::*;
10−pub use tab_bar::*;
11−pub use title_bar::*;
4+pub use list::*;
5+pub use palette::*;
crates/ui/src/modules/list.rs+64−0
@@ -0,0 +1,64 @@
1+use crate::theme::theme;
2+use crate::tokens::token;
3+use crate::{icon, label, prelude::*, IconAsset, LabelColor, ListItem, ListSectionHeader};
4+use gpui2::style::StyleHelpers;
5+use gpui2::{elements::div, IntoElement};
6+use gpui2::{Element, ParentElement, ViewContext};
7+
8+#[derive(Element)]
9+pub struct List {
10+ header: Option<ListSectionHeader>,
11+ items: Vec<ListItem>,
12+ empty_message: &'static str,
13+ toggle: Option<ToggleState>,
14+ // footer: Option<ListSectionFooter>,
15+}
16+
17+pub fn list(items: Vec<ListItem>) -> List {
18+ List {
19+ header: None,
20+ items,
21+ empty_message: "No items",
22+ toggle: None,
23+ }
24+}
25+
26+impl List {
27+ pub fn header(mut self, header: ListSectionHeader) -> Self {
28+ self.header = Some(header);
29+ self
30+ }
31+
32+ pub fn empty_message(mut self, empty_message: &'static str) -> Self {
33+ self.empty_message = empty_message;
34+ self
35+ }
36+
37+ pub fn set_toggle(mut self, toggle: ToggleState) -> Self {
38+ self.toggle = Some(toggle);
39+ self
40+ }
41+
42+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
43+ let theme = theme(cx);
44+ let token = token();
45+
46+ let disclosure_control = match self.toggle {
47+ Some(ToggleState::NotToggled) => Some(icon(IconAsset::ChevronRight)),
48+ Some(ToggleState::Toggled) => Some(icon(IconAsset::ChevronDown)),
49+ None => None,
50+ };
51+
52+ div()
53+ .py_1()
54+ .flex()
55+ .flex_col()
56+ .children(self.header.map(|h| h))
57+ .children(
58+ self.items
59+ .is_empty()
60+ .then(|| label(self.empty_message).color(LabelColor::Muted)),
61+ )
62+ .children(self.items.iter().cloned())
63+ }
64+}
crates/ui/src/modules/palette.rs+124−0
@@ -0,0 +1,124 @@
1+use std::marker::PhantomData;
2+
3+use crate::prelude::OrderMethod;
4+use crate::theme::theme;
5+use crate::{label, palette_item, LabelColor, PaletteItem};
6+use gpui2::elements::div::ScrollState;
7+use gpui2::style::{StyleHelpers, Styleable};
8+use gpui2::{elements::div, IntoElement};
9+use gpui2::{Element, ParentElement, ViewContext};
10+
11+#[derive(Element)]
12+pub struct Palette<V: 'static> {
13+ view_type: PhantomData<V>,
14+ scroll_state: ScrollState,
15+ input_placeholder: &'static str,
16+ empty_string: &'static str,
17+ items: Vec<PaletteItem>,
18+ default_order: OrderMethod,
19+}
20+
21+pub fn palette<V: 'static>(scroll_state: ScrollState) -> Palette<V> {
22+ Palette {
23+ view_type: PhantomData,
24+ scroll_state,
25+ input_placeholder: "Find something...",
26+ empty_string: "No items found.",
27+ items: vec![],
28+ default_order: OrderMethod::default(),
29+ }
30+}
31+
32+impl<V: 'static> Palette<V> {
33+ pub fn items(mut self, mut items: Vec<PaletteItem>) -> Self {
34+ items.sort_by_key(|item| item.label);
35+ self.items = items;
36+ self
37+ }
38+
39+ pub fn placeholder(mut self, input_placeholder: &'static str) -> Self {
40+ self.input_placeholder = input_placeholder;
41+ self
42+ }
43+
44+ pub fn empty_string(mut self, empty_string: &'static str) -> Self {
45+ self.empty_string = empty_string;
46+ self
47+ }
48+
49+ // TODO: Hook up sort order
50+ pub fn default_order(mut self, default_order: OrderMethod) -> Self {
51+ self.default_order = default_order;
52+ self
53+ }
54+
55+ fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
56+ let theme = theme(cx);
57+
58+ div()
59+ .w_96()
60+ .rounded_lg()
61+ .fill(theme.lowest.base.default.background)
62+ .border()
63+ .border_color(theme.lowest.base.default.border)
64+ .flex()
65+ .flex_col()
66+ .child(
67+ div()
68+ .flex()
69+ .flex_col()
70+ .gap_px()
71+ .child(
72+ div().py_0p5().px_1().flex().flex_col().child(
73+ div().px_2().py_0p5().child(
74+ label(self.input_placeholder).color(LabelColor::Placeholder),
75+ ),
76+ ),
77+ )
78+ .child(div().h_px().w_full().fill(theme.lowest.base.default.border))
79+ .child(
80+ div()
81+ .py_0p5()
82+ .px_1()
83+ .flex()
84+ .flex_col()
85+ .grow()
86+ .max_h_96()
87+ .overflow_y_scroll(self.scroll_state.clone())
88+ .children(
89+ vec![if self.items.is_empty() {
90+ Some(
91+ div()
92+ .flex()
93+ .flex_row()
94+ .justify_between()
95+ .px_2()
96+ .py_1()
97+ .child(
98+ label(self.empty_string).color(LabelColor::Muted),
99+ ),
100+ )
101+ } else {
102+ None
103+ }]
104+ .into_iter()
105+ .flatten(),
106+ )
107+ .children(self.items.iter().map(|item| {
108+ div()
109+ .flex()
110+ .flex_row()
111+ .justify_between()
112+ .px_2()
113+ .py_0p5()
114+ .rounded_lg()
115+ .hover()
116+ .fill(theme.lowest.base.hovered.background)
117+ .active()
118+ .fill(theme.lowest.base.pressed.background)
119+ .child(palette_item(item.label, item.keybinding))
120+ })),
121+ ),
122+ )
123+ }
124+}
crates/ui/src/modules/project_panel.rs+0−94
@@ -1,94 +0,0 @@
1−use std::marker::PhantomData;
2−
3−use gpui2::elements::div;
4−use gpui2::elements::div::ScrollState;
5−use gpui2::style::StyleHelpers;
6−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
7−
8−use crate::prelude::*;
9−use crate::{details, input, label, list_item, theme, IconAsset, LabelColor};
10−
11−#[derive(Element)]
12−pub struct ProjectPanel<V: 'static> {
13− view_type: PhantomData<V>,
14− scroll_state: ScrollState,
15−}
16−
17−pub fn project_panel<V: 'static>(scroll_state: ScrollState) -> ProjectPanel<V> {
18− ProjectPanel {
19− view_type: PhantomData,
20− scroll_state,
21− }
22−}
23−
24−impl<V: 'static> ProjectPanel<V> {
25− fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
26− let theme = theme(cx);
27−
28− div()
29− .w_56()
30− .h_full()
31− .flex()
32− .flex_col()
33− .fill(theme.middle.base.default.background)
34− .child(
35− div()
36− .w_56()
37− .flex()
38− .flex_col()
39− .overflow_y_scroll(self.scroll_state.clone())
40− .child(details("This is a long string that should wrap when it keeps going for a long time.").meta_text("6 h ago)"))
41− .child(
42− div().flex().flex_col().children(
43− std::iter::repeat_with(|| {
44− vec![
45− list_item(label("sqlez").color(LabelColor::Modified))
46− .left_icon(IconAsset::FolderOpen.into())
47− .indent_level(0)
48− .set_toggle(ToggleState::NotToggled),
49− list_item(label("storybook").color(LabelColor::Modified))
50− .left_icon(IconAsset::FolderOpen.into())
51− .indent_level(0)
52− .set_toggle(ToggleState::Toggled),
53− list_item(label("docs").color(LabelColor::Default))
54− .left_icon(IconAsset::Folder.into())
55− .indent_level(1)
56− .set_toggle(ToggleState::Toggled),
57− list_item(label("src").color(LabelColor::Modified))
58− .left_icon(IconAsset::FolderOpen.into())
59− .indent_level(2)
60− .set_toggle(ToggleState::Toggled),
61− list_item(label("ui").color(LabelColor::Modified))
62− .left_icon(IconAsset::FolderOpen.into())
63− .indent_level(3)
64− .set_toggle(ToggleState::Toggled),
65− list_item(label("component").color(LabelColor::Created))
66− .left_icon(IconAsset::FolderOpen.into())
67− .indent_level(4)
68− .set_toggle(ToggleState::Toggled),
69− list_item(label("facepile.rs").color(LabelColor::Default))
70− .left_icon(IconAsset::File.into())
71− .indent_level(5),
72− list_item(label("follow_group.rs").color(LabelColor::Default))
73− .left_icon(IconAsset::File.into())
74− .indent_level(5),
75− list_item(label("list_item.rs").color(LabelColor::Created))
76− .left_icon(IconAsset::File.into())
77− .indent_level(5),
78− list_item(label("tab.rs").color(LabelColor::Default))
79− .left_icon(IconAsset::File.into())
80− .indent_level(5),
81− ]
82− })
83− .take(10)
84− .flatten(),
85− ),
86− ),
87− )
88− .child(
89− input("Find something...")
90− .value("buffe".to_string())
91− .state(InteractionState::Focused),
92− )
93− }
94−}
crates/ui/src/prelude.rs+15−0
@@ -1,3 +1,11 @@
1+#[derive(Default, PartialEq)]
2+pub enum OrderMethod {
3+ #[default]
4+ Ascending,
5+ Descending,
6+ MostRecent,
7+}
8+
19 #[derive(Default, PartialEq)]
210 pub enum ButtonVariant {
311 #[default]
@@ -19,6 +27,13 @@ pub enum Shape { · 15 unmodified lines
1927 RoundedRectangle,
2028 }
2129
30+#[derive(Default, PartialEq, Clone, Copy)]
31+pub enum DisclosureControlVisibility {
32+ #[default]
33+ OnHover,
34+ Always,
35+}
36+
2237 #[derive(Default, PartialEq, Clone, Copy)]
2338 pub enum InteractionState {
2439 #[default]
crates/ui/src/static_data.rs+166−0
@@ -0,0 +1,166 @@
1+use crate::{
2+ label, list_item, palette_item, IconAsset, LabelColor, ListItem, PaletteItem, ToggleState,
3+};
4+
5+pub fn static_project_panel_project_items() -> Vec<ListItem> {
6+ vec![
7+ list_item(label("zed"))
8+ .left_icon(IconAsset::FolderOpen.into())
9+ .indent_level(0)
10+ .set_toggle(ToggleState::Toggled),
11+ list_item(label(".cargo"))
12+ .left_icon(IconAsset::Folder.into())
13+ .indent_level(1),
14+ list_item(label(".config"))
15+ .left_icon(IconAsset::Folder.into())
16+ .indent_level(1),
17+ list_item(label(".git").color(LabelColor::Hidden))
18+ .left_icon(IconAsset::Folder.into())
19+ .indent_level(1),
20+ list_item(label(".cargo"))
21+ .left_icon(IconAsset::Folder.into())
22+ .indent_level(1),
23+ list_item(label(".idea").color(LabelColor::Hidden))
24+ .left_icon(IconAsset::Folder.into())
25+ .indent_level(1),
26+ list_item(label("assets"))
27+ .left_icon(IconAsset::Folder.into())
28+ .indent_level(1)
29+ .set_toggle(ToggleState::Toggled),
30+ list_item(label("cargo-target").color(LabelColor::Hidden))
31+ .left_icon(IconAsset::Folder.into())
32+ .indent_level(1),
33+ list_item(label("crates"))
34+ .left_icon(IconAsset::FolderOpen.into())
35+ .indent_level(1)
36+ .set_toggle(ToggleState::Toggled),
37+ list_item(label("activity_indicator"))
38+ .left_icon(IconAsset::Folder.into())
39+ .indent_level(2),
40+ list_item(label("ai"))
41+ .left_icon(IconAsset::Folder.into())
42+ .indent_level(2),
43+ list_item(label("audio"))
44+ .left_icon(IconAsset::Folder.into())
45+ .indent_level(2),
46+ list_item(label("auto_update"))
47+ .left_icon(IconAsset::Folder.into())
48+ .indent_level(2),
49+ list_item(label("breadcrumbs"))
50+ .left_icon(IconAsset::Folder.into())
51+ .indent_level(2),
52+ list_item(label("call"))
53+ .left_icon(IconAsset::Folder.into())
54+ .indent_level(2),
55+ list_item(label("sqlez").color(LabelColor::Modified))
56+ .left_icon(IconAsset::Folder.into())
57+ .indent_level(2)
58+ .set_toggle(ToggleState::NotToggled),
59+ list_item(label("gpui2"))
60+ .left_icon(IconAsset::FolderOpen.into())
61+ .indent_level(2)
62+ .set_toggle(ToggleState::Toggled),
63+ list_item(label("src"))
64+ .left_icon(IconAsset::FolderOpen.into())
65+ .indent_level(3)
66+ .set_toggle(ToggleState::Toggled),
67+ list_item(label("derrive_element.rs"))
68+ .left_icon(IconAsset::FileRust.into())
69+ .indent_level(4),
70+ list_item(label("storybook").color(LabelColor::Modified))
71+ .left_icon(IconAsset::FolderOpen.into())
72+ .indent_level(1)
73+ .set_toggle(ToggleState::Toggled),
74+ list_item(label("docs").color(LabelColor::Default))
75+ .left_icon(IconAsset::Folder.into())
76+ .indent_level(2)
77+ .set_toggle(ToggleState::Toggled),
78+ list_item(label("src").color(LabelColor::Modified))
79+ .left_icon(IconAsset::FolderOpen.into())
80+ .indent_level(3)
81+ .set_toggle(ToggleState::Toggled),
82+ list_item(label("ui").color(LabelColor::Modified))
83+ .left_icon(IconAsset::FolderOpen.into())
84+ .indent_level(4)
85+ .set_toggle(ToggleState::Toggled),
86+ list_item(label("component").color(LabelColor::Created))
87+ .left_icon(IconAsset::FolderOpen.into())
88+ .indent_level(5)
89+ .set_toggle(ToggleState::Toggled),
90+ list_item(label("facepile.rs").color(LabelColor::Default))
91+ .left_icon(IconAsset::FileRust.into())
92+ .indent_level(6),
93+ list_item(label("follow_group.rs").color(LabelColor::Default))
94+ .left_icon(IconAsset::FileRust.into())
95+ .indent_level(6),
96+ list_item(label("list_item.rs").color(LabelColor::Created))
97+ .left_icon(IconAsset::FileRust.into())
98+ .indent_level(6),
99+ list_item(label("tab.rs").color(LabelColor::Default))
100+ .left_icon(IconAsset::FileRust.into())
101+ .indent_level(6),
102+ list_item(label("target").color(LabelColor::Hidden))
103+ .left_icon(IconAsset::Folder.into())
104+ .indent_level(1),
105+ list_item(label(".dockerignore"))
106+ .left_icon(IconAsset::File.into())
107+ .indent_level(1),
108+ list_item(label(".DS_Store").color(LabelColor::Hidden))
109+ .left_icon(IconAsset::File.into())
110+ .indent_level(1),
111+ list_item(label("Cargo.lock"))
112+ .left_icon(IconAsset::FileLock.into())
113+ .indent_level(1),
114+ list_item(label("Cargo.toml"))
115+ .left_icon(IconAsset::FileToml.into())
116+ .indent_level(1),
117+ list_item(label("Dockerfile"))
118+ .left_icon(IconAsset::File.into())
119+ .indent_level(1),
120+ list_item(label("Procfile"))
121+ .left_icon(IconAsset::File.into())
122+ .indent_level(1),
123+ list_item(label("README.md"))
124+ .left_icon(IconAsset::FileDoc.into())
125+ .indent_level(1),
126+ ]
127+}
128+
129+pub fn static_project_panel_single_items() -> Vec<ListItem> {
130+ vec![
131+ list_item(label("todo.md"))
132+ .left_icon(IconAsset::FileDoc.into())
133+ .indent_level(0),
134+ list_item(label("README.md"))
135+ .left_icon(IconAsset::FileDoc.into())
136+ .indent_level(0),
137+ list_item(label("config.json"))
138+ .left_icon(IconAsset::File.into())
139+ .indent_level(0),
140+ ]
141+}
142+
143+pub fn example_editor_actions() -> Vec<PaletteItem> {
144+ vec![
145+ palette_item("New File", Some("Ctrl+N")),
146+ palette_item("Open File", Some("Ctrl+O")),
147+ palette_item("Save File", Some("Ctrl+S")),
148+ palette_item("Cut", Some("Ctrl+X")),
149+ palette_item("Copy", Some("Ctrl+C")),
150+ palette_item("Paste", Some("Ctrl+V")),
151+ palette_item("Undo", Some("Ctrl+Z")),
152+ palette_item("Redo", Some("Ctrl+Shift+Z")),
153+ palette_item("Find", Some("Ctrl+F")),
154+ palette_item("Replace", Some("Ctrl+R")),
155+ palette_item("Jump to Line", None),
156+ palette_item("Select All", None),
157+ palette_item("Deselect All", None),
158+ palette_item("Switch Document", None),
159+ palette_item("Insert Line Below", None),
160+ palette_item("Insert Line Above", None),
161+ palette_item("Move Line Up", None),
162+ palette_item("Move Line Down", None),
163+ palette_item("Toggle Comment", None),
164+ palette_item("Delete Line", None),
165+ ]
166+}
crates/ui/src/templates.rs+17−0
@@ -0,0 +1,17 @@
1+mod chat_panel;
2+mod collab_panel;
3+mod command_palette;
4+mod project_panel;
5+mod status_bar;
6+mod tab_bar;
7+mod title_bar;
8+mod workspace;
9+
10+pub use chat_panel::*;
11+pub use collab_panel::*;
12+pub use command_palette::*;
13+pub use project_panel::*;
14+pub use status_bar::*;
15+pub use tab_bar::*;
16+pub use title_bar::*;
17+pub use workspace::*;
crates/ui/src/templates/chat_panel.rsrenamed from crates/ui/src/modules/chat_panel.rs+4−4
@@ -1,11 +1,11 @@
11 use std::marker::PhantomData;
22
3−use gpui2::elements::div;
3+use crate::icon_button;
4+use crate::theme::theme;
45 use gpui2::elements::div::ScrollState;
56 use gpui2::style::StyleHelpers;
6−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
7−
8−use crate::{icon_button, theme};
7+use gpui2::{elements::div, IntoElement};
8+use gpui2::{Element, ParentElement, ViewContext};
99
1010 #[derive(Element)]
1111 pub struct ChatPanel<V: 'static> {
crates/ui/src/templates/collab_panel.rs+177−0
@@ -0,0 +1,177 @@
1+use crate::theme::{theme, Theme};
2+use gpui2::{
3+ elements::{div, div::ScrollState, img, svg},
4+ style::{StyleHelpers, Styleable},
5+ ArcCow, Element, IntoElement, ParentElement, ViewContext,
6+};
7+use std::marker::PhantomData;
8+
9+#[derive(Element)]
10+pub struct CollabPanelElement<V: 'static> {
11+ view_type: PhantomData<V>,
12+ scroll_state: ScrollState,
13+}
14+
15+// When I improve child view rendering, I'd like to have V implement a trait that
16+// provides the scroll state, among other things.
17+pub fn collab_panel<V: 'static>(scroll_state: ScrollState) -> CollabPanelElement<V> {
18+ CollabPanelElement {
19+ view_type: PhantomData,
20+ scroll_state,
21+ }
22+}
23+
24+impl<V: 'static> CollabPanelElement<V> {
25+ fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
26+ let theme = theme(cx);
27+
28+ // Panel
29+ div()
30+ .w_64()
31+ .h_full()
32+ .flex()
33+ .flex_col()
34+ .font("Zed Sans Extended")
35+ .text_color(theme.middle.base.default.foreground)
36+ .border_color(theme.middle.base.default.border)
37+ .border()
38+ .fill(theme.middle.base.default.background)
39+ .child(
40+ div()
41+ .w_full()
42+ .flex()
43+ .flex_col()
44+ .overflow_y_scroll(self.scroll_state.clone())
45+ // List Container
46+ .child(
47+ div()
48+ .fill(theme.lowest.base.default.background)
49+ .pb_1()
50+ .border_color(theme.lowest.base.default.border)
51+ .border_b()
52+ //:: https://tailwindcss.com/docs/hover-focus-and-other-states#styling-based-on-parent-state
53+ // .group()
54+ // List Section Header
55+ .child(self.list_section_header("#CRDB", true, theme))
56+ // List Item Large
57+ .child(self.list_item(
58+ "http://github.com/maxbrunsfeld.png?s=50",
59+ "maxbrunsfeld",
60+ theme,
61+ )),
62+ )
63+ .child(
64+ div()
65+ .py_2()
66+ .flex()
67+ .flex_col()
68+ .child(self.list_section_header("CHANNELS", true, theme)),
69+ )
70+ .child(
71+ div()
72+ .py_2()
73+ .flex()
74+ .flex_col()
75+ .child(self.list_section_header("CONTACTS", true, theme))
76+ .children(
77+ std::iter::repeat_with(|| {
78+ vec![
79+ self.list_item(
80+ "http://github.com/as-cii.png?s=50",
81+ "as-cii",
82+ theme,
83+ ),
84+ self.list_item(
85+ "http://github.com/nathansobo.png?s=50",
86+ "nathansobo",
87+ theme,
88+ ),
89+ self.list_item(
90+ "http://github.com/maxbrunsfeld.png?s=50",
91+ "maxbrunsfeld",
92+ theme,
93+ ),
94+ ]
95+ })
96+ .take(3)
97+ .flatten(),
98+ ),
99+ ),
100+ )
101+ .child(
102+ div()
103+ .h_7()
104+ .px_2()
105+ .border_t()
106+ .border_color(theme.middle.variant.default.border)
107+ .flex()
108+ .items_center()
109+ .child(
110+ div()
111+ .text_sm()
112+ .text_color(theme.middle.variant.default.foreground)
113+ .child("Find..."),
114+ ),
115+ )
116+ }
117+
118+ fn list_section_header(
119+ &self,
120+ label: impl Into<ArcCow<'static, str>>,
121+ expanded: bool,
122+ theme: &Theme,
123+ ) -> impl Element<V> {
124+ div()
125+ .h_7()
126+ .px_2()
127+ .flex()
128+ .justify_between()
129+ .items_center()
130+ .child(div().flex().gap_1().text_sm().child(label))
131+ .child(
132+ div().flex().h_full().gap_1().items_center().child(
133+ svg()
134+ .path(if expanded {
135+ "icons/caret_down.svg"
136+ } else {
137+ "icons/caret_up.svg"
138+ })
139+ .w_3p5()
140+ .h_3p5()
141+ .fill(theme.middle.variant.default.foreground),
142+ ),
143+ )
144+ }
145+
146+ fn list_item(
147+ &self,
148+ avatar_uri: impl Into<ArcCow<'static, str>>,
149+ label: impl Into<ArcCow<'static, str>>,
150+ theme: &Theme,
151+ ) -> impl Element<V> {
152+ div()
153+ .h_7()
154+ .px_2()
155+ .flex()
156+ .items_center()
157+ .hover()
158+ .fill(theme.lowest.variant.hovered.background)
159+ .active()
160+ .fill(theme.lowest.variant.pressed.background)
161+ .child(
162+ div()
163+ .flex()
164+ .items_center()
165+ .gap_1()
166+ .text_sm()
167+ .child(
168+ img()
169+ .uri(avatar_uri)
170+ .size_3p5()
171+ .rounded_full()
172+ .fill(theme.middle.positive.default.foreground),
173+ )
174+ .child(label),
175+ )
176+ }
177+}
crates/ui/src/templates/command_palette.rs+31−0
@@ -0,0 +1,31 @@
1+use gpui2::elements::div;
2+use gpui2::{elements::div::ScrollState, ViewContext};
3+use gpui2::{Element, IntoElement, ParentElement};
4+use std::marker::PhantomData;
5+
6+use crate::{example_editor_actions, palette, OrderMethod};
7+
8+#[derive(Element)]
9+pub struct CommandPalette<V: 'static> {
10+ view_type: PhantomData<V>,
11+ scroll_state: ScrollState,
12+}
13+
14+pub fn command_palette<V: 'static>(scroll_state: ScrollState) -> CommandPalette<V> {
15+ CommandPalette {
16+ view_type: PhantomData,
17+ scroll_state,
18+ }
19+}
20+
21+impl<V: 'static> CommandPalette<V> {
22+ fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
23+ div().child(
24+ palette(self.scroll_state.clone())
25+ .items(example_editor_actions())
26+ .placeholder("Execute a command...")
27+ .empty_string("No items found.")
28+ .default_order(OrderMethod::Ascending),
29+ )
30+ }
31+}
crates/ui/src/templates/project_panel.rs+62−0
@@ -0,0 +1,62 @@
1+use crate::{
2+ input, list, list_section_header, prelude::*, static_project_panel_project_items,
3+ static_project_panel_single_items, theme,
4+};
5+
6+use gpui2::{
7+ elements::{div, div::ScrollState},
8+ style::StyleHelpers,
9+ ParentElement, ViewContext,
10+};
11+use gpui2::{Element, IntoElement};
12+use std::marker::PhantomData;
13+
14+#[derive(Element)]
15+pub struct ProjectPanel<V: 'static> {
16+ view_type: PhantomData<V>,
17+ scroll_state: ScrollState,
18+}
19+
20+pub fn project_panel<V: 'static>(scroll_state: ScrollState) -> ProjectPanel<V> {
21+ ProjectPanel {
22+ view_type: PhantomData,
23+ scroll_state,
24+ }
25+}
26+
27+impl<V: 'static> ProjectPanel<V> {
28+ fn render(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
29+ let theme = theme(cx);
30+
31+ div()
32+ .w_56()
33+ .h_full()
34+ .flex()
35+ .flex_col()
36+ .fill(theme.middle.base.default.background)
37+ .child(
38+ div()
39+ .w_56()
40+ .flex()
41+ .flex_col()
42+ .overflow_y_scroll(self.scroll_state.clone())
43+ .child(
44+ list(static_project_panel_single_items())
45+ .header(list_section_header("FILES").set_toggle(ToggleState::Toggled))
46+ .empty_message("No files in directory")
47+ .set_toggle(ToggleState::Toggled),
48+ )
49+ .child(
50+ list(static_project_panel_project_items())
51+ .header(list_section_header("PROJECT").set_toggle(ToggleState::Toggled))
52+ .empty_message("No folders in directory")
53+ .set_toggle(ToggleState::Toggled),
54+ ),
55+ )
56+ .child(
57+ input("Find something...")
58+ .value("buffe".to_string())
59+ .state(InteractionState::Focused),
60+ )
61+ }
62+}
crates/ui/src/templates/status_bar.rsrenamed from crates/ui/src/modules/status_bar.rs+3−4
@@ -1,11 +1,10 @@
11 use std::marker::PhantomData;
22
3−use gpui2::elements::div;
4−use gpui2::style::StyleHelpers;
5−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
6−
73 use crate::theme::{theme, Theme};
84 use crate::{icon_button, text_button, tool_divider};
5+use gpui2::style::StyleHelpers;
6+use gpui2::{elements::div, IntoElement};
7+use gpui2::{Element, ParentElement, ViewContext};
98
109 #[derive(Default, PartialEq)]
1110 pub enum Tool {
crates/ui/src/templates/tab_bar.rsrenamed from crates/ui/src/modules/tab_bar.rs+5−5
@@ -1,12 +1,12 @@
11 use std::marker::PhantomData;
22
3−use gpui2::elements::div;
3+use crate::prelude::InteractionState;
4+use crate::theme::theme;
5+use crate::{icon_button, tab};
46 use gpui2::elements::div::ScrollState;
57 use gpui2::style::StyleHelpers;
6−use gpui2::{Element, IntoElement, ParentElement, ViewContext};
7−
8−use crate::prelude::InteractionState;
9−use crate::{icon_button, tab, theme};
8+use gpui2::{elements::div, IntoElement};
9+use gpui2::{Element, ParentElement, ViewContext};
1010
1111 #[derive(Element)]
1212 pub struct TabBar<V: 'static> {
crates/ui/src/templates/title_bar.rsrenamed from crates/ui/src/modules/title_bar.rs+0−0

File renamed without changes.

crates/ui/src/templates/workspace.rs+80−0
@@ -0,0 +1,80 @@
1+use crate::{chat_panel, collab_panel, project_panel, status_bar, tab_bar, theme, title_bar};
2+
3+use gpui2::{
4+ elements::{div, div::ScrollState},
5+ style::StyleHelpers,
6+ Element, IntoElement, ParentElement, ViewContext,
7+};
8+
9+#[derive(Element, Default)]
10+struct WorkspaceElement {
11+ project_panel_scroll_state: ScrollState,
12+ collab_panel_scroll_state: ScrollState,
13+ right_scroll_state: ScrollState,
14+ tab_bar_scroll_state: ScrollState,
15+ palette_scroll_state: ScrollState,
16+}
17+
18+pub fn workspace<V: 'static>() -> impl Element<V> {
19+ WorkspaceElement::default()
20+}
21+
22+impl WorkspaceElement {
23+ fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
24+ let theme = theme(cx);
25+
26+ div()
27+ // Elevation Level 0
28+ .size_full()
29+ .flex()
30+ .flex_col()
31+ .font("Zed Sans Extended")
32+ .gap_0()
33+ .justify_start()
34+ .items_start()
35+ .text_color(theme.lowest.base.default.foreground)
36+ .fill(theme.lowest.base.default.background)
37+ .relative()
38+ // Elevation Level 1
39+ .child(title_bar())
40+ .child(
41+ div()
42+ .flex_1()
43+ .w_full()
44+ .flex()
45+ .flex_row()
46+ .overflow_hidden()
47+ .child(project_panel(self.project_panel_scroll_state.clone()))
48+ .child(collab_panel(self.collab_panel_scroll_state.clone()))
49+ .child(
50+ div()
51+ .h_full()
52+ .flex_1()
53+ .fill(theme.highest.base.default.background)
54+ .child(
55+ div()
56+ .flex()
57+ .flex_col()
58+ .flex_1()
59+ .child(tab_bar(self.tab_bar_scroll_state.clone())),
60+ ),
61+ )
62+ .child(chat_panel(self.right_scroll_state.clone())),
63+ )
64+ .child(status_bar())
65+ // Elevation Level 3
66+ // .child(
67+ // div()
68+ // .absolute()
69+ // .top_0()
70+ // .left_0()
71+ // .size_full()
72+ // .flex()
73+ // .justify_center()
74+ // .items_center()
75+ // // .fill(theme.lowest.base.default.background)
76+ // // Elevation Level 4
77+ // .child(command_palette(self.palette_scroll_state.clone())),
78+ // )
79+ }
80+}
crates/ui/src/tokens.rs+18−0
@@ -0,0 +1,18 @@
1+use gpui2::geometry::AbsoluteLength;
2+
3+#[derive(Clone, Copy)]
4+pub struct Token {
5+ pub list_indent_depth: AbsoluteLength,
6+}
7+
8+impl Default for Token {
9+ fn default() -> Self {
10+ Self {
11+ list_indent_depth: AbsoluteLength::Rems(0.5),
12+ }
13+ }
14+}
15+
16+pub fn token() -> Token {
17+ Token::default()
18+}
docs/ui/states.md+0−43
@@ -1,43 +0,0 @@
1−## Interaction State
2−
3−**Enabled**
4−
5−An enabled state communicates an interactive component or element.
6−
7−**Disabled**
8−
9−A disabled state communicates a inoperable component or element.
10−
11−**Hover**
12−
13−A hover state communicates when a user has placed a cursor above an interactive element.
14−
15−**Focused**
16−
17−A focused state communicates when a user has highlighted an element, using an input method such as a keyboard or voice.
18−
19−**Activated**
20−
21−An activated state communicates a highlighted destination, whether initiated by the user or by default.
22−
23−**Pressed**
24−
25−A pressed state communicates a user tap.
26−
27−**Dragged**
28−
29−A dragged state communicates when a user presses and moves an element.
30−
31−## Selected State
32−
33−**Unselected**
34−
35−dfa
36−
37−**Partially Selected**
38−
39−daf
40−
41−**Selected**
42−
43−dfa

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t