Files
oak-gpui/crates/extensions_ui/src/components/extension_card.rs
T
Danilo Leal 9b37206147 extensions_ui: Add design changes to expose the filters more (#29582)
Closes https://github.com/zed-industries/zed/issues/28086

The main motivator for this change is to have the "MCP Servers" filter
more clearly visible. And because of this, all other filters end up more
visible, as they're not in a dropdown menu anymore. Ended up pushing
some other small changes here and there as well. This is our final
product:

<img
src="https://github.com/user-attachments/assets/16ac78b6-72d9-4a8a-801b-b4b992221331"
width="700"/>

Release Notes:

- N/A
2025-04-29 07:54:39 -03:00

63 lines
1.9 KiB
Rust

use gpui::{AnyElement, prelude::*};
use smallvec::SmallVec;
use ui::prelude::*;
#[derive(IntoElement)]
pub struct ExtensionCard {
overridden_by_dev_extension: bool,
children: SmallVec<[AnyElement; 2]>,
}
impl ExtensionCard {
pub fn new() -> Self {
Self {
overridden_by_dev_extension: false,
children: SmallVec::new(),
}
}
pub fn overridden_by_dev_extension(mut self, overridden: bool) -> Self {
self.overridden_by_dev_extension = overridden;
self
}
}
impl ParentElement for ExtensionCard {
fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
self.children.extend(elements)
}
}
impl RenderOnce for ExtensionCard {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
div().w_full().child(
v_flex()
.w_full()
.h(rems(7.))
.p_3()
.mt_4()
.gap_2()
.bg(cx.theme().colors().elevated_surface_background)
.border_1()
.border_color(cx.theme().colors().border)
.rounded_md()
.children(self.children)
.when(self.overridden_by_dev_extension, |card| {
card.child(
h_flex()
.absolute()
.top_0()
.left_0()
.block_mouse_down()
.cursor_default()
.size_full()
.items_center()
.justify_center()
.bg(cx.theme().colors().elevated_surface_background.alpha(0.8))
.child(Label::new("Overridden by dev extension.")),
)
}),
)
}
}