mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-30 00:18:21 +01:00
663612fdb4
Summary: Adds a basic div box that takes some styles. Not sure this is the best approach for the spacing, but overall hoping people can spend less time in CSS and just use this class. Test Plan: UIExamples Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin, AnhNhan Differential Revision: https://secure.phabricator.com/D5723
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class PhabricatorUIExampleRenderController extends PhabricatorController {
|
|
|
|
private $class;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->class = idx($data, 'class');
|
|
}
|
|
|
|
public function processRequest() {
|
|
|
|
$classes = id(new PhutilSymbolLoader())
|
|
->setAncestorClass('PhabricatorUIExample')
|
|
->setConcreteOnly(true)
|
|
->selectAndLoadSymbols();
|
|
$classes = ipull($classes, 'name', 'name');
|
|
|
|
foreach ($classes as $class => $ignored) {
|
|
$classes[$class] = newv($class, array());
|
|
}
|
|
|
|
$classes = msort($classes, 'getName');
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
|
|
|
|
foreach ($classes as $class => $obj) {
|
|
$name = $obj->getName();
|
|
$nav->addFilter($class, $name);
|
|
}
|
|
|
|
$selected = $nav->selectFilter($this->class, head_key($classes));
|
|
|
|
$example = $classes[$selected];
|
|
$example->setRequest($this->getRequest());
|
|
|
|
$result = $example->renderExample();
|
|
if ($result instanceof AphrontResponse) {
|
|
// This allows examples to generate dialogs, etc., for demonstration.
|
|
return $result;
|
|
}
|
|
|
|
require_celerity_resource('phabricator-ui-example-css');
|
|
|
|
$nav->appendChild(hsprintf(
|
|
'<div class="phabricator-ui-example-header">'.
|
|
'<h1 class="phabricator-ui-example-name">%s (%s)</h1>'.
|
|
'<p class="phabricator-ui-example-description">%s</p>'.
|
|
'</div>',
|
|
$example->getName(),
|
|
get_class($example),
|
|
$example->getDescription()));
|
|
|
|
$nav->appendChild($result);
|
|
|
|
return $this->buildApplicationPage(
|
|
$nav,
|
|
array(
|
|
'title' => 'UI Example',
|
|
'device' => true,
|
|
'dust' => true,
|
|
));
|
|
}
|
|
|
|
}
|