simplify autocomplete ux

This commit is contained in:
Sean Yesmunt 2018-06-19 13:59:55 -04:00 committed by seanyesmunt
parent 941672bd81
commit 6be2388620
3 changed files with 13 additions and 7 deletions

View file

@ -60,7 +60,7 @@ class IconComponent extends React.PureComponent<Props> {
}
const inner = <Icon size={size} className="icon" color={color} />;
return tooltip ? (
return tooltip && tooltipText ? (
<Tooltip icon body={tooltipText} direction={tooltip}>
{inner}
</Tooltip>

View file

@ -1,7 +1,7 @@
// @flow
import React from 'react';
import classnames from 'classnames';
import { normalizeURI } from 'lbry-redux';
import { normalizeURI, SEARCH_TYPES } from 'lbry-redux';
import Icon from 'component/common/icon';
import { parseQueryParams } from 'util/query_params';
import * as icons from 'constants/icons';
@ -29,7 +29,7 @@ class WunderBar extends React.PureComponent<Props> {
getSuggestionIcon = (type: string) => {
switch (type) {
case 'file':
return icons.COMPASS;
return icons.LOCAL;
case 'channel':
return icons.AT_SIGN;
default:
@ -109,7 +109,7 @@ class WunderBar extends React.PureComponent<Props> {
placeholder="Enter LBRY URL here or search for videos, music, games and more"
/>
)}
renderItem={({ value, type, shorthand }, isHighlighted) => (
renderItem={({ value, type }, isHighlighted) => (
<div
key={value}
className={classnames('wunderbar__suggestion', {
@ -117,11 +117,13 @@ class WunderBar extends React.PureComponent<Props> {
})}
>
<Icon icon={this.getSuggestionIcon(type)} />
<span className="wunderbar__suggestion-label">{shorthand || value}</span>
{(true || isHighlighted) && (
<span className="wunderbar__suggestion-label">{value}</span>
{isHighlighted && (
<span className="wunderbar__suggestion-label--action">
{'- '}
{type === 'search' ? 'Search' : value}
{type === SEARCH_TYPES.SEARCH && __('Search')}
{type === SEARCH_TYPES.CHANNEL && __('View channel')}
{type === SEARCH_TYPES.FILE && __('View file')}
</span>
)}
</div>

View file

@ -53,6 +53,7 @@
display: flex;
flex-direction: row;
justify-items: flex-start;
align-items: center;
font-family: 'metropolis-medium';
&:not(:first-of-type) {
@ -74,6 +75,9 @@
.wunderbar__suggestion-label--action {
margin-left: $spacing-vertical * 1/3;
white-space: nowrap;
font-family: 'metropolis-medium';
font-size: 12px;
line-height: 0.1; // to vertically align because the font size is smaller
}
.wunderbar__active-suggestion {