Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Add `shadow_xs`, `shadow_2xs` and fix shadow values to match Tailwind CSS (#33361)

Jason Leef34a7abf17b2
diff --git a/crates/component/src/component_layout.rs b/crates/component/src/component_layout.rs
index 9090c49cf9f..b749ea20eab 100644
--- a/crates/component/src/component_layout.rs
+++ b/crates/component/src/component_layout.rs
@@ -61,7 +61,7 @@ impl RenderOnce for ComponentExample {
12.0,
12.0,
))
- .shadow_sm()
+ .shadow_xs()
.child(self.element),
)
.into_any_element()
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index fb3d76d3440..47223aa59a8 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -8715,7 +8715,7 @@ impl Editor {
h_flex()
.bg(cx.theme().colors().editor_background)
.border(BORDER_WIDTH)
- .shadow_sm()
+ .shadow_xs()
.border_color(cx.theme().colors().border)
.rounded_l_lg()
.when(line_count > 1, |el| el.rounded_br_lg())
@@ -8915,7 +8915,7 @@ impl Editor {
.border_1()
.bg(Self::edit_prediction_line_popover_bg_color(cx))
.border_color(Self::edit_prediction_callout_popover_border_color(cx))
- .shadow_sm()
+ .shadow_xs()
.when(!has_keybind, |el| {
let status_colors = cx.theme().status();
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 2aea0ef956b..3fa8697c193 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -1875,7 +1875,7 @@ impl EditorElement {
let mut minimap = div()
.size_full()
- .shadow_sm()
+ .shadow_xs()
.px(PADDING_OFFSET)
.child(minimap_editor)
.into_any_element();
diff --git a/crates/gpui/examples/shadow.rs b/crates/gpui/examples/shadow.rs
index c42b0f55f0d..352e29c042a 100644
--- a/crates/gpui/examples/shadow.rs
+++ b/crates/gpui/examples/shadow.rs
@@ -156,6 +156,10 @@ impl Render for Shadow {
.w_full()
.children(vec![
example("None", Shadow::base()),
+ // 2Xsmall shadow
+ example("2X Small", Shadow::base().shadow_2xs()),
+ // Xsmall shadow
+ example("Extra Small", Shadow::base().shadow_xs()),
// Small shadow
example("Small", Shadow::base().shadow_sm()),
// Medium shadow
diff --git a/crates/gpui_macros/src/styles.rs b/crates/gpui_macros/src/styles.rs
index 4e3dda9ed24..36d46cfb515 100644
--- a/crates/gpui_macros/src/styles.rs
+++ b/crates/gpui_macros/src/styles.rs
@@ -407,7 +407,22 @@ pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
/// Sets the box shadow of the element.
/// [Docs](https://tailwindcss.com/docs/box-shadow)
- #visibility fn shadow_sm(mut self) -> Self {
+ #visibility fn shadow_2xs(mut self) -> Self {
+ use gpui::{BoxShadow, hsla, point, px};
+ use std::vec;
+
+ self.style().box_shadow = Some(vec![BoxShadow {
+ color: hsla(0., 0., 0., 0.05),
+ offset: point(px(0.), px(1.)),
+ blur_radius: px(0.),
+ spread_radius: px(0.),
+ }]);
+ self
+ }
+
+ /// Sets the box shadow of the element.
+ /// [Docs](https://tailwindcss.com/docs/box-shadow)
+ #visibility fn shadow_xs(mut self) -> Self {
use gpui::{BoxShadow, hsla, point, px};
use std::vec;
@@ -420,6 +435,29 @@ pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
self
}
+ /// Sets the box shadow of the element.
+ /// [Docs](https://tailwindcss.com/docs/box-shadow)
+ #visibility fn shadow_sm(mut self) -> Self {
+ use gpui::{BoxShadow, hsla, point, px};
+ use std::vec;
+
+ self.style().box_shadow = Some(vec![
+ BoxShadow {
+ color: hsla(0., 0., 0., 0.1),
+ offset: point(px(0.), px(1.)),
+ blur_radius: px(3.),
+ spread_radius: px(0.),
+ },
+ BoxShadow {
+ color: hsla(0., 0., 0., 0.1),
+ offset: point(px(0.), px(1.)),
+ blur_radius: px(2.),
+ spread_radius: px(-1.),
+ }
+ ]);
+ self
+ }
+
/// Sets the box shadow of the element.
/// [Docs](https://tailwindcss.com/docs/box-shadow)
#visibility fn shadow_md(mut self) -> Self {
@@ -428,7 +466,7 @@ pub fn box_shadow_style_methods(input: TokenStream) -> TokenStream {
self.style().box_shadow = Some(vec![
BoxShadow {
- color: hsla(0.5, 0., 0., 0.1),
+ color: hsla(0., 0., 0., 0.1),
offset: point(px(0.), px(4.)),
blur_radius: px(6.),
spread_radius: px(-1.),
diff --git a/crates/repl/src/notebook/cell.rs b/crates/repl/src/notebook/cell.rs
index 7bfb2ed69cf..2ed68c17d13 100644
--- a/crates/repl/src/notebook/cell.rs
+++ b/crates/repl/src/notebook/cell.rs
@@ -656,7 +656,7 @@ impl Render for CodeCell {
// .bg(cx.theme().colors().editor_background)
// .border(px(1.))
// .border_color(cx.theme().colors().border)
- // .shadow_sm()
+ // .shadow_xs()
.children(content)
},
))),