From e3134a1d478e649df86761acb53a3822fb9409bd Mon Sep 17 00:00:00 2001 From: lkassianik Date: Fri, 15 May 2015 12:17:34 -0700 Subject: [PATCH] This week should be marked with a bottom blue horizontal bar in Calendar month view. Summary: Closes T8185, This week should be marked with a bottom blue horizontal bar in Calendar month view. Test Plan: Open calendar month view, "this week" should show a dark blue bar under it and a lighter blue bar on "today". Reviewers: chad, #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8185 Differential Revision: https://secure.phabricator.com/D12862 --- resources/celerity/map.php | 4 +- .../phui/calendar/PHUICalendarMonthView.php | 47 +++++++++++++++++++ .../css/phui/calendar/phui-calendar-month.css | 17 +++++-- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 1b82da2ae9..a6a4fecbae 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -122,7 +122,7 @@ return array( 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', 'rsrc/css/phui/calendar/phui-calendar-day.css' => '3b4a65d8', 'rsrc/css/phui/calendar/phui-calendar-list.css' => '840baa8d', - 'rsrc/css/phui/calendar/phui-calendar-month.css' => '7819a8b1', + 'rsrc/css/phui/calendar/phui-calendar-month.css' => '4fba442e', 'rsrc/css/phui/calendar/phui-calendar.css' => '8345be98', 'rsrc/css/phui/phui-action-header-view.css' => '89c497e7', 'rsrc/css/phui/phui-action-list.css' => '4f4d09f2', @@ -763,7 +763,7 @@ return array( 'phui-calendar-css' => '8345be98', 'phui-calendar-day-css' => '3b4a65d8', 'phui-calendar-list-css' => '840baa8d', - 'phui-calendar-month-css' => '7819a8b1', + 'phui-calendar-month-css' => '4fba442e', 'phui-crumbs-view-css' => '594d719e', 'phui-document-view-css' => '94d5dcd8', 'phui-feed-story-css' => 'c9f3a0b5', diff --git a/src/view/phui/calendar/PHUICalendarMonthView.php b/src/view/phui/calendar/PHUICalendarMonthView.php index 16e58e3203..fd2ca4e458 100644 --- a/src/view/phui/calendar/PHUICalendarMonthView.php +++ b/src/view/phui/calendar/PHUICalendarMonthView.php @@ -228,6 +228,15 @@ final class PHUICalendarMonthView extends AphrontView { $today_class = 'phui-calendar-today-slot'; } + if ($this->isDateInCurrentWeek($date)) { + $today_class .= ' phui-calendar-this-week'; + } + + $last_week_day = 6; + if ($date->format('w') == $last_week_day) { + $today_class .= ' last-weekday'; + } + $today_slot = phutil_tag ( 'div', array( @@ -254,6 +263,16 @@ final class PHUICalendarMonthView extends AphrontView { $cell_div); } + private function isDateInCurrentWeek($date) { + list($week_start_date, $week_end_date) = $this->getThisWeekRange(); + + if ($date->format('U') < $week_end_date->format('U') && + $date->format('U') >= $week_start_date->format('U')) { + return true; + } + return false; + } + private function getEventCountBadge($count, $viewer_is_invited) { $class = 'phui-calendar-month-count-badge'; @@ -484,6 +503,34 @@ final class PHUICalendarMonthView extends AphrontView { return $days; } + private function getTodayMidnight() { + $viewer = $this->getUser(); + $today = new DateTime('@'.time()); + $today->setTimeZone($viewer->getTimeZone()); + $today->setTime(0, 0, 0); + + return $today; + } + + private function getThisWeekRange() { + $week_start = 0; + $week_end = 6; + + $today = $this->getTodayMidnight(); + $date_weekday = $today->format('w'); + + $days_from_week_start = $date_weekday - $week_start; + $days_to_week_end = $week_end - $date_weekday + 1; + + $modify = '-'.$days_from_week_start.' days'; + $week_start_date = id(clone $today)->modify($modify); + + $modify = '+'.$days_to_week_end.' days'; + $week_end_date = id(clone $today)->modify($modify); + + return array($week_start_date, $week_end_date); + } + private function getDateTime() { $user = $this->user; $timezone = new DateTimeZone($user->getTimezoneIdentifier()); diff --git a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css index ba268f332f..14d25e7f67 100644 --- a/webroot/rsrc/css/phui/calendar/phui-calendar-month.css +++ b/webroot/rsrc/css/phui/calendar/phui-calendar-month.css @@ -96,7 +96,7 @@ table.phui-calendar-view tr td:first-child { table.phui-calendar-view a.phui-calendar-date-number { color: {$lightgreytext}; - padding: 0 4px; + padding: 4px; display: inline-block; min-width: 16px; text-align: center; @@ -111,10 +111,19 @@ table.phui-calendar-view td.phui-calendar-date-number-container { .phui-calendar-today-slot { display: block; - width: 100%; height: 4px; - padding: 0; - margin: 0; + position: absolute; + left: 0; + right: -1px; + bottom: 0; +} + +.phui-calendar-today-slot.last-weekday { + right: 0px; +} + +.phui-calendar-today-slot.phui-calendar-this-week { + background-color: {$blueborder}; } .phui-calendar-today-slot.phui-calendar-today {