1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 10:52:41 +01:00
phorge-phorge/src/applications/uiexample/examples/PhabricatorHovercardExample.php
Anh Nhan Nguyen 5bd54e35bc First pass at hovercard design
Summary:
Refs T1048 - I'm pretty happy and happy to tell you

Savepoint CR

Everything's dummy right now. If you are testing locally, don't forget to edit the PHIDs. Or populate your own handles. Doesn't really matter.

I'm mainly sending it in for the CSS, not the messy PHP code. Ignore the `margin: auto`, that's just for looking nice.

Test Plan: UI Example » Hovercard

Reviewers: epriestley, chad

CC: aran, Korvin

Maniphest Tasks: T1048

Differential Revision: https://secure.phabricator.com/D5519
2013-04-02 09:16:23 -07:00

77 lines
2.5 KiB
PHP

<?php
final class PhabricatorHovercardExample extends PhabricatorUIExample {
public function getName() {
return 'Hovercard';
}
public function getDescription() {
return hsprintf('Use <tt>PhabricatorHovercardView</tt> to render '.
'hovercards. Aren\'t I genius?');
}
public function renderExample() {
$request = $this->getRequest();
$user = $request->getUser();
$elements = array();
$diff_handle = $this->createBasicDummyHandle(
"Introduce cooler Differential Revisions",
PhabricatorPHIDConstants::PHID_TYPE_DREV);
$panel = $this->createPanel("Differential Hovercard");
$panel->appendChild(id(new PhabricatorHovercardView())
->setObjectHandle($diff_handle)
->addField(pht('Author'), $user->getUsername())
->addField(pht('Updated'), phabricator_datetime(time(), $user))
->addAction(pht('Subscribe'), '/dev/random')
->setUser($user));
$elements[] = $panel;
$task_handle = $this->createBasicDummyHandle(
"Improve Mobile Experience for Phabricator",
PhabricatorPHIDConstants::PHID_TYPE_TASK);
$tag = id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_STATE)
->setBackgroundColor(PhabricatorTagView::COLOR_BLACK)
->setName('Abandoned (Really)');
$panel = $this->createPanel("Maniphest Hovercard");
$panel->appendChild(id(new PhabricatorHovercardView())
->setObjectHandle($task_handle)
->setUser($user)
->addField(pht('Assigned to'), $user->getUsername())
->addField(pht('Dependent Tasks'), 'T123, T124, T125')
->addAction(pht('Subscribe'), '/dev/random')
->addAction(pht('Create Subtask'), '/dev/urandom')
->addTag($tag));
$elements[] = $panel;
$user_handle = $this->createBasicDummyHandle(
'gwashington',
PhabricatorPHIDConstants::PHID_TYPE_USER,
'George Washington');
$user_handle->setImageURI(
celerity_get_resource_uri('/rsrc/image/people/washington.png'));
$panel = $this->createPanel("Whatevery Hovercard");
$panel->appendChild(id(new PhabricatorHovercardView())
->setObjectHandle($user_handle)
->addField(pht('Status'), 'Available')
->addField(pht('Member since'), '30. February 1750')
->addAction(pht('Start a Conpherence'), '/dev/null')
->setUser($user));
$elements[] = $panel;
return phutil_implode_html("", $elements);
}
private function createPanel($header) {
$panel = new AphrontPanelView();
$panel->setNoBackground();
$panel->setHeader($header);
return $panel;
}
}