Skip to content

Commit 977ac2a

Browse files
afaquejamepriestley
authored andcommitted
Highlighting the current day in calendar.
Summary: Highlights the current day :) I am not great in choosing colors. @chad can suggest some improvements :) Test Plan: {F41738} Reviewers: epriestley Reviewed By: epriestley CC: chad, aran, Korvin, AnhNhan Maniphest Tasks: T2627 Differential Revision: https://secure.phabricator.com/D5790
1 parent 9885165 commit 977ac2a

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/__celerity_resource_map__.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@
741741
),
742742
'aphront-calendar-view-css' =>
743743
array(
744-
'uri' => '/res/73061a31/rsrc/css/aphront/calendar-view.css',
744+
'uri' => '/res/ae6f5b54/rsrc/css/aphront/calendar-view.css',
745745
'type' => 'css',
746746
'requires' =>
747747
array(

src/applications/calendar/controller/PhabricatorCalendarBrowseController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public function processRequest() {
1111
$year = $request->getInt('year', $year_d);
1212
$month_d = phabricator_format_local_time($now, $user, 'm');
1313
$month = $request->getInt('month', $month_d);
14+
$day = phabricator_format_local_time($now, $user, 'j');
15+
1416

1517
$holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere(
1618
'day BETWEEN %s AND %s',
@@ -23,7 +25,12 @@ public function processRequest() {
2325
strtotime("{$year}-{$month}-01"),
2426
strtotime("{$year}-{$month}-01 next month"));
2527

26-
$month_view = new AphrontCalendarMonthView($month, $year);
28+
if ($month == $month_d && $year == $year_d) {
29+
$month_view = new AphrontCalendarMonthView($month, $year, $day);
30+
} else {
31+
$month_view = new AphrontCalendarMonthView($month, $year);
32+
}
33+
2734
$month_view->setBrowseURI($request->getRequestURI());
2835
$month_view->setUser($user);
2936
$month_view->setHolidays($holidays);

src/applications/calendar/view/AphrontCalendarMonthView.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
final class AphrontCalendarMonthView extends AphrontView {
44

5+
private $day;
56
private $month;
67
private $year;
78
private $holidays = array();
@@ -27,7 +28,8 @@ public function setHolidays(array $holidays) {
2728
return $this;
2829
}
2930

30-
public function __construct($month, $year) {
31+
public function __construct($month, $year, $day = null) {
32+
$this->day = $day;
3133
$this->month = $month;
3234
$this->year = $year;
3335
}
@@ -65,6 +67,11 @@ public function render() {
6567
$holiday = idx($this->holidays, $day->format('Y-m-d'));
6668
$class = 'aphront-calendar-day';
6769
$weekday = $day->format('w');
70+
71+
if ($day_number == $this->day) {
72+
$class .= ' aphront-calendar-today';
73+
}
74+
6875
if ($holiday || $weekday == 0 || $weekday == 6) {
6976
$class .= ' aphront-calendar-not-work-day';
7077
}

webroot/rsrc/css/aphront/calendar-view.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ table.aphront-calendar-view td div.aphront-calendar-day {
7575
background-color: #fdfae7;
7676
}
7777

78+
.aphront-calendar-today {
79+
background-color: #A6FAAD;
80+
}
81+
7882
.aphront-calendar-empty {
7983
background-color: #ededed;
8084
}

0 commit comments

Comments
 (0)