Skip to content

Commit 78f73e7

Browse files
committedAug 1, 2013
Add one-line feed story.
Summary: It turns out not everything is interesting. This adds a oneline story with less vertical space. Test Plan: UIExamples Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D6640
1 parent fd2593e commit 78f73e7

File tree

4 files changed

+120
-49
lines changed

4 files changed

+120
-49
lines changed
 

‎src/__celerity_resource_map__.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@
38303830
),
38313831
'phui-feed-story-css' =>
38323832
array(
3833-
'uri' => '/res/6afac7dd/rsrc/css/phui/phui-feed-story.css',
3833+
'uri' => '/res/e5d6825b/rsrc/css/phui/phui-feed-story.css',
38343834
'type' => 'css',
38353835
'requires' =>
38363836
array(

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

+29-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ public function renderExample() {
1515
$request = $this->getRequest();
1616
$user = $request->getUser();
1717

18-
/* Basic "One Line" Story */
19-
$text = hsprintf('<strong><a>harding (Tom Harding)</a></strong> closed <a>'.
18+
/* Basic Story */
19+
$text = hsprintf(
20+
'<strong><a>harding (Tom Harding)</a></strong> closed <a>'.
2021
'D12: New spacer classes for blog views</a>.');
2122
$story1 = id(new PHUIFeedStoryView())
2223
->setTitle($text)
@@ -118,11 +119,22 @@ public function renderExample() {
118119
->setPontification('If we ever create a lightweight status app '.
119120
'this story would be how that would be displayed.');
120121

121-
122+
/* Basic "One Line" Story */
123+
$text = hsprintf(
124+
'<strong><a>harding (Tom Harding)</a></strong> updated <a>'.
125+
'D12: New spacer classes for blog views</a>.');
126+
$story6 = id(new PHUIFeedStoryView())
127+
->setTitle($text)
128+
->setImage(celerity_get_resource_uri('/rsrc/image/people/harding.png'))
129+
->setImageHref('http://en.wikipedia.org/wiki/Warren_G._Harding')
130+
->setEpoch(1)
131+
->setOneLine(true)
132+
->setAppIcon('differential-dark')
133+
->setUser($user);
122134

123135

124136
$head1 = id(new PhabricatorHeaderView())
125-
->setHeader(pht('Basic "one-line" Story'));
137+
->setHeader(pht('Basic Story'));
126138

127139
$head2 = id(new PhabricatorHeaderView())
128140
->setHeader(pht('Title / Text Story'));
@@ -136,6 +148,9 @@ public function renderExample() {
136148
$head5 = id(new PhabricatorHeaderView())
137149
->setHeader(pht('Status Story'));
138150

151+
$head6 = id(new PhabricatorHeaderView())
152+
->setHeader(pht('One Line Story'));
153+
139154
$wrap1 =
140155
array(
141156
id(new PHUIBoxView())
@@ -171,6 +186,13 @@ public function renderExample() {
171186
->addMargin(PHUI::MARGIN_MEDIUM)
172187
->addPadding(PHUI::PADDING_SMALL));
173188

189+
$wrap6 =
190+
array(
191+
id(new PHUIBoxView())
192+
->appendChild($story6)
193+
->addMargin(PHUI::MARGIN_MEDIUM)
194+
->addPadding(PHUI::PADDING_SMALL));
195+
174196
return phutil_tag(
175197
'div',
176198
array(),
@@ -184,7 +206,9 @@ public function renderExample() {
184206
$head4,
185207
$wrap4,
186208
$head5,
187-
$wrap5
209+
$wrap5,
210+
$head6,
211+
$wrap6
188212
));
189213
}
190214
}

‎src/view/phui/PHUIFeedStoryView.php

+64-35
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ final class PHUIFeedStoryView extends AphrontView {
1010
private $epoch;
1111
private $viewed;
1212
private $href;
13+
private $oneline = false;
1314
private $pontification = null;
1415
private $tokenBar = array();
1516
private $projects = array();
@@ -35,6 +36,11 @@ public function setEpoch($epoch) {
3536
return $this;
3637
}
3738

39+
public function setOneLine($oneline) {
40+
$this->oneline = $oneline;
41+
return $this;
42+
}
43+
3844
public function setImage($image) {
3945
$this->image = $image;
4046
return $this;
@@ -80,6 +86,7 @@ public function addAction(PHUIIconView $action) {
8086
}
8187

8288
public function setPontification($text, $title = null) {
89+
$this->setOneLine(false);
8390
if ($title) {
8491
$title = phutil_tag('h3', array(), $title);
8592
}
@@ -124,7 +131,11 @@ public function render() {
124131

125132
require_celerity_resource('phui-feed-story-css');
126133

134+
$body = null;
135+
$foot = null;
136+
$image_style = null;
127137
$actor = '';
138+
128139
if ($this->image) {
129140
$actor = new PHUIIconView();
130141
$actor->setImage($this->image);
@@ -134,6 +145,46 @@ public function render() {
134145
}
135146
}
136147

148+
if ($this->epoch) {
149+
// TODO: This is really bad; when rendering through Conduit and via
150+
// renderText() we don't have a user.
151+
if ($this->user) {
152+
$foot = phabricator_datetime($this->epoch, $this->user);
153+
} else {
154+
$foot = null;
155+
}
156+
} else {
157+
$foot = pht('No time specified.');
158+
}
159+
160+
if ($this->chronologicalKey) {
161+
$foot = phutil_tag(
162+
'a',
163+
array(
164+
'href' => '/feed/'.$this->chronologicalKey.'/',
165+
),
166+
$foot);
167+
}
168+
169+
$icon = null;
170+
if ($this->appIcon) {
171+
$icon = new PHUIIconView();
172+
$icon->setSpriteIcon($this->appIcon);
173+
$icon->setSpriteSheet(PHUIIconView::SPRITE_APPS);
174+
}
175+
176+
$ol_foot = null;
177+
if ($this->oneline) {
178+
$ol_foot = phutil_tag(
179+
'div',
180+
array(
181+
'class' => 'phui-feed-story-oneline-foot'
182+
),
183+
array(
184+
$icon,
185+
$foot));
186+
}
187+
137188
$action_list = array();
138189
$icons = null;
139190
foreach ($this->actions as $action) {
@@ -161,13 +212,10 @@ public function render() {
161212
array(
162213
$actor,
163214
nonempty($this->title, pht('Untitled Story')),
164-
$icons
215+
$icons,
216+
$ol_foot
165217
));
166218

167-
$body = null;
168-
$foot = null;
169-
$image_style = null;
170-
171219
if (!empty($this->tokenBar)) {
172220
$tokenview = phutil_tag(
173221
'div',
@@ -188,45 +236,26 @@ public function render() {
188236
$body_content);
189237
}
190238

191-
if ($this->epoch) {
192-
// TODO: This is really bad; when rendering through Conduit and via
193-
// renderText() we don't have a user.
194-
if ($this->user) {
195-
$foot = phabricator_datetime($this->epoch, $this->user);
196-
} else {
197-
$foot = null;
198-
}
239+
if ($this->oneline) {
240+
$foot = null;
199241
} else {
200-
$foot = pht('No time specified.');
201-
}
202-
203-
if ($this->chronologicalKey) {
204242
$foot = phutil_tag(
205-
'a',
243+
'div',
206244
array(
207-
'href' => '/feed/'.$this->chronologicalKey.'/',
245+
'class' => 'phui-feed-story-foot',
208246
),
209-
$foot);
247+
array(
248+
$icon,
249+
$foot));
210250
}
211251

212-
$icon = null;
213-
if ($this->appIcon) {
214-
$icon = new PHUIIconView();
215-
$icon->setSpriteIcon($this->appIcon);
216-
$icon->setSpriteSheet(PHUIIconView::SPRITE_APPS);
252+
$classes = array('phui-feed-story');
253+
if ($this->oneline) {
254+
$classes[] = 'phui-feed-story-oneline';
217255
}
218256

219-
$foot = phutil_tag(
220-
'div',
221-
array(
222-
'class' => 'phui-feed-story-foot',
223-
),
224-
array(
225-
$icon,
226-
$foot));
227-
228257
return id(new PHUIBoxView())
229-
->addClass('phui-feed-story')
258+
->addClass(implode(' ', $classes))
230259
->setShadow(true)
231260
->addMargin(PHUI::MARGIN_MEDIUM_BOTTOM)
232261
->appendChild(array($head, $body, $foot));

‎webroot/rsrc/css/phui/phui-feed-story.css

+26-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
.phui-feed-story {
66
background: 5px 2px no-repeat;
7-
min-height: 50px;
7+
min-height: 44px;
88
background-color: #fff;
99
}
1010

@@ -13,25 +13,25 @@
1313
height: 35px;
1414
background-size: 35px;
1515
float: left;
16-
margin-right: 10px;
16+
margin-right: 8px;
1717
}
1818

1919
.phui-feed-story-head {
20-
padding: 10px;
20+
padding: 8px;
2121
overflow: hidden;
2222
color: #333;
2323
}
2424

2525
.phui-feed-story-body {
26-
padding: 0 10px 10px;
26+
padding: 0 8px 8px;
2727
color: #444444;
2828
word-break: break-word;
2929
}
3030

3131
.phui-feed-story-foot {
3232
font-size: 11px;
3333
background: #f7f7f7;
34-
padding: 10px;
34+
padding: 8px;
3535
line-height: 14px;
3636
}
3737

@@ -40,7 +40,8 @@
4040
color: #777;
4141
}
4242

43-
.phui-feed-story-foot .phui-icon-view {
43+
.phui-feed-story-foot .phui-icon-view,
44+
.phui-feed-story-oneline-foot .phui-icon-view {
4445
float: left;
4546
display: inline-block;
4647
margin-right: 5px;
@@ -60,9 +61,9 @@
6061
}
6162

6263
.phui-feed-token-bar {
63-
margin-top: 10px;
64+
margin-top: 8px;
6465
border-top: 1px solid #e7e7e7;
65-
padding-top: 10px;
66+
padding-top: 8px;
6667
}
6768

6869
.phui-feed-token-bar .phui-icon-view {
@@ -83,3 +84,20 @@
8384
.phui-feed-story-action-list .phui-icon-view {
8485
display: block;
8586
}
87+
88+
.phui-feed-story-oneline .phui-feed-story-head {
89+
padding: 4px;
90+
}
91+
92+
.phui-feed-story-oneline .phui-feed-story-body {
93+
padding: 0;
94+
}
95+
96+
.phui-feed-story-oneline-foot,
97+
.phui-feed-story-oneline-foot a {
98+
font-size: 11px;
99+
color: #777;
100+
margin-top: 2px;
101+
line-height: 14px;
102+
}
103+

0 commit comments

Comments
 (0)
Failed to load comments.