Skip to content

Commit 1761abc

Browse files
author
epriestley
committedDec 11, 2012
Make timeline view prettier
Summary: Aligns the timeline view more closely with the `diff_full_view.png` mock. Test Plan: Desktop: {F26822} Mobile: {F26823} Reviewers: chad, btrahan Reviewed By: chad CC: aran Maniphest Tasks: T2104 Differential Revision: https://secure.phabricator.com/D4137
1 parent 7b6fa0d commit 1761abc

File tree

9 files changed

+326
-183
lines changed

9 files changed

+326
-183
lines changed
 

‎resources/sprite/manifest/icon.json

+60-60
Large diffs are not rendered by default.

‎src/applications/pholio/controller/PholioMockViewController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ private function buildTransactionView(
201201
continue;
202202
}
203203

204-
$title = $xaction->getTitle();
205-
206204
$event = id(new PhabricatorTimelineEventView())
207205
->setUserHandle($xaction->getHandle($xaction->getAuthorPHID()))
208-
->setTitle($title);
206+
->setIcon($xaction->getIcon())
207+
->setColor($xaction->getColor())
208+
->setTitle($xaction->getTitle());
209209

210210
if ($xaction->getComment()) {
211211
$event->appendChild(

‎src/applications/transactions/constants/PhabricatorTransactions.php

+11
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,15 @@ final class PhabricatorTransactions {
77
const TYPE_VIEW_POLICY = 'core:view-policy';
88
const TYPE_EDIT_POLICY = 'core:edit-policy';
99

10+
const COLOR_RED = 'red';
11+
const COLOR_ORANGE = 'orange';
12+
const COLOR_YELLOW = 'yellow';
13+
const COLOR_GREEN = 'green';
14+
const COLOR_SKY = 'sky';
15+
const COLOR_BLUE = 'blue';
16+
const COLOR_INDIGO = 'indigo';
17+
const COLOR_VIOLET = 'violet';
18+
const COLOR_GREY = 'grey';
19+
const COLOR_BLACK = 'black';
20+
1021
}

‎src/applications/transactions/storage/PhabricatorApplicationTransaction.php

+8
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ protected function renderHandleList(array $phids) {
119119
return implode(', ', $links);
120120
}
121121

122+
public function getIcon() {
123+
return null;
124+
}
125+
126+
public function getColor() {
127+
return null;
128+
}
129+
122130
public function shouldHide() {
123131
switch ($this->getTransactionType()) {
124132
case PhabricatorTransactions::TYPE_VIEW_POLICY:

‎src/applications/uiexample/examples/PhabricatorTimelineExample.php

+30-10
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ public function renderExample() {
4343
$events[] = id(new PhabricatorTimelineEventView())
4444
->setUserHandle($handle)
4545
->setTitle('Major Red Event')
46+
->setIcon('love')
4647
->appendChild('This event is red!')
47-
->addClass('phabricator-timeline-red');
48+
->setColor(PhabricatorTransactions::COLOR_RED);
4849

4950
$events[] = id(new PhabricatorTimelineEventView())
5051
->setUserHandle($handle)
5152
->setTitle('Minor Red Event')
52-
->addClass('phabricator-timeline-red');
53+
->setColor(PhabricatorTransactions::COLOR_RED);
5354

5455
$events[] = id(new PhabricatorTimelineEventView())
5556
->setUserHandle($handle)
@@ -58,24 +59,43 @@ public function renderExample() {
5859
$events[] = id(new PhabricatorTimelineEventView())
5960
->setUserHandle($handle)
6061
->setTitle('Minor Red Event')
61-
->addClass('phabricator-timeline-red');
62+
->setColor(PhabricatorTransactions::COLOR_RED);
6263

6364
$events[] = id(new PhabricatorTimelineEventView())
6465
->setUserHandle($handle)
6566
->setTitle('Minor Not-Red Event');
6667

6768
$events[] = id(new PhabricatorTimelineEventView())
6869
->setUserHandle($handle)
69-
->setTitle('Unstyled event')
70-
->appendChild('This event disables standard title and content styling.')
71-
->setDisableStandardTitleStyle(true)
72-
->setDisableStandardContentStyle(true);
70+
->setTitle('Major Green Event')
71+
->appendChild('This event is green!')
72+
->setColor(PhabricatorTransactions::COLOR_GREEN);
73+
74+
$colors = array(
75+
PhabricatorTransactions::COLOR_RED,
76+
PhabricatorTransactions::COLOR_ORANGE,
77+
PhabricatorTransactions::COLOR_YELLOW,
78+
PhabricatorTransactions::COLOR_GREEN,
79+
PhabricatorTransactions::COLOR_SKY,
80+
PhabricatorTransactions::COLOR_BLUE,
81+
PhabricatorTransactions::COLOR_INDIGO,
82+
PhabricatorTransactions::COLOR_VIOLET,
83+
PhabricatorTransactions::COLOR_GREY,
84+
PhabricatorTransactions::COLOR_BLACK,
85+
);
7386

7487
$events[] = id(new PhabricatorTimelineEventView())
7588
->setUserHandle($handle)
76-
->setTitle('Major Green Event')
77-
->appendChild('This event is green!')
78-
->addClass('phabricator-timeline-green');
89+
->setTitle(phutil_escape_html("Colorless"))
90+
->setIcon('lock');
91+
92+
foreach ($colors as $color) {
93+
$events[] = id(new PhabricatorTimelineEventView())
94+
->setUserHandle($handle)
95+
->setTitle(phutil_escape_html("Color '{$color}'"))
96+
->setIcon('lock')
97+
->setColor($color);
98+
}
7999

80100
$timeline = id(new PhabricatorTimelineView());
81101
foreach ($events as $event) {

‎src/infrastructure/celerity/CeleritySpriteGenerator.php

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function buildIconSheet() {
3737

3838
if ($color == 'white') {
3939
$sprite->setTargetCSS(
40+
'.action-'.$icon.$suffix.', '.
4041
'.device-desktop .phabricator-action-view:hover .action-'.$icon);
4142
} else {
4243
$sprite->setTargetCSS('.action-'.$icon.$suffix);

‎src/view/layout/PhabricatorTimelineEventView.php

+30-13
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ final class PhabricatorTimelineEventView extends AphrontView {
44

55
private $userHandle;
66
private $title;
7+
private $icon;
8+
private $color;
79
private $classes = array();
8-
private $disableStandardTitleStyle;
9-
private $disableStandardContentStyle;
1010

1111
public function setUserHandle(PhabricatorObjectHandle $handle) {
1212
$this->userHandle = $handle;
@@ -23,13 +23,13 @@ public function addClass($class) {
2323
return $this;
2424
}
2525

26-
public function setDisableStandardTitleStyle($disable) {
27-
$this->disableStandardTitleStyle = $disable;
26+
public function setIcon($icon) {
27+
$this->icon = $icon;
2828
return $this;
2929
}
3030

31-
public function setDisableStandardContentStyle($disable) {
32-
$this->disableStandardContentStyle = $disable;
31+
public function setColor($color) {
32+
$this->color = $color;
3333
return $this;
3434
}
3535

@@ -44,16 +44,31 @@ public function render() {
4444
if ($title !== null) {
4545
$title_classes = array();
4646
$title_classes[] = 'phabricator-timeline-title';
47-
if (!$this->disableStandardTitleStyle) {
48-
$title_classes[] = 'phabricator-timeline-standard-title';
47+
48+
$icon = null;
49+
if ($this->icon) {
50+
$title_classes[] = 'phabricator-timeline-title-with-icon';
51+
52+
$icon = phutil_render_tag(
53+
'span',
54+
array(
55+
'class' => 'phabricator-timeline-icon-fill',
56+
),
57+
phutil_render_tag(
58+
'span',
59+
array(
60+
'class' => 'phabricator-timeline-icon sprite-icon '.
61+
'action-'.$this->icon.'-white',
62+
),
63+
''));
4964
}
5065

5166
$title = phutil_render_tag(
5267
'div',
5368
array(
5469
'class' => implode(' ', $title_classes),
5570
),
56-
$title);
71+
$icon.$title);
5772
}
5873

5974
$wedge = phutil_render_tag(
@@ -74,9 +89,6 @@ public function render() {
7489

7590
$content_classes = array();
7691
$content_classes[] = 'phabricator-timeline-content';
77-
if (!$this->disableStandardContentStyle) {
78-
$content_classes[] = 'phabricator-timeline-standard-content';
79-
}
8092

8193
$classes = array();
8294
$classes[] = 'phabricator-timeline-event-view';
@@ -111,10 +123,15 @@ public function render() {
111123
$image.$wedge.$title);
112124
}
113125

126+
$outer_classes = $this->classes;
127+
if ($this->color) {
128+
$outer_classes[] = 'phabricator-timeline-'.$this->color;
129+
}
130+
114131
return phutil_render_tag(
115132
'div',
116133
array(
117-
'class' => implode(' ', $this->classes),
134+
'class' => implode(' ', $outer_classes),
118135
),
119136
phutil_render_tag(
120137
'div',

0 commit comments

Comments
 (0)
Failed to load comments.