forked from zed-industries/zed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: Iterate on design of REPL sessions view (zed-industries#14987)
This PR iterates on the design of the REPL sessions view. We now use the same component for both available kernels and running ones to provide some consistency between the two modes: <img width="1208" alt="Screenshot 2024-07-22 at 6 49 08 PM" src="https://github.com/user-attachments/assets/8b5c3600-e438-49fa-8484-cefabf4b44f1"> <img width="1208" alt="Screenshot 2024-07-22 at 6 49 14 PM" src="https://github.com/user-attachments/assets/5125e9b3-6465-4d1e-9036-e6ca270dedcb"> Release Notes: - N/A
- Loading branch information
1 parent
01392c1
commit fe1f55c
Showing
6 changed files
with
188 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod kernel_list_item; | ||
|
||
pub use kernel_list_item::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use gpui::AnyElement; | ||
use ui::{prelude::*, Indicator, ListItem}; | ||
|
||
use crate::KernelSpecification; | ||
|
||
#[derive(IntoElement)] | ||
pub struct KernelListItem { | ||
kernel_specification: KernelSpecification, | ||
status_color: Color, | ||
buttons: Vec<AnyElement>, | ||
children: Vec<AnyElement>, | ||
} | ||
|
||
impl KernelListItem { | ||
pub fn new(kernel_specification: KernelSpecification) -> Self { | ||
Self { | ||
kernel_specification, | ||
status_color: Color::Disabled, | ||
buttons: Vec::new(), | ||
children: Vec::new(), | ||
} | ||
} | ||
|
||
pub fn status_color(mut self, color: Color) -> Self { | ||
self.status_color = color; | ||
self | ||
} | ||
|
||
pub fn button(mut self, button: impl IntoElement) -> Self { | ||
self.buttons.push(button.into_any_element()); | ||
self | ||
} | ||
|
||
pub fn buttons(mut self, buttons: impl IntoIterator<Item = impl IntoElement>) -> Self { | ||
self.buttons | ||
.extend(buttons.into_iter().map(|button| button.into_any_element())); | ||
self | ||
} | ||
} | ||
|
||
impl ParentElement for KernelListItem { | ||
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) { | ||
self.children.extend(elements); | ||
} | ||
} | ||
|
||
impl RenderOnce for KernelListItem { | ||
fn render(self, _cx: &mut WindowContext) -> impl IntoElement { | ||
ListItem::new(SharedString::from(self.kernel_specification.name.clone())) | ||
.selectable(false) | ||
.start_slot( | ||
h_flex() | ||
.size_3() | ||
.justify_center() | ||
.child(Indicator::dot().color(self.status_color)), | ||
) | ||
.children(self.children) | ||
.end_slot(h_flex().gap_2().children(self.buttons)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.