From 66afb92fb3b0b5c62fb8064e22f2116a250f9b68 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Wed, 1 Jul 2015 11:33:31 -0700 Subject: [PATCH] [Redesign] Add color to diff Table of Contents Summary: Ref T8099. I think these colors make sense, but if any seem wrong, lmk. Colors the type of file change. Test Plan: Test a few diffs locally, read carefully, ask epriestley. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T8099 Differential Revision: https://secure.phabricator.com/D13502 --- .../constants/DifferentialChangeType.php | 16 ++++++++++++++++ .../view/DifferentialDiffTableOfContentsView.php | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/applications/differential/constants/DifferentialChangeType.php b/src/applications/differential/constants/DifferentialChangeType.php index 6f8f6ad364..fb0fd58883 100644 --- a/src/applications/differential/constants/DifferentialChangeType.php +++ b/src/applications/differential/constants/DifferentialChangeType.php @@ -38,6 +38,22 @@ final class DifferentialChangeType extends Phobject { return idx($types, coalesce($type, '?'), '~'); } + public static function getSummaryColorForChangeType($type) { + static $types = array( + self::TYPE_ADD => 'green', + self::TYPE_CHANGE => 'black', + self::TYPE_DELETE => 'red', + self::TYPE_MOVE_AWAY => 'orange', + self::TYPE_COPY_AWAY => 'black', + self::TYPE_MOVE_HERE => 'green', + self::TYPE_COPY_HERE => 'green', + self::TYPE_MULTICOPY => 'orange', + self::TYPE_MESSAGE => 'black', + self::TYPE_CHILD => 'black', + ); + return idx($types, coalesce($type, '?'), 'black'); + } + public static function getShortNameForFileType($type) { static $names = array( self::FILE_TEXT => null, diff --git a/src/applications/differential/view/DifferentialDiffTableOfContentsView.php b/src/applications/differential/view/DifferentialDiffTableOfContentsView.php index 65783a5bb2..f20c7ce19b 100644 --- a/src/applications/differential/view/DifferentialDiffTableOfContentsView.php +++ b/src/applications/differential/view/DifferentialDiffTableOfContentsView.php @@ -56,6 +56,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView { $this->requireResource('differential-core-view-css'); $this->requireResource('differential-table-of-contents-css'); + $this->requireResource('phui-text-css'); $rows = array(); @@ -130,6 +131,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView { $char = DifferentialChangeType::getSummaryCharacterForChangeType($type); $chartitle = DifferentialChangeType::getFullNameForChangeType($type); $desc = DifferentialChangeType::getShortNameForFileType($ftype); + $color = DifferentialChangeType::getSummaryColorForChangeType($type); if ($desc) { $desc = '('.$desc.')'; } @@ -170,6 +172,8 @@ final class DifferentialDiffTableOfContentsView extends AphrontView { $changeset->getAbsoluteRepositoryPath($this->repository, $this->diff); } + $char = phutil_tag('span', array('class' => 'phui-text-'.$color), $char); + $rows[] = array( $char, $pchar,