1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 02:42:40 +01:00

Improve desktop and mobile layouts for new "CommitGridView"

Summary:
Ref T13552. The current layout doesn't work particularly well on desktops or devices.

We have some device/desktop table layout code, but it isn't generic. We also have property list layout code, but it isn't generic either.

Provide generic layout elements ("Fuel", from "Phabricator UI Layout" to "PHUIL"?) and narrowly specialize their display behavior. Then swap the ListItemView stuff to use it.

Test Plan:
Saw slightly better responsive behavior:

{F7637457}

Maniphest Tasks: T13552

Differential Revision: https://secure.phabricator.com/D21418
This commit is contained in:
epriestley 2020-07-12 14:07:17 -07:00
parent 8aec3f916b
commit 57f9450bcf
13 changed files with 392 additions and 20 deletions

View file

@ -121,6 +121,8 @@ return array(
'rsrc/css/font/font-awesome.css' => '3883938a', 'rsrc/css/font/font-awesome.css' => '3883938a',
'rsrc/css/font/font-lato.css' => '23631304', 'rsrc/css/font/font-lato.css' => '23631304',
'rsrc/css/font/phui-font-icon-base.css' => '303c9b87', 'rsrc/css/font/phui-font-icon-base.css' => '303c9b87',
'rsrc/css/fuel/fuel-grid.css' => 'd87031e7',
'rsrc/css/fuel/fuel-map.css' => 'd6e31510',
'rsrc/css/layout/phabricator-source-code-view.css' => '03d7ac28', 'rsrc/css/layout/phabricator-source-code-view.css' => '03d7ac28',
'rsrc/css/phui/button/phui-button-bar.css' => 'a4aa75c4', 'rsrc/css/phui/button/phui-button-bar.css' => 'a4aa75c4',
'rsrc/css/phui/button/phui-button-simple.css' => '1ff278aa', 'rsrc/css/phui/button/phui-button-simple.css' => '1ff278aa',
@ -574,6 +576,8 @@ return array(
'diviner-shared-css' => '4bd263b0', 'diviner-shared-css' => '4bd263b0',
'font-fontawesome' => '3883938a', 'font-fontawesome' => '3883938a',
'font-lato' => '23631304', 'font-lato' => '23631304',
'fuel-grid-css' => 'd87031e7',
'fuel-map-css' => 'd6e31510',
'global-drag-and-drop-css' => '1d2713a4', 'global-drag-and-drop-css' => '1d2713a4',
'harbormaster-css' => '8dfe16b2', 'harbormaster-css' => '8dfe16b2',
'herald-css' => '648d39e2', 'herald-css' => '648d39e2',

View file

@ -1305,6 +1305,13 @@ phutil_register_library_map(array(
'FlagDeleteConduitAPIMethod' => 'applications/flag/conduit/FlagDeleteConduitAPIMethod.php', 'FlagDeleteConduitAPIMethod' => 'applications/flag/conduit/FlagDeleteConduitAPIMethod.php',
'FlagEditConduitAPIMethod' => 'applications/flag/conduit/FlagEditConduitAPIMethod.php', 'FlagEditConduitAPIMethod' => 'applications/flag/conduit/FlagEditConduitAPIMethod.php',
'FlagQueryConduitAPIMethod' => 'applications/flag/conduit/FlagQueryConduitAPIMethod.php', 'FlagQueryConduitAPIMethod' => 'applications/flag/conduit/FlagQueryConduitAPIMethod.php',
'FuelComponentView' => 'view/fuel/FuelComponentView.php',
'FuelGridCellView' => 'view/fuel/FuelGridCellView.php',
'FuelGridRowView' => 'view/fuel/FuelGridRowView.php',
'FuelGridView' => 'view/fuel/FuelGridView.php',
'FuelMapItemView' => 'view/fuel/FuelMapItemView.php',
'FuelMapView' => 'view/fuel/FuelMapView.php',
'FuelView' => 'view/fuel/FuelView.php',
'FundBacker' => 'applications/fund/storage/FundBacker.php', 'FundBacker' => 'applications/fund/storage/FundBacker.php',
'FundBackerCart' => 'applications/fund/phortune/FundBackerCart.php', 'FundBackerCart' => 'applications/fund/phortune/FundBackerCart.php',
'FundBackerEditor' => 'applications/fund/editor/FundBackerEditor.php', 'FundBackerEditor' => 'applications/fund/editor/FundBackerEditor.php',
@ -7439,6 +7446,13 @@ phutil_register_library_map(array(
'FlagDeleteConduitAPIMethod' => 'FlagConduitAPIMethod', 'FlagDeleteConduitAPIMethod' => 'FlagConduitAPIMethod',
'FlagEditConduitAPIMethod' => 'FlagConduitAPIMethod', 'FlagEditConduitAPIMethod' => 'FlagConduitAPIMethod',
'FlagQueryConduitAPIMethod' => 'FlagConduitAPIMethod', 'FlagQueryConduitAPIMethod' => 'FlagConduitAPIMethod',
'FuelComponentView' => 'FuelView',
'FuelGridCellView' => 'FuelView',
'FuelGridRowView' => 'FuelView',
'FuelGridView' => 'FuelComponentView',
'FuelMapItemView' => 'AphrontView',
'FuelMapView' => 'FuelComponentView',
'FuelView' => 'AphrontView',
'FundBacker' => array( 'FundBacker' => array(
'FundDAO', 'FundDAO',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',

View file

@ -164,21 +164,23 @@ final class DiffusionCommitGraphView
$this->addAuditAction($item_view, $hash); $this->addAuditAction($item_view, $hash);
if ($show_auditors) { if ($show_auditors) {
$auditor_list = $item_view->newPropertyList(); $auditor_list = $item_view->newMapView();
if ($commit) { if ($commit) {
$auditors = $this->newAuditorList($commit, $handles); $auditors = $this->newAuditorList($commit, $handles);
$auditor_list->addProperty(pht('Auditors'), $auditors); $auditor_list->newItem()
->setName(pht('Auditors'))
->setValue($auditors);
} }
} }
$property_list = $item_view->newPropertyList(); $property_list = $item_view->newMapView();
if ($commit) { if ($commit) {
$author_view = $this->getCommitAuthorView($commit); $author_view = $this->getCommitAuthorView($commit);
if ($author_view) { if ($author_view) {
$property_list->addProperty( $property_list->newItem()
pht('Author'), ->setName(pht('Author'))
$this->getCommitAuthorView($commit)); ->setValue($author_view);
} }
} }
@ -189,9 +191,9 @@ final class DiffusionCommitGraphView
$revision = head($revisions); $revision = head($revisions);
$handle = $handles[$revision->getPHID()]; $handle = $handles[$revision->getPHID()];
$property_list->addProperty( $property_list->newItem()
pht('Revision'), ->setName(pht('Revision'))
$handle->renderLink()); ->setValue($handle->renderLink());
} }
} }
} }

View file

@ -0,0 +1,35 @@
<?php
abstract class FuelComponentView
extends FuelView {
private $classes = array();
final public function addClass($class) {
$this->classes[] = $class;
return $this;
}
private function getClasses() {
return $this->classes;
}
final protected function newComponentTag(
$tag,
array $attributes,
$content) {
$classes = $this->getClasses();
if (isset($attributes['class'])) {
$classes[] = $attributes['class'];
}
if ($classes) {
$classes = implode(' ', $classes);
$attributes['class'] = $classes;
}
return javelin_tag($tag, $attributes, $content);
}
}

View file

@ -0,0 +1,28 @@
<?php
final class FuelGridCellView
extends FuelView {
private $content;
public function setContent($content) {
$this->content = $content;
return $this;
}
public function getContent() {
return $this->content;
}
public function render() {
$content = $this->getContent();
return phutil_tag(
'div',
array(
'class' => 'fuel-grid-cell',
),
$content);
}
}

View file

@ -0,0 +1,32 @@
<?php
final class FuelGridRowView
extends FuelView {
private $cells = array();
public function newCell() {
$cell = new FuelGridCellView();
$this->cells[] = $cell;
return $cell;
}
public function render() {
$cells = $this->cells;
$classes = array();
$classes[] = 'fuel-grid-row';
$classes[] = sprintf(
'fuel-grid-cell-count-%d',
count($cells));
return phutil_tag(
'div',
array(
'class' => implode(' ', $classes),
),
$cells);
}
}

View file

@ -0,0 +1,41 @@
<?php
final class FuelGridView
extends FuelComponentView {
private $rows = array();
public function newRow() {
$row = new FuelGridRowView();
$this->rows[] = $row;
return $row;
}
public function render() {
require_celerity_resource('fuel-grid-css');
$rows = $this->rows;
$body = phutil_tag(
'div',
array(
'class' => 'fuel-grid-body',
),
$rows);
$grid = phutil_tag(
'div',
array(
'class' => 'fuel-grid',
),
$body);
return $this->newComponentTag(
'div',
array(
'class' => 'fuel-grid-component',
),
$grid);
}
}

View file

@ -0,0 +1,54 @@
<?php
final class FuelMapItemView
extends AphrontView {
private $name;
private $value;
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function setValue($value) {
$this->value = $value;
return $this;
}
public function getValue() {
return $this->value;
}
public function render() {
$value = $this->getValue();
$view = array();
$view[] = phutil_tag(
'div',
array(
'class' => 'fuel-map-name',
),
$this->getName());
$view[] = phutil_tag(
'div',
array(
'class' => 'fuel-map-value',
),
$value);
return phutil_tag(
'div',
array(
'class' => 'fuel-map-pair',
),
$view);
}
}

View file

@ -0,0 +1,45 @@
<?php
final class FuelMapView
extends FuelComponentView {
private $items = array();
public function newItem() {
$item = new FuelMapItemView();
$this->items[] = $item;
return $item;
}
public function render() {
require_celerity_resource('fuel-map-css');
$items = $this->items;
if (!$items) {
return null;
}
$body = phutil_tag(
'div',
array(
'class' => 'fuel-map-items',
),
$items);
$map = phutil_tag(
'div',
array(
'class' => 'fuel-map',
),
$body);
return $this->newComponentTag(
'div',
array(
'class' => 'fuel-map-component',
),
$map);
}
}

View file

@ -0,0 +1,10 @@
<?php
abstract class FuelView
extends AphrontView {
final protected function canAppendChild() {
return false;
}
}

View file

@ -30,7 +30,7 @@ final class PHUIObjectItemView extends AphrontTagView {
private $coverImage; private $coverImage;
private $description; private $description;
private $clickable; private $clickable;
private $propertyLists = array(); private $mapViews = array();
private $selectableName; private $selectableName;
private $selectableValue; private $selectableValue;
@ -220,9 +220,10 @@ final class PHUIObjectItemView extends AphrontTagView {
return $action; return $action;
} }
public function newPropertyList() { public function newMapView() {
$list = new PHUIPropertyListView(); $list = id(new FuelMapView())
$this->propertyLists[] = $list; ->addClass('fuel-map-property-list');
$this->mapViews[] = $list;
return $list; return $list;
} }
@ -612,12 +613,18 @@ final class PHUIObjectItemView extends AphrontTagView {
''); '');
} }
$property_lists = null; $map_views = null;
if ($this->propertyLists) { if ($this->mapViews) {
$property_lists[] = phutil_tag( $grid = id(new FuelGridView())
'div', ->addClass('fuel-grid-property-list');
array(),
$this->propertyLists); $row = $grid->newRow();
foreach ($this->mapViews as $map_view) {
$row->newCell()
->setContent($map_view);
}
$map_views = $grid;
} }
$content = phutil_tag( $content = phutil_tag(
@ -628,7 +635,7 @@ final class PHUIObjectItemView extends AphrontTagView {
array( array(
$subhead, $subhead,
$attrs, $attrs,
$property_lists, $map_views,
$this->renderChildren(), $this->renderChildren(),
)); ));

View file

@ -0,0 +1,29 @@
/**
* @provides fuel-grid-css
*/
.device-desktop .fuel-grid {
display: table;
table-layout: fixed;
}
.device-desktop .fuel-grid-body {
display: table-row-group;
}
.device-desktop .fuel-grid-row {
display: table-row;
}
.device-desktop .fuel-grid-cell {
display: table-cell;
vertical-align: top;
}
.device-desktop .fuel-grid-cell-count-2 > .fuel-grid-cell {
width: 50%;
}
.fuel-grid-property-list > .fuel-grid {
width: 100%;
}

View file

@ -0,0 +1,71 @@
/**
* @provides fuel-map-css
*/
.device-desktop .fuel-map {
display: table;
table-layout: fixed;
}
.device-desktop .fuel-map-items {
display: table-row-group;
}
.device-desktop .fuel-map-pair {
display: table-row;
}
.device-desktop .fuel-map-name,
.device-desktop .fuel-map-value {
display: table-cell;
vertical-align: top;
}
.fuel-map-property-list {
margin: 4px;
}
.fuel-map-property-list > .fuel-map {
overflow: hidden;
width: 100%;
max-width: 100%;
}
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-name,
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-value {
padding: 2px 4px;
white-space: nowrap;
}
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-name {
color: {$bluetext};
}
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-value {
color: {$lightgreytext};
}
.device-desktop
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-name {
text-align: right;
min-width: 80px;
width: 80px;
}
.device-desktop
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-value {
text-overflow: ellipsis;
overflow: hidden;
}
.device
.fuel-map-property-list > .fuel-map > .fuel-map-items > .fuel-map-pair >
.fuel-map-value {
padding-left: 12px;
}