BlueGit

ict rusty-teams

feat(calendar): Teams-like grid look and calendar colours

- day headers: number over the full weekday name in the app language,
  today in the accent colour with its bar
- hour grid: hour lines plus lighter minor lines per time scale (solid,
  islands look), right-aligned labels at the hour line, 24h as 07:00
- off-hours and non-work days shaded; a thin now line across the week,
  thicker accent line with a dot in today's column
- event blocks: bold title with the organizer on the same line, series
  icon, block, all-day and month chips in the calendar's colour
  (theme::calendar_color: accent, then the avatar palette)
- header: pane toggle, localized controls and view menu; layout guard
  checks header and day headers at every size
- week start defaults to the mailbox language region (en-CH -> Monday,
  as Teams shows) before the regional format
- demo week anchors on the Monday inside the shown range

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Joachim Mild · pushed by metis

Authored 2026-11-15 · 2 weeks ago

Hash
064c42883642edbc7d767afcbb3883754f063044
Parent
68fc471c
16 files changed +530 −139
crates/app-base/locales/app.yml +2 −2
@@ -335,8 +335,8 @@ settings:
335 335 en: Week, work week and month start on this day
336 336 de: Woche, Arbeitswoche und Monat beginnen an diesem Tag
337 337 first_day_regional:
338 en: "Regional format (%{day})"
339 de: "Regionalformat (%{day})"
338 en: "As in Outlook (%{day})"
339 de: "Wie in Outlook (%{day})"
340 340 work_days:
341 341 en: Work days
342 342 de: Arbeitstage
@@ -335,8 +335,8 @@ settings:
335 en: Week, work week and month start on this day
335 en: Week, work week and month start on this day
336 de: Woche, Arbeitswoche und Monat beginnen an diesem Tag
336 de: Woche, Arbeitswoche und Monat beginnen an diesem Tag
337 first_day_regional:
337 first_day_regional:
338 en: "Regional format (%{day})"
338 en: "As in Outlook (%{day})"
339 de: "Regionalformat (%{day})"
339 de: "Wie in Outlook (%{day})"
340 work_days:
340 work_days:
341 en: Work days
341 en: Work days
342 de: Arbeitstage
342 de: Arbeitstage
crates/app-base/src/format.rs +9 −0
@@ -80,6 +80,13 @@ pub fn regional_first_day() -> Weekday {
80 80 current_date_style().map_or(Weekday::Mon, |style| style.first_day)
81 81 }
82 82
83 /// First day of the week for a locale tag such as `en-CH` (CLDR region data).
84 pub fn first_day_for_locale(locale: &str) -> Weekday {
85 let locale = locale.to_ascii_lowercase().replace('_', "-");
86 let language = locale.split('-').next().unwrap_or_default().to_owned();
87 first_day_for(&locale, &language)
88 }
89
83 90 fn first_day_for(locale: &str, language: &str) -> Weekday {
84 91 if SUNDAY_FIRST_LOCALES.contains(&locale) || SUNDAY_FIRST_LOCALES.contains(&language) {
85 92 Weekday::Sun
@@ -404,6 +411,8 @@ mod tests {
404 411 assert_eq!(first("ar-SA"), Weekday::Sat);
405 412 assert_eq!(first("ar-MA"), Weekday::Mon);
406 413 assert_eq!(first("ja-JP"), Weekday::Sun);
414 assert_eq!(first_day_for_locale("en-CH"), Weekday::Mon);
415 assert_eq!(first_day_for_locale("en_US"), Weekday::Sun);
407 416 set_date_locale(None);
408 417 assert_eq!(regional_first_day(), Weekday::Mon);
409 418 }
@@ -80,6 +80,13 @@ pub fn regional_first_day() -> Weekday {
80 current_date_style().map_or(Weekday::Mon, |style| style.first_day)
80 current_date_style().map_or(Weekday::Mon, |style| style.first_day)
81}
81}
82
82
83/// First day of the week for a locale tag such as `en-CH` (CLDR region data).
84pub fn first_day_for_locale(locale: &str) -> Weekday {
85 let locale = locale.to_ascii_lowercase().replace('_', "-");
86 let language = locale.split('-').next().unwrap_or_default().to_owned();
87 first_day_for(&locale, &language)
88}
89
83fn first_day_for(locale: &str, language: &str) -> Weekday {
90fn first_day_for(locale: &str, language: &str) -> Weekday {
84 if SUNDAY_FIRST_LOCALES.contains(&locale) || SUNDAY_FIRST_LOCALES.contains(&language) {
91 if SUNDAY_FIRST_LOCALES.contains(&locale) || SUNDAY_FIRST_LOCALES.contains(&language) {
85 Weekday::Sun
92 Weekday::Sun
@@ -404,6 +411,8 @@ mod tests {
404 assert_eq!(first("ar-SA"), Weekday::Sat);
411 assert_eq!(first("ar-SA"), Weekday::Sat);
405 assert_eq!(first("ar-MA"), Weekday::Mon);
412 assert_eq!(first("ar-MA"), Weekday::Mon);
406 assert_eq!(first("ja-JP"), Weekday::Sun);
413 assert_eq!(first("ja-JP"), Weekday::Sun);
414 assert_eq!(first_day_for_locale("en-CH"), Weekday::Mon);
415 assert_eq!(first_day_for_locale("en_US"), Weekday::Sun);
407 set_date_locale(None);
416 set_date_locale(None);
408 assert_eq!(regional_first_day(), Weekday::Mon);
417 assert_eq!(regional_first_day(), Weekday::Mon);
409 }
418 }
crates/app-base/src/theme.rs +19 −0
@@ -397,6 +397,15 @@ pub fn avatar_color(index: usize) -> Hsla {
397 397 color(palette[index % palette.len()])
398 398 }
399 399
400 /// Colour of the calendar at `index` in the calendar list: Outlook (0) takes the
401 /// accent, every further calendar the next avatar palette colour.
402 pub fn calendar_color(index: usize) -> Hsla {
403 match index {
404 0 => accent(),
405 index => avatar_color(index - 1),
406 }
407 }
408
400 409 pub fn avatar_palette_len() -> usize {
401 410 palette().avatar_palette.len()
402 411 }
@@ -408,6 +417,16 @@ mod tests {
408 417 set_thread_scheme, set_thread_shade,
409 418 };
410 419
420 #[test]
421 fn calendar_colors_start_with_the_accent_then_follow_the_palette() {
422 assert_eq!(super::calendar_color(0), super::accent());
423 assert_eq!(super::calendar_color(1), avatar_color(0));
424 assert_eq!(
425 super::calendar_color(1 + avatar_palette_len()),
426 avatar_color(0)
427 );
428 }
429
411 430 #[test]
412 431 fn avatar_colors_wrap_around_the_palette() {
413 432 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
@@ -397,6 +397,15 @@ pub fn avatar_color(index: usize) -> Hsla {
397 color(palette[index % palette.len()])
397 color(palette[index % palette.len()])
398}
398}
399
399
400/// Colour of the calendar at `index` in the calendar list: Outlook (0) takes the
401/// accent, every further calendar the next avatar palette colour.
402pub fn calendar_color(index: usize) -> Hsla {
403 match index {
404 0 => accent(),
405 index => avatar_color(index - 1),
406 }
407}
408
400pub fn avatar_palette_len() -> usize {
409pub fn avatar_palette_len() -> usize {
401 palette().avatar_palette.len()
410 palette().avatar_palette.len()
402}
411}
@@ -408,6 +417,16 @@ mod tests {
408 set_thread_scheme, set_thread_shade,
417 set_thread_scheme, set_thread_shade,
409 };
418 };
410
419
420 #[test]
421 fn calendar_colors_start_with_the_accent_then_follow_the_palette() {
422 assert_eq!(super::calendar_color(0), super::accent());
423 assert_eq!(super::calendar_color(1), avatar_color(0));
424 assert_eq!(
425 super::calendar_color(1 + avatar_palette_len()),
426 avatar_color(0)
427 );
428 }
429
411 #[test]
430 #[test]
412 fn avatar_colors_wrap_around_the_palette() {
431 fn avatar_colors_wrap_around_the_palette() {
413 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
432 assert_eq!(avatar_color(0), avatar_color(avatar_palette_len()));
crates/app-base/src/ui_locale.rs +59 −0
@@ -135,6 +135,65 @@ mod tests {
135 135 use super::*;
136 136 use tempfile::tempdir;
137 137
138 /// Leaf keys (`a.b.c`) with the languages they define, read from the locale file.
139 fn leaf_languages() -> Vec<(String, Vec<String>)> {
140 let mut path: Vec<(usize, String)> = Vec::new();
141 let mut leaves: Vec<(String, Vec<String>)> = Vec::new();
142 for line in include_str!("../locales/app.yml").lines() {
143 let trimmed = line.trim_start();
144 if trimmed.is_empty() || trimmed.starts_with('#') || trimmed.starts_with('_') {
145 continue;
146 }
147 let indent = line.len() - trimmed.len();
148 let Some((key, value)) = trimmed.split_once(':') else {
149 continue;
150 };
151 if key == "en" || key == "de" {
152 if let Some(last) = leaves.last_mut() {
153 last.1.push(key.to_owned());
154 }
155 continue;
156 }
157 path.retain(|(depth, _)| *depth < indent);
158 path.push((indent, key.to_owned()));
159 if value.trim().is_empty() {
160 let full: Vec<&str> = path.iter().map(|(_, key)| key.as_str()).collect();
161 leaves.push((full.join("."), Vec::new()));
162 }
163 }
164 leaves.retain(|(_, languages)| !languages.is_empty());
165 leaves
166 }
167
168 #[test]
169 fn calendar_strings_exist_in_english_and_german() {
170 const PREFIXES: [&str; 5] = [
171 "calendar.view.",
172 "calendar.weekday.",
173 "calendar.weekday_short.",
174 "calendar.month.",
175 "settings.calendar.",
176 ];
177 let leaves = leaf_languages();
178 let covered: Vec<_> = leaves
179 .iter()
180 .filter(|(key, _)| PREFIXES.iter().any(|prefix| key.starts_with(prefix)))
181 .collect();
182 assert!(
183 covered.len() > 60,
184 "only {} calendar keys found",
185 covered.len()
186 );
187 let missing: Vec<_> = covered
188 .iter()
189 .filter(|(_, languages)| {
190 !(languages.contains(&"en".into()) && languages.contains(&"de".into()))
191 })
192 .map(|(key, _)| key.as_str())
193 .collect();
194 assert!(missing.is_empty(), "missing en or de: {missing:?}");
195 }
196
138 197 #[test]
139 198 fn ui_locale_effective_prefers_explicit_english_and_german() {
140 199 let _guard = locale_test_lock();
@@ -135,6 +135,65 @@ mod tests {
135 use super::*;
135 use super::*;
136 use tempfile::tempdir;
136 use tempfile::tempdir;
137
137
138 /// Leaf keys (`a.b.c`) with the languages they define, read from the locale file.
139 fn leaf_languages() -> Vec<(String, Vec<String>)> {
140 let mut path: Vec<(usize, String)> = Vec::new();
141 let mut leaves: Vec<(String, Vec<String>)> = Vec::new();
142 for line in include_str!("../locales/app.yml").lines() {
143 let trimmed = line.trim_start();
144 if trimmed.is_empty() || trimmed.starts_with('#') || trimmed.starts_with('_') {
145 continue;
146 }
147 let indent = line.len() - trimmed.len();
148 let Some((key, value)) = trimmed.split_once(':') else {
149 continue;
150 };
151 if key == "en" || key == "de" {
152 if let Some(last) = leaves.last_mut() {
153 last.1.push(key.to_owned());
154 }
155 continue;
156 }
157 path.retain(|(depth, _)| *depth < indent);
158 path.push((indent, key.to_owned()));
159 if value.trim().is_empty() {
160 let full: Vec<&str> = path.iter().map(|(_, key)| key.as_str()).collect();
161 leaves.push((full.join("."), Vec::new()));
162 }
163 }
164 leaves.retain(|(_, languages)| !languages.is_empty());
165 leaves
166 }
167
168 #[test]
169 fn calendar_strings_exist_in_english_and_german() {
170 const PREFIXES: [&str; 5] = [
171 "calendar.view.",
172 "calendar.weekday.",
173 "calendar.weekday_short.",
174 "calendar.month.",
175 "settings.calendar.",
176 ];
177 let leaves = leaf_languages();
178 let covered: Vec<_> = leaves
179 .iter()
180 .filter(|(key, _)| PREFIXES.iter().any(|prefix| key.starts_with(prefix)))
181 .collect();
182 assert!(
183 covered.len() > 60,
184 "only {} calendar keys found",
185 covered.len()
186 );
187 let missing: Vec<_> = covered
188 .iter()
189 .filter(|(_, languages)| {
190 !(languages.contains(&"en".into()) && languages.contains(&"de".into()))
191 })
192 .map(|(key, _)| key.as_str())
193 .collect();
194 assert!(missing.is_empty(), "missing en or de: {missing:?}");
195 }
196
138 #[test]
197 #[test]
139 fn ui_locale_effective_prefers_explicit_english_and_german() {
198 fn ui_locale_effective_prefers_explicit_english_and_german() {
140 let _guard = locale_test_lock();
199 let _guard = locale_test_lock();
crates/app-call-model/src/calendar_prefs.rs +2 −0
@@ -133,6 +133,8 @@ pub struct CalendarPrefs {
133 133 pub pane_hidden: bool,
134 134 pub collapsed_groups: Vec<String>,
135 135 pub work_hours: WorkHours,
136 /// Mailbox language (`en-CH`), cached; Outlook takes the default week start from it.
137 pub mailbox_locale: Option<String>,
136 138 }
137 139
138 140 impl CalendarPrefs {
@@ -133,6 +133,8 @@ pub struct CalendarPrefs {
133 pub pane_hidden: bool,
133 pub pane_hidden: bool,
134 pub collapsed_groups: Vec<String>,
134 pub collapsed_groups: Vec<String>,
135 pub work_hours: WorkHours,
135 pub work_hours: WorkHours,
136 /// Mailbox language (`en-CH`), cached; Outlook takes the default week start from it.
137 pub mailbox_locale: Option<String>,
136}
138}
137
139
138impl CalendarPrefs {
140impl CalendarPrefs {
crates/app-call-model/src/week_grid.rs +72 −2
@@ -225,6 +225,38 @@ pub fn week_range(
225 225 )
226 226 }
227 227
228 /// Position of a Google calendar in the calendar list; Outlook is 0.
229 pub fn google_calendar_index(
230 accounts: &store::CalendarAccounts,
231 account_id: &str,
232 calendar_id: &str,
233 ) -> Option<usize> {
234 accounts
235 .google_accounts
236 .iter()
237 .flat_map(|account| {
238 account
239 .calendars
240 .iter()
241 .map(move |calendar| (account.id.as_str(), calendar.id.as_str()))
242 })
243 .position(|(account, calendar)| account == account_id && calendar == calendar_id)
244 .map(|position| position + 1)
245 }
246
247 /// Calendar list position that colours an event (merged events keep Outlook's colour).
248 pub fn calendar_index(event: &CalendarEvent, accounts: &store::CalendarAccounts) -> usize {
249 match event.source {
250 chatsvc::CalendarSource::Outlook => 0,
251 chatsvc::CalendarSource::Google => event
252 .account_id
253 .as_deref()
254 .zip(event.calendar_id.as_deref())
255 .and_then(|(account, calendar)| google_calendar_index(accounts, account, calendar))
256 .unwrap_or(1),
257 }
258 }
259
228 260 pub fn shown_in_calendar(event: &CalendarEvent) -> bool {
229 261 event.response != ResponseType::Declined
230 262 }
@@ -338,7 +370,7 @@ pub fn event_look(event: &CalendarEvent) -> EventLook {
338 370
339 371 pub fn hour_label(hour: u32, twelve_hour: bool) -> String {
340 372 if !twelve_hour {
341 return hour.to_string();
373 return format!("{hour:02}:00");
342 374 }
343 375 match hour {
344 376 0 => "12 AM".to_owned(),
@@ -582,11 +614,49 @@ mod tests {
582 614 );
583 615 }
584 616
617 #[test]
618 fn events_take_the_colour_index_of_their_calendar() {
619 use store::{CalendarAccounts, GoogleAccount, GoogleCalendarInfo, GoogleTokenSet};
620 let calendar = |id: &str| GoogleCalendarInfo {
621 id: id.into(),
622 summary: id.into(),
623 selected: true,
624 primary: false,
625 };
626 let accounts = CalendarAccounts {
627 google_accounts: vec![
628 GoogleAccount {
629 id: "a".into(),
630 email: "a@example.com".into(),
631 calendars: vec![calendar("primary"), calendar("family")],
632 tokens: GoogleTokenSet::default(),
633 },
634 GoogleAccount {
635 id: "b".into(),
636 email: "b@example.com".into(),
637 calendars: vec![calendar("work")],
638 tokens: GoogleTokenSet::default(),
639 },
640 ],
641 ..CalendarAccounts::default()
642 };
643 let mut google = event(9, 0, 30);
644 google.source = chatsvc::CalendarSource::Google;
645 google.account_id = Some("b".into());
646 google.calendar_id = Some("work".into());
647 assert_eq!(calendar_index(&google, &accounts), 3);
648 google.account_id = Some("a".into());
649 google.calendar_id = Some("family".into());
650 assert_eq!(calendar_index(&google, &accounts), 2);
651 assert_eq!(calendar_index(&event(9, 0, 30), &accounts), 0);
652 }
653
585 654 #[test]
586 655 fn labels_read_like_teams() {
587 656 assert_eq!(hour_label(0, true), "12 AM");
588 657 assert_eq!(hour_label(13, true), "1 PM");
589 assert_eq!(hour_label(13, false), "13");
658 assert_eq!(hour_label(13, false), "13:00");
659 assert_eq!(hour_label(7, false), "07:00");
590 660 }
591 661
592 662 #[test]
@@ -225,6 +225,38 @@ pub fn week_range(
225 )
225 )
226}
226}
227
227
228/// Position of a Google calendar in the calendar list; Outlook is 0.
229pub fn google_calendar_index(
230 accounts: &store::CalendarAccounts,
231 account_id: &str,
232 calendar_id: &str,
233) -> Option<usize> {
234 accounts
235 .google_accounts
236 .iter()
237 .flat_map(|account| {
238 account
239 .calendars
240 .iter()
241 .map(move |calendar| (account.id.as_str(), calendar.id.as_str()))
242 })
243 .position(|(account, calendar)| account == account_id && calendar == calendar_id)
244 .map(|position| position + 1)
245}
246
247/// Calendar list position that colours an event (merged events keep Outlook's colour).
248pub fn calendar_index(event: &CalendarEvent, accounts: &store::CalendarAccounts) -> usize {
249 match event.source {
250 chatsvc::CalendarSource::Outlook => 0,
251 chatsvc::CalendarSource::Google => event
252 .account_id
253 .as_deref()
254 .zip(event.calendar_id.as_deref())
255 .and_then(|(account, calendar)| google_calendar_index(accounts, account, calendar))
256 .unwrap_or(1),
257 }
258}
259
228pub fn shown_in_calendar(event: &CalendarEvent) -> bool {
260pub fn shown_in_calendar(event: &CalendarEvent) -> bool {
229 event.response != ResponseType::Declined
261 event.response != ResponseType::Declined
230}
262}
@@ -338,7 +370,7 @@ pub fn event_look(event: &CalendarEvent) -> EventLook {
338
370
339pub fn hour_label(hour: u32, twelve_hour: bool) -> String {
371pub fn hour_label(hour: u32, twelve_hour: bool) -> String {
340 if !twelve_hour {
372 if !twelve_hour {
341 return hour.to_string();
373 return format!("{hour:02}:00");
342 }
374 }
343 match hour {
375 match hour {
344 0 => "12 AM".to_owned(),
376 0 => "12 AM".to_owned(),
@@ -582,11 +614,49 @@ mod tests {
582 );
614 );
583 }
615 }
584
616
617 #[test]
618 fn events_take_the_colour_index_of_their_calendar() {
619 use store::{CalendarAccounts, GoogleAccount, GoogleCalendarInfo, GoogleTokenSet};
620 let calendar = |id: &str| GoogleCalendarInfo {
621 id: id.into(),
622 summary: id.into(),
623 selected: true,
624 primary: false,
625 };
626 let accounts = CalendarAccounts {
627 google_accounts: vec![
628 GoogleAccount {
629 id: "a".into(),
630 email: "a@example.com".into(),
631 calendars: vec![calendar("primary"), calendar("family")],
632 tokens: GoogleTokenSet::default(),
633 },
634 GoogleAccount {
635 id: "b".into(),
636 email: "b@example.com".into(),
637 calendars: vec![calendar("work")],
638 tokens: GoogleTokenSet::default(),
639 },
640 ],
641 ..CalendarAccounts::default()
642 };
643 let mut google = event(9, 0, 30);
644 google.source = chatsvc::CalendarSource::Google;
645 google.account_id = Some("b".into());
646 google.calendar_id = Some("work".into());
647 assert_eq!(calendar_index(&google, &accounts), 3);
648 google.account_id = Some("a".into());
649 google.calendar_id = Some("family".into());
650 assert_eq!(calendar_index(&google, &accounts), 2);
651 assert_eq!(calendar_index(&event(9, 0, 30), &accounts), 0);
652 }
653
585 #[test]
654 #[test]
586 fn labels_read_like_teams() {
655 fn labels_read_like_teams() {
587 assert_eq!(hour_label(0, true), "12 AM");
656 assert_eq!(hour_label(0, true), "12 AM");
588 assert_eq!(hour_label(13, true), "1 PM");
657 assert_eq!(hour_label(13, true), "1 PM");
589 assert_eq!(hour_label(13, false), "13");
658 assert_eq!(hour_label(13, false), "13:00");
659 assert_eq!(hour_label(7, false), "07:00");
590 }
660 }
591
661
592 #[test]
662 #[test]
crates/app-state/src/call/calendar_settings.rs +30 −2
@@ -43,8 +43,16 @@ impl AppState {
43 43 Ok(mailbox) => {
44 44 state.mailbox_time_zone = mailbox.time_zone.clone();
45 45 let hours = work_hours_from(&mailbox);
46 if hours != state.calendar_prefs.work_hours {
47 state.update_calendar_prefs(|prefs| prefs.work_hours = hours, cx);
46 let locale = mailbox.locale.clone();
47 let prefs = &state.calendar_prefs;
48 if hours != prefs.work_hours || locale != prefs.mailbox_locale {
49 state.update_calendar_prefs(
50 |prefs| {
51 prefs.work_hours = hours;
52 prefs.mailbox_locale = locale;
53 },
54 cx,
55 );
48 56 }
49 57 }
50 58 Err(error) => crate::diagnostics::record(format!(
@@ -76,6 +84,7 @@ impl AppState {
76 84 start: hours.start,
77 85 end: hours.end,
78 86 time_zone: self.mailbox_time_zone.clone(),
87 locale: None,
79 88 };
80 89 let receiver =
81 90 crate::runtime::spawn(async move { engine.remote().set_working_hours(&mailbox).await });
@@ -120,6 +129,25 @@ mod tests {
120 129 use crate::call::calendar_prefs::{DefaultView, WorkHours, load_calendar_prefs};
121 130 use crate::call::week_grid::CalendarSpan;
122 131
132 #[gpui_kit::test]
133 fn the_week_start_follows_the_mailbox_language(cx: &mut TestAppContext) {
134 cx.update(gpui_kit::init);
135 let store = Arc::new(Store::open_in_memory().unwrap());
136 let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
137 cx.update(|cx| {
138 app.update(cx, |state, cx| {
139 state
140 .update_calendar_prefs(|prefs| prefs.mailbox_locale = Some("en-US".into()), cx);
141 assert_eq!(state.calendar_layout().first_day, Weekday::Sun);
142 state
143 .update_calendar_prefs(|prefs| prefs.mailbox_locale = Some("en-CH".into()), cx);
144 assert_eq!(state.calendar_layout().first_day, Weekday::Mon);
145 state.update_calendar_prefs(|prefs| prefs.first_day = Some(Weekday::Sat), cx);
146 assert_eq!(state.calendar_layout().first_day, Weekday::Sat);
147 })
148 });
149 }
150
123 151 #[gpui_kit::test]
124 152 fn the_chosen_span_survives_a_restart(cx: &mut TestAppContext) {
125 153 cx.update(gpui_kit::init);
@@ -43,8 +43,16 @@ impl AppState {
43 Ok(mailbox) => {
43 Ok(mailbox) => {
44 state.mailbox_time_zone = mailbox.time_zone.clone();
44 state.mailbox_time_zone = mailbox.time_zone.clone();
45 let hours = work_hours_from(&mailbox);
45 let hours = work_hours_from(&mailbox);
46 if hours != state.calendar_prefs.work_hours {
46 let locale = mailbox.locale.clone();
47 state.update_calendar_prefs(|prefs| prefs.work_hours = hours, cx);
47 let prefs = &state.calendar_prefs;
48 if hours != prefs.work_hours || locale != prefs.mailbox_locale {
49 state.update_calendar_prefs(
50 |prefs| {
51 prefs.work_hours = hours;
52 prefs.mailbox_locale = locale;
53 },
54 cx,
55 );
48 }
56 }
49 }
57 }
50 Err(error) => crate::diagnostics::record(format!(
58 Err(error) => crate::diagnostics::record(format!(
@@ -76,6 +84,7 @@ impl AppState {
76 start: hours.start,
84 start: hours.start,
77 end: hours.end,
85 end: hours.end,
78 time_zone: self.mailbox_time_zone.clone(),
86 time_zone: self.mailbox_time_zone.clone(),
87 locale: None,
79 };
88 };
80 let receiver =
89 let receiver =
81 crate::runtime::spawn(async move { engine.remote().set_working_hours(&mailbox).await });
90 crate::runtime::spawn(async move { engine.remote().set_working_hours(&mailbox).await });
@@ -120,6 +129,25 @@ mod tests {
120 use crate::call::calendar_prefs::{DefaultView, WorkHours, load_calendar_prefs};
129 use crate::call::calendar_prefs::{DefaultView, WorkHours, load_calendar_prefs};
121 use crate::call::week_grid::CalendarSpan;
130 use crate::call::week_grid::CalendarSpan;
122
131
132 #[gpui_kit::test]
133 fn the_week_start_follows_the_mailbox_language(cx: &mut TestAppContext) {
134 cx.update(gpui_kit::init);
135 let store = Arc::new(Store::open_in_memory().unwrap());
136 let app = cx.update(|cx| cx.new(|_| AppState::new(store, Mode::default())));
137 cx.update(|cx| {
138 app.update(cx, |state, cx| {
139 state
140 .update_calendar_prefs(|prefs| prefs.mailbox_locale = Some("en-US".into()), cx);
141 assert_eq!(state.calendar_layout().first_day, Weekday::Sun);
142 state
143 .update_calendar_prefs(|prefs| prefs.mailbox_locale = Some("en-CH".into()), cx);
144 assert_eq!(state.calendar_layout().first_day, Weekday::Mon);
145 state.update_calendar_prefs(|prefs| prefs.first_day = Some(Weekday::Sat), cx);
146 assert_eq!(state.calendar_layout().first_day, Weekday::Sat);
147 })
148 });
149 }
150
123 #[gpui_kit::test]
151 #[gpui_kit::test]
124 fn the_chosen_span_survives_a_restart(cx: &mut TestAppContext) {
152 fn the_chosen_span_survives_a_restart(cx: &mut TestAppContext) {
125 cx.update(gpui_kit::init);
153 cx.update(gpui_kit::init);
crates/app-state/src/call/week.rs +42 −3
@@ -53,8 +53,17 @@ impl CalendarWeek {
53 53 impl AppState {
54 54 /// Week layout from the calendar settings and the regional first day.
55 55 pub fn calendar_layout(&self) -> WeekLayout {
56 self.calendar_prefs.layout(self.default_first_day())
57 }
58
59 /// First day of week without an override: the mailbox language's region, as in
60 /// Outlook and Teams, else the regional format.
61 pub fn default_first_day(&self) -> Weekday {
56 62 self.calendar_prefs
57 .layout(app_base::format::regional_first_day())
63 .mailbox_locale
64 .as_deref()
65 .map(app_base::format::first_day_for_locale)
66 .unwrap_or_else(app_base::format::regional_first_day)
58 67 }
59 68
60 69 pub fn calendar_start(&self) -> NaiveDate {
@@ -173,7 +182,11 @@ impl AppState {
173 182 let (from, to) = dates_range(&self.calendar_dates(), offset);
174 183 if self.mode.demo {
175 184 let mut events = demo_events(demo_anchor());
176 events.extend(demo_week(week_start(start, Weekday::Mon), offset));
185 // Demo meetings sit Monday to Friday of the week the grid shows.
186 // The Monday inside the first shown week, whatever day the week starts on.
187 let dates = self.calendar_dates();
188 let anchor = dates.get(6).or(dates.last()).copied().unwrap_or(start);
189 events.extend(demo_week(week_start(anchor, Weekday::Mon), offset));
177 190 events.extend(self.demo_meetings.iter().cloned());
178 191 events.retain(|event| event.end > from && event.start < to);
179 192 events.sort_by_key(|event| (event.start, event.end));
@@ -472,7 +485,7 @@ mod tests {
472 485 use std::sync::Arc;
473 486
474 487 use chatsvc::{CalendarEvent, CalendarSource};
475 use chrono::{TimeZone, Utc};
488 use chrono::{Offset as _, TimeZone, Utc};
476 489 use gpui_kit::{AppContext as _, TestAppContext};
477 490 use store::Store;
478 491
@@ -544,6 +557,32 @@ mod tests {
544 557 });
545 558 }
546 559
560 #[gpui_kit::test]
561 fn demo_week_fills_the_visible_work_week(cx: &mut TestAppContext) {
562 cx.update(gpui_kit::init);
563 let store = Arc::new(Store::open_in_memory().unwrap());
564 let mode = Mode {
565 demo: true,
566 ..Mode::default()
567 };
568 let app = cx.update(|cx| cx.new(|_| AppState::new(store, mode)));
569 cx.update(|cx| {
570 app.update(cx, |state, cx| {
571 state.open_calendar(cx);
572 let dates = state.calendar_dates();
573 let offset = chrono::Local::now().offset().fix();
574 let days =
575 crate::call::week_grid::week_days(&state.calendar_week.events, &dates, offset);
576 let blocks: usize = days.iter().map(|day| day.blocks.len()).sum();
577 assert!(
578 blocks >= 8,
579 "dates {dates:?}, events {}, blocks {blocks}",
580 state.calendar_week.events.len()
581 );
582 })
583 });
584 }
585
547 586 #[test]
548 587 fn a_failed_source_keeps_its_previous_events() {
549 588 let previous = vec![
@@ -53,8 +53,17 @@ impl CalendarWeek {
53impl AppState {
53impl AppState {
54 /// Week layout from the calendar settings and the regional first day.
54 /// Week layout from the calendar settings and the regional first day.
55 pub fn calendar_layout(&self) -> WeekLayout {
55 pub fn calendar_layout(&self) -> WeekLayout {
56 self.calendar_prefs.layout(self.default_first_day())
57 }
58
59 /// First day of week without an override: the mailbox language's region, as in
60 /// Outlook and Teams, else the regional format.
61 pub fn default_first_day(&self) -> Weekday {
56 self.calendar_prefs
62 self.calendar_prefs
57 .layout(app_base::format::regional_first_day())
63 .mailbox_locale
64 .as_deref()
65 .map(app_base::format::first_day_for_locale)
66 .unwrap_or_else(app_base::format::regional_first_day)
58 }
67 }
59
68
60 pub fn calendar_start(&self) -> NaiveDate {
69 pub fn calendar_start(&self) -> NaiveDate {
@@ -173,7 +182,11 @@ impl AppState {
173 let (from, to) = dates_range(&self.calendar_dates(), offset);
182 let (from, to) = dates_range(&self.calendar_dates(), offset);
174 if self.mode.demo {
183 if self.mode.demo {
175 let mut events = demo_events(demo_anchor());
184 let mut events = demo_events(demo_anchor());
176 events.extend(demo_week(week_start(start, Weekday::Mon), offset));
185 // Demo meetings sit Monday to Friday of the week the grid shows.
186 // The Monday inside the first shown week, whatever day the week starts on.
187 let dates = self.calendar_dates();
188 let anchor = dates.get(6).or(dates.last()).copied().unwrap_or(start);
189 events.extend(demo_week(week_start(anchor, Weekday::Mon), offset));
177 events.extend(self.demo_meetings.iter().cloned());
190 events.extend(self.demo_meetings.iter().cloned());
178 events.retain(|event| event.end > from && event.start < to);
191 events.retain(|event| event.end > from && event.start < to);
179 events.sort_by_key(|event| (event.start, event.end));
192 events.sort_by_key(|event| (event.start, event.end));
@@ -472,7 +485,7 @@ mod tests {
472 use std::sync::Arc;
485 use std::sync::Arc;
473
486
474 use chatsvc::{CalendarEvent, CalendarSource};
487 use chatsvc::{CalendarEvent, CalendarSource};
475 use chrono::{TimeZone, Utc};
488 use chrono::{Offset as _, TimeZone, Utc};
476 use gpui_kit::{AppContext as _, TestAppContext};
489 use gpui_kit::{AppContext as _, TestAppContext};
477 use store::Store;
490 use store::Store;
478
491
@@ -544,6 +557,32 @@ mod tests {
544 });
557 });
545 }
558 }
546
559
560 #[gpui_kit::test]
561 fn demo_week_fills_the_visible_work_week(cx: &mut TestAppContext) {
562 cx.update(gpui_kit::init);
563 let store = Arc::new(Store::open_in_memory().unwrap());
564 let mode = Mode {
565 demo: true,
566 ..Mode::default()
567 };
568 let app = cx.update(|cx| cx.new(|_| AppState::new(store, mode)));
569 cx.update(|cx| {
570 app.update(cx, |state, cx| {
571 state.open_calendar(cx);
572 let dates = state.calendar_dates();
573 let offset = chrono::Local::now().offset().fix();
574 let days =
575 crate::call::week_grid::week_days(&state.calendar_week.events, &dates, offset);
576 let blocks: usize = days.iter().map(|day| day.blocks.len()).sum();
577 assert!(
578 blocks >= 8,
579 "dates {dates:?}, events {}, blocks {blocks}",
580 state.calendar_week.events.len()
581 );
582 })
583 });
584 }
585
547 #[test]
586 #[test]
548 fn a_failed_source_keeps_its_previous_events() {
587 fn a_failed_source_keeps_its_previous_events() {
549 let previous = vec![
588 let previous = vec![
crates/app/src/layout_guard.rs +22 −0
@@ -265,6 +265,9 @@ mod frames {
265 265 ];
266 266 const AGENTS_LIST: &str = "shell/islands/sidebar/agents";
267 267 const CALENDAR: &str = "shell/islands/calendar";
268 use crate::views::calendar_view::{
269 CALENDAR_DAY_HEADERS_TAG, CALENDAR_HEADER_TAG, CALENDAR_NEW_MEETING_TAG,
270 };
268 271 const CHAT_FILTER_TAGS: &[&str] = &[FILTER_TAG, FILTER_PILLS_TAG];
269 272 const CHAT_FILTER_OPEN_TAGS: &[&str] = &[FILTER_INPUT_TAG, FILTER_EMPTY_TAG];
270 273 const FIND_TAGS: &[&str] = &[
@@ -633,6 +636,9 @@ mod frames {
633 636 &ACTIVITY_PROPOSALS_TAG,
634 637 &AGENTS_LIST,
635 638 &CALENDAR,
639 &CALENDAR_HEADER_TAG,
640 &CALENDAR_DAY_HEADERS_TAG,
641 &CALENDAR_NEW_MEETING_TAG,
636 642 &CALL_TRANSCRIPT,
637 643 &MENU,
638 644 &RECAP_TAB,
@@ -1043,6 +1049,7 @@ mod frames {
1043 1049 !matches!(*path, "shell/islands/sidebar" | "shell/islands/main")
1044 1050 });
1045 1051 expected.push(CALENDAR);
1052 expected.extend([CALENDAR_HEADER_TAG, CALENDAR_DAY_HEADERS_TAG]);
1046 1053 }
1047 1054 "prejoin" => expected.extend(PREJOIN_TAGS),
1048 1055 _ => {}
@@ -1066,6 +1073,21 @@ mod frames {
1066 1073 ));
1067 1074 }
1068 1075 }
1076 if screen_name == "calendar"
1077 && let (Some(header), Some(button)) = (
1078 bounds_of(CALENDAR_HEADER_TAG),
1079 bounds_of(CALENDAR_NEW_MEETING_TAG),
1080 )
1081 {
1082 let overflow = f32::from(button.origin.x + button.size.width)
1083 - f32::from(header.origin.x + header.size.width);
1084 if overflow > TOLERANCE {
1085 found.push((
1086 CALENDAR_HEADER_TAG.to_owned(),
1087 format!("header controls overflow by {overflow} px"),
1088 ));
1089 }
1090 }
1069 1091 if status_menu {
1070 1092 let menu = tags
1071 1093 .iter()
@@ -265,6 +265,9 @@ mod frames {
265 ];
265 ];
266 const AGENTS_LIST: &str = "shell/islands/sidebar/agents";
266 const AGENTS_LIST: &str = "shell/islands/sidebar/agents";
267 const CALENDAR: &str = "shell/islands/calendar";
267 const CALENDAR: &str = "shell/islands/calendar";
268 use crate::views::calendar_view::{
269 CALENDAR_DAY_HEADERS_TAG, CALENDAR_HEADER_TAG, CALENDAR_NEW_MEETING_TAG,
270 };
268 const CHAT_FILTER_TAGS: &[&str] = &[FILTER_TAG, FILTER_PILLS_TAG];
271 const CHAT_FILTER_TAGS: &[&str] = &[FILTER_TAG, FILTER_PILLS_TAG];
269 const CHAT_FILTER_OPEN_TAGS: &[&str] = &[FILTER_INPUT_TAG, FILTER_EMPTY_TAG];
272 const CHAT_FILTER_OPEN_TAGS: &[&str] = &[FILTER_INPUT_TAG, FILTER_EMPTY_TAG];
270 const FIND_TAGS: &[&str] = &[
273 const FIND_TAGS: &[&str] = &[
@@ -633,6 +636,9 @@ mod frames {
633 &ACTIVITY_PROPOSALS_TAG,
636 &ACTIVITY_PROPOSALS_TAG,
634 &AGENTS_LIST,
637 &AGENTS_LIST,
635 &CALENDAR,
638 &CALENDAR,
639 &CALENDAR_HEADER_TAG,
640 &CALENDAR_DAY_HEADERS_TAG,
641 &CALENDAR_NEW_MEETING_TAG,
636 &CALL_TRANSCRIPT,
642 &CALL_TRANSCRIPT,
637 &MENU,
643 &MENU,
638 &RECAP_TAB,
644 &RECAP_TAB,
@@ -1043,6 +1049,7 @@ mod frames {
1043 !matches!(*path, "shell/islands/sidebar" | "shell/islands/main")
1049 !matches!(*path, "shell/islands/sidebar" | "shell/islands/main")
1044 });
1050 });
1045 expected.push(CALENDAR);
1051 expected.push(CALENDAR);
1052 expected.extend([CALENDAR_HEADER_TAG, CALENDAR_DAY_HEADERS_TAG]);
1046 }
1053 }
1047 "prejoin" => expected.extend(PREJOIN_TAGS),
1054 "prejoin" => expected.extend(PREJOIN_TAGS),
1048 _ => {}
1055 _ => {}
@@ -1066,6 +1073,21 @@ mod frames {
1066 ));
1073 ));
1067 }
1074 }
1068 }
1075 }
1076 if screen_name == "calendar"
1077 && let (Some(header), Some(button)) = (
1078 bounds_of(CALENDAR_HEADER_TAG),
1079 bounds_of(CALENDAR_NEW_MEETING_TAG),
1080 )
1081 {
1082 let overflow = f32::from(button.origin.x + button.size.width)
1083 - f32::from(header.origin.x + header.size.width);
1084 if overflow > TOLERANCE {
1085 found.push((
1086 CALENDAR_HEADER_TAG.to_owned(),
1087 format!("header controls overflow by {overflow} px"),
1088 ));
1089 }
1090 }
1069 if status_menu {
1091 if status_menu {
1070 let menu = tags
1092 let menu = tags
1071 .iter()
1093 .iter()
crates/app/src/settings/calendar.rs +18 −10
@@ -5,7 +5,7 @@ use store::{CalendarProvider, CalendarRef};
5 5
6 6 use std::collections::HashMap;
7 7
8 use app_base::format::{WeekdayWidth, clock_format, regional_first_day, weekday_name};
8 use app_base::format::{WeekdayWidth, clock_format, weekday_name};
9 9 use chrono::{NaiveTime, Weekday};
10 10 use gpui_kit::component::h_flex;
11 11 use gpui_kit::prelude::FluentBuilder as _;
@@ -25,7 +25,7 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
25 25 let mut body = v_flex()
26 26 .w_full()
27 27 .child(caption(tr("settings.calendar.section_view")))
28 .children(view_rows(app, &prefs))
28 .children(view_rows(app, &prefs, app.read(cx).default_first_day()))
29 29 .child(caption(tr("settings.calendar.section_google")))
30 30 .child(connect_row(app, accounts.has_google(), pending));
31 31 for account in &accounts.google_accounts {
@@ -252,7 +252,11 @@ const CHIP_SIZE: f32 = 32.;
252 252 const TIME_SELECT_WIDTH: f32 = 104.;
253 253
254 254 /// Default view, first day, work days and hours, time scale, weekend Work week.
255 fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
255 fn view_rows(
256 app: &Entity<AppState>,
257 prefs: &CalendarPrefs,
258 default_first_day: Weekday,
259 ) -> Vec<Div> {
256 260 vec![
257 261 control_row(
258 262 tr("settings.calendar.default_view"),
@@ -279,14 +283,14 @@ fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
279 283 tr("settings.calendar.first_day_detail"),
280 284 select(
281 285 "settings-calendar-first-day",
282 first_day_label(prefs.first_day),
286 first_day_label(prefs.first_day, default_first_day),
283 287 false,
284 288 std::iter::once(None)
285 289 .chain(FIRST_DAY_CHOICES.into_iter().map(Some))
286 290 .map(|day| {
287 291 prefs_choice(
288 292 app,
289 first_day_label(day),
293 first_day_label(day, default_first_day),
290 294 prefs.first_day == day,
291 295 move |prefs| prefs.first_day = day,
292 296 )
@@ -297,7 +301,7 @@ fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
297 301 control_row(
298 302 tr("settings.calendar.work_days"),
299 303 tr("settings.calendar.mailbox_detail"),
300 work_day_chips(app, prefs),
304 work_day_chips(app, prefs, default_first_day),
301 305 ),
302 306 control_row(
303 307 tr("settings.calendar.work_hours"),
@@ -371,14 +375,14 @@ fn default_view_label(view: DefaultView) -> String {
371 375 .map_or_else(|| tr("settings.calendar.last_used"), |span| span.label())
372 376 }
373 377
374 fn first_day_label(day: Option<Weekday>) -> String {
378 fn first_day_label(day: Option<Weekday>, default_first_day: Weekday) -> String {
375 379 match day {
376 380 Some(day) => weekday_name(day, WeekdayWidth::Full),
377 381 None => {
378 382 let mut args = HashMap::new();
379 383 args.insert(
380 384 "day".to_owned(),
381 weekday_name(regional_first_day(), WeekdayWidth::Full),
385 weekday_name(default_first_day, WeekdayWidth::Full),
382 386 );
383 387 crate::i18n::tr_args("settings.calendar.first_day_regional", &args)
384 388 }
@@ -399,8 +403,12 @@ fn weekend_label(rule: WeekendWorkWeek) -> String {
399 403 }
400 404
401 405 /// Seven day chips from the first day of week; the last work day cannot be turned off.
402 fn work_day_chips(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Div {
403 let layout = prefs.layout(regional_first_day());
406 fn work_day_chips(
407 app: &Entity<AppState>,
408 prefs: &CalendarPrefs,
409 default_first_day: Weekday,
410 ) -> Div {
411 let layout = prefs.layout(default_first_day);
404 412 h_flex()
405 413 .gap(px(4.))
406 414 .children(layout.weekdays().into_iter().map(|day| {
@@ -5,7 +5,7 @@ use store::{CalendarProvider, CalendarRef};
5
5
6use std::collections::HashMap;
6use std::collections::HashMap;
7
7
8use app_base::format::{WeekdayWidth, clock_format, regional_first_day, weekday_name};
8use app_base::format::{WeekdayWidth, clock_format, weekday_name};
9use chrono::{NaiveTime, Weekday};
9use chrono::{NaiveTime, Weekday};
10use gpui_kit::component::h_flex;
10use gpui_kit::component::h_flex;
11use gpui_kit::prelude::FluentBuilder as _;
11use gpui_kit::prelude::FluentBuilder as _;
@@ -25,7 +25,7 @@ pub fn render(app: &Entity<AppState>, cx: &App) -> Div {
25 let mut body = v_flex()
25 let mut body = v_flex()
26 .w_full()
26 .w_full()
27 .child(caption(tr("settings.calendar.section_view")))
27 .child(caption(tr("settings.calendar.section_view")))
28 .children(view_rows(app, &prefs))
28 .children(view_rows(app, &prefs, app.read(cx).default_first_day()))
29 .child(caption(tr("settings.calendar.section_google")))
29 .child(caption(tr("settings.calendar.section_google")))
30 .child(connect_row(app, accounts.has_google(), pending));
30 .child(connect_row(app, accounts.has_google(), pending));
31 for account in &accounts.google_accounts {
31 for account in &accounts.google_accounts {
@@ -252,7 +252,11 @@ const CHIP_SIZE: f32 = 32.;
252const TIME_SELECT_WIDTH: f32 = 104.;
252const TIME_SELECT_WIDTH: f32 = 104.;
253
253
254/// Default view, first day, work days and hours, time scale, weekend Work week.
254/// Default view, first day, work days and hours, time scale, weekend Work week.
255fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
255fn view_rows(
256 app: &Entity<AppState>,
257 prefs: &CalendarPrefs,
258 default_first_day: Weekday,
259) -> Vec<Div> {
256 vec![
260 vec![
257 control_row(
261 control_row(
258 tr("settings.calendar.default_view"),
262 tr("settings.calendar.default_view"),
@@ -279,14 +283,14 @@ fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
279 tr("settings.calendar.first_day_detail"),
283 tr("settings.calendar.first_day_detail"),
280 select(
284 select(
281 "settings-calendar-first-day",
285 "settings-calendar-first-day",
282 first_day_label(prefs.first_day),
286 first_day_label(prefs.first_day, default_first_day),
283 false,
287 false,
284 std::iter::once(None)
288 std::iter::once(None)
285 .chain(FIRST_DAY_CHOICES.into_iter().map(Some))
289 .chain(FIRST_DAY_CHOICES.into_iter().map(Some))
286 .map(|day| {
290 .map(|day| {
287 prefs_choice(
291 prefs_choice(
288 app,
292 app,
289 first_day_label(day),
293 first_day_label(day, default_first_day),
290 prefs.first_day == day,
294 prefs.first_day == day,
291 move |prefs| prefs.first_day = day,
295 move |prefs| prefs.first_day = day,
292 )
296 )
@@ -297,7 +301,7 @@ fn view_rows(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Vec<Div> {
297 control_row(
301 control_row(
298 tr("settings.calendar.work_days"),
302 tr("settings.calendar.work_days"),
299 tr("settings.calendar.mailbox_detail"),
303 tr("settings.calendar.mailbox_detail"),
300 work_day_chips(app, prefs),
304 work_day_chips(app, prefs, default_first_day),
301 ),
305 ),
302 control_row(
306 control_row(
303 tr("settings.calendar.work_hours"),
307 tr("settings.calendar.work_hours"),
@@ -371,14 +375,14 @@ fn default_view_label(view: DefaultView) -> String {
371 .map_or_else(|| tr("settings.calendar.last_used"), |span| span.label())
375 .map_or_else(|| tr("settings.calendar.last_used"), |span| span.label())
372}
376}
373
377
374fn first_day_label(day: Option<Weekday>) -> String {
378fn first_day_label(day: Option<Weekday>, default_first_day: Weekday) -> String {
375 match day {
379 match day {
376 Some(day) => weekday_name(day, WeekdayWidth::Full),
380 Some(day) => weekday_name(day, WeekdayWidth::Full),
377 None => {
381 None => {
378 let mut args = HashMap::new();
382 let mut args = HashMap::new();
379 args.insert(
383 args.insert(
380 "day".to_owned(),
384 "day".to_owned(),
381 weekday_name(regional_first_day(), WeekdayWidth::Full),
385 weekday_name(default_first_day, WeekdayWidth::Full),
382 );
386 );
383 crate::i18n::tr_args("settings.calendar.first_day_regional", &args)
387 crate::i18n::tr_args("settings.calendar.first_day_regional", &args)
384 }
388 }
@@ -399,8 +403,12 @@ fn weekend_label(rule: WeekendWorkWeek) -> String {
399}
403}
400
404
401/// Seven day chips from the first day of week; the last work day cannot be turned off.
405/// Seven day chips from the first day of week; the last work day cannot be turned off.
402fn work_day_chips(app: &Entity<AppState>, prefs: &CalendarPrefs) -> Div {
406fn work_day_chips(
403 let layout = prefs.layout(regional_first_day());
407 app: &Entity<AppState>,
408 prefs: &CalendarPrefs,
409 default_first_day: Weekday,
410) -> Div {
411 let layout = prefs.layout(default_first_day);
404 h_flex()
412 h_flex()
405 .gap(px(4.))
413 .gap(px(4.))
406 .children(layout.weekdays().into_iter().map(|day| {
414 .children(layout.weekdays().into_iter().map(|day| {
crates/app/src/views/calendar_date_picker.rs +3 −3
@@ -123,7 +123,7 @@ impl Render for DatePicker {
123 123 .text_size(px(14.))
124 124 .font_weight(FontWeight::SEMIBOLD)
125 125 .text_color(theme::text())
126 .child(self.month.format("%B %Y").to_string()),
126 .child(app_base::format::month_year_label(self.month)),
127 127 )
128 128 .child(
129 129 h_flex()
@@ -132,7 +132,7 @@ impl Render for DatePicker {
132 132 .small()
133 133 .ghost()
134 134 .icon(IconName::ChevronLeft)
135 .tooltip("Previous month")
135 .tooltip(crate::i18n::tr("calendar.view.previous_month_short"))
136 136 .on_click(
137 137 cx.listener(|this, _, _, cx| this.move_month(false, cx)),
138 138 ),
@@ -142,7 +142,7 @@ impl Render for DatePicker {
142 142 .small()
143 143 .ghost()
144 144 .icon(IconName::ChevronRight)
145 .tooltip("Next month")
145 .tooltip(crate::i18n::tr("calendar.view.next_month_short"))
146 146 .on_click(
147 147 cx.listener(|this, _, _, cx| this.move_month(true, cx)),
148 148 ),
@@ -123,7 +123,7 @@ impl Render for DatePicker {
123 .text_size(px(14.))
123 .text_size(px(14.))
124 .font_weight(FontWeight::SEMIBOLD)
124 .font_weight(FontWeight::SEMIBOLD)
125 .text_color(theme::text())
125 .text_color(theme::text())
126 .child(self.month.format("%B %Y").to_string()),
126 .child(app_base::format::month_year_label(self.month)),
127 )
127 )
128 .child(
128 .child(
129 h_flex()
129 h_flex()
@@ -132,7 +132,7 @@ impl Render for DatePicker {
132 .small()
132 .small()
133 .ghost()
133 .ghost()
134 .icon(IconName::ChevronLeft)
134 .icon(IconName::ChevronLeft)
135 .tooltip("Previous month")
135 .tooltip(crate::i18n::tr("calendar.view.previous_month_short"))
136 .on_click(
136 .on_click(
137 cx.listener(|this, _, _, cx| this.move_month(false, cx)),
137 cx.listener(|this, _, _, cx| this.move_month(false, cx)),
138 ),
138 ),
@@ -142,7 +142,7 @@ impl Render for DatePicker {
142 .small()
142 .small()
143 .ghost()
143 .ghost()
144 .icon(IconName::ChevronRight)
144 .icon(IconName::ChevronRight)
145 .tooltip("Next month")
145 .tooltip(crate::i18n::tr("calendar.view.next_month_short"))
146 .on_click(
146 .on_click(
147 cx.listener(|this, _, _, cx| this.move_month(true, cx)),
147 cx.listener(|this, _, _, cx| this.move_month(true, cx)),
148 ),
148 ),
crates/app/src/views/calendar_month.rs +32 −8
@@ -31,10 +31,12 @@ fn day_events(day: &WeekDay) -> Vec<usize> {
31 31 }
32 32
33 33 fn more_label(hidden: usize) -> String {
34 format!("+{hidden} more")
34 let mut args = std::collections::HashMap::new();
35 args.insert("count".to_owned(), hidden.to_string());
36 app_base::ui_locale::tr_args("calendar.view.more", &args)
35 37 }
36 38
37 fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
39 fn event_chip(event: &CalendarEvent, color: Hsla, offset: FixedOffset) -> Div {
38 40 let all_day = is_effective_all_day(event, offset);
39 41 let time = (!all_day).then(|| {
40 42 event
@@ -50,8 +52,8 @@ fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
50 52 .px(px(6.))
51 53 .gap(px(6.))
52 54 .items_center()
53 .rounded(px(4.))
54 .bg(theme::accent().opacity(if all_day { 0.28 } else { 0.14 }))
55 .rounded(px(6.))
56 .bg(color.opacity(if all_day { 0.28 } else { 0.14 }))
55 57 .text_size(px(11.5))
56 58 .text_color(theme::text())
57 59 .children(time.map(|time| div().flex_none().text_color(theme::text_soft()).child(time)))
@@ -79,6 +81,7 @@ fn day_cell(
79 81 state: &Entity<AppState>,
80 82 day: &WeekDay,
81 83 events: &[CalendarEvent],
84 colors: &[Hsla],
82 85 shown_month: NaiveDate,
83 86 today: NaiveDate,
84 87 offset: FixedOffset,
@@ -89,7 +92,14 @@ fn day_cell(
89 92 let indexes = day_events(day);
90 93 let hidden = indexes.len().saturating_sub(VISIBLE_EVENTS);
91 94 let number = if date.day() == 1 {
92 date.format("%b %-d").to_string()
95 format!(
96 "{} {}",
97 app_base::format::month_name(date)
98 .chars()
99 .take(3)
100 .collect::<String>(),
101 date.day()
102 )
93 103 } else {
94 104 date.day().to_string()
95 105 };
@@ -136,8 +146,8 @@ fn day_cell(
136 146 indexes
137 147 .iter()
138 148 .take(VISIBLE_EVENTS)
139 .filter_map(|index| events.get(*index))
140 .map(|event| event_chip(event, offset)),
149 .filter_map(|index| Some((events.get(*index)?, *colors.get(*index)?)))
150 .map(|(event, color)| event_chip(event, color, offset)),
141 151 )
142 152 .when(hidden > 0, |cell| {
143 153 cell.child(
@@ -166,6 +176,7 @@ pub fn month_grid(
166 176 start: NaiveDate,
167 177 days: &[WeekDay],
168 178 events: &[CalendarEvent],
179 colors: &[Hsla],
169 180 today: NaiveDate,
170 181 offset: FixedOffset,
171 182 weekdays: [Weekday; 7],
@@ -178,7 +189,15 @@ pub fn month_grid(
178 189 if position > 0 {
179 190 row = row.child(vertical_line());
180 191 }
181 row = row.child(day_cell(state, day, events, shown_month, today, offset));
192 row = row.child(day_cell(
193 state,
194 day,
195 events,
196 colors,
197 shown_month,
198 today,
199 offset,
200 ));
182 201 }
183 202 rows = rows.child(horizontal_line()).child(row);
184 203 }
@@ -225,6 +244,11 @@ mod tests {
225 244 blocks: vec![block(2, 600), block(1, 540)],
226 245 };
227 246 assert_eq!(day_events(&day), [4, 1, 2]);
247 let _guard = crate::i18n::locale_test_lock();
248 app_base::ui_locale::apply_locale("en");
228 249 assert_eq!(more_label(2), "+2 more");
250 app_base::ui_locale::apply_locale("de");
251 assert_eq!(more_label(2), "+2 weitere");
252 app_base::ui_locale::apply_locale("en");
229 253 }
230 254 }
@@ -31,10 +31,12 @@ fn day_events(day: &WeekDay) -> Vec<usize> {
31}
31}
32
32
33fn more_label(hidden: usize) -> String {
33fn more_label(hidden: usize) -> String {
34 format!("+{hidden} more")
34 let mut args = std::collections::HashMap::new();
35 args.insert("count".to_owned(), hidden.to_string());
36 app_base::ui_locale::tr_args("calendar.view.more", &args)
35}
37}
36
38
37fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
39fn event_chip(event: &CalendarEvent, color: Hsla, offset: FixedOffset) -> Div {
38 let all_day = is_effective_all_day(event, offset);
40 let all_day = is_effective_all_day(event, offset);
39 let time = (!all_day).then(|| {
41 let time = (!all_day).then(|| {
40 event
42 event
@@ -50,8 +52,8 @@ fn event_chip(event: &CalendarEvent, offset: FixedOffset) -> Div {
50 .px(px(6.))
52 .px(px(6.))
51 .gap(px(6.))
53 .gap(px(6.))
52 .items_center()
54 .items_center()
53 .rounded(px(4.))
55 .rounded(px(6.))
54 .bg(theme::accent().opacity(if all_day { 0.28 } else { 0.14 }))
56 .bg(color.opacity(if all_day { 0.28 } else { 0.14 }))
55 .text_size(px(11.5))
57 .text_size(px(11.5))
56 .text_color(theme::text())
58 .text_color(theme::text())
57 .children(time.map(|time| div().flex_none().text_color(theme::text_soft()).child(time)))
59 .children(time.map(|time| div().flex_none().text_color(theme::text_soft()).child(time)))
@@ -79,6 +81,7 @@ fn day_cell(
79 state: &Entity<AppState>,
81 state: &Entity<AppState>,
80 day: &WeekDay,
82 day: &WeekDay,
81 events: &[CalendarEvent],
83 events: &[CalendarEvent],
84 colors: &[Hsla],
82 shown_month: NaiveDate,
85 shown_month: NaiveDate,
83 today: NaiveDate,
86 today: NaiveDate,
84 offset: FixedOffset,
87 offset: FixedOffset,
@@ -89,7 +92,14 @@ fn day_cell(
89 let indexes = day_events(day);
92 let indexes = day_events(day);
90 let hidden = indexes.len().saturating_sub(VISIBLE_EVENTS);
93 let hidden = indexes.len().saturating_sub(VISIBLE_EVENTS);
91 let number = if date.day() == 1 {
94 let number = if date.day() == 1 {
92 date.format("%b %-d").to_string()
95 format!(
96 "{} {}",
97 app_base::format::month_name(date)
98 .chars()
99 .take(3)
100 .collect::<String>(),
101 date.day()
102 )
93 } else {
103 } else {
94 date.day().to_string()
104 date.day().to_string()
95 };
105 };
@@ -136,8 +146,8 @@ fn day_cell(
136 indexes
146 indexes
137 .iter()
147 .iter()
138 .take(VISIBLE_EVENTS)
148 .take(VISIBLE_EVENTS)
139 .filter_map(|index| events.get(*index))
149 .filter_map(|index| Some((events.get(*index)?, *colors.get(*index)?)))
140 .map(|event| event_chip(event, offset)),
150 .map(|(event, color)| event_chip(event, color, offset)),
141 )
151 )
142 .when(hidden > 0, |cell| {
152 .when(hidden > 0, |cell| {
143 cell.child(
153 cell.child(
@@ -166,6 +176,7 @@ pub fn month_grid(
166 start: NaiveDate,
176 start: NaiveDate,
167 days: &[WeekDay],
177 days: &[WeekDay],
168 events: &[CalendarEvent],
178 events: &[CalendarEvent],
179 colors: &[Hsla],
169 today: NaiveDate,
180 today: NaiveDate,
170 offset: FixedOffset,
181 offset: FixedOffset,
171 weekdays: [Weekday; 7],
182 weekdays: [Weekday; 7],
@@ -178,7 +189,15 @@ pub fn month_grid(
178 if position > 0 {
189 if position > 0 {
179 row = row.child(vertical_line());
190 row = row.child(vertical_line());
180 }
191 }
181 row = row.child(day_cell(state, day, events, shown_month, today, offset));
192 row = row.child(day_cell(
193 state,
194 day,
195 events,
196 colors,
197 shown_month,
198 today,
199 offset,
200 ));
182 }
201 }
183 rows = rows.child(horizontal_line()).child(row);
202 rows = rows.child(horizontal_line()).child(row);
184 }
203 }
@@ -225,6 +244,11 @@ mod tests {
225 blocks: vec![block(2, 600), block(1, 540)],
244 blocks: vec![block(2, 600), block(1, 540)],
226 };
245 };
227 assert_eq!(day_events(&day), [4, 1, 2]);
246 assert_eq!(day_events(&day), [4, 1, 2]);
247 let _guard = crate::i18n::locale_test_lock();
248 app_base::ui_locale::apply_locale("en");
228 assert_eq!(more_label(2), "+2 more");
249 assert_eq!(more_label(2), "+2 more");
250 app_base::ui_locale::apply_locale("de");
251 assert_eq!(more_label(2), "+2 weitere");
252 app_base::ui_locale::apply_locale("en");
229 }
253 }
230}
254}
crates/app/src/views/calendar_view.rs +204 −107
@@ -1,8 +1,8 @@
1 1 use std::time::Duration;
2 2
3 use app_base::format::{self, clock_format};
3 use app_base::format::{self, WeekdayWidth, clock_format, weekday_name};
4 4 use chatsvc::{CalendarEvent, ResponseType, join_info_text};
5 use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
5 use chrono::{DateTime, Datelike, Local, NaiveDate, Offset, Timelike, Utc};
6 6 use gpui_kit::assets::IconName;
7 7 use gpui_kit::component::Sizable as _;
8 8 use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -27,20 +27,24 @@ use crate::call::calendar_now::{
27 27 };
28 28 use crate::call::week::CalendarLoadFailure;
29 29 use crate::call::week_grid::{
30 CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, event_look, hour_label, month_shown,
31 week_days,
30 CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, calendar_index, event_look,
31 hour_label, month_shown, week_days,
32 32 };
33 33 use crate::i18n::tr;
34 34 use crate::theme;
35 use crate::views::widgets::icon;
35 36
36 const QUARTER_LINE_OPACITY: f32 = 0.45;
37 37 const GUTTER_WIDTH: f32 = 50.;
38 38 const HEADER_HEIGHT: f32 = 52.;
39 39 const DAY_HEADER_HEIGHT: f32 = 56.;
40 40 const ALL_DAY_HEIGHT: f32 = 26.;
41 41 const BLOCK_GAP: f32 = 2.;
42 const CANCELED_PREFIX: &str = "Canceled: ";
43 const COPY_JOIN_INFO: &str = "Copy join info";
42 const MINOR_LINE_OPACITY: f32 = 0.45;
43 const OFF_HOURS_OPACITY: f32 = 0.85;
44 const NOW_ELSEWHERE_OPACITY: f32 = 0.4;
45 pub const CALENDAR_HEADER_TAG: &str = "shell/islands/calendar/header";
46 pub const CALENDAR_DAY_HEADERS_TAG: &str = "shell/islands/calendar/day-headers";
47 pub const CALENDAR_NEW_MEETING_TAG: &str = "shell/islands/calendar/header/new-meeting";
44 48 const COMPACT_HEADER_WIDTH: f32 = 960.;
45 49 const BUSY_FILL_OPACITY: f32 = 0.28;
46 50 const FREE_FILL_OPACITY: f32 = 0.12;
@@ -214,31 +218,49 @@ impl CalendarView {
214 218 compact: bool,
215 219 ) -> impl IntoElement {
216 220 let span_state = self.state.clone();
217 let label = |text: &'static str| (!compact).then_some(text);
221 let label = |key: &'static str| (!compact).then(|| tr(key));
218 222 let (today, back, forward) = (self.state.clone(), self.state.clone(), self.state.clone());
219 223 let (join_state, meet_state, new_state) =
220 224 (self.state.clone(), self.state.clone(), self.state.clone());
225 let pane_state = self.state.clone();
226 let (back_tip, forward_tip) = match span {
227 CalendarSpan::Day => ("calendar.view.previous_day", "calendar.view.next_day"),
228 CalendarSpan::Month => ("calendar.view.previous_month", "calendar.view.next_month"),
229 _ => ("calendar.view.previous_week", "calendar.view.next_week"),
230 };
221 231 h_flex()
232 .debug_selector(|| CALENDAR_HEADER_TAG.into())
222 233 .h(px(HEADER_HEIGHT))
223 234 .flex_none()
224 235 .items_center()
225 236 .gap(px(8.))
226 237 .px(px(16.))
227 .child(
228 div()
229 .flex_none()
230 .text_size(px(16.))
231 .font_weight(FontWeight::BOLD)
232 .mr(px(8.))
233 .child("Calendar"),
234 )
238 .when(!compact, |header| {
239 header.child(
240 Button::new("calendar-pane-toggle")
241 .small()
242 .ghost()
243 .icon(IconName::PanelLeft)
244 .tooltip(tr("calendar.view.toggle_pane"))
245 .on_click(move |_, _, cx| {
246 pane_state.update(cx, |state, cx| {
247 state.update_calendar_prefs(
248 |prefs| prefs.pane_hidden = !prefs.pane_hidden,
249 cx,
250 )
251 })
252 }),
253 )
254 })
235 255 .child(
236 256 Button::new("calendar-today")
237 257 .small()
238 258 .outline()
239 259 .icon(IconName::Calendar)
240 .when_some(label("Today"), |button, text| button.label(text))
241 .tooltip("Today")
260 .when_some(label("calendar.view.today"), |button, text| {
261 button.label(text)
262 })
263 .tooltip(tr("calendar.view.today"))
242 264 .on_click(move |_, _, cx| {
243 265 today.update(cx, |state, cx| state.calendar_to_today(cx))
244 266 }),
@@ -248,11 +270,7 @@ impl CalendarView {
248 270 .small()
249 271 .ghost()
250 272 .icon(IconName::ChevronLeft)
251 .tooltip(match span {
252 CalendarSpan::Day => "Go to previous day",
253 CalendarSpan::Month => "Go to previous month",
254 _ => "Go to previous week",
255 })
273 .tooltip(tr(back_tip))
256 274 .on_click(move |_, _, cx| {
257 275 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
258 276 }),
@@ -262,11 +280,7 @@ impl CalendarView {
262 280 .small()
263 281 .ghost()
264 282 .icon(IconName::ChevronRight)
265 .tooltip(match span {
266 CalendarSpan::Day => "Go to next day",
267 CalendarSpan::Month => "Go to next month",
268 _ => "Go to next week",
269 })
283 .tooltip(tr(forward_tip))
270 284 .on_click(move |_, _, cx| {
271 285 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
272 286 }),
@@ -286,6 +300,7 @@ impl CalendarView {
286 300 Button::new("calendar-span")
287 301 .small()
288 302 .ghost()
303 .icon(IconName::LayoutGrid)
289 304 .label(span.label())
290 305 .dropdown_caret(true)
291 306 .dropdown_menu(move |menu, _, _| {
@@ -308,8 +323,10 @@ impl CalendarView {
308 323 .small()
309 324 .outline()
310 325 .icon(IconName::Hash)
311 .when_some(label("Join with an ID"), |button, text| button.label(text))
312 .tooltip("Join with an ID")
326 .when_some(label("calendar.view.join_with_id"), |button, text| {
327 button.label(text)
328 })
329 .tooltip(tr("calendar.view.join_with_id"))
313 330 .on_click(move |_, window, cx| {
314 331 open_join_with_id(join_state.clone(), window, cx)
315 332 }),
@@ -319,25 +336,32 @@ impl CalendarView {
319 336 .small()
320 337 .outline()
321 338 .icon(IconName::Video)
322 .when_some(label("Meet now"), |button, text| button.label(text))
323 .tooltip("Meet now")
339 .when_some(label("calendar.view.meet_now"), |button, text| {
340 button.label(text)
341 })
342 .tooltip(tr("calendar.view.meet_now"))
324 343 .on_click(move |_, _, cx| {
325 344 meet_state.update(cx, |state, cx| state.start_meet_now(cx))
326 345 }),
327 346 )
328 347 .child(
329 348 Button::new("calendar-new-meeting")
349 .debug_selector(|| CALENDAR_NEW_MEETING_TAG.into())
330 350 .small()
331 351 .primary()
332 352 .icon(IconName::Plus)
333 .when_some(label("New meeting"), |button, text| button.label(text))
334 .tooltip("New meeting")
353 .when_some(label("calendar.view.new_meeting"), |button, text| {
354 button.label(text)
355 })
356 .tooltip(tr("calendar.view.new_meeting"))
335 357 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
336 358 )
337 359 }
338 360
361 /// Day number above the full weekday name; today in the accent colour with its bar.
339 362 fn day_headers(&self, days: &[WeekDay], today: NaiveDate) -> impl IntoElement {
340 363 h_flex()
364 .debug_selector(|| CALENDAR_DAY_HEADERS_TAG.into())
341 365 .h(px(DAY_HEADER_HEIGHT))
342 366 .flex_none()
343 367 .border_b_1()
@@ -345,10 +369,10 @@ impl CalendarView {
345 369 .child(div().w(px(GUTTER_WIDTH)).flex_none())
346 370 .children(days.iter().map(|day| {
347 371 let is_today = day.date == today;
348 let color = if is_today {
349 theme::accent_text()
372 let (number_color, name_color) = if is_today {
373 (theme::accent_text(), theme::accent_text())
350 374 } else {
351 theme::text_soft()
375 (theme::text(), theme::text_soft())
352 376 };
353 377 v_flex()
354 378 .relative()
@@ -374,14 +398,16 @@ impl CalendarView {
374 398 div()
375 399 .text_size(px(20.))
376 400 .line_height(px(24.))
377 .text_color(color)
401 .text_color(number_color)
402 .when(is_today, |number| number.font_weight(FontWeight::SEMIBOLD))
378 403 .child(format::calendar_day_number(day.date)),
379 404 )
380 405 .child(
381 406 div()
382 407 .text_size(px(12.))
383 .text_color(color)
384 .child(day.date.format("%a").to_string()),
408 .text_color(name_color)
409 .truncate()
410 .child(weekday_name(day.date.weekday(), WeekdayWidth::Full)),
385 411 )
386 412 }))
387 413 }
@@ -390,6 +416,7 @@ impl CalendarView {
390 416 &self,
391 417 days: &[WeekDay],
392 418 events: &[CalendarEvent],
419 colors: &[Hsla],
393 420 send_response: bool,
394 421 ) -> Option<Div> {
395 422 if days.iter().all(|day| day.all_day.is_empty()) {
@@ -411,6 +438,7 @@ impl CalendarView {
411 438 .border_color(theme::border())
412 439 .children(day.all_day.iter().map(|&index| {
413 440 let event = events[index].clone();
441 let color = colors[index];
414 442 let open_state = self.state.clone();
415 443 let (menu_state, menu_event) = (self.state.clone(), event.clone());
416 444 // Day-qualified id: multi-day all-day chips share object_id.
@@ -423,8 +451,8 @@ impl CalendarView {
423 451 .px(px(6.))
424 452 .flex()
425 453 .items_center()
426 .rounded(px(4.))
427 .bg(event_fill(event_look(&event)))
454 .rounded(px(6.))
455 .bg(event_fill(event_look(&event), color))
428 456 .text_size(px(12.))
429 457 .truncate()
430 458 .cursor_pointer()
@@ -449,6 +477,7 @@ impl CalendarView {
449 477 &self,
450 478 block: &WeekBlock,
451 479 event: &CalendarEvent,
480 color: Hsla,
452 481 day: NaiveDate,
453 482 send_response: bool,
454 483 ) -> impl IntoElement {
@@ -460,10 +489,10 @@ impl CalendarView {
460 489 let compact = height < 36.;
461 490 let small = height < SMALL_TITLE_HEIGHT;
462 491 let title_size = if small { 10. } else { 12. };
463 let title_line = if small { 14. } else { 18. };
464 let pad_y = if compact { 1. } else { 4. };
465 // Fill the block: long titles use the free height instead of clamping to 2 lines.
466 let title_lines = (((height - pad_y * 2.) / title_line).floor() as usize).clamp(1, 8);
492 let title_line = if small { 14. } else { 16. };
493 let pad_y = if compact { 1. } else { 3. };
494 // Title and organizer flow as one text; tall blocks wrap it over more lines.
495 let lines = (((height - pad_y * 2.) / title_line).floor() as usize).clamp(1, 8);
467 496 let look = event_look(event);
468 497 // Join on the block whenever a Teams link exists (same as detail dialog).
469 498 // Skip on tiny blocks — the button would crush the title.
@@ -497,13 +526,13 @@ impl CalendarView {
497 526 .size_full()
498 527 .items_start()
499 528 .overflow_hidden()
500 .rounded(px(4.))
501 .bg(event_fill(look))
529 .rounded(px(6.))
530 .bg(event_fill(look, color))
502 531 .when(event.cancelled, |block| block.opacity(0.6))
503 532 .cursor_pointer()
504 .children(status_bar(look))
533 .children(status_bar(look, color))
505 534 .child(
506 v_flex()
535 div()
507 536 .flex_1()
508 537 .min_w_0()
509 538 .pl(px(5.))
@@ -511,28 +540,20 @@ impl CalendarView {
511 540 .h_full()
512 541 .py(px(pad_y))
513 542 .overflow_hidden()
514 .when(compact, |body| body.justify_center())
515 .child(
516 div()
517 .text_size(px(title_size))
518 .line_height(px(title_line))
519 .font_weight(FontWeight::SEMIBOLD)
520 .text_color(title_color)
521 .when(compact, |title| title.truncate())
522 .when(!compact, |title| title.line_clamp(title_lines))
523 .child(event_title(event)),
524 )
525 .when(!compact && title_lines > 2, |body| {
526 body.children(event.organizer_name.clone().map(|organizer| {
527 div()
528 .text_size(px(12.))
529 .line_height(px(16.))
530 .text_color(detail_color)
531 .truncate()
532 .child(organizer)
533 }))
534 }),
543 .text_size(px(title_size))
544 .line_height(px(title_line))
545 .text_color(detail_color)
546 .line_clamp(lines)
547 .text_ellipsis()
548 .child(title_and_organizer(event, title_color)),
535 549 )
550 .when(event.series, |block| {
551 block.child(div().flex_none().pt(px(pad_y + 1.)).pr(px(4.)).child(icon(
552 IconName::Repeat,
553 12.,
554 detail_color,
555 )))
556 })
536 557 .when(can_join, |block| {
537 558 block.child(
538 559 div().flex_none().pr(px(4.)).pt(px(3.)).child(
@@ -565,10 +586,14 @@ impl CalendarView {
565 586 })
566 587 }
567 588
589 #[allow(clippy::too_many_arguments)]
568 590 fn grid(
569 591 &self,
570 592 days: &[WeekDay],
571 593 events: &[CalendarEvent],
594 colors: &[Hsla],
595 layout: &WeekLayout,
596 work_minutes: (i64, i64),
572 597 today: NaiveDate,
573 598 now: DateTime<Utc>,
574 599 send_response: bool,
@@ -582,6 +607,9 @@ impl CalendarView {
582 607 let local = now.with_timezone(&Local);
583 608 local.hour() * 60 + local.minute()
584 609 };
610 let now_top = now_minute as f32 / 60. * row;
611 let today_shown = days.iter().any(|day| day.date == today);
612 let minute_y = |minute: i64| minute as f32 / 60. * row;
585 613 div()
586 614 .id("calendar-grid")
587 615 .flex_1()
@@ -600,17 +628,37 @@ impl CalendarView {
600 628 .children((0..24).map(|hour| {
601 629 div()
602 630 .h(px(row))
603 .pt(px(4.))
631 .pt(px(2.))
632 .pr(px(8.))
604 633 .flex()
605 .justify_center()
606 .text_size(px(12.))
607 .text_color(theme::text_soft())
634 .justify_end()
635 .text_size(px(11.))
636 .text_color(theme::text_muted())
608 637 .when(hour > 0, |label| {
609 638 label.child(hour_label(hour, twelve_hour))
610 639 })
611 640 })),
612 641 )
613 642 .children(days.iter().map(|day| {
643 let work_day = layout.is_work_day(day.date.weekday());
644 let (work_start, work_end) = work_minutes;
645 let shade = |top: f32, height: f32| {
646 div()
647 .absolute()
648 .top(px(top))
649 .left_0()
650 .right_0()
651 .h(px(height))
652 .bg(theme::background().opacity(OFF_HOURS_OPACITY))
653 };
654 let shading = if work_day {
655 vec![
656 shade(0., minute_y(work_start)),
657 shade(minute_y(work_end), total_height - minute_y(work_end)),
658 ]
659 } else {
660 vec![shade(0., total_height)]
661 };
614 662 div()
615 663 .relative()
616 664 .flex_1()
@@ -618,29 +666,41 @@ impl CalendarView {
618 666 .h_full()
619 667 .border_l_1()
620 668 .border_color(theme::border())
621 .children((1..24 * steps).map(|quarter| {
669 .children(shading)
670 .children((1..24 * steps).map(|step| {
622 671 let line = div()
623 672 .absolute()
624 .top(px(quarter as f32 * row / steps as f32))
673 .top(px(step as f32 * row / steps as f32))
625 674 .left_0()
626 .right_0();
627 if quarter % steps == 0 {
628 line.h(px(1.)).bg(theme::border())
675 .right_0()
676 .h(px(1.));
677 if step % steps == 0 {
678 line.bg(theme::border())
629 679 } else {
630 line.h(px(1.))
631 .bg(theme::border().opacity(QUARTER_LINE_OPACITY))
680 line.bg(theme::border().opacity(MINOR_LINE_OPACITY))
632 681 }
633 682 }))
634 683 .children(day.blocks.iter().map(|block| {
635 684 self.event_block(
636 685 block,
637 686 &events[block.event_index],
687 colors[block.event_index],
638 688 day.date,
639 689 send_response,
640 690 )
641 691 }))
692 .when(today_shown && day.date != today, |column| {
693 column.child(
694 div()
695 .absolute()
696 .top(px(now_top))
697 .left_0()
698 .right_0()
699 .h(px(1.))
700 .bg(theme::accent().opacity(NOW_ELSEWHERE_OPACITY)),
701 )
702 })
642 703 .when(day.date == today, |column| {
643 let now_top = now_minute as f32 / 60. * row;
644 704 column
645 705 .child(
646 706 div()
@@ -655,7 +715,7 @@ impl CalendarView {
655 715 div()
656 716 .absolute()
657 717 .top(px(now_top - NOW_DOT_SIZE / 2.))
658 .left_0()
718 .left(px(-NOW_DOT_SIZE / 2.))
659 719 .size(px(NOW_DOT_SIZE))
660 720 .rounded_full()
661 721 .bg(theme::accent()),
@@ -739,18 +799,20 @@ fn event_menu(
739 799 .filter(|_| event.online && !event.cancelled)
740 800 {
741 801 let (join_state, subject) = (state.clone(), event.subject.clone());
742 menu = menu.item(PopupMenuItem::new("Join").icon(IconName::Video).on_click(
743 move |_, _, cx| {
744 join_state.update(cx, |state, cx| {
745 state.join_calendar_meeting(Some(&join_url), &subject, cx)
746 })
747 },
748 ));
802 menu = menu.item(
803 PopupMenuItem::new(tr("common.join"))
804 .icon(IconName::Video)
805 .on_click(move |_, _, cx| {
806 join_state.update(cx, |state, cx| {
807 state.join_calendar_meeting(Some(&join_url), &subject, cx)
808 })
809 }),
810 );
749 811 }
750 812 if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {
751 813 let info = join_info_text(join_url, event.dial_in.as_ref());
752 814 menu = menu.item(
753 PopupMenuItem::new(COPY_JOIN_INFO)
815 PopupMenuItem::new(tr("calendar.view.copy_join_info"))
754 816 .icon(IconName::Copy)
755 817 .on_click(move |_, _, cx| {
756 818 cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))
@@ -760,7 +822,7 @@ fn event_menu(
760 822 if let Some(thread_id) = event.thread_id.clone() {
761 823 let chat_state = state.clone();
762 824 menu = menu.item(
763 PopupMenuItem::new("Chat with participants")
825 PopupMenuItem::new(tr("calendar.view.chat_with_participants"))
764 826 .icon(IconName::MessageSquare)
765 827 .on_click(move |_, _, cx| {
766 828 chat_state.update(cx, |state, cx| {
@@ -781,31 +843,49 @@ fn event_menu(
781 843 )
782 844 }
783 845
784 fn event_fill(look: EventLook) -> Hsla {
846 fn event_fill(look: EventLook, color: Hsla) -> Hsla {
785 847 match look {
786 EventLook::Busy => theme::accent().opacity(BUSY_FILL_OPACITY),
787 EventLook::Free | EventLook::Tentative => theme::accent().opacity(FREE_FILL_OPACITY),
848 EventLook::Busy => color.opacity(BUSY_FILL_OPACITY),
849 EventLook::Free | EventLook::Tentative => color.opacity(FREE_FILL_OPACITY),
788 850 }
789 851 }
790 852
791 fn status_bar(look: EventLook) -> Option<Div> {
853 fn status_bar(look: EventLook, color: Hsla) -> Option<Div> {
792 854 let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();
793 855 match look {
794 EventLook::Busy => Some(bar.bg(theme::accent())),
856 EventLook::Busy => Some(bar.bg(color)),
795 857 EventLook::Tentative => Some(
796 bar.bg(theme::accent().opacity(BUSY_FILL_OPACITY)).child(
797 div()
798 .size_full()
799 .bg(pattern_slash(theme::accent(), HATCH_STRIPE, HATCH_GAP)),
800 ),
858 bar.bg(color.opacity(BUSY_FILL_OPACITY))
859 .child(
860 div()
861 .size_full()
862 .bg(pattern_slash(color, HATCH_STRIPE, HATCH_GAP)),
863 ),
801 864 ),
802 865 EventLook::Free => None,
803 866 }
804 867 }
805 868
869 /// "Daily Standup Zulal Fouque": bold title, organizer right after it on the same line.
870 fn title_and_organizer(event: &CalendarEvent, title_color: Hsla) -> StyledText {
871 let title = event_title(event);
872 let text = match event.organizer_name.as_deref() {
873 Some(organizer) if !organizer.is_empty() => format!("{title} {organizer}"),
874 _ => title.clone(),
875 };
876 StyledText::new(text).with_highlights([(
877 0..title.len(),
878 HighlightStyle {
879 color: Some(title_color),
880 font_weight: Some(FontWeight::SEMIBOLD),
881 ..Default::default()
882 },
883 )])
884 }
885
806 886 fn event_title(event: &CalendarEvent) -> String {
807 887 let subject = if event.cancelled {
808 format!("{CANCELED_PREFIX}{}", event.subject)
888 format!("{}{}", tr("calendar.peek.canceled_prefix"), event.subject)
809 889 } else {
810 890 event.subject.clone()
811 891 };
@@ -851,7 +931,13 @@ impl Render for CalendarView {
851 931 let days = week_days(&events, &dates, offset);
852 932 let today = Local::now().date_naive();
853 933 let now = Utc::now();
854 let show_picker = !compact;
934 let accounts = state.calendar_accounts();
935 let colors: Vec<Hsla> = events
936 .iter()
937 .map(|event| theme::calendar_color(calendar_index(event, &accounts)))
938 .collect();
939 let work_minutes = state.calendar_prefs.work_hours.minute_range();
940 let show_picker = !compact && !state.calendar_prefs.pane_hidden;
855 941 h_flex()
856 942 .debug_selector(|| "shell/islands/calendar".into())
857 943 .flex_1()
@@ -879,6 +965,7 @@ impl Render for CalendarView {
879 965 start,
880 966 &days,
881 967 &events,
968 &colors,
882 969 today,
883 970 offset,
884 971 layout.weekdays(),
@@ -886,8 +973,18 @@ impl Render for CalendarView {
886 973 } else {
887 974 calendar
888 975 .child(self.day_headers(&days, today))
889 .children(self.all_day_row(&days, &events, send_response))
890 .child(self.grid(&days, &events, today, now, send_response, cx))
976 .children(self.all_day_row(&days, &events, &colors, send_response))
977 .child(self.grid(
978 &days,
979 &events,
980 &colors,
981 &layout,
982 work_minutes,
983 today,
984 now,
985 send_response,
986 cx,
987 ))
891 988 }
892 989 }),
893 990 )
@@ -1,8 +1,8 @@
1use std::time::Duration;
1use std::time::Duration;
2
2
3use app_base::format::{self, clock_format};
3use app_base::format::{self, WeekdayWidth, clock_format, weekday_name};
4use chatsvc::{CalendarEvent, ResponseType, join_info_text};
4use chatsvc::{CalendarEvent, ResponseType, join_info_text};
5use chrono::{DateTime, Local, NaiveDate, Offset, Timelike, Utc};
5use chrono::{DateTime, Datelike, Local, NaiveDate, Offset, Timelike, Utc};
6use gpui_kit::assets::IconName;
6use gpui_kit::assets::IconName;
7use gpui_kit::component::Sizable as _;
7use gpui_kit::component::Sizable as _;
8use gpui_kit::component::button::{Button, ButtonVariants as _};
8use gpui_kit::component::button::{Button, ButtonVariants as _};
@@ -27,20 +27,24 @@ use crate::call::calendar_now::{
27};
27};
28use crate::call::week::CalendarLoadFailure;
28use crate::call::week::CalendarLoadFailure;
29use crate::call::week_grid::{
29use crate::call::week_grid::{
30 CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, event_look, hour_label, month_shown,
30 CalendarSpan, EventLook, WeekBlock, WeekDay, WeekLayout, calendar_index, event_look,
31 week_days,
31 hour_label, month_shown, week_days,
32};
32};
33use crate::i18n::tr;
33use crate::i18n::tr;
34use crate::theme;
34use crate::theme;
35use crate::views::widgets::icon;
35
36
36const QUARTER_LINE_OPACITY: f32 = 0.45;
37const GUTTER_WIDTH: f32 = 50.;
37const GUTTER_WIDTH: f32 = 50.;
38const HEADER_HEIGHT: f32 = 52.;
38const HEADER_HEIGHT: f32 = 52.;
39const DAY_HEADER_HEIGHT: f32 = 56.;
39const DAY_HEADER_HEIGHT: f32 = 56.;
40const ALL_DAY_HEIGHT: f32 = 26.;
40const ALL_DAY_HEIGHT: f32 = 26.;
41const BLOCK_GAP: f32 = 2.;
41const BLOCK_GAP: f32 = 2.;
42const CANCELED_PREFIX: &str = "Canceled: ";
42const MINOR_LINE_OPACITY: f32 = 0.45;
43const COPY_JOIN_INFO: &str = "Copy join info";
43const OFF_HOURS_OPACITY: f32 = 0.85;
44const NOW_ELSEWHERE_OPACITY: f32 = 0.4;
45pub const CALENDAR_HEADER_TAG: &str = "shell/islands/calendar/header";
46pub const CALENDAR_DAY_HEADERS_TAG: &str = "shell/islands/calendar/day-headers";
47pub const CALENDAR_NEW_MEETING_TAG: &str = "shell/islands/calendar/header/new-meeting";
44const COMPACT_HEADER_WIDTH: f32 = 960.;
48const COMPACT_HEADER_WIDTH: f32 = 960.;
45const BUSY_FILL_OPACITY: f32 = 0.28;
49const BUSY_FILL_OPACITY: f32 = 0.28;
46const FREE_FILL_OPACITY: f32 = 0.12;
50const FREE_FILL_OPACITY: f32 = 0.12;
@@ -214,31 +218,49 @@ impl CalendarView {
214 compact: bool,
218 compact: bool,
215 ) -> impl IntoElement {
219 ) -> impl IntoElement {
216 let span_state = self.state.clone();
220 let span_state = self.state.clone();
217 let label = |text: &'static str| (!compact).then_some(text);
221 let label = |key: &'static str| (!compact).then(|| tr(key));
218 let (today, back, forward) = (self.state.clone(), self.state.clone(), self.state.clone());
222 let (today, back, forward) = (self.state.clone(), self.state.clone(), self.state.clone());
219 let (join_state, meet_state, new_state) =
223 let (join_state, meet_state, new_state) =
220 (self.state.clone(), self.state.clone(), self.state.clone());
224 (self.state.clone(), self.state.clone(), self.state.clone());
225 let pane_state = self.state.clone();
226 let (back_tip, forward_tip) = match span {
227 CalendarSpan::Day => ("calendar.view.previous_day", "calendar.view.next_day"),
228 CalendarSpan::Month => ("calendar.view.previous_month", "calendar.view.next_month"),
229 _ => ("calendar.view.previous_week", "calendar.view.next_week"),
230 };
221 h_flex()
231 h_flex()
232 .debug_selector(|| CALENDAR_HEADER_TAG.into())
222 .h(px(HEADER_HEIGHT))
233 .h(px(HEADER_HEIGHT))
223 .flex_none()
234 .flex_none()
224 .items_center()
235 .items_center()
225 .gap(px(8.))
236 .gap(px(8.))
226 .px(px(16.))
237 .px(px(16.))
227 .child(
238 .when(!compact, |header| {
228 div()
239 header.child(
229 .flex_none()
240 Button::new("calendar-pane-toggle")
230 .text_size(px(16.))
241 .small()
231 .font_weight(FontWeight::BOLD)
242 .ghost()
232 .mr(px(8.))
243 .icon(IconName::PanelLeft)
233 .child("Calendar"),
244 .tooltip(tr("calendar.view.toggle_pane"))
234 )
245 .on_click(move |_, _, cx| {
246 pane_state.update(cx, |state, cx| {
247 state.update_calendar_prefs(
248 |prefs| prefs.pane_hidden = !prefs.pane_hidden,
249 cx,
250 )
251 })
252 }),
253 )
254 })
235 .child(
255 .child(
236 Button::new("calendar-today")
256 Button::new("calendar-today")
237 .small()
257 .small()
238 .outline()
258 .outline()
239 .icon(IconName::Calendar)
259 .icon(IconName::Calendar)
240 .when_some(label("Today"), |button, text| button.label(text))
260 .when_some(label("calendar.view.today"), |button, text| {
241 .tooltip("Today")
261 button.label(text)
262 })
263 .tooltip(tr("calendar.view.today"))
242 .on_click(move |_, _, cx| {
264 .on_click(move |_, _, cx| {
243 today.update(cx, |state, cx| state.calendar_to_today(cx))
265 today.update(cx, |state, cx| state.calendar_to_today(cx))
244 }),
266 }),
@@ -248,11 +270,7 @@ impl CalendarView {
248 .small()
270 .small()
249 .ghost()
271 .ghost()
250 .icon(IconName::ChevronLeft)
272 .icon(IconName::ChevronLeft)
251 .tooltip(match span {
273 .tooltip(tr(back_tip))
252 CalendarSpan::Day => "Go to previous day",
253 CalendarSpan::Month => "Go to previous month",
254 _ => "Go to previous week",
255 })
256 .on_click(move |_, _, cx| {
274 .on_click(move |_, _, cx| {
257 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
275 back.update(cx, |state, cx| state.shift_calendar_week(-1, cx))
258 }),
276 }),
@@ -262,11 +280,7 @@ impl CalendarView {
262 .small()
280 .small()
263 .ghost()
281 .ghost()
264 .icon(IconName::ChevronRight)
282 .icon(IconName::ChevronRight)
265 .tooltip(match span {
283 .tooltip(tr(forward_tip))
266 CalendarSpan::Day => "Go to next day",
267 CalendarSpan::Month => "Go to next month",
268 _ => "Go to next week",
269 })
270 .on_click(move |_, _, cx| {
284 .on_click(move |_, _, cx| {
271 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
285 forward.update(cx, |state, cx| state.shift_calendar_week(1, cx))
272 }),
286 }),
@@ -286,6 +300,7 @@ impl CalendarView {
286 Button::new("calendar-span")
300 Button::new("calendar-span")
287 .small()
301 .small()
288 .ghost()
302 .ghost()
303 .icon(IconName::LayoutGrid)
289 .label(span.label())
304 .label(span.label())
290 .dropdown_caret(true)
305 .dropdown_caret(true)
291 .dropdown_menu(move |menu, _, _| {
306 .dropdown_menu(move |menu, _, _| {
@@ -308,8 +323,10 @@ impl CalendarView {
308 .small()
323 .small()
309 .outline()
324 .outline()
310 .icon(IconName::Hash)
325 .icon(IconName::Hash)
311 .when_some(label("Join with an ID"), |button, text| button.label(text))
326 .when_some(label("calendar.view.join_with_id"), |button, text| {
312 .tooltip("Join with an ID")
327 button.label(text)
328 })
329 .tooltip(tr("calendar.view.join_with_id"))
313 .on_click(move |_, window, cx| {
330 .on_click(move |_, window, cx| {
314 open_join_with_id(join_state.clone(), window, cx)
331 open_join_with_id(join_state.clone(), window, cx)
315 }),
332 }),
@@ -319,25 +336,32 @@ impl CalendarView {
319 .small()
336 .small()
320 .outline()
337 .outline()
321 .icon(IconName::Video)
338 .icon(IconName::Video)
322 .when_some(label("Meet now"), |button, text| button.label(text))
339 .when_some(label("calendar.view.meet_now"), |button, text| {
323 .tooltip("Meet now")
340 button.label(text)
341 })
342 .tooltip(tr("calendar.view.meet_now"))
324 .on_click(move |_, _, cx| {
343 .on_click(move |_, _, cx| {
325 meet_state.update(cx, |state, cx| state.start_meet_now(cx))
344 meet_state.update(cx, |state, cx| state.start_meet_now(cx))
326 }),
345 }),
327 )
346 )
328 .child(
347 .child(
329 Button::new("calendar-new-meeting")
348 Button::new("calendar-new-meeting")
349 .debug_selector(|| CALENDAR_NEW_MEETING_TAG.into())
330 .small()
350 .small()
331 .primary()
351 .primary()
332 .icon(IconName::Plus)
352 .icon(IconName::Plus)
333 .when_some(label("New meeting"), |button, text| button.label(text))
353 .when_some(label("calendar.view.new_meeting"), |button, text| {
334 .tooltip("New meeting")
354 button.label(text)
355 })
356 .tooltip(tr("calendar.view.new_meeting"))
335 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
357 .on_click(move |_, window, cx| open_new_meeting(new_state.clone(), window, cx)),
336 )
358 )
337 }
359 }
338
360
361 /// Day number above the full weekday name; today in the accent colour with its bar.
339 fn day_headers(&self, days: &[WeekDay], today: NaiveDate) -> impl IntoElement {
362 fn day_headers(&self, days: &[WeekDay], today: NaiveDate) -> impl IntoElement {
340 h_flex()
363 h_flex()
364 .debug_selector(|| CALENDAR_DAY_HEADERS_TAG.into())
341 .h(px(DAY_HEADER_HEIGHT))
365 .h(px(DAY_HEADER_HEIGHT))
342 .flex_none()
366 .flex_none()
343 .border_b_1()
367 .border_b_1()
@@ -345,10 +369,10 @@ impl CalendarView {
345 .child(div().w(px(GUTTER_WIDTH)).flex_none())
369 .child(div().w(px(GUTTER_WIDTH)).flex_none())
346 .children(days.iter().map(|day| {
370 .children(days.iter().map(|day| {
347 let is_today = day.date == today;
371 let is_today = day.date == today;
348 let color = if is_today {
372 let (number_color, name_color) = if is_today {
349 theme::accent_text()
373 (theme::accent_text(), theme::accent_text())
350 } else {
374 } else {
351 theme::text_soft()
375 (theme::text(), theme::text_soft())
352 };
376 };
353 v_flex()
377 v_flex()
354 .relative()
378 .relative()
@@ -374,14 +398,16 @@ impl CalendarView {
374 div()
398 div()
375 .text_size(px(20.))
399 .text_size(px(20.))
376 .line_height(px(24.))
400 .line_height(px(24.))
377 .text_color(color)
401 .text_color(number_color)
402 .when(is_today, |number| number.font_weight(FontWeight::SEMIBOLD))
378 .child(format::calendar_day_number(day.date)),
403 .child(format::calendar_day_number(day.date)),
379 )
404 )
380 .child(
405 .child(
381 div()
406 div()
382 .text_size(px(12.))
407 .text_size(px(12.))
383 .text_color(color)
408 .text_color(name_color)
384 .child(day.date.format("%a").to_string()),
409 .truncate()
410 .child(weekday_name(day.date.weekday(), WeekdayWidth::Full)),
385 )
411 )
386 }))
412 }))
387 }
413 }
@@ -390,6 +416,7 @@ impl CalendarView {
390 &self,
416 &self,
391 days: &[WeekDay],
417 days: &[WeekDay],
392 events: &[CalendarEvent],
418 events: &[CalendarEvent],
419 colors: &[Hsla],
393 send_response: bool,
420 send_response: bool,
394 ) -> Option<Div> {
421 ) -> Option<Div> {
395 if days.iter().all(|day| day.all_day.is_empty()) {
422 if days.iter().all(|day| day.all_day.is_empty()) {
@@ -411,6 +438,7 @@ impl CalendarView {
411 .border_color(theme::border())
438 .border_color(theme::border())
412 .children(day.all_day.iter().map(|&index| {
439 .children(day.all_day.iter().map(|&index| {
413 let event = events[index].clone();
440 let event = events[index].clone();
441 let color = colors[index];
414 let open_state = self.state.clone();
442 let open_state = self.state.clone();
415 let (menu_state, menu_event) = (self.state.clone(), event.clone());
443 let (menu_state, menu_event) = (self.state.clone(), event.clone());
416 // Day-qualified id: multi-day all-day chips share object_id.
444 // Day-qualified id: multi-day all-day chips share object_id.
@@ -423,8 +451,8 @@ impl CalendarView {
423 .px(px(6.))
451 .px(px(6.))
424 .flex()
452 .flex()
425 .items_center()
453 .items_center()
426 .rounded(px(4.))
454 .rounded(px(6.))
427 .bg(event_fill(event_look(&event)))
455 .bg(event_fill(event_look(&event), color))
428 .text_size(px(12.))
456 .text_size(px(12.))
429 .truncate()
457 .truncate()
430 .cursor_pointer()
458 .cursor_pointer()
@@ -449,6 +477,7 @@ impl CalendarView {
449 &self,
477 &self,
450 block: &WeekBlock,
478 block: &WeekBlock,
451 event: &CalendarEvent,
479 event: &CalendarEvent,
480 color: Hsla,
452 day: NaiveDate,
481 day: NaiveDate,
453 send_response: bool,
482 send_response: bool,
454 ) -> impl IntoElement {
483 ) -> impl IntoElement {
@@ -460,10 +489,10 @@ impl CalendarView {
460 let compact = height < 36.;
489 let compact = height < 36.;
461 let small = height < SMALL_TITLE_HEIGHT;
490 let small = height < SMALL_TITLE_HEIGHT;
462 let title_size = if small { 10. } else { 12. };
491 let title_size = if small { 10. } else { 12. };
463 let title_line = if small { 14. } else { 18. };
492 let title_line = if small { 14. } else { 16. };
464 let pad_y = if compact { 1. } else { 4. };
493 let pad_y = if compact { 1. } else { 3. };
465 // Fill the block: long titles use the free height instead of clamping to 2 lines.
494 // Title and organizer flow as one text; tall blocks wrap it over more lines.
466 let title_lines = (((height - pad_y * 2.) / title_line).floor() as usize).clamp(1, 8);
495 let lines = (((height - pad_y * 2.) / title_line).floor() as usize).clamp(1, 8);
467 let look = event_look(event);
496 let look = event_look(event);
468 // Join on the block whenever a Teams link exists (same as detail dialog).
497 // Join on the block whenever a Teams link exists (same as detail dialog).
469 // Skip on tiny blocks — the button would crush the title.
498 // Skip on tiny blocks — the button would crush the title.
@@ -497,13 +526,13 @@ impl CalendarView {
497 .size_full()
526 .size_full()
498 .items_start()
527 .items_start()
499 .overflow_hidden()
528 .overflow_hidden()
500 .rounded(px(4.))
529 .rounded(px(6.))
501 .bg(event_fill(look))
530 .bg(event_fill(look, color))
502 .when(event.cancelled, |block| block.opacity(0.6))
531 .when(event.cancelled, |block| block.opacity(0.6))
503 .cursor_pointer()
532 .cursor_pointer()
504 .children(status_bar(look))
533 .children(status_bar(look, color))
505 .child(
534 .child(
506 v_flex()
535 div()
507 .flex_1()
536 .flex_1()
508 .min_w_0()
537 .min_w_0()
509 .pl(px(5.))
538 .pl(px(5.))
@@ -511,28 +540,20 @@ impl CalendarView {
511 .h_full()
540 .h_full()
512 .py(px(pad_y))
541 .py(px(pad_y))
513 .overflow_hidden()
542 .overflow_hidden()
514 .when(compact, |body| body.justify_center())
543 .text_size(px(title_size))
515 .child(
544 .line_height(px(title_line))
516 div()
545 .text_color(detail_color)
517 .text_size(px(title_size))
546 .line_clamp(lines)
518 .line_height(px(title_line))
547 .text_ellipsis()
519 .font_weight(FontWeight::SEMIBOLD)
548 .child(title_and_organizer(event, title_color)),
520 .text_color(title_color)
521 .when(compact, |title| title.truncate())
522 .when(!compact, |title| title.line_clamp(title_lines))
523 .child(event_title(event)),
524 )
525 .when(!compact && title_lines > 2, |body| {
526 body.children(event.organizer_name.clone().map(|organizer| {
527 div()
528 .text_size(px(12.))
529 .line_height(px(16.))
530 .text_color(detail_color)
531 .truncate()
532 .child(organizer)
533 }))
534 }),
535 )
549 )
550 .when(event.series, |block| {
551 block.child(div().flex_none().pt(px(pad_y + 1.)).pr(px(4.)).child(icon(
552 IconName::Repeat,
553 12.,
554 detail_color,
555 )))
556 })
536 .when(can_join, |block| {
557 .when(can_join, |block| {
537 block.child(
558 block.child(
538 div().flex_none().pr(px(4.)).pt(px(3.)).child(
559 div().flex_none().pr(px(4.)).pt(px(3.)).child(
@@ -565,10 +586,14 @@ impl CalendarView {
565 })
586 })
566 }
587 }
567
588
589 #[allow(clippy::too_many_arguments)]
568 fn grid(
590 fn grid(
569 &self,
591 &self,
570 days: &[WeekDay],
592 days: &[WeekDay],
571 events: &[CalendarEvent],
593 events: &[CalendarEvent],
594 colors: &[Hsla],
595 layout: &WeekLayout,
596 work_minutes: (i64, i64),
572 today: NaiveDate,
597 today: NaiveDate,
573 now: DateTime<Utc>,
598 now: DateTime<Utc>,
574 send_response: bool,
599 send_response: bool,
@@ -582,6 +607,9 @@ impl CalendarView {
582 let local = now.with_timezone(&Local);
607 let local = now.with_timezone(&Local);
583 local.hour() * 60 + local.minute()
608 local.hour() * 60 + local.minute()
584 };
609 };
610 let now_top = now_minute as f32 / 60. * row;
611 let today_shown = days.iter().any(|day| day.date == today);
612 let minute_y = |minute: i64| minute as f32 / 60. * row;
585 div()
613 div()
586 .id("calendar-grid")
614 .id("calendar-grid")
587 .flex_1()
615 .flex_1()
@@ -600,17 +628,37 @@ impl CalendarView {
600 .children((0..24).map(|hour| {
628 .children((0..24).map(|hour| {
601 div()
629 div()
602 .h(px(row))
630 .h(px(row))
603 .pt(px(4.))
631 .pt(px(2.))
632 .pr(px(8.))
604 .flex()
633 .flex()
605 .justify_center()
634 .justify_end()
606 .text_size(px(12.))
635 .text_size(px(11.))
607 .text_color(theme::text_soft())
636 .text_color(theme::text_muted())
608 .when(hour > 0, |label| {
637 .when(hour > 0, |label| {
609 label.child(hour_label(hour, twelve_hour))
638 label.child(hour_label(hour, twelve_hour))
610 })
639 })
611 })),
640 })),
612 )
641 )
613 .children(days.iter().map(|day| {
642 .children(days.iter().map(|day| {
643 let work_day = layout.is_work_day(day.date.weekday());
644 let (work_start, work_end) = work_minutes;
645 let shade = |top: f32, height: f32| {
646 div()
647 .absolute()
648 .top(px(top))
649 .left_0()
650 .right_0()
651 .h(px(height))
652 .bg(theme::background().opacity(OFF_HOURS_OPACITY))
653 };
654 let shading = if work_day {
655 vec![
656 shade(0., minute_y(work_start)),
657 shade(minute_y(work_end), total_height - minute_y(work_end)),
658 ]
659 } else {
660 vec![shade(0., total_height)]
661 };
614 div()
662 div()
615 .relative()
663 .relative()
616 .flex_1()
664 .flex_1()
@@ -618,29 +666,41 @@ impl CalendarView {
618 .h_full()
666 .h_full()
619 .border_l_1()
667 .border_l_1()
620 .border_color(theme::border())
668 .border_color(theme::border())
621 .children((1..24 * steps).map(|quarter| {
669 .children(shading)
670 .children((1..24 * steps).map(|step| {
622 let line = div()
671 let line = div()
623 .absolute()
672 .absolute()
624 .top(px(quarter as f32 * row / steps as f32))
673 .top(px(step as f32 * row / steps as f32))
625 .left_0()
674 .left_0()
626 .right_0();
675 .right_0()
627 if quarter % steps == 0 {
676 .h(px(1.));
628 line.h(px(1.)).bg(theme::border())
677 if step % steps == 0 {
678 line.bg(theme::border())
629 } else {
679 } else {
630 line.h(px(1.))
680 line.bg(theme::border().opacity(MINOR_LINE_OPACITY))
631 .bg(theme::border().opacity(QUARTER_LINE_OPACITY))
632 }
681 }
633 }))
682 }))
634 .children(day.blocks.iter().map(|block| {
683 .children(day.blocks.iter().map(|block| {
635 self.event_block(
684 self.event_block(
636 block,
685 block,
637 &events[block.event_index],
686 &events[block.event_index],
687 colors[block.event_index],
638 day.date,
688 day.date,
639 send_response,
689 send_response,
640 )
690 )
641 }))
691 }))
692 .when(today_shown && day.date != today, |column| {
693 column.child(
694 div()
695 .absolute()
696 .top(px(now_top))
697 .left_0()
698 .right_0()
699 .h(px(1.))
700 .bg(theme::accent().opacity(NOW_ELSEWHERE_OPACITY)),
701 )
702 })
642 .when(day.date == today, |column| {
703 .when(day.date == today, |column| {
643 let now_top = now_minute as f32 / 60. * row;
644 column
704 column
645 .child(
705 .child(
646 div()
706 div()
@@ -655,7 +715,7 @@ impl CalendarView {
655 div()
715 div()
656 .absolute()
716 .absolute()
657 .top(px(now_top - NOW_DOT_SIZE / 2.))
717 .top(px(now_top - NOW_DOT_SIZE / 2.))
658 .left_0()
718 .left(px(-NOW_DOT_SIZE / 2.))
659 .size(px(NOW_DOT_SIZE))
719 .size(px(NOW_DOT_SIZE))
660 .rounded_full()
720 .rounded_full()
661 .bg(theme::accent()),
721 .bg(theme::accent()),
@@ -739,18 +799,20 @@ fn event_menu(
739 .filter(|_| event.online && !event.cancelled)
799 .filter(|_| event.online && !event.cancelled)
740 {
800 {
741 let (join_state, subject) = (state.clone(), event.subject.clone());
801 let (join_state, subject) = (state.clone(), event.subject.clone());
742 menu = menu.item(PopupMenuItem::new("Join").icon(IconName::Video).on_click(
802 menu = menu.item(
743 move |_, _, cx| {
803 PopupMenuItem::new(tr("common.join"))
744 join_state.update(cx, |state, cx| {
804 .icon(IconName::Video)
745 state.join_calendar_meeting(Some(&join_url), &subject, cx)
805 .on_click(move |_, _, cx| {
746 })
806 join_state.update(cx, |state, cx| {
747 },
807 state.join_calendar_meeting(Some(&join_url), &subject, cx)
748 ));
808 })
809 }),
810 );
749 }
811 }
750 if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {
812 if let Some(join_url) = event.join_url.as_deref().filter(|_| event.online) {
751 let info = join_info_text(join_url, event.dial_in.as_ref());
813 let info = join_info_text(join_url, event.dial_in.as_ref());
752 menu = menu.item(
814 menu = menu.item(
753 PopupMenuItem::new(COPY_JOIN_INFO)
815 PopupMenuItem::new(tr("calendar.view.copy_join_info"))
754 .icon(IconName::Copy)
816 .icon(IconName::Copy)
755 .on_click(move |_, _, cx| {
817 .on_click(move |_, _, cx| {
756 cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))
818 cx.write_to_clipboard(ClipboardItem::new_string(info.clone()))
@@ -760,7 +822,7 @@ fn event_menu(
760 if let Some(thread_id) = event.thread_id.clone() {
822 if let Some(thread_id) = event.thread_id.clone() {
761 let chat_state = state.clone();
823 let chat_state = state.clone();
762 menu = menu.item(
824 menu = menu.item(
763 PopupMenuItem::new("Chat with participants")
825 PopupMenuItem::new(tr("calendar.view.chat_with_participants"))
764 .icon(IconName::MessageSquare)
826 .icon(IconName::MessageSquare)
765 .on_click(move |_, _, cx| {
827 .on_click(move |_, _, cx| {
766 chat_state.update(cx, |state, cx| {
828 chat_state.update(cx, |state, cx| {
@@ -781,31 +843,49 @@ fn event_menu(
781 )
843 )
782}
844}
783
845
784fn event_fill(look: EventLook) -> Hsla {
846fn event_fill(look: EventLook, color: Hsla) -> Hsla {
785 match look {
847 match look {
786 EventLook::Busy => theme::accent().opacity(BUSY_FILL_OPACITY),
848 EventLook::Busy => color.opacity(BUSY_FILL_OPACITY),
787 EventLook::Free | EventLook::Tentative => theme::accent().opacity(FREE_FILL_OPACITY),
849 EventLook::Free | EventLook::Tentative => color.opacity(FREE_FILL_OPACITY),
788 }
850 }
789}
851}
790
852
791fn status_bar(look: EventLook) -> Option<Div> {
853fn status_bar(look: EventLook, color: Hsla) -> Option<Div> {
792 let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();
854 let bar = div().flex_none().w(px(STATUS_BAR_WIDTH)).h_full();
793 match look {
855 match look {
794 EventLook::Busy => Some(bar.bg(theme::accent())),
856 EventLook::Busy => Some(bar.bg(color)),
795 EventLook::Tentative => Some(
857 EventLook::Tentative => Some(
796 bar.bg(theme::accent().opacity(BUSY_FILL_OPACITY)).child(
858 bar.bg(color.opacity(BUSY_FILL_OPACITY))
797 div()
859 .child(
798 .size_full()
860 div()
799 .bg(pattern_slash(theme::accent(), HATCH_STRIPE, HATCH_GAP)),
861 .size_full()
800 ),
862 .bg(pattern_slash(color, HATCH_STRIPE, HATCH_GAP)),
863 ),
801 ),
864 ),
802 EventLook::Free => None,
865 EventLook::Free => None,
803 }
866 }
804}
867}
805
868
869/// "Daily Standup Zulal Fouque": bold title, organizer right after it on the same line.
870fn title_and_organizer(event: &CalendarEvent, title_color: Hsla) -> StyledText {
871 let title = event_title(event);
872 let text = match event.organizer_name.as_deref() {
873 Some(organizer) if !organizer.is_empty() => format!("{title} {organizer}"),
874 _ => title.clone(),
875 };
876 StyledText::new(text).with_highlights([(
877 0..title.len(),
878 HighlightStyle {
879 color: Some(title_color),
880 font_weight: Some(FontWeight::SEMIBOLD),
881 ..Default::default()
882 },
883 )])
884}
885
806fn event_title(event: &CalendarEvent) -> String {
886fn event_title(event: &CalendarEvent) -> String {
807 let subject = if event.cancelled {
887 let subject = if event.cancelled {
808 format!("{CANCELED_PREFIX}{}", event.subject)
888 format!("{}{}", tr("calendar.peek.canceled_prefix"), event.subject)
809 } else {
889 } else {
810 event.subject.clone()
890 event.subject.clone()
811 };
891 };
@@ -851,7 +931,13 @@ impl Render for CalendarView {
851 let days = week_days(&events, &dates, offset);
931 let days = week_days(&events, &dates, offset);
852 let today = Local::now().date_naive();
932 let today = Local::now().date_naive();
853 let now = Utc::now();
933 let now = Utc::now();
854 let show_picker = !compact;
934 let accounts = state.calendar_accounts();
935 let colors: Vec<Hsla> = events
936 .iter()
937 .map(|event| theme::calendar_color(calendar_index(event, &accounts)))
938 .collect();
939 let work_minutes = state.calendar_prefs.work_hours.minute_range();
940 let show_picker = !compact && !state.calendar_prefs.pane_hidden;
855 h_flex()
941 h_flex()
856 .debug_selector(|| "shell/islands/calendar".into())
942 .debug_selector(|| "shell/islands/calendar".into())
857 .flex_1()
943 .flex_1()
@@ -879,6 +965,7 @@ impl Render for CalendarView {
879 start,
965 start,
880 &days,
966 &days,
881 &events,
967 &events,
968 &colors,
882 today,
969 today,
883 offset,
970 offset,
884 layout.weekdays(),
971 layout.weekdays(),
@@ -886,8 +973,18 @@ impl Render for CalendarView {
886 } else {
973 } else {
887 calendar
974 calendar
888 .child(self.day_headers(&days, today))
975 .child(self.day_headers(&days, today))
889 .children(self.all_day_row(&days, &events, send_response))
976 .children(self.all_day_row(&days, &events, &colors, send_response))
890 .child(self.grid(&days, &events, today, now, send_response, cx))
977 .child(self.grid(
978 &days,
979 &events,
980 &colors,
981 &layout,
982 work_minutes,
983 today,
984 now,
985 send_response,
986 cx,
987 ))
891 }
988 }
892 }),
989 }),
893 )
990 )
crates/graph/src/mailbox.rs +14 −1
@@ -21,6 +21,8 @@ pub struct MailboxWorkingHours {
21 21 pub end: NaiveTime,
22 22 /// Windows or IANA name as the mailbox stores it; written back unchanged.
23 23 pub time_zone: Option<String>,
24 /// Mailbox language (`en-CH`); Outlook derives the first day of week from it.
25 pub locale: Option<String>,
24 26 }
25 27
26 28 impl Graph {
@@ -67,6 +69,11 @@ pub fn parse_working_hours(body: &Value) -> Option<MailboxWorkingHours> {
67 69 .pointer("/timeZone/name")
68 70 .and_then(Value::as_str)
69 71 .map(str::to_owned),
72 locale: body
73 .pointer("/language/locale")
74 .and_then(Value::as_str)
75 .filter(|locale| !locale.is_empty())
76 .map(str::to_owned),
70 77 })
71 78 }
72 79
@@ -108,6 +115,7 @@ mod tests {
108 115 json!({
109 116 "timeFormat": "HH:mm",
110 117 "dateFormat": "d MMM yyyy",
118 "language": {"locale": "en-CH", "displayName": "English (Switzerland)"},
111 119 "workingHours": {
112 120 "daysOfWeek": ["monday", "tuesday", "wednesday", "thursday", "friday"],
113 121 "startTime": "08:00:00.0000000",
@@ -133,6 +141,7 @@ mod tests {
133 141 assert_eq!(hours.start, NaiveTime::from_hms_opt(8, 0, 0).unwrap());
134 142 assert_eq!(hours.end, NaiveTime::from_hms_opt(17, 0, 0).unwrap());
135 143 assert_eq!(hours.time_zone.as_deref(), Some("W. Europe Standard Time"));
144 assert_eq!(hours.locale.as_deref(), Some("en-CH"));
136 145 }
137 146
138 147 #[test]
@@ -150,7 +159,11 @@ mod tests {
150 159 body["workingHours"]["timeZone"]["name"],
151 160 "W. Europe Standard Time"
152 161 );
153 assert_eq!(parse_working_hours(&body).unwrap(), hours);
162 let parsed = parse_working_hours(&body).unwrap();
163 assert_eq!(
164 (parsed.days, parsed.start, parsed.end),
165 (hours.days, hours.start, hours.end)
166 );
154 167 }
155 168
156 169 #[test]
@@ -21,6 +21,8 @@ pub struct MailboxWorkingHours {
21 pub end: NaiveTime,
21 pub end: NaiveTime,
22 /// Windows or IANA name as the mailbox stores it; written back unchanged.
22 /// Windows or IANA name as the mailbox stores it; written back unchanged.
23 pub time_zone: Option<String>,
23 pub time_zone: Option<String>,
24 /// Mailbox language (`en-CH`); Outlook derives the first day of week from it.
25 pub locale: Option<String>,
24}
26}
25
27
26impl Graph {
28impl Graph {
@@ -67,6 +69,11 @@ pub fn parse_working_hours(body: &Value) -> Option<MailboxWorkingHours> {
67 .pointer("/timeZone/name")
69 .pointer("/timeZone/name")
68 .and_then(Value::as_str)
70 .and_then(Value::as_str)
69 .map(str::to_owned),
71 .map(str::to_owned),
72 locale: body
73 .pointer("/language/locale")
74 .and_then(Value::as_str)
75 .filter(|locale| !locale.is_empty())
76 .map(str::to_owned),
70 })
77 })
71}
78}
72
79
@@ -108,6 +115,7 @@ mod tests {
108 json!({
115 json!({
109 "timeFormat": "HH:mm",
116 "timeFormat": "HH:mm",
110 "dateFormat": "d MMM yyyy",
117 "dateFormat": "d MMM yyyy",
118 "language": {"locale": "en-CH", "displayName": "English (Switzerland)"},
111 "workingHours": {
119 "workingHours": {
112 "daysOfWeek": ["monday", "tuesday", "wednesday", "thursday", "friday"],
120 "daysOfWeek": ["monday", "tuesday", "wednesday", "thursday", "friday"],
113 "startTime": "08:00:00.0000000",
121 "startTime": "08:00:00.0000000",
@@ -133,6 +141,7 @@ mod tests {
133 assert_eq!(hours.start, NaiveTime::from_hms_opt(8, 0, 0).unwrap());
141 assert_eq!(hours.start, NaiveTime::from_hms_opt(8, 0, 0).unwrap());
134 assert_eq!(hours.end, NaiveTime::from_hms_opt(17, 0, 0).unwrap());
142 assert_eq!(hours.end, NaiveTime::from_hms_opt(17, 0, 0).unwrap());
135 assert_eq!(hours.time_zone.as_deref(), Some("W. Europe Standard Time"));
143 assert_eq!(hours.time_zone.as_deref(), Some("W. Europe Standard Time"));
144 assert_eq!(hours.locale.as_deref(), Some("en-CH"));
136 }
145 }
137
146
138 #[test]
147 #[test]
@@ -150,7 +159,11 @@ mod tests {
150 body["workingHours"]["timeZone"]["name"],
159 body["workingHours"]["timeZone"]["name"],
151 "W. Europe Standard Time"
160 "W. Europe Standard Time"
152 );
161 );
153 assert_eq!(parse_working_hours(&body).unwrap(), hours);
162 let parsed = parse_working_hours(&body).unwrap();
163 assert_eq!(
164 (parsed.days, parsed.start, parsed.end),
165 (hours.days, hours.start, hours.end)
166 );
154 }
167 }
155
168
156 #[test]
169 #[test]
docs/decisions/0016-calendar-week-start-and-time-scale-stay-local.md +1 −1
@@ -21,7 +21,7 @@ The options were:
21 21 ## Decision
22 22
23 23 - Work days and hours are read from and written to the mailbox working hours through Graph. A local copy is only a cache for the grid.
24 - First day of week defaults to the regional format, which is where Teams takes it from when no OWA option is set. A local override can change it.
24 - First day of week defaults to the region of the mailbox language (`language.locale` in the mailbox settings), which is where Outlook takes the OWA default from. The regional format is the fallback. A local override can change it.
25 25 - The time scale is a local setting. Its default, 30 minutes, matches Teams.
26 26 - Default view and the last used span are fork settings and stay local.
27 27
@@ -21,7 +21,7 @@ The options were:
21## Decision
21## Decision
22
22
23- Work days and hours are read from and written to the mailbox working hours through Graph. A local copy is only a cache for the grid.
23- Work days and hours are read from and written to the mailbox working hours through Graph. A local copy is only a cache for the grid.
24- First day of week defaults to the regional format, which is where Teams takes it from when no OWA option is set. A local override can change it.
24- First day of week defaults to the region of the mailbox language (`language.locale` in the mailbox settings), which is where Outlook takes the OWA default from. The regional format is the fallback. A local override can change it.
25- The time scale is a local setting. Its default, 30 minutes, matches Teams.
25- The time scale is a local setting. Its default, 30 minutes, matches Teams.
26- Default view and the last used span are fork settings and stay local.
26- Default view and the last used span are fork settings and stay local.
27
27
docs/design/islands/SPEC.md +1 −0
@@ -85,6 +85,7 @@ Core roles (non-exhaustive; prefer an existing role over inventing a hex):
85 85 | `accent`, `accent_text`, `accent_soft`, `accent_strong`, `on_accent` | Primary actions and links |
86 86 | `bubble_own` / `bubble_other` | Message bubbles |
87 87 | `green`, `red`, `amber`, … | Status semantics already defined on the palette |
88 | `accent`, then `avatar_palette` | Calendar colours: Outlook takes `accent`, every further calendar in the calendar list the next palette colour (`theme::calendar_color`) |
88 89
89 90 Shades: Dark (default), Light, High contrast. Schemes: Rusty Teams and Teams (`SCHEMES` in `schemes.rs`). Changing a hex belongs in the palette / scheme tables, not in a view.
90 91
@@ -85,6 +85,7 @@ Core roles (non-exhaustive; prefer an existing role over inventing a hex):
85| `accent`, `accent_text`, `accent_soft`, `accent_strong`, `on_accent` | Primary actions and links |
85| `accent`, `accent_text`, `accent_soft`, `accent_strong`, `on_accent` | Primary actions and links |
86| `bubble_own` / `bubble_other` | Message bubbles |
86| `bubble_own` / `bubble_other` | Message bubbles |
87| `green`, `red`, `amber`, … | Status semantics already defined on the palette |
87| `green`, `red`, `amber`, … | Status semantics already defined on the palette |
88| `accent`, then `avatar_palette` | Calendar colours: Outlook takes `accent`, every further calendar in the calendar list the next palette colour (`theme::calendar_color`) |
88
89
89Shades: Dark (default), Light, High contrast. Schemes: Rusty Teams and Teams (`SCHEMES` in `schemes.rs`). Changing a hex belongs in the palette / scheme tables, not in a view.
90Shades: Dark (default), Light, High contrast. Schemes: Rusty Teams and Teams (`SCHEMES` in `schemes.rs`). Changing a hex belongs in the palette / scheme tables, not in a view.
90
91