diff --git a/modules/atom-ide-ui/pkg/atom-ide-outline-view/lib/OutlineView.js b/modules/atom-ide-ui/pkg/atom-ide-outline-view/lib/OutlineView.js index aa4a57b4..ee7fea17 100644 --- a/modules/atom-ide-ui/pkg/atom-ide-outline-view/lib/OutlineView.js +++ b/modules/atom-ide-ui/pkg/atom-ide-outline-view/lib/OutlineView.js @@ -14,6 +14,7 @@ import type {OutlineForUi, OutlineTreeForUi} from './createOutlines'; import type {TextToken} from 'nuclide-commons/tokenized-text'; import type {TreeNode, NodePath} from 'nuclide-commons-ui/SelectableTree'; +import Atomicon from 'nuclide-commons-ui/Atomicon'; import HighlightedText from 'nuclide-commons-ui/HighlightedText'; import {arrayEqual} from 'nuclide-commons/collection'; import memoizeUntilChanged from 'nuclide-commons/memoizeUntilChanged'; @@ -410,12 +411,9 @@ function renderItem( searchResult: ?SearchResult, ): React.Element | string { const r = []; - const icon = - // flowlint-next-line sketchy-null-string:off - outline.icon || (outline.kind && OUTLINE_KIND_TO_ICON[outline.kind]); - if (icon != null) { - r.push(); + if (outline.kind != null) { + r.push(); // Note: icons here are fixed-width, so the text lines up. } @@ -485,24 +483,3 @@ function selectNodeFromPath( } return node; } - -const OUTLINE_KIND_TO_ICON = { - array: 'type-array', - boolean: 'type-boolean', - class: 'type-class', - constant: 'type-constant', - constructor: 'type-constructor', - enum: 'type-enum', - field: 'type-field', - file: 'type-file', - function: 'type-function', - interface: 'type-interface', - method: 'type-method', - module: 'type-module', - namespace: 'type-namespace', - number: 'type-number', - package: 'type-package', - property: 'type-property', - string: 'type-string', - variable: 'type-variable', -}; diff --git a/modules/nuclide-commons-ui/Atomicon.js b/modules/nuclide-commons-ui/Atomicon.js new file mode 100644 index 00000000..a4f01093 --- /dev/null +++ b/modules/nuclide-commons-ui/Atomicon.js @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow + * @format + */ + +import * as React from 'react'; +import {capitalize} from 'nuclide-commons/string'; +import classnames from 'classnames'; + +const TYPE_TO_CLASSNAME_SUFFIX = { + array: 'type-array', + boolean: 'type-boolean', + class: 'type-class', + constant: 'type-constant', + constructor: 'type-constructor', + enum: 'type-enum', + field: 'type-field', + file: 'type-file', + function: 'type-function', + interface: 'type-interface', + method: 'type-method', + module: 'type-module', + namespace: 'type-namespace', + number: 'type-number', + package: 'type-package', + property: 'type-property', + string: 'type-string', + variable: 'type-variable', +}; + +type AtomiconName = $Keys; + +export default function Atomicon({type}: {type: AtomiconName}) { + const displayName = capitalize(type); + return ( + + ); +}