Differential D17456 Diff 41982 src/applications/files/controller/PhabricatorFileIconSetSelectController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileIconSetSelectController.php
Show All 25 Lines | if ($request->isFormPost()) { | ||||
} | } | ||||
} | } | ||||
require_celerity_resource('phui-icon-set-selector-css'); | require_celerity_resource('phui-icon-set-selector-css'); | ||||
Javelin::initBehavior('phabricator-tooltips'); | Javelin::initBehavior('phabricator-tooltips'); | ||||
$ii = 0; | $ii = 0; | ||||
$buttons = array(); | $buttons = array(); | ||||
$breakpoint = ceil(sqrt(count($set->getIcons()))); | |||||
epriestley: This should work correctly for all cases we have now, but I think it does some slightly odd… | |||||
foreach ($set->getIcons() as $icon) { | foreach ($set->getIcons() as $icon) { | ||||
$label = $icon->getLabel(); | $label = $icon->getLabel(); | ||||
$view = id(new PHUIIconView()) | $view = id(new PHUIIconView()) | ||||
->setIcon($icon->getIcon()); | ->setIcon($icon->getIcon()); | ||||
$classes = array(); | $classes = array(); | ||||
$classes[] = 'icon-button'; | $classes[] = 'icon-button'; | ||||
Show All 28 Lines | foreach ($set->getIcons() as $icon) { | ||||
'tip' => $label, | 'tip' => $label, | ||||
), | ), | ||||
), | ), | ||||
array( | array( | ||||
$aural, | $aural, | ||||
$view, | $view, | ||||
)); | )); | ||||
if ((++$ii % 4) == 0) { | if ((++$ii % $breakpoint) == 0) { | ||||
$buttons[] = phutil_tag('br'); | $buttons[] = phutil_tag('br'); | ||||
} | } | ||||
} | } | ||||
$buttons = phutil_tag( | $buttons = phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'icon-grid', | 'class' => 'icon-grid', | ||||
Show All 12 Lines |
This should work correctly for all cases we have now, but I think it does some slightly odd stuff for numbers like 24, which I believe it will lay out as:
If we eventually let users customize this or hit weird cases, we could start with this breakpoint and then search nearby values for one that divides the count evenly, so this would end up as 4x6.