fix(ui): popups get Fluent shadows and a lighter level when nested
- New elevation tokens (vendor gpui-component elevation.rs): Fluent dark shadow8/16/28/64 (ambient 0.24, key 0.28, blur halved for GPUI), flyout levels, dialog, toast - Flyout level follows open modal layers per window: framework dialog layer and AppShell dialogs report their count, so a dropdown inside a dialog gets the lighter fill and hover - popover_style (menus, popovers, selects, combobox, date picker), tooltips, notifications and the framework dialog read the tokens - Hand-rolled flyouts and dialogs use theme::ElevatedSurface; skin tone picker is a nested flyout; call dialogs and mini call use the shared shadows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -1,5 +1,6 @@
1
1
use std::borrow::Cow;
2
2
3
use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};
3
4
use gpui_kit::component::{Theme, ThemeMode};
4
5
use gpui_kit::*;
5
6
@@ -19,6 +20,8 @@ const SURFACE_RAISED: u32 = 0x232325;
19
20
const ROW_HOVER: u32 = 0x1c1c1e;
20
21
const POPUP: u32 = 0x2c2c2f;
21
22
const POPUP_HOVER: u32 = 0x38383c;
23
const POPUP_NESTED: u32 = 0x3a3a3e;
24
const POPUP_NESTED_HOVER: u32 = 0x47474c;
22
25
const REPLY_SURFACE: u32 = 0x19191b;
23
26
const BORDER: u32 = 0x262628;
24
27
const BORDER_STRONG: u32 = 0x3f3f42;
@@ -141,8 +144,69 @@ pub fn apply(cx: &mut App) {
141
144
colors.list_hover = color(ROW_HOVER);
142
145
colors.list_active = color(SURFACE_RAISED);
143
146
});
147
cx.set_global(elevation_tokens());
148
}
149
150
fn elevation_tokens() -> ElevationTokens {
151
let flyout = Elevation {
152
fill: color(POPUP),
153
hover: color(POPUP_HOVER),
154
shadow: elevation::shadow16(),
155
};
156
let nested_flyout = Elevation {
157
fill: color(POPUP_NESTED),
158
hover: color(POPUP_NESTED_HOVER),
159
shadow: elevation::shadow16(),
160
};
161
ElevationTokens {
162
flyouts: vec![flyout.clone(), nested_flyout],
163
dialog: Elevation {
164
shadow: elevation::shadow64(),
165
..flyout.clone()
166
},
167
toast: Elevation {
168
shadow: elevation::shadow8(),
169
..flyout
170
},
171
}
172
}
173
174
pub fn flyout_shadow() -> Vec<BoxShadow> {
175
elevation::shadow16()
176
}
177
178
pub fn dialog_shadow() -> Vec<BoxShadow> {
179
elevation::shadow64()
180
}
181
182
pub fn toast_shadow() -> Vec<BoxShadow> {
183
elevation::shadow8()
144
184
}
145
185
186
pub fn popup_nested() -> Hsla {
187
color(POPUP_NESTED)
188
}
189
190
pub trait ElevatedSurface: Styled + Sized {
191
fn flyout_surface(self) -> Self {
192
self.bg(popup()).shadow(flyout_shadow())
193
}
194
195
fn nested_flyout_surface(self) -> Self {
196
self.bg(popup_nested()).shadow(flyout_shadow())
197
}
198
199
fn dialog_surface(self) -> Self {
200
self.bg(popup()).shadow(dialog_shadow())
201
}
202
203
fn toast_surface(self) -> Self {
204
self.bg(popup()).shadow(toast_shadow())
205
}
206
}
207
208
impl<T: Styled + Sized> ElevatedSurface for T {}
209
146
210
pub fn font_family() -> SharedString {
147
211
FONT_FAMILY.into()
148
212
}
@@ -341,11 +405,32 @@ pub fn avatar_palette_len() -> usize {
341
405
342
406
#[cfg(test)]
343
407
mod tests {
344
use super::{avatar_color, avatar_palette_len};
408
use super::{POPUP, POPUP_HOVER, POPUP_NESTED, avatar_color, avatar_palette_len, color, elevation_tokens};
345
409
346
410
#[test]
347
411
fn avatar_colors_wrap_around_the_palette() {
348
412
assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
349
413
assert_ne!(avatar_color(0), avatar_color(1));
350
414
}
415
416
#[test]
417
fn flyout_over_a_dialog_takes_a_lighter_fill_than_the_dialog() {
418
let tokens = elevation_tokens();
419
assert_eq!(tokens.dialog.fill, color(POPUP));
420
assert_eq!(tokens.flyout_at(0).fill, color(POPUP));
421
let nested = tokens.flyout_at(1);
422
assert_eq!(nested.fill, color(POPUP_NESTED));
423
assert!(nested.fill.l > tokens.dialog.fill.l);
424
assert!(nested.hover.l > nested.fill.l);
425
assert_ne!(nested.fill, color(POPUP_HOVER));
426
}
427
428
#[test]
429
fn fluent_shadow_blur_is_halved_for_gpui() {
430
let shadow = super::flyout_shadow();
431
assert_eq!(shadow[0].blur_radius, gpui_kit::px(1.));
432
assert_eq!(shadow[1].offset.y, gpui_kit::px(8.));
433
assert_eq!(shadow[1].blur_radius, gpui_kit::px(8.));
434
assert_eq!(super::dialog_shadow()[1].blur_radius, gpui_kit::px(32.));
435
}
351
436
}
@@ -1,5 +1,6 @@1
use std::borrow::Cow;1
use std::borrow::Cow;2
2
3
use gpui_kit::component::elevation::{self, Elevation, ElevationTokens};3
use gpui_kit::component::{Theme, ThemeMode};4
use gpui_kit::component::{Theme, ThemeMode};4
use gpui_kit::*;5
use gpui_kit::*;5
6
@@ -19,6 +20,8 @@ const SURFACE_RAISED: u32 = 0x232325;19
const ROW_HOVER: u32 = 0x1c1c1e;20
const ROW_HOVER: u32 = 0x1c1c1e;20
const POPUP: u32 = 0x2c2c2f;21
const POPUP: u32 = 0x2c2c2f;21
const POPUP_HOVER: u32 = 0x38383c;22
const POPUP_HOVER: u32 = 0x38383c;23
const POPUP_NESTED: u32 = 0x3a3a3e;24
const POPUP_NESTED_HOVER: u32 = 0x47474c;22
const REPLY_SURFACE: u32 = 0x19191b;25
const REPLY_SURFACE: u32 = 0x19191b;23
const BORDER: u32 = 0x262628;26
const BORDER: u32 = 0x262628;24
const BORDER_STRONG: u32 = 0x3f3f42;27
const BORDER_STRONG: u32 = 0x3f3f42;@@ -141,8 +144,69 @@ pub fn apply(cx: &mut App) {141
colors.list_hover = color(ROW_HOVER);144
colors.list_hover = color(ROW_HOVER);142
colors.list_active = color(SURFACE_RAISED);145
colors.list_active = color(SURFACE_RAISED);143
});146
});147
cx.set_global(elevation_tokens());148
}149
150
fn elevation_tokens() -> ElevationTokens {151
let flyout = Elevation {152
fill: color(POPUP),153
hover: color(POPUP_HOVER),154
shadow: elevation::shadow16(),155
};156
let nested_flyout = Elevation {157
fill: color(POPUP_NESTED),158
hover: color(POPUP_NESTED_HOVER),159
shadow: elevation::shadow16(),160
};161
ElevationTokens {162
flyouts: vec![flyout.clone(), nested_flyout],163
dialog: Elevation {164
shadow: elevation::shadow64(),165
..flyout.clone()166
},167
toast: Elevation {168
shadow: elevation::shadow8(),169
..flyout170
},171
}172
}173
174
pub fn flyout_shadow() -> Vec<BoxShadow> {175
elevation::shadow16()176
}177
178
pub fn dialog_shadow() -> Vec<BoxShadow> {179
elevation::shadow64()180
}181
182
pub fn toast_shadow() -> Vec<BoxShadow> {183
elevation::shadow8()144
}184
}145
185
186
pub fn popup_nested() -> Hsla {187
color(POPUP_NESTED)188
}189
190
pub trait ElevatedSurface: Styled + Sized {191
fn flyout_surface(self) -> Self {192
self.bg(popup()).shadow(flyout_shadow())193
}194
195
fn nested_flyout_surface(self) -> Self {196
self.bg(popup_nested()).shadow(flyout_shadow())197
}198
199
fn dialog_surface(self) -> Self {200
self.bg(popup()).shadow(dialog_shadow())201
}202
203
fn toast_surface(self) -> Self {204
self.bg(popup()).shadow(toast_shadow())205
}206
}207
208
impl<T: Styled + Sized> ElevatedSurface for T {}209
146
pub fn font_family() -> SharedString {210
pub fn font_family() -> SharedString {147
FONT_FAMILY.into()211
FONT_FAMILY.into()148
}212
}@@ -341,11 +405,32 @@ pub fn avatar_palette_len() -> usize {341
405
342
#[cfg(test)]406
#[cfg(test)]343
mod tests {407
mod tests {344
use super::{avatar_color, avatar_palette_len};408
use super::{POPUP, POPUP_HOVER, POPUP_NESTED, avatar_color, avatar_palette_len, color, elevation_tokens};345
409
346
#[test]410
#[test]347
fn avatar_colors_wrap_around_the_palette() {411
fn avatar_colors_wrap_around_the_palette() {348
assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));412
assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));349
assert_ne!(avatar_color(0), avatar_color(1));413
assert_ne!(avatar_color(0), avatar_color(1));350
}414
}415
416
#[test]417
fn flyout_over_a_dialog_takes_a_lighter_fill_than_the_dialog() {418
let tokens = elevation_tokens();419
assert_eq!(tokens.dialog.fill, color(POPUP));420
assert_eq!(tokens.flyout_at(0).fill, color(POPUP));421
let nested = tokens.flyout_at(1);422
assert_eq!(nested.fill, color(POPUP_NESTED));423
assert!(nested.fill.l > tokens.dialog.fill.l);424
assert!(nested.hover.l > nested.fill.l);425
assert_ne!(nested.fill, color(POPUP_HOVER));426
}427
428
#[test]429
fn fluent_shadow_blur_is_halved_for_gpui() {430
let shadow = super::flyout_shadow();431
assert_eq!(shadow[0].blur_radius, gpui_kit::px(1.));432
assert_eq!(shadow[1].offset.y, gpui_kit::px(8.));433
assert_eq!(shadow[1].blur_radius, gpui_kit::px(8.));434
assert_eq!(super::dialog_shadow()[1].blur_radius, gpui_kit::px(32.));435
}351
}436
}@@ -20,7 +20,7 @@ use super::{
20
20
mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,
21
21
};
22
22
use crate::app_state::AppState;
23
use crate::theme;
23
use crate::theme::{self, ElevatedSurface as _};
24
24
use crate::views::widgets::{icon, symbol};
25
25
26
26
const CARD_WIDTH: f32 = 520.;
@@ -661,7 +661,7 @@ impl Render for StartDialog {
661
661
.p(px(CARD_PADDING))
662
662
.gap(px(SECTION_GAP))
663
663
.rounded(px(CARD_RADIUS))
664
.bg(theme::popup())
664
.dialog_surface()
665
665
.text_color(theme::text())
666
666
.occlude()
667
667
.capture_key_down(cx.listener(Self::on_key_down))
@@ -20,7 +20,7 @@ use super::{20
mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,20
mcp_bridge, message_context, raise_notice, runs_handle, start_run, start_run_when_mcp_ready,21
};21
};22
use crate::app_state::AppState;22
use crate::app_state::AppState;23
use crate::theme;23
use crate::theme::{self, ElevatedSurface as _};24
use crate::views::widgets::{icon, symbol};24
use crate::views::widgets::{icon, symbol};25
25
26
const CARD_WIDTH: f32 = 520.;26
const CARD_WIDTH: f32 = 520.;@@ -661,7 +661,7 @@ impl Render for StartDialog {661
.p(px(CARD_PADDING))661
.p(px(CARD_PADDING))662
.gap(px(SECTION_GAP))662
.gap(px(SECTION_GAP))663
.rounded(px(CARD_RADIUS))663
.rounded(px(CARD_RADIUS))664
.bg(theme::popup())664
.dialog_surface()665
.text_color(theme::text())665
.text_color(theme::text())666
.occlude()666
.occlude()667
.capture_key_down(cx.listener(Self::on_key_down))667
.capture_key_down(cx.listener(Self::on_key_down))@@ -16,7 +16,7 @@ use super::transfer_picker::{PickerMode, TransferPicker};
16
16
use super::widgets::icon;
17
17
use crate::app_state::AppState;
18
18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};
19
use crate::theme;
19
use crate::theme::{self, ElevatedSurface as _};
20
20
21
21
const STAGE_RADIUS: f32 = 12.;
22
22
const THUMBNAIL_WIDTH: f32 = 64.;
@@ -242,7 +242,7 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE
242
242
.p(px(20.))
243
243
.gap(px(12.))
244
244
.rounded(px(10.))
245
.bg(theme::popup())
245
.dialog_surface()
246
246
.text_color(theme::text())
247
247
.occlude()
248
248
.child(
@@ -16,7 +16,7 @@ use super::transfer_picker::{PickerMode, TransferPicker};16
use super::widgets::icon;16
use super::widgets::icon;17
use crate::app_state::AppState;17
use crate::app_state::AppState;18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};18
use crate::call::{BackgroundPick, CallModel, RecordAction, RecordingChip};19
use crate::theme;19
use crate::theme::{self, ElevatedSurface as _};20
20
21
const STAGE_RADIUS: f32 = 12.;21
const STAGE_RADIUS: f32 = 12.;22
const THUMBNAIL_WIDTH: f32 = 64.;22
const THUMBNAIL_WIDTH: f32 = 64.;@@ -242,7 +242,7 @@ pub fn consent_overlay(app: &Entity<AppState>, model: &CallModel) -> Option<AnyE242
.p(px(20.))242
.p(px(20.))243
.gap(px(12.))243
.gap(px(12.))244
.rounded(px(10.))244
.rounded(px(10.))245
.bg(theme::popup())245
.dialog_surface()246
.text_color(theme::text())246
.text_color(theme::text())247
.occlude()247
.occlude()248
.child(248
.child(@@ -121,7 +121,7 @@ impl Render for CallMiniView {
121
121
.border_2()
122
122
.border_color(border)
123
123
.text_color(theme::text())
124
.shadow_lg()
124
.shadow(theme::flyout_shadow())
125
125
.cursor_pointer()
126
126
.on_click(move |_, _, cx| {
127
127
open_app.update(cx, |state, cx| state.show_call(true, cx));
@@ -121,7 +121,7 @@ impl Render for CallMiniView {121
.border_2()121
.border_2()122
.border_color(border)122
.border_color(border)123
.text_color(theme::text())123
.text_color(theme::text())124
.shadow_lg()124
.shadow(theme::flyout_shadow())125
.cursor_pointer()125
.cursor_pointer()126
.on_click(move |_, _, cx| {126
.on_click(move |_, _, cx| {127
open_app.update(cx, |state, cx| state.show_call(true, cx));127
open_app.update(cx, |state, cx| state.show_call(true, cx));@@ -656,7 +656,7 @@ pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyEl
656
656
.border_1()
657
657
.border_color(theme::border_strong())
658
658
.text_color(theme::text())
659
.shadow_lg()
659
.shadow(theme::dialog_shadow())
660
660
.occlude()
661
661
.child(
662
662
div()
@@ -656,7 +656,7 @@ pub fn options_dialog(app: &Entity<AppState>, call: &ActiveCall) -> Option<AnyEl656
.border_1()656
.border_1()657
.border_color(theme::border_strong())657
.border_color(theme::border_strong())658
.text_color(theme::text())658
.text_color(theme::text())659
.shadow_lg()659
.shadow(theme::dialog_shadow())660
.occlude()660
.occlude()661
.child(661
.child(662
div()662
div()@@ -53,7 +53,7 @@ pub use crate::outgoing::{EditPreview, Outgoing, ReplyPreview};
53
53
use crate::remote_image::RemoteImage;
54
54
use crate::runtime;
55
55
use crate::scheduled_rows::scheduled_label;
56
use crate::theme;
56
use crate::theme::{self, ElevatedSurface as _};
57
57
use crate::typing::OutgoingTyping;
58
58
59
59
const MIN_ROWS: usize = 1;
@@ -2154,7 +2154,7 @@ impl Composer {
2154
2154
.w(px(POPUP_WIDTH))
2155
2155
.py(px(6.))
2156
2156
.rounded(px(10.))
2157
.bg(theme::popup())
2157
.flyout_surface()
2158
2158
.occlude()
2159
2159
.children(rows)
2160
2160
.into_any_element(),
@@ -53,7 +53,7 @@ pub use crate::outgoing::{EditPreview, Outgoing, ReplyPreview};53
use crate::remote_image::RemoteImage;53
use crate::remote_image::RemoteImage;54
use crate::runtime;54
use crate::runtime;55
use crate::scheduled_rows::scheduled_label;55
use crate::scheduled_rows::scheduled_label;56
use crate::theme;56
use crate::theme::{self, ElevatedSurface as _};57
use crate::typing::OutgoingTyping;57
use crate::typing::OutgoingTyping;58
58
59
const MIN_ROWS: usize = 1;59
const MIN_ROWS: usize = 1;@@ -2154,7 +2154,7 @@ impl Composer {2154
.w(px(POPUP_WIDTH))2154
.w(px(POPUP_WIDTH))2155
.py(px(6.))2155
.py(px(6.))2156
.rounded(px(10.))2156
.rounded(px(10.))2157
.bg(theme::popup())2157
.flyout_surface()2158
.occlude()2158
.occlude()2159
.children(rows)2159
.children(rows)2160
.into_any_element(),2160
.into_any_element(),@@ -10,7 +10,7 @@ use crate::schedule_time::{
10
10
DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,
11
11
format_time, parse_time, presets, step_time, validate,
12
12
};
13
use crate::theme;
13
use crate::theme::{self, ElevatedSurface as _};
14
14
use crate::views::widgets::symbol;
15
15
16
16
const MENU_WIDTH: f32 = 190.;
@@ -317,7 +317,7 @@ impl Composer {
317
317
}))
318
318
.p(px(4.))
319
319
.rounded(px(10.))
320
.bg(theme::popup())
320
.flyout_surface()
321
321
.occlude()
322
322
.on_mouse_down_out(
323
323
cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),
@@ -10,7 +10,7 @@ use crate::schedule_time::{10
DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,10
DayChoice, Preset, PresetKind, ScheduleError, custom_time, day_choices, default_custom_time,11
format_time, parse_time, presets, step_time, validate,11
format_time, parse_time, presets, step_time, validate,12
};12
};13
use crate::theme;13
use crate::theme::{self, ElevatedSurface as _};14
use crate::views::widgets::symbol;14
use crate::views::widgets::symbol;15
15
16
const MENU_WIDTH: f32 = 190.;16
const MENU_WIDTH: f32 = 190.;@@ -317,7 +317,7 @@ impl Composer {317
}))317
}))318
.p(px(4.))318
.p(px(4.))319
.rounded(px(10.))319
.rounded(px(10.))320
.bg(theme::popup())320
.flyout_surface()321
.occlude()321
.occlude()322
.on_mouse_down_out(322
.on_mouse_down_out(323
cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),323
cx.listener(|this, _, window, cx| this.close_schedule(window, cx)),@@ -5,7 +5,7 @@ use super::adaptive_card::card_view;
5
5
use super::widgets::symbol;
6
6
use crate::app_state::{AppHandle, AppState};
7
7
use crate::card_state::TaskDialogState;
8
use crate::theme;
8
use crate::theme::{self, ElevatedSurface as _};
9
9
10
10
const BACKDROP_OPACITY: f32 = 0.55;
11
11
const PANEL_MARGIN: f32 = 32.;
@@ -56,7 +56,7 @@ fn panel(dialog: &TaskDialogState, cx: &App) -> Div {
56
56
.p(px(PANEL_PADDING))
57
57
.gap(px(HEADER_GAP))
58
58
.rounded(px(PANEL_RADIUS))
59
.bg(theme::popup())
59
.dialog_surface()
60
60
.text_color(theme::text())
61
61
.occlude()
62
62
.child(
@@ -5,7 +5,7 @@ use super::adaptive_card::card_view;5
use super::widgets::symbol;5
use super::widgets::symbol;6
use crate::app_state::{AppHandle, AppState};6
use crate::app_state::{AppHandle, AppState};7
use crate::card_state::TaskDialogState;7
use crate::card_state::TaskDialogState;8
use crate::theme;8
use crate::theme::{self, ElevatedSurface as _};9
9
10
const BACKDROP_OPACITY: f32 = 0.55;10
const BACKDROP_OPACITY: f32 = 0.55;11
const PANEL_MARGIN: f32 = 32.;11
const PANEL_MARGIN: f32 = 32.;@@ -56,7 +56,7 @@ fn panel(dialog: &TaskDialogState, cx: &App) -> Div {56
.p(px(PANEL_PADDING))56
.p(px(PANEL_PADDING))57
.gap(px(HEADER_GAP))57
.gap(px(HEADER_GAP))58
.rounded(px(PANEL_RADIUS))58
.rounded(px(PANEL_RADIUS))59
.bg(theme::popup())59
.dialog_surface()60
.text_color(theme::text())60
.text_color(theme::text())61
.occlude()61
.occlude()62
.child(62
.child(@@ -7,7 +7,7 @@ use gpui_kit::*;
7
7
use super::widgets::symbol;
8
8
use crate::emoji::Match;
9
9
use crate::emoticons;
10
use crate::theme;
10
use crate::theme::{self, ElevatedSurface as _};
11
11
12
12
pub const LIMIT: usize = 40;
13
13
const WIDTH: f32 = 300.;
@@ -183,7 +183,7 @@ pub fn render(
183
183
.w(px(WIDTH))
184
184
.p(px(4.))
185
185
.rounded(px(10.))
186
.bg(theme::popup())
186
.flyout_surface()
187
187
.occlude()
188
188
.child(
189
189
v_flex()
@@ -7,7 +7,7 @@ use gpui_kit::*;7
use super::widgets::symbol;7
use super::widgets::symbol;8
use crate::emoji::Match;8
use crate::emoji::Match;9
use crate::emoticons;9
use crate::emoticons;10
use crate::theme;10
use crate::theme::{self, ElevatedSurface as _};11
11
12
pub const LIMIT: usize = 40;12
pub const LIMIT: usize = 40;13
const WIDTH: f32 = 300.;13
const WIDTH: f32 = 300.;@@ -183,7 +183,7 @@ pub fn render(183
.w(px(WIDTH))183
.w(px(WIDTH))184
.p(px(4.))184
.p(px(4.))185
.rounded(px(10.))185
.rounded(px(10.))186
.bg(theme::popup())186
.flyout_surface()187
.occlude()187
.occlude()188
.child(188
.child(189
v_flex()189
v_flex()@@ -7,7 +7,7 @@ use gpui_kit::*;
7
7
use teams_core::FormatState;
8
8
9
9
use super::widgets::symbol;
10
use crate::theme;
10
use crate::theme::{self, ElevatedSurface as _};
11
11
12
12
const PADDING: f32 = 4.;
13
13
const BUTTON: f32 = 28.;
@@ -339,7 +339,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {
339
339
div()
340
340
.p(px(PADDING))
341
341
.rounded(px(10.))
342
.bg(theme::popup())
342
.flyout_surface()
343
343
.child(content),
344
344
)
345
345
.child(arrow(placement.arrow_x)),
@@ -7,7 +7,7 @@ use gpui_kit::*;7
use teams_core::FormatState;7
use teams_core::FormatState;8
8
9
use super::widgets::symbol;9
use super::widgets::symbol;10
use crate::theme;10
use crate::theme::{self, ElevatedSurface as _};11
11
12
const PADDING: f32 = 4.;12
const PADDING: f32 = 4.;13
const BUTTON: f32 = 28.;13
const BUTTON: f32 = 28.;@@ -339,7 +339,7 @@ pub fn render(placement: Placement, mode: Mode<'_>) -> AnyElement {339
div()339
div()340
.p(px(PADDING))340
.p(px(PADDING))341
.rounded(px(10.))341
.rounded(px(10.))342
.bg(theme::popup())342
.flyout_surface()343
.child(content),343
.child(content),344
)344
)345
.child(arrow(placement.arrow_x)),345
.child(arrow(placement.arrow_x)),@@ -15,7 +15,7 @@ use crate::fuzzy;
15
15
use crate::message_actions::ForwardSource;
16
16
use crate::notice::short_error;
17
17
use crate::runtime;
18
use crate::theme;
18
use crate::theme::{self, ElevatedSurface as _};
19
19
20
20
const MAX_RESULTS: usize = 8;
21
21
const CARD_WIDTH: f32 = 480.;
@@ -461,7 +461,7 @@ impl Render for ForwardDialog {
461
461
.p(px(CARD_PADDING))
462
462
.gap(px(SECTION_GAP))
463
463
.rounded(px(CARD_RADIUS))
464
.bg(theme::popup())
464
.dialog_surface()
465
465
.text_color(theme::text())
466
466
.occlude()
467
467
.on_key_down(cx.listener(Self::on_key_down))
@@ -15,7 +15,7 @@ use crate::fuzzy;15
use crate::message_actions::ForwardSource;15
use crate::message_actions::ForwardSource;16
use crate::notice::short_error;16
use crate::notice::short_error;17
use crate::runtime;17
use crate::runtime;18
use crate::theme;18
use crate::theme::{self, ElevatedSurface as _};19
19
20
const MAX_RESULTS: usize = 8;20
const MAX_RESULTS: usize = 8;21
const CARD_WIDTH: f32 = 480.;21
const CARD_WIDTH: f32 = 480.;@@ -461,7 +461,7 @@ impl Render for ForwardDialog {461
.p(px(CARD_PADDING))461
.p(px(CARD_PADDING))462
.gap(px(SECTION_GAP))462
.gap(px(SECTION_GAP))463
.rounded(px(CARD_RADIUS))463
.rounded(px(CARD_RADIUS))464
.bg(theme::popup())464
.dialog_surface()465
.text_color(theme::text())465
.text_color(theme::text())466
.occlude()466
.occlude()467
.on_key_down(cx.listener(Self::on_key_down))467
.on_key_down(cx.listener(Self::on_key_down))@@ -16,7 +16,7 @@ use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};
16
16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
17
17
use super::widgets::icon;
18
18
use crate::rows::reaction_glyph;
19
use crate::theme;
19
use crate::theme::{self, ElevatedSurface as _};
20
20
21
21
const BAR_BUTTON: f32 = 30.;
22
22
const BAR_PADDING: f32 = 3.;
@@ -319,7 +319,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {
319
319
.gap(px(1.))
320
320
.items_center()
321
321
.rounded(px(10.))
322
.bg(theme::popup())
322
.flyout_surface()
323
323
.on_mouse_down(MouseButton::Left, |_, _, cx| {
324
324
GlobalState::suppress_text_selection(cx)
325
325
})
@@ -16,7 +16,7 @@ use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};17
use super::widgets::icon;17
use super::widgets::icon;18
use crate::rows::reaction_glyph;18
use crate::rows::reaction_glyph;19
use crate::theme;19
use crate::theme::{self, ElevatedSurface as _};20
20
21
const BAR_BUTTON: f32 = 30.;21
const BAR_BUTTON: f32 = 30.;22
const BAR_PADDING: f32 = 3.;22
const BAR_PADDING: f32 = 3.;@@ -319,7 +319,7 @@ pub fn message_toolbar(menu: MessageMenu, cx: &App) -> AnyElement {319
.gap(px(1.))319
.gap(px(1.))320
.items_center()320
.items_center()321
.rounded(px(10.))321
.rounded(px(10.))322
.bg(theme::popup())322
.flyout_surface()323
.on_mouse_down(MouseButton::Left, |_, _, cx| {323
.on_mouse_down(MouseButton::Left, |_, _, cx| {324
GlobalState::suppress_text_selection(cx)324
GlobalState::suppress_text_selection(cx)325
})325
})@@ -18,7 +18,7 @@ use super::widgets::icon;
18
18
use crate::app_state::AppState;
19
19
use crate::data::{self, Directory, Person};
20
20
use crate::runtime;
21
use crate::theme;
21
use crate::theme::{self, ElevatedSurface as _};
22
22
23
23
const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);
24
24
const SUGGESTED_LIMIT: usize = 6;
@@ -527,7 +527,7 @@ impl NewChatDraft {
527
527
.mt(px(4.))
528
528
.p(px(6.))
529
529
.rounded(px(10.))
530
.bg(theme::popup())
530
.flyout_surface()
531
531
.occlude()
532
532
.when(!results_empty, |popup| {
533
533
popup.child(
@@ -18,7 +18,7 @@ use super::widgets::icon;18
use crate::app_state::AppState;18
use crate::app_state::AppState;19
use crate::data::{self, Directory, Person};19
use crate::data::{self, Directory, Person};20
use crate::runtime;20
use crate::runtime;21
use crate::theme;21
use crate::theme::{self, ElevatedSurface as _};22
22
23
const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);23
const SEARCH_DEBOUNCE: Duration = Duration::from_millis(200);24
const SUGGESTED_LIMIT: usize = 6;24
const SUGGESTED_LIMIT: usize = 6;@@ -527,7 +527,7 @@ impl NewChatDraft {527
.mt(px(4.))527
.mt(px(4.))528
.p(px(6.))528
.p(px(6.))529
.rounded(px(10.))529
.rounded(px(10.))530
.bg(theme::popup())530
.flyout_surface()531
.occlude()531
.occlude()532
.when(!results_empty, |popup| {532
.when(!results_empty, |popup| {533
popup.child(533
popup.child(@@ -17,7 +17,7 @@ use crate::profile_model::{
17
17
ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,
18
18
mailto_url, status_box, status_line, work_location_label,
19
19
};
20
use crate::theme;
20
use crate::theme::{self, ElevatedSurface as _};
21
21
22
22
const CARD_WIDTH: f32 = 340.;
23
23
const CARD_RADIUS: f32 = 10.;
@@ -624,7 +624,7 @@ impl Render for ProfileCard {
624
624
.p(px(CARD_PADDING))
625
625
.gap(px(CARD_GAP))
626
626
.rounded(px(CARD_RADIUS))
627
.bg(theme::popup())
627
.flyout_surface()
628
628
.text_color(theme::text())
629
629
.occlude()
630
630
.on_key_down(cx.listener(Self::on_key_down))
@@ -17,7 +17,7 @@ use crate::profile_model::{17
ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,17
ContactKind, ContactRow, StatusBox, contact_rows, has_organization, local_time_label,18
mailto_url, status_box, status_line, work_location_label,18
mailto_url, status_box, status_line, work_location_label,19
};19
};20
use crate::theme;20
use crate::theme::{self, ElevatedSurface as _};21
21
22
const CARD_WIDTH: f32 = 340.;22
const CARD_WIDTH: f32 = 340.;23
const CARD_RADIUS: f32 = 10.;23
const CARD_RADIUS: f32 = 10.;@@ -624,7 +624,7 @@ impl Render for ProfileCard {624
.p(px(CARD_PADDING))624
.p(px(CARD_PADDING))625
.gap(px(CARD_GAP))625
.gap(px(CARD_GAP))626
.rounded(px(CARD_RADIUS))626
.rounded(px(CARD_RADIUS))627
.bg(theme::popup())627
.flyout_surface()628
.text_color(theme::text())628
.text_color(theme::text())629
.occlude()629
.occlude()630
.on_key_down(cx.listener(Self::on_key_down))630
.on_key_down(cx.listener(Self::on_key_down))@@ -14,7 +14,7 @@ use crate::reaction_model::{
14
14
reaction_time_label, shows_faces,
15
15
};
16
16
use crate::rows::ReactionChip;
17
use crate::theme;
17
use crate::theme::{self, ElevatedSurface as _};
18
18
19
19
const PILL_HEIGHT: f32 = 24.;
20
20
const PILL_EMOJI_SIZE: f32 = 14.;
@@ -249,7 +249,7 @@ fn popover(
249
249
.p(px(6.))
250
250
.gap(px(4.))
251
251
.rounded(px(10.))
252
.bg(theme::popup())
252
.flyout_surface()
253
253
.occlude()
254
254
.on_mouse_down_out(move |_, _, cx| close(cx))
255
255
.on_mouse_down(MouseButton::Left, |_, _, cx| {
@@ -14,7 +14,7 @@ use crate::reaction_model::{14
reaction_time_label, shows_faces,14
reaction_time_label, shows_faces,15
};15
};16
use crate::rows::ReactionChip;16
use crate::rows::ReactionChip;17
use crate::theme;17
use crate::theme::{self, ElevatedSurface as _};18
18
19
const PILL_HEIGHT: f32 = 24.;19
const PILL_HEIGHT: f32 = 24.;20
const PILL_EMOJI_SIZE: f32 = 14.;20
const PILL_EMOJI_SIZE: f32 = 14.;@@ -249,7 +249,7 @@ fn popover(249
.p(px(6.))249
.p(px(6.))250
.gap(px(4.))250
.gap(px(4.))251
.rounded(px(10.))251
.rounded(px(10.))252
.bg(theme::popup())252
.flyout_surface()253
.occlude()253
.occlude()254
.on_mouse_down_out(move |_, _, cx| close(cx))254
.on_mouse_down_out(move |_, _, cx| close(cx))255
.on_mouse_down(MouseButton::Left, |_, _, cx| {255
.on_mouse_down(MouseButton::Left, |_, _, cx| {@@ -6,7 +6,7 @@ use gpui_kit::*;
6
6
use super::message_actions::{Action, bar_button};
7
7
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
8
8
use super::widgets::icon;
9
use crate::theme;
9
use crate::theme::{self, ElevatedSurface as _};
10
10
11
11
pub struct ScheduledMenu {
12
12
pub key: String,
@@ -43,7 +43,7 @@ pub fn scheduled_toolbar(menu: ScheduledMenu) -> AnyElement {
43
43
.gap(px(1.))
44
44
.items_center()
45
45
.rounded(px(10.))
46
.bg(theme::popup())
46
.flyout_surface()
47
47
.on_mouse_down(MouseButton::Left, |_, _, cx| {
48
48
GlobalState::suppress_text_selection(cx)
49
49
})
@@ -6,7 +6,7 @@ use gpui_kit::*;6
use super::message_actions::{Action, bar_button};6
use super::message_actions::{Action, bar_button};7
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};7
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};8
use super::widgets::icon;8
use super::widgets::icon;9
use crate::theme;9
use crate::theme::{self, ElevatedSurface as _};10
10
11
pub struct ScheduledMenu {11
pub struct ScheduledMenu {12
pub key: String,12
pub key: String,@@ -43,7 +43,7 @@ pub fn scheduled_toolbar(menu: ScheduledMenu) -> AnyElement {43
.gap(px(1.))43
.gap(px(1.))44
.items_center()44
.items_center()45
.rounded(px(10.))45
.rounded(px(10.))46
.bg(theme::popup())46
.flyout_surface()47
.on_mouse_down(MouseButton::Left, |_, _, cx| {47
.on_mouse_down(MouseButton::Left, |_, _, cx| {48
GlobalState::suppress_text_selection(cx)48
GlobalState::suppress_text_selection(cx)49
})49
})@@ -1,6 +1,6 @@
1
1
use std::sync::Arc;
2
2
3
use gpui_kit::component::{h_flex, v_flex};
3
use gpui_kit::component::{elevation, h_flex, v_flex};
4
4
use gpui_kit::*;
5
5
6
6
use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
@@ -762,6 +762,17 @@ impl AppShell {
762
762
763
763
impl Render for AppShell {
764
764
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
765
let open_dialogs = [
766
self.state.read(cx).task_dialog.is_some(),
767
self.forward_dialog.is_some(),
768
self.status_dialog.is_some(),
769
self.shortcuts_dialog.is_some(),
770
self.agent_dialog.is_some(),
771
]
772
.into_iter()
773
.filter(|open| *open)
774
.count();
775
elevation::set_app_modal_layers(window, open_dialogs, cx);
765
776
if let Some(dialog) = self
766
777
.state
767
778
.read(cx)
@@ -1,6 +1,6 @@1
use std::sync::Arc;1
use std::sync::Arc;2
2
3
use gpui_kit::component::{h_flex, v_flex};3
use gpui_kit::component::{elevation, h_flex, v_flex};4
use gpui_kit::*;4
use gpui_kit::*;5
5
6
use super::activity_panel::{ActivityPanel, ActivityPanelEvent};6
use super::activity_panel::{ActivityPanel, ActivityPanelEvent};@@ -762,6 +762,17 @@ impl AppShell {762
762
763
impl Render for AppShell {763
impl Render for AppShell {764
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {764
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {765
let open_dialogs = [766
self.state.read(cx).task_dialog.is_some(),767
self.forward_dialog.is_some(),768
self.status_dialog.is_some(),769
self.shortcuts_dialog.is_some(),770
self.agent_dialog.is_some(),771
]772
.into_iter()773
.filter(|open| *open)774
.count();775
elevation::set_app_modal_layers(window, open_dialogs, cx);765
if let Some(dialog) = self776
if let Some(dialog) = self766
.state777
.state767
.read(cx)778
.read(cx)@@ -3,7 +3,7 @@ use gpui_kit::*;
3
3
4
4
use super::shortcuts::{Group, shortcuts_in};
5
5
use super::widgets::symbol;
6
use crate::theme;
6
use crate::theme::{self, ElevatedSurface as _};
7
7
8
8
const CARD_WIDTH: f32 = 520.;
9
9
const CARD_RADIUS: f32 = 10.;
@@ -137,7 +137,7 @@ impl Render for ShortcutsDialog {
137
137
.p(px(CARD_PADDING))
138
138
.gap(px(SECTION_GAP))
139
139
.rounded(px(CARD_RADIUS))
140
.bg(theme::popup())
140
.dialog_surface()
141
141
.text_color(theme::text())
142
142
.occlude()
143
143
.capture_key_down(cx.listener(Self::on_key_down))
@@ -3,7 +3,7 @@ use gpui_kit::*;3
3
4
use super::shortcuts::{Group, shortcuts_in};4
use super::shortcuts::{Group, shortcuts_in};5
use super::widgets::symbol;5
use super::widgets::symbol;6
use crate::theme;6
use crate::theme::{self, ElevatedSurface as _};7
7
8
const CARD_WIDTH: f32 = 520.;8
const CARD_WIDTH: f32 = 520.;9
const CARD_RADIUS: f32 = 10.;9
const CARD_RADIUS: f32 = 10.;@@ -137,7 +137,7 @@ impl Render for ShortcutsDialog {137
.p(px(CARD_PADDING))137
.p(px(CARD_PADDING))138
.gap(px(SECTION_GAP))138
.gap(px(SECTION_GAP))139
.rounded(px(CARD_RADIUS))139
.rounded(px(CARD_RADIUS))140
.bg(theme::popup())140
.dialog_surface()141
.text_color(theme::text())141
.text_color(theme::text())142
.occlude()142
.occlude()143
.capture_key_down(cx.listener(Self::on_key_down))143
.capture_key_down(cx.listener(Self::on_key_down))@@ -7,7 +7,7 @@ use gpui_kit::*;
7
7
8
8
use super::widgets::{Corner, corner_badge};
9
9
use crate::emoticons::{SKIN_TONE_COUNT, with_tone};
10
use crate::theme;
10
use crate::theme::{self, ElevatedSurface as _};
11
11
12
12
const CHOICE_SIZE: f32 = 32.;
13
13
const CHOICE_GLYPH_SIZE: f32 = 20.;
@@ -70,10 +70,7 @@ pub fn tone_choices(
70
70
.gap(px(PANEL_GAP))
71
71
.p(px(PANEL_PADDING))
72
72
.rounded(px(8.))
73
.bg(theme::popup())
74
.border_1()
75
.border_color(theme::border_strong())
76
.shadow_md()
73
.nested_flyout_surface()
77
74
.occlude()
78
75
.on_mouse_down_out(move |_, window, cx| dismiss(window, cx))
79
76
.children(choices),
@@ -7,7 +7,7 @@ use gpui_kit::*;7
7
8
use super::widgets::{Corner, corner_badge};8
use super::widgets::{Corner, corner_badge};9
use crate::emoticons::{SKIN_TONE_COUNT, with_tone};9
use crate::emoticons::{SKIN_TONE_COUNT, with_tone};10
use crate::theme;10
use crate::theme::{self, ElevatedSurface as _};11
11
12
const CHOICE_SIZE: f32 = 32.;12
const CHOICE_SIZE: f32 = 32.;13
const CHOICE_GLYPH_SIZE: f32 = 20.;13
const CHOICE_GLYPH_SIZE: f32 = 20.;@@ -70,10 +70,7 @@ pub fn tone_choices(70
.gap(px(PANEL_GAP))70
.gap(px(PANEL_GAP))71
.p(px(PANEL_PADDING))71
.p(px(PANEL_PADDING))72
.rounded(px(8.))72
.rounded(px(8.))73
.bg(theme::popup())73
.nested_flyout_surface()74
.border_1()75
.border_color(theme::border_strong())76
.shadow_md()77
.occlude()74
.occlude()78
.on_mouse_down_out(move |_, window, cx| dismiss(window, cx))75
.on_mouse_down_out(move |_, window, cx| dismiss(window, cx))79
.children(choices),76
.children(choices),@@ -15,7 +15,7 @@ use teams_core::StatusNote;
15
15
use super::widgets::symbol;
16
16
use crate::app_state::AppState;
17
17
use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};
18
use crate::theme;
18
use crate::theme::{self, ElevatedSurface as _};
19
19
20
20
const CARD_WIDTH: f32 = 440.;
21
21
const CARD_RADIUS: f32 = 10.;
@@ -266,7 +266,7 @@ impl Render for StatusMessageDialog {
266
266
.p(px(CARD_PADDING))
267
267
.gap(px(SECTION_GAP))
268
268
.rounded(px(CARD_RADIUS))
269
.bg(theme::popup())
269
.dialog_surface()
270
270
.text_color(theme::text())
271
271
.occlude()
272
272
.capture_key_down(cx.listener(Self::on_key_down))
@@ -15,7 +15,7 @@ use teams_core::StatusNote;15
use super::widgets::symbol;15
use super::widgets::symbol;16
use crate::app_state::AppState;16
use crate::app_state::AppState;17
use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};17
use crate::own_status::{NOTE_DURATIONS, NOTE_LIMIT, NoteDuration, clamp_note};18
use crate::theme;18
use crate::theme::{self, ElevatedSurface as _};19
19
20
const CARD_WIDTH: f32 = 440.;20
const CARD_WIDTH: f32 = 440.;21
const CARD_RADIUS: f32 = 10.;21
const CARD_RADIUS: f32 = 10.;@@ -266,7 +266,7 @@ impl Render for StatusMessageDialog {266
.p(px(CARD_PADDING))266
.p(px(CARD_PADDING))267
.gap(px(SECTION_GAP))267
.gap(px(SECTION_GAP))268
.rounded(px(CARD_RADIUS))268
.rounded(px(CARD_RADIUS))269
.bg(theme::popup())269
.dialog_surface()270
.text_color(theme::text())270
.text_color(theme::text())271
.occlude()271
.occlude()272
.capture_key_down(cx.listener(Self::on_key_down))272
.capture_key_down(cx.listener(Self::on_key_down))@@ -20,7 +20,7 @@ use crate::data::{Directory, is_one_on_one};
20
20
use crate::format;
21
21
use crate::fuzzy;
22
22
use crate::sidebar_model::{AvatarSpec, avatar_for};
23
use crate::theme;
23
use crate::theme::{self, ElevatedSurface as _};
24
24
25
25
const MAX_RESULTS: usize = 9;
26
26
const MAX_RESULTS_WITH_MESSAGES: usize = 5;
@@ -488,7 +488,7 @@ impl Render for Switcher {
488
488
.w(px(CARD_WIDTH))
489
489
.max_h(px(640.))
490
490
.rounded(px(10.))
491
.bg(theme::popup())
491
.flyout_surface()
492
492
.overflow_hidden()
493
493
.on_click(|_, _, cx| cx.stop_propagation())
494
494
.on_key_down(cx.listener(Self::on_key_down))
@@ -20,7 +20,7 @@ use crate::data::{Directory, is_one_on_one};20
use crate::format;20
use crate::format;21
use crate::fuzzy;21
use crate::fuzzy;22
use crate::sidebar_model::{AvatarSpec, avatar_for};22
use crate::sidebar_model::{AvatarSpec, avatar_for};23
use crate::theme;23
use crate::theme::{self, ElevatedSurface as _};24
24
25
const MAX_RESULTS: usize = 9;25
const MAX_RESULTS: usize = 9;26
const MAX_RESULTS_WITH_MESSAGES: usize = 5;26
const MAX_RESULTS_WITH_MESSAGES: usize = 5;@@ -488,7 +488,7 @@ impl Render for Switcher {488
.w(px(CARD_WIDTH))488
.w(px(CARD_WIDTH))489
.max_h(px(640.))489
.max_h(px(640.))490
.rounded(px(10.))490
.rounded(px(10.))491
.bg(theme::popup())491
.flyout_surface()492
.overflow_hidden()492
.overflow_hidden()493
.on_click(|_, _, cx| cx.stop_propagation())493
.on_click(|_, _, cx| cx.stop_propagation())494
.on_key_down(cx.listener(Self::on_key_down))494
.on_key_down(cx.listener(Self::on_key_down))@@ -271,7 +271,7 @@ impl Render for TransferPicker {
271
271
.border_1()
272
272
.border_color(theme::border_strong())
273
273
.text_color(theme::text())
274
.shadow_lg()
274
.shadow(theme::dialog_shadow())
275
275
.occlude()
276
276
.on_key_down(cx.listener(Self::on_key_down))
277
277
.child(
@@ -271,7 +271,7 @@ impl Render for TransferPicker {271
.border_1()271
.border_1()272
.border_color(theme::border_strong())272
.border_color(theme::border_strong())273
.text_color(theme::text())273
.text_color(theme::text())274
.shadow_lg()274
.shadow(theme::dialog_shadow())275
.occlude()275
.occlude()276
.on_key_down(cx.listener(Self::on_key_down))276
.on_key_down(cx.listener(Self::on_key_down))277
.child(277
.child(@@ -704,6 +704,7 @@ where
704
704
bounds,
705
705
footer_el,
706
706
dismiss_handler,
707
window,
707
708
cx,
708
709
))
709
710
.with_priority(gpui_base::POPUP_PRIORITY),
@@ -1040,6 +1041,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1040
1041
bounds: Bounds<Pixels>,
1041
1042
footer_el: Option<AnyElement>,
1042
1043
dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,
1044
window: &Window,
1043
1045
cx: &mut App,
1044
1046
) -> AnyElement {
1045
1047
let has_footer = footer_el.is_some();
@@ -1053,7 +1055,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(
1053
1055
Length::Auto => this.w(bounds.size.width),
1054
1056
Length::Definite(w) => this.w(w),
1055
1057
})
1056
.popover_style(cx)
1058
.popover_style(window, cx)
1057
1059
.child(
1058
1060
List::new(list)
1059
1061
.when_some(search_placeholder, |this, placeholder| {
@@ -704,6 +704,7 @@ where704
bounds,704
bounds,705
footer_el,705
footer_el,706
dismiss_handler,706
dismiss_handler,707
window,707
cx,708
cx,708
))709
))709
.with_priority(gpui_base::POPUP_PRIORITY),710
.with_priority(gpui_base::POPUP_PRIORITY),@@ -1040,6 +1041,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(1040
bounds: Bounds<Pixels>,1041
bounds: Bounds<Pixels>,1041
footer_el: Option<AnyElement>,1042
footer_el: Option<AnyElement>,1042
dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,1043
dismiss_handler: Box<dyn Fn(&MouseDownEvent, &mut Window, &mut App) + 'static>,1044
window: &Window,1043
cx: &mut App,1045
cx: &mut App,1044
) -> AnyElement {1046
) -> AnyElement {1045
let has_footer = footer_el.is_some();1047
let has_footer = footer_el.is_some();@@ -1053,7 +1055,7 @@ fn render_popup_shell<D: SearchableListDelegate + 'static>(1053
Length::Auto => this.w(bounds.size.width),1055
Length::Auto => this.w(bounds.size.width),1054
Length::Definite(w) => this.w(w),1056
Length::Definite(w) => this.w(w),1055
})1057
})1056
.popover_style(cx)1058
.popover_style(window, cx)1057
.child(1059
.child(1058
List::new(list)1060
List::new(list)1059
.when_some(search_placeholder, |this, placeholder| {1061
.when_some(search_placeholder, |this, placeholder| {@@ -3,7 +3,7 @@ use gpui_base::TestSupportExt as _;
3
3
use std::{rc::Rc, sync::LazyLock, time::Duration};
4
4
5
5
use gpui::{
6
Action, Anchor, Animation, AnimationExt as _, AnyElement, App, BoxShadow, ClickEvent, Edges,
6
Action, Anchor, Animation, AnimationExt as _, AnyElement, App, ClickEvent, Edges,
7
7
FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,
8
8
SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,
9
9
prelude::FluentBuilder, px,
@@ -611,6 +611,8 @@ impl RenderOnce for Dialog {
611
611
1.,
612
612
));
613
613
614
let dialog_elevation = crate::elevation::dialog(cx);
615
614
616
anchored()
615
617
.position(point(window_paddings.left, window_paddings.top))
616
618
.snap_to_window()
@@ -666,9 +668,7 @@ impl RenderOnce for Dialog {
666
668
.id(layer_ix)
667
669
.test_support()
668
670
.debug_selector(move || format!("dialog-{layer_ix}"))
669
.bg(cx.theme().tokens.background)
670
.border_1()
671
.border_color(cx.theme().border)
671
.bg(dialog_elevation.fill)
672
672
.rounded(cx.theme().radius_lg)
673
673
.min_h_24()
674
674
.pt(paddings.top)
@@ -753,24 +753,7 @@ impl RenderOnce for Dialog {
753
753
"slide-down-shadow",
754
754
animation.clone(),
755
755
move |this, delta| {
756
// This is equivalent to `shadow_xl` with an extra opacity.
757
let shadow = vec![
758
BoxShadow {
759
color: hsla(0., 0., 0., 0.1 * delta),
760
offset: point(px(0.), px(20.)),
761
blur_radius: px(25.),
762
spread_radius: px(-5.),
763
inset: false,
764
},
765
BoxShadow {
766
color: hsla(0., 0., 0., 0.1 * delta),
767
offset: point(px(0.), px(8.)),
768
blur_radius: px(10.),
769
spread_radius: px(-6.),
770
inset: false,
771
},
772
];
773
this.shadow(shadow)
756
this.shadow(dialog_elevation.shadow_at(delta))
774
757
},
775
758
)
776
759
.text_selection_scope(selection_scope),
@@ -3,7 +3,7 @@ use gpui_base::TestSupportExt as _;3
use std::{rc::Rc, sync::LazyLock, time::Duration};3
use std::{rc::Rc, sync::LazyLock, time::Duration};4
4
5
use gpui::{5
use gpui::{6
Action, Anchor, Animation, AnimationExt as _, AnyElement, App, BoxShadow, ClickEvent, Edges,6
Action, Anchor, Animation, AnimationExt as _, AnyElement, App, ClickEvent, Edges,7
FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,7
FocusHandle, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels, RenderOnce,8
SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,8
SharedString, StyleRefinement, Styled, Window, WindowControlArea, anchored, div, hsla, point,9
prelude::FluentBuilder, px,9
prelude::FluentBuilder, px,@@ -611,6 +611,8 @@ impl RenderOnce for Dialog {611
1.,611
1.,612
));612
));613
613
614
let dialog_elevation = crate::elevation::dialog(cx);615
614
anchored()616
anchored()615
.position(point(window_paddings.left, window_paddings.top))617
.position(point(window_paddings.left, window_paddings.top))616
.snap_to_window()618
.snap_to_window()@@ -666,9 +668,7 @@ impl RenderOnce for Dialog {666
.id(layer_ix)668
.id(layer_ix)667
.test_support()669
.test_support()668
.debug_selector(move || format!("dialog-{layer_ix}"))670
.debug_selector(move || format!("dialog-{layer_ix}"))669
.bg(cx.theme().tokens.background)671
.bg(dialog_elevation.fill)670
.border_1()671
.border_color(cx.theme().border)672
.rounded(cx.theme().radius_lg)672
.rounded(cx.theme().radius_lg)673
.min_h_24()673
.min_h_24()674
.pt(paddings.top)674
.pt(paddings.top)@@ -753,24 +753,7 @@ impl RenderOnce for Dialog {753
"slide-down-shadow",753
"slide-down-shadow",754
animation.clone(),754
animation.clone(),755
move |this, delta| {755
move |this, delta| {756
// This is equivalent to `shadow_xl` with an extra opacity.756
this.shadow(dialog_elevation.shadow_at(delta))757
let shadow = vec![758
BoxShadow {759
color: hsla(0., 0., 0., 0.1 * delta),760
offset: point(px(0.), px(20.)),761
blur_radius: px(25.),762
spread_radius: px(-5.),763
inset: false,764
},765
BoxShadow {766
color: hsla(0., 0., 0., 0.1 * delta),767
offset: point(px(0.), px(8.)),768
blur_radius: px(10.),769
spread_radius: px(-6.),770
inset: false,771
},772
];773
this.shadow(shadow)774
},757
},775
)758
)776
.text_selection_scope(selection_scope),759
.text_selection_scope(selection_scope),@@ -0,0 +1,184 @@
1
//! Fluent 2 dark shadows as Teams paints them. GPUI's shader takes the blur as
2
//! the gaussian's sigma while CSS takes twice that, so every CSS blur is halved.
3
4
use std::collections::HashMap;
5
6
use gpui::{App, BoxShadow, Global, Hsla, Window, WindowId, hsla, point, px};
7
8
use crate::ActiveTheme as _;
9
10
const AMBIENT_INK: f32 = 0.24;
11
const KEY_INK: f32 = 0.28;
12
13
#[derive(Clone, Debug, PartialEq)]
14
pub struct Elevation {
15
pub fill: Hsla,
16
pub hover: Hsla,
17
pub shadow: Vec<BoxShadow>,
18
}
19
20
impl Elevation {
21
pub fn shadow_at(&self, strength: f32) -> Vec<BoxShadow> {
22
let strength = strength.clamp(0., 1.);
23
self.shadow
24
.iter()
25
.cloned()
26
.map(|mut layer| {
27
layer.color = layer.color.alpha(layer.color.a * strength);
28
layer
29
})
30
.collect()
31
}
32
}
33
34
#[derive(Clone, Debug, PartialEq)]
35
pub struct ElevationTokens {
36
pub flyouts: Vec<Elevation>,
37
pub dialog: Elevation,
38
pub toast: Elevation,
39
}
40
41
impl Global for ElevationTokens {}
42
43
fn fluent_shadow(
44
ambient_blur: f32,
45
key_offset: f32,
46
key_blur: f32,
47
ambient_ink: f32,
48
key_ink: f32,
49
) -> Vec<BoxShadow> {
50
vec![
51
BoxShadow {
52
color: hsla(0., 0., 0., ambient_ink),
53
offset: point(px(0.), px(0.)),
54
blur_radius: px(ambient_blur / 2.),
55
spread_radius: px(0.),
56
inset: false,
57
},
58
BoxShadow {
59
color: hsla(0., 0., 0., key_ink),
60
offset: point(px(0.), px(key_offset)),
61
blur_radius: px(key_blur / 2.),
62
spread_radius: px(0.),
63
inset: false,
64
},
65
]
66
}
67
68
pub fn shadow8() -> Vec<BoxShadow> {
69
fluent_shadow(2., 4., 8., AMBIENT_INK, KEY_INK)
70
}
71
72
pub fn shadow16() -> Vec<BoxShadow> {
73
fluent_shadow(2., 8., 16., AMBIENT_INK, KEY_INK)
74
}
75
76
pub fn shadow28() -> Vec<BoxShadow> {
77
fluent_shadow(8., 14., 28., AMBIENT_INK, KEY_INK)
78
}
79
80
pub fn shadow64() -> Vec<BoxShadow> {
81
fluent_shadow(8., 32., 64., AMBIENT_INK, KEY_INK)
82
}
83
84
impl ElevationTokens {
85
pub fn from_theme(cx: &App) -> Self {
86
let theme = cx.theme();
87
let flyout = Elevation {
88
fill: theme.popover,
89
hover: theme.sidebar_accent,
90
shadow: shadow16(),
91
};
92
let nested = Elevation {
93
fill: theme.sidebar_accent,
94
hover: theme.secondary_hover,
95
shadow: shadow16(),
96
};
97
Self {
98
flyouts: vec![flyout.clone(), nested],
99
dialog: Elevation {
100
shadow: shadow64(),
101
..flyout.clone()
102
},
103
toast: Elevation {
104
shadow: shadow8(),
105
..flyout
106
},
107
}
108
}
109
110
pub fn flyout_at(&self, modal_layers: usize) -> &Elevation {
111
let last = self.flyouts.len().saturating_sub(1);
112
&self.flyouts[modal_layers.min(last)]
113
}
114
}
115
116
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]
117
struct ModalLayers {
118
app: usize,
119
framework: usize,
120
}
121
122
impl ModalLayers {
123
fn total(self) -> usize {
124
self.app + self.framework
125
}
126
}
127
128
#[derive(Default)]
129
struct WindowModalLayers(HashMap<WindowId, ModalLayers>);
130
131
impl Global for WindowModalLayers {}
132
133
fn update_layers(window: &Window, cx: &mut App, update: impl FnOnce(&mut ModalLayers)) {
134
let window_id = window.window_handle().window_id();
135
let current = cx
136
.try_global::<WindowModalLayers>()
137
.and_then(|layers| layers.0.get(&window_id).copied())
138
.unwrap_or_default();
139
let mut next = current;
140
update(&mut next);
141
if next == current {
142
return;
143
}
144
let layers = cx.default_global::<WindowModalLayers>();
145
if next == ModalLayers::default() {
146
layers.0.remove(&window_id);
147
} else {
148
layers.0.insert(window_id, next);
149
}
150
}
151
152
pub fn set_app_modal_layers(window: &Window, count: usize, cx: &mut App) {
153
update_layers(window, cx, |layers| layers.app = count);
154
}
155
156
pub(crate) fn set_framework_modal_layers(window: &Window, count: usize, cx: &mut App) {
157
update_layers(window, cx, |layers| layers.framework = count);
158
}
159
160
pub fn modal_layers(window: &Window, cx: &App) -> usize {
161
let window_id = window.window_handle().window_id();
162
cx.try_global::<WindowModalLayers>()
163
.and_then(|layers| layers.0.get(&window_id).copied())
164
.map(ModalLayers::total)
165
.unwrap_or(0)
166
}
167
168
pub fn tokens(cx: &App) -> ElevationTokens {
169
cx.try_global::<ElevationTokens>()
170
.cloned()
171
.unwrap_or_else(|| ElevationTokens::from_theme(cx))
172
}
173
174
pub fn flyout(window: &Window, cx: &App) -> Elevation {
175
tokens(cx).flyout_at(modal_layers(window, cx)).clone()
176
}
177
178
pub fn dialog(cx: &App) -> Elevation {
179
tokens(cx).dialog
180
}
181
182
pub fn toast(cx: &App) -> Elevation {
183
tokens(cx).toast
184
}
@@ -0,0 +1,184 @@1
//! Fluent 2 dark shadows as Teams paints them. GPUI's shader takes the blur as2
//! the gaussian's sigma while CSS takes twice that, so every CSS blur is halved.3
4
use std::collections::HashMap;5
6
use gpui::{App, BoxShadow, Global, Hsla, Window, WindowId, hsla, point, px};7
8
use crate::ActiveTheme as _;9
10
const AMBIENT_INK: f32 = 0.24;11
const KEY_INK: f32 = 0.28;12
13
#[derive(Clone, Debug, PartialEq)]14
pub struct Elevation {15
pub fill: Hsla,16
pub hover: Hsla,17
pub shadow: Vec<BoxShadow>,18
}19
20
impl Elevation {21
pub fn shadow_at(&self, strength: f32) -> Vec<BoxShadow> {22
let strength = strength.clamp(0., 1.);23
self.shadow24
.iter()25
.cloned()26
.map(|mut layer| {27
layer.color = layer.color.alpha(layer.color.a * strength);28
layer29
})30
.collect()31
}32
}33
34
#[derive(Clone, Debug, PartialEq)]35
pub struct ElevationTokens {36
pub flyouts: Vec<Elevation>,37
pub dialog: Elevation,38
pub toast: Elevation,39
}40
41
impl Global for ElevationTokens {}42
43
fn fluent_shadow(44
ambient_blur: f32,45
key_offset: f32,46
key_blur: f32,47
ambient_ink: f32,48
key_ink: f32,49
) -> Vec<BoxShadow> {50
vec![51
BoxShadow {52
color: hsla(0., 0., 0., ambient_ink),53
offset: point(px(0.), px(0.)),54
blur_radius: px(ambient_blur / 2.),55
spread_radius: px(0.),56
inset: false,57
},58
BoxShadow {59
color: hsla(0., 0., 0., key_ink),60
offset: point(px(0.), px(key_offset)),61
blur_radius: px(key_blur / 2.),62
spread_radius: px(0.),63
inset: false,64
},65
]66
}67
68
pub fn shadow8() -> Vec<BoxShadow> {69
fluent_shadow(2., 4., 8., AMBIENT_INK, KEY_INK)70
}71
72
pub fn shadow16() -> Vec<BoxShadow> {73
fluent_shadow(2., 8., 16., AMBIENT_INK, KEY_INK)74
}75
76
pub fn shadow28() -> Vec<BoxShadow> {77
fluent_shadow(8., 14., 28., AMBIENT_INK, KEY_INK)78
}79
80
pub fn shadow64() -> Vec<BoxShadow> {81
fluent_shadow(8., 32., 64., AMBIENT_INK, KEY_INK)82
}83
84
impl ElevationTokens {85
pub fn from_theme(cx: &App) -> Self {86
let theme = cx.theme();87
let flyout = Elevation {88
fill: theme.popover,89
hover: theme.sidebar_accent,90
shadow: shadow16(),91
};92
let nested = Elevation {93
fill: theme.sidebar_accent,94
hover: theme.secondary_hover,95
shadow: shadow16(),96
};97
Self {98
flyouts: vec![flyout.clone(), nested],99
dialog: Elevation {100
shadow: shadow64(),101
..flyout.clone()102
},103
toast: Elevation {104
shadow: shadow8(),105
..flyout106
},107
}108
}109
110
pub fn flyout_at(&self, modal_layers: usize) -> &Elevation {111
let last = self.flyouts.len().saturating_sub(1);112
&self.flyouts[modal_layers.min(last)]113
}114
}115
116
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq)]117
struct ModalLayers {118
app: usize,119
framework: usize,120
}121
122
impl ModalLayers {123
fn total(self) -> usize {124
self.app + self.framework125
}126
}127
128
#[derive(Default)]129
struct WindowModalLayers(HashMap<WindowId, ModalLayers>);130
131
impl Global for WindowModalLayers {}132
133
fn update_layers(window: &Window, cx: &mut App, update: impl FnOnce(&mut ModalLayers)) {134
let window_id = window.window_handle().window_id();135
let current = cx136
.try_global::<WindowModalLayers>()137
.and_then(|layers| layers.0.get(&window_id).copied())138
.unwrap_or_default();139
let mut next = current;140
update(&mut next);141
if next == current {142
return;143
}144
let layers = cx.default_global::<WindowModalLayers>();145
if next == ModalLayers::default() {146
layers.0.remove(&window_id);147
} else {148
layers.0.insert(window_id, next);149
}150
}151
152
pub fn set_app_modal_layers(window: &Window, count: usize, cx: &mut App) {153
update_layers(window, cx, |layers| layers.app = count);154
}155
156
pub(crate) fn set_framework_modal_layers(window: &Window, count: usize, cx: &mut App) {157
update_layers(window, cx, |layers| layers.framework = count);158
}159
160
pub fn modal_layers(window: &Window, cx: &App) -> usize {161
let window_id = window.window_handle().window_id();162
cx.try_global::<WindowModalLayers>()163
.and_then(|layers| layers.0.get(&window_id).copied())164
.map(ModalLayers::total)165
.unwrap_or(0)166
}167
168
pub fn tokens(cx: &App) -> ElevationTokens {169
cx.try_global::<ElevationTokens>()170
.cloned()171
.unwrap_or_else(|| ElevationTokens::from_theme(cx))172
}173
174
pub fn flyout(window: &Window, cx: &App) -> Elevation {175
tokens(cx).flyout_at(modal_layers(window, cx)).clone()176
}177
178
pub fn dialog(cx: &App) -> Elevation {179
tokens(cx).dialog180
}181
182
pub fn toast(cx: &App) -> Elevation {183
tokens(cx).toast184
}@@ -166,8 +166,7 @@ impl Element for Popover {
166
166
.occlude()
167
167
.p_1()
168
168
.text_xs()
169
.popover_style(cx)
170
.shadow_md()
169
.popover_style(window, cx)
171
170
.max_w(max_width)
172
171
.max_h(max_height)
173
172
.overflow_y_scroll()
@@ -166,8 +166,7 @@ impl Element for Popover {166
.occlude()166
.occlude()167
.p_1()167
.p_1()168
.text_xs()168
.text_xs()169
.popover_style(cx)169
.popover_style(window, cx)170
.shadow_md()171
.max_w(max_width)170
.max_w(max_width)172
.max_h(max_height)171
.max_h(max_height)173
.overflow_y_scroll()172
.overflow_y_scroll()@@ -43,13 +43,12 @@ pub(super) fn render_markdown(
43
43
.selectable(true)
44
44
}
45
45
46
pub(super) fn editor_popover(id: impl Into<ElementId>, cx: &App) -> Stateful<Div> {
46
pub(super) fn editor_popover(id: impl Into<ElementId>, window: &Window, cx: &App) -> Stateful<Div> {
47
47
div()
48
48
.id(id)
49
49
.flex_none()
50
50
.occlude()
51
.popover_style(cx)
52
.shadow_md()
51
.popover_style(window, cx)
53
52
.text_xs()
54
53
.p_1()
55
54
}
@@ -43,13 +43,12 @@ pub(super) fn render_markdown(43
.selectable(true)43
.selectable(true)44
}44
}45
45
46
pub(super) fn editor_popover(id: impl Into<ElementId>, cx: &App) -> Stateful<Div> {46
pub(super) fn editor_popover(id: impl Into<ElementId>, window: &Window, cx: &App) -> Stateful<Div> {47
div()47
div()48
.id(id)48
.id(id)49
.flex_none()49
.flex_none()50
.occlude()50
.occlude()51
.popover_style(cx)51
.popover_style(window, cx)52
.shadow_md()53
.text_xs()52
.text_xs()54
.p_1()53
.p_1()55
}54
}@@ -42,6 +42,7 @@ pub mod command;
42
42
pub mod description_list;
43
43
pub mod dialog;
44
44
pub mod dock;
45
pub mod elevation;
45
46
pub mod empty;
46
47
pub mod form;
47
48
pub mod group_box;
@@ -42,6 +42,7 @@ pub mod command;42
pub mod description_list;42
pub mod description_list;43
pub mod dialog;43
pub mod dialog;44
pub mod dock;44
pub mod dock;45
pub mod elevation;45
pub mod empty;46
pub mod empty;46
pub mod form;47
pub mod form;47
pub mod group_box;48
pub mod group_box;@@ -23,7 +23,6 @@ use crate::{
23
23
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,
24
24
animation::cubic_bezier,
25
25
button::{Button, ButtonVariants as _},
26
styled::toast_shadow,
27
26
v_flex,
28
27
};
29
28
@@ -418,6 +417,8 @@ impl Render for Notification {
418
417
};
419
418
let has_icon = icon.is_some();
420
419
let placement = self.placement.unwrap_or(cx.theme().notification.placement);
420
let toast_elevation = crate::elevation::toast(cx);
421
let resting_shadow = toast_elevation.shadow.clone();
421
422
422
423
BaseToast::new("notification")
423
424
.transition_status(transition_status)
@@ -428,9 +429,9 @@ impl Render for Notification {
428
429
.w_full()
429
430
.border_1()
430
431
.border_color(cx.theme().border)
431
.bg(cx.theme().tokens.popover)
432
.bg(toast_elevation.fill)
432
433
.rounded(cx.theme().radius_lg)
433
.shadow(toast_shadow(1.))
434
.shadow(resting_shadow)
434
435
.py_3p5()
435
436
.px_4()
436
437
.gap_3()
@@ -492,7 +493,9 @@ impl Render for Notification {
492
493
move |this, delta| {
493
494
if closing {
494
495
let opacity = 1. - delta;
495
let that = this.opacity(opacity).shadow(toast_shadow(opacity.powi(3)));
496
let that = this
497
.opacity(opacity)
498
.shadow(toast_elevation.shadow_at(opacity.powi(3)));
496
499
let y_offset = match placement {
497
500
Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {
498
501
-delta * NOTIFICATION_TRANSITION_OFFSET
@@ -525,7 +528,7 @@ impl Render for Notification {
525
528
// threshold, which popped.
526
529
this.top(px(0.) + y_offset)
527
530
.opacity(opacity)
528
.shadow(toast_shadow(opacity.powi(3)))
531
.shadow(toast_elevation.shadow_at(opacity.powi(3)))
529
532
}
530
533
},
531
534
)
@@ -23,7 +23,6 @@ use crate::{23
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,23
ActiveTheme as _, Edges, Icon, IconName, Sizable as _, StyledExt, TITLE_BAR_HEIGHT,24
animation::cubic_bezier,24
animation::cubic_bezier,25
button::{Button, ButtonVariants as _},25
button::{Button, ButtonVariants as _},26
styled::toast_shadow,27
v_flex,26
v_flex,28
};27
};29
28
@@ -418,6 +417,8 @@ impl Render for Notification {418
};417
};419
let has_icon = icon.is_some();418
let has_icon = icon.is_some();420
let placement = self.placement.unwrap_or(cx.theme().notification.placement);419
let placement = self.placement.unwrap_or(cx.theme().notification.placement);420
let toast_elevation = crate::elevation::toast(cx);421
let resting_shadow = toast_elevation.shadow.clone();421
422
422
BaseToast::new("notification")423
BaseToast::new("notification")423
.transition_status(transition_status)424
.transition_status(transition_status)@@ -428,9 +429,9 @@ impl Render for Notification {428
.w_full()429
.w_full()429
.border_1()430
.border_1()430
.border_color(cx.theme().border)431
.border_color(cx.theme().border)431
.bg(cx.theme().tokens.popover)432
.bg(toast_elevation.fill)432
.rounded(cx.theme().radius_lg)433
.rounded(cx.theme().radius_lg)433
.shadow(toast_shadow(1.))434
.shadow(resting_shadow)434
.py_3p5()435
.py_3p5()435
.px_4()436
.px_4()436
.gap_3()437
.gap_3()@@ -492,7 +493,9 @@ impl Render for Notification {492
move |this, delta| {493
move |this, delta| {493
if closing {494
if closing {494
let opacity = 1. - delta;495
let opacity = 1. - delta;495
let that = this.opacity(opacity).shadow(toast_shadow(opacity.powi(3)));496
let that = this497
.opacity(opacity)498
.shadow(toast_elevation.shadow_at(opacity.powi(3)));496
let y_offset = match placement {499
let y_offset = match placement {497
Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {500
Anchor::TopLeft | Anchor::TopRight | Anchor::TopCenter => {498
-delta * NOTIFICATION_TRANSITION_OFFSET501
-delta * NOTIFICATION_TRANSITION_OFFSET@@ -525,7 +528,7 @@ impl Render for Notification {525
// threshold, which popped.528
// threshold, which popped.526
this.top(px(0.) + y_offset)529
this.top(px(0.) + y_offset)527
.opacity(opacity)530
.opacity(opacity)528
.shadow(toast_shadow(opacity.powi(3)))531
.shadow(toast_elevation.shadow_at(opacity.powi(3)))529
}532
}530
},533
},531
)534
)@@ -587,7 +587,7 @@ impl RenderOnce for Tooltip {
587
587
this.absolute()
588
588
.opacity(progress)
589
589
.when(min_w_unset, |c| c.min_w(px(150.)))
590
.popover_style(cx)
590
.popover_style(window, cx)
591
591
.p_2()
592
592
.map(|c| {
593
593
if cursor.x < within.width * 0.5 {
@@ -587,7 +587,7 @@ impl RenderOnce for Tooltip {587
this.absolute()587
this.absolute()588
.opacity(progress)588
.opacity(progress)589
.when(min_w_unset, |c| c.min_w(px(150.)))589
.when(min_w_unset, |c| c.min_w(px(150.)))590
.popover_style(cx)590
.popover_style(window, cx)591
.p_2()591
.p_2()592
.map(|c| {592
.map(|c| {593
if cursor.x < within.width * 0.5 {593
if cursor.x < within.width * 0.5 {@@ -61,7 +61,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {
61
61
/// shadow, and mid-fade the shadow shows straight through the panel as a dark
62
62
/// slab. Ramping the ink by the cube of the fade keeps it out of sight until the
63
63
/// panel is opaque enough to cover it, and still lands on the resting shadow
64
/// [`popover_shadow`] gives every other popup.
64
/// [`crate::elevation::flyout`] gives every other popup.
65
65
///
66
66
/// # Departures from shadcn
67
67
///
@@ -292,14 +292,14 @@ impl Popover {
292
292
pub(crate) fn render_popover_content(
293
293
anchor: Anchor,
294
294
appearance: bool,
295
_: &mut Window,
295
window: &mut Window,
296
296
cx: &mut App,
297
297
) -> Stateful<Div> {
298
298
v_flex()
299
299
.id("content")
300
300
.occlude()
301
301
.tab_group()
302
.when(appearance, |this| this.popover_style(cx).p_3())
302
.when(appearance, |this| this.popover_style(window, cx).p_3())
303
303
.map(|this| match anchor {
304
304
Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),
305
305
Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),
@@ -346,7 +346,7 @@ impl RenderOnce for Popover {
346
346
.id("content")
347
347
.occlude()
348
348
.tab_group()
349
.when(appearance, |this| this.popover_style(cx).p_3())
349
.when(appearance, |this| this.popover_style(window, cx).p_3())
350
350
.when_some(content, |this, content| {
351
351
this.child((content)(state, window, cx))
352
352
})
@@ -61,7 +61,7 @@ fn dropdown_positioner(bounds: Bounds<Pixels>) -> gpui_base::Positioner {61
/// shadow, and mid-fade the shadow shows straight through the panel as a dark61
/// shadow, and mid-fade the shadow shows straight through the panel as a dark62
/// slab. Ramping the ink by the cube of the fade keeps it out of sight until the62
/// slab. Ramping the ink by the cube of the fade keeps it out of sight until the63
/// panel is opaque enough to cover it, and still lands on the resting shadow63
/// panel is opaque enough to cover it, and still lands on the resting shadow64
/// [`popover_shadow`] gives every other popup.64
/// [`crate::elevation::flyout`] gives every other popup.65
///65
///66
/// # Departures from shadcn66
/// # Departures from shadcn67
///67
///@@ -292,14 +292,14 @@ impl Popover {292
pub(crate) fn render_popover_content(292
pub(crate) fn render_popover_content(293
anchor: Anchor,293
anchor: Anchor,294
appearance: bool,294
appearance: bool,295
_: &mut Window,295
window: &mut Window,296
cx: &mut App,296
cx: &mut App,297
) -> Stateful<Div> {297
) -> Stateful<Div> {298
v_flex()298
v_flex()299
.id("content")299
.id("content")300
.occlude()300
.occlude()301
.tab_group()301
.tab_group()302
.when(appearance, |this| this.popover_style(cx).p_3())302
.when(appearance, |this| this.popover_style(window, cx).p_3())303
.map(|this| match anchor {303
.map(|this| match anchor {304
Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),304
Anchor::TopLeft | Anchor::TopCenter | Anchor::TopRight => this.top_1(),305
Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),305
Anchor::BottomLeft | Anchor::BottomCenter | Anchor::BottomRight => this.bottom_1(),@@ -346,7 +346,7 @@ impl RenderOnce for Popover {346
.id("content")346
.id("content")347
.occlude()347
.occlude()348
.tab_group()348
.tab_group()349
.when(appearance, |this| this.popover_style(cx).p_3())349
.when(appearance, |this| this.popover_style(window, cx).p_3())350
.when_some(content, |this, content| {350
.when_some(content, |this, content| {351
this.child((content)(state, window, cx))351
this.child((content)(state, window, cx))352
})352
})@@ -184,6 +184,7 @@ impl WindowState {
184
184
cx: &mut App,
185
185
) -> Option<impl IntoElement + use<>> {
186
186
let active_dialogs = root.read(cx).active_dialogs.clone();
187
crate::elevation::set_framework_modal_layers(window, active_dialogs.len(), cx);
187
188
188
189
if active_dialogs.is_empty() {
189
190
return None;
@@ -184,6 +184,7 @@ impl WindowState {184
cx: &mut App,184
cx: &mut App,185
) -> Option<impl IntoElement + use<>> {185
) -> Option<impl IntoElement + use<>> {186
let active_dialogs = root.read(cx).active_dialogs.clone();186
let active_dialogs = root.read(cx).active_dialogs.clone();187
crate::elevation::set_framework_modal_layers(window, active_dialogs.len(), cx);187
188
188
if active_dialogs.is_empty() {189
if active_dialogs.is_empty() {189
return None;190
return None;@@ -616,7 +616,7 @@ where
616
616
Length::Auto => this.w(bounds.size.width),
617
617
Length::Definite(w) => this.w(w),
618
618
})
619
.popover_style(cx)
619
.popover_style(window, cx)
620
620
.child(
621
621
List::new(&self.state.list)
622
622
.when_some(
@@ -616,7 +616,7 @@ where616
Length::Auto => this.w(bounds.size.width),616
Length::Auto => this.w(bounds.size.width),617
Length::Definite(w) => this.w(w),617
Length::Definite(w) => this.w(w),618
})618
})619
.popover_style(cx)619
.popover_style(window, cx)620
.child(620
.child(621
List::new(&self.state.list)621
List::new(&self.state.list)622
.when_some(622
.when_some(@@ -37,64 +37,6 @@ pub(crate) fn popover_ring(cx: &App) -> Hsla {
37
37
cx.theme().foreground.alpha(POPOVER_RING_INK)
38
38
}
39
39
40
/// shadcn/ui's popup surface shadow — a hairline `ring` plus `shadow-md` — at
41
/// `strength` of its full ink.
42
///
43
/// Callers animating a surface in pass a rising `strength`; a resting surface
44
/// passes `1.0`.
45
///
46
/// The two blurred layers use Tailwind's radii **halved**, which is the
47
/// conversion CSS requires and not a taste adjustment. CSS defines a box
48
/// shadow's blur radius as twice the gaussian's standard deviation, while GPUI's
49
/// shader takes the field as the deviation itself (`gaussian(y, sigma)`).
50
/// Copying Tailwind's `6px` and `4px` across therefore spreads the shadow over
51
/// twice the distance, which is why [`Styled::shadow_md`] reads as a wide grey
52
/// haze next to a browser's compact one.
53
///
54
/// Measured against shadcn's own render, this lands within a luminance step of
55
/// it the whole way down the falloff.
56
///
57
/// The ring is taken as a colour rather than read from the theme here so that an
58
/// animation can hold it across frames, where no `App` is in hand.
59
#[allow(dead_code)]
60
pub(crate) fn popover_shadow(ring: Hsla, strength: f32) -> Vec<BoxShadow> {
61
let strength = strength.clamp(0., 1.);
62
let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength);
63
vec![
64
// The ring, sitting in the 1px band outside the surface. No blur, so it
65
// takes the shader's crisp path rather than the gaussian one.
66
BoxShadow::new(px(0.), px(0.), ring.alpha(ring.a * strength))
67
.blur_radius(px(0.))
68
.spread_radius(px(1.)),
69
BoxShadow::new(px(0.), px(4.), ink)
70
.blur_radius(px(3.))
71
.spread_radius(px(-1.)),
72
BoxShadow::new(px(0.), px(2.), ink)
73
.blur_radius(px(2.))
74
.spread_radius(px(-2.)),
75
]
76
}
77
78
/// shadcn/ui's `shadow-lg`, the elevation it lifts a toast to, at `strength` of
79
/// its full ink.
80
///
81
/// A toast sits higher than a popover and is built differently: shadcn gives it
82
/// a real 1px border rather than the translucent ring it puts on a popup, so
83
/// there is no ring layer here. Its corner radius is left to the caller.
84
///
85
/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains.
86
pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
87
let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength.clamp(0., 1.));
88
vec![
89
BoxShadow::new(px(0.), px(10.), ink)
90
.blur_radius(px(7.5))
91
.spread_radius(px(-3.)),
92
BoxShadow::new(px(0.), px(4.), ink)
93
.blur_radius(px(3.))
94
.spread_radius(px(-4.)),
95
]
96
}
97
98
40
/// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of
99
41
/// the container it sits in — the active pill of a segmented tab bar — at full
100
42
/// ink.
@@ -105,7 +47,7 @@ pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {
105
47
/// wide one, and a wide one would read as grime against the trough wall rather
106
48
/// than as lift.
107
49
///
108
/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains:
50
/// The radii are Tailwind's halved, for the reason [`crate::elevation`] explains:
109
51
/// CSS defines a box shadow's blur radius as twice the gaussian's standard
110
52
/// deviation, while GPUI's shader takes the field as the deviation itself
111
53
/// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore
@@ -148,12 +90,13 @@ pub trait ThemeStyled: Styled + Sized {
148
90
where
149
91
Self: ParentElement;
150
92
151
/// Give this element the surface, edge, shadow and radius of a popover.
93
/// Give this element the surface, shadow and radius of a flyout at the
94
/// elevation level `window` currently opens flyouts at.
152
95
///
153
96
/// This is the one surface every popup shares — Popover, PopupMenu, Select,
154
97
/// Combobox, DatePicker and the editor's hover popovers — so they cannot
155
/// drift apart. See [`popover_shadow`] for what the shadow is modelled on.
156
fn popover_style(self, cx: &App) -> Self;
98
/// drift apart. See [`crate::elevation`].
99
fn popover_style(self, window: &Window, cx: &App) -> Self;
157
100
158
101
/// Round this element as far as its size allows — a circle if it is square,
159
102
/// a pill if it is not — unless the theme squares its corners.
@@ -184,9 +127,11 @@ impl<T: Styled + Sized> ThemeStyled for T {
184
127
focus_style(self, FocusLine::Edge, window, cx)
185
128
}
186
129
187
fn popover_style(self, cx: &App) -> Self {
130
fn popover_style(self, window: &Window, cx: &App) -> Self {
188
131
let theme = cx.theme();
189
self.bg(theme.popover)
132
let elevation = crate::elevation::flyout(window, cx);
133
self.bg(elevation.fill)
134
.shadow(elevation.shadow)
190
135
.text_color(theme.popover_foreground)
191
136
.rounded(theme.radius_lg)
192
137
}
@@ -37,64 +37,6 @@ pub(crate) fn popover_ring(cx: &App) -> Hsla {37
cx.theme().foreground.alpha(POPOVER_RING_INK)37
cx.theme().foreground.alpha(POPOVER_RING_INK)38
}38
}39
39
40
/// shadcn/ui's popup surface shadow — a hairline `ring` plus `shadow-md` — at41
/// `strength` of its full ink.42
///43
/// Callers animating a surface in pass a rising `strength`; a resting surface44
/// passes `1.0`.45
///46
/// The two blurred layers use Tailwind's radii **halved**, which is the47
/// conversion CSS requires and not a taste adjustment. CSS defines a box48
/// shadow's blur radius as twice the gaussian's standard deviation, while GPUI's49
/// shader takes the field as the deviation itself (`gaussian(y, sigma)`).50
/// Copying Tailwind's `6px` and `4px` across therefore spreads the shadow over51
/// twice the distance, which is why [`Styled::shadow_md`] reads as a wide grey52
/// haze next to a browser's compact one.53
///54
/// Measured against shadcn's own render, this lands within a luminance step of55
/// it the whole way down the falloff.56
///57
/// The ring is taken as a colour rather than read from the theme here so that an58
/// animation can hold it across frames, where no `App` is in hand.59
#[allow(dead_code)]60
pub(crate) fn popover_shadow(ring: Hsla, strength: f32) -> Vec<BoxShadow> {61
let strength = strength.clamp(0., 1.);62
let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength);63
vec![64
// The ring, sitting in the 1px band outside the surface. No blur, so it65
// takes the shader's crisp path rather than the gaussian one.66
BoxShadow::new(px(0.), px(0.), ring.alpha(ring.a * strength))67
.blur_radius(px(0.))68
.spread_radius(px(1.)),69
BoxShadow::new(px(0.), px(4.), ink)70
.blur_radius(px(3.))71
.spread_radius(px(-1.)),72
BoxShadow::new(px(0.), px(2.), ink)73
.blur_radius(px(2.))74
.spread_radius(px(-2.)),75
]76
}77
78
/// shadcn/ui's `shadow-lg`, the elevation it lifts a toast to, at `strength` of79
/// its full ink.80
///81
/// A toast sits higher than a popover and is built differently: shadcn gives it82
/// a real 1px border rather than the translucent ring it puts on a popup, so83
/// there is no ring layer here. Its corner radius is left to the caller.84
///85
/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains.86
pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {87
let ink = hsla(0., 0., 0., SURFACE_SHADOW_INK * strength.clamp(0., 1.));88
vec![89
BoxShadow::new(px(0.), px(10.), ink)90
.blur_radius(px(7.5))91
.spread_radius(px(-3.)),92
BoxShadow::new(px(0.), px(4.), ink)93
.blur_radius(px(3.))94
.spread_radius(px(-4.)),95
]96
}97
98
/// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of40
/// shadcn/ui's `shadow-sm`, the elevation it spends on a control raised out of99
/// the container it sits in — the active pill of a segmented tab bar — at full41
/// the container it sits in — the active pill of a segmented tab bar — at full100
/// ink.42
/// ink.@@ -105,7 +47,7 @@ pub(crate) fn toast_shadow(strength: f32) -> Vec<BoxShadow> {105
/// wide one, and a wide one would read as grime against the trough wall rather47
/// wide one, and a wide one would read as grime against the trough wall rather106
/// than as lift.48
/// than as lift.107
///49
///108
/// The radii are Tailwind's halved, for the reason [`popover_shadow`] explains:50
/// The radii are Tailwind's halved, for the reason [`crate::elevation`] explains:109
/// CSS defines a box shadow's blur radius as twice the gaussian's standard51
/// CSS defines a box shadow's blur radius as twice the gaussian's standard110
/// deviation, while GPUI's shader takes the field as the deviation itself52
/// deviation, while GPUI's shader takes the field as the deviation itself111
/// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore53
/// (`gaussian(y, sigma)`). Copying Tailwind's `3px` and `2px` across therefore@@ -148,12 +90,13 @@ pub trait ThemeStyled: Styled + Sized {148
where90
where149
Self: ParentElement;91
Self: ParentElement;150
92
151
/// Give this element the surface, edge, shadow and radius of a popover.93
/// Give this element the surface, shadow and radius of a flyout at the94
/// elevation level `window` currently opens flyouts at.152
///95
///153
/// This is the one surface every popup shares — Popover, PopupMenu, Select,96
/// This is the one surface every popup shares — Popover, PopupMenu, Select,154
/// Combobox, DatePicker and the editor's hover popovers — so they cannot97
/// Combobox, DatePicker and the editor's hover popovers — so they cannot155
/// drift apart. See [`popover_shadow`] for what the shadow is modelled on.98
/// drift apart. See [`crate::elevation`].156
fn popover_style(self, cx: &App) -> Self;99
fn popover_style(self, window: &Window, cx: &App) -> Self;157
100
158
/// Round this element as far as its size allows — a circle if it is square,101
/// Round this element as far as its size allows — a circle if it is square,159
/// a pill if it is not — unless the theme squares its corners.102
/// a pill if it is not — unless the theme squares its corners.@@ -184,9 +127,11 @@ impl<T: Styled + Sized> ThemeStyled for T {184
focus_style(self, FocusLine::Edge, window, cx)127
focus_style(self, FocusLine::Edge, window, cx)185
}128
}186
129
187
fn popover_style(self, cx: &App) -> Self {130
fn popover_style(self, window: &Window, cx: &App) -> Self {188
let theme = cx.theme();131
let theme = cx.theme();189
self.bg(theme.popover)132
let elevation = crate::elevation::flyout(window, cx);133
self.bg(elevation.fill)134
.shadow(elevation.shadow)190
.text_color(theme.popover_foreground)135
.text_color(theme.popover_foreground)191
.rounded(theme.radius_lg)136
.rounded(theme.radius_lg)192
}137
}@@ -792,7 +792,7 @@ impl RenderOnce for DatePicker {
792
792
div()
793
793
.occlude()
794
794
.p_3()
795
.popover_style(cx)
795
.popover_style(window, cx)
796
796
.on_mouse_up_out(
797
797
MouseButton::Left,
798
798
window.listener_for(&self.state, |view, _, window, cx| {
@@ -792,7 +792,7 @@ impl RenderOnce for DatePicker {792
div()792
div()793
.occlude()793
.occlude()794
.p_3()794
.p_3()795
.popover_style(cx)795
.popover_style(window, cx)796
.on_mouse_up_out(796
.on_mouse_up_out(797
MouseButton::Left,797
MouseButton::Left,798
window.listener_for(&self.state, |view, _, window, cx| {798
window.listener_for(&self.state, |view, _, window, cx| {@@ -91,6 +91,7 @@ impl Styled for Tooltip {
91
91
}
92
92
impl Render for Tooltip {
93
93
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
94
let flyout_fill = crate::elevation::flyout(window, cx).fill;
94
95
let key_binding = if let Some(key_binding) = &self.key_binding {
95
96
Some(key_binding.clone())
96
97
} else {
@@ -111,9 +112,9 @@ impl Render for Tooltip {
111
112
.h_flex()
112
113
.font_family(cx.theme().font_family.clone())
113
114
.m_3()
114
.bg(cx.theme().tokens.popover)
115
.bg(flyout_fill)
116
.shadow(crate::elevation::shadow8())
115
117
.text_color(cx.theme().popover_foreground)
116
.bg(cx.theme().tokens.popover)
117
118
.rounded(cx.theme().radius)
118
119
.justify_between()
119
120
.py_0p5()
@@ -91,6 +91,7 @@ impl Styled for Tooltip {91
}91
}92
impl Render for Tooltip {92
impl Render for Tooltip {93
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {93
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {94
let flyout_fill = crate::elevation::flyout(window, cx).fill;94
let key_binding = if let Some(key_binding) = &self.key_binding {95
let key_binding = if let Some(key_binding) = &self.key_binding {95
Some(key_binding.clone())96
Some(key_binding.clone())96
} else {97
} else {@@ -111,9 +112,9 @@ impl Render for Tooltip {111
.h_flex()112
.h_flex()112
.font_family(cx.theme().font_family.clone())113
.font_family(cx.theme().font_family.clone())113
.m_3()114
.m_3()114
.bg(cx.theme().tokens.popover)115
.bg(flyout_fill)116
.shadow(crate::elevation::shadow8())115
.text_color(cx.theme().popover_foreground)117
.text_color(cx.theme().popover_foreground)116
.bg(cx.theme().tokens.popover)117
.rounded(cx.theme().radius)118
.rounded(cx.theme().radius)118
.justify_between()119
.justify_between()119
.py_0p5()120
.py_0p5()