소스 검색

hint support for typeahead

David Kaltschmidt 7 년 전
부모
커밋
73ddf2c3ed
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 5 2
      public/app/containers/Explore/Typeahead.tsx
  2. 5 0
      public/sass/components/_slate_editor.scss

+ 5 - 2
public/app/containers/Explore/Typeahead.tsx

@@ -23,12 +23,13 @@ class TypeaheadItem extends React.PureComponent<any, any> {
   };
 
   render() {
-    const { isSelected, label, onClickItem } = this.props;
+    const { hint, isSelected, label, onClickItem } = this.props;
     const className = isSelected ? 'typeahead-item typeahead-item__selected' : 'typeahead-item';
     const onClick = () => onClickItem(label);
     return (
       <li ref={this.getRef} className={className} onClick={onClick}>
         {label}
+        {hint && isSelected ? <div className="typeahead-item-hint">{hint}</div> : null}
       </li>
     );
   }
@@ -43,12 +44,14 @@ class TypeaheadGroup extends React.PureComponent<any, any> {
         <ul className="typeahead-group__list">
           {items.map(item => {
             const text = typeof item === 'object' ? item.text : item;
+            const label = typeof item === 'object' ? item.display || item.text : item;
             return (
               <TypeaheadItem
                 key={text}
                 onClickItem={onClickItem}
                 isSelected={selected.indexOf(text) > -1}
-                label={text}
+                hint={item.hint}
+                label={label}
               />
             );
           })}

+ 5 - 0
public/sass/components/_slate_editor.scss

@@ -67,6 +67,11 @@
   .typeahead-item__selected {
     background-color: $typeahead-selected-bg;
     color: $typeahead-selected-color;
+
+    .typeahead-item-hint {
+      font-size: $font-size-xs;
+      color: $text-color;
+    }
   }
 }