11import React from 'react' ;
22import HomeIcon from 'react-icons/lib/io/home' ;
3+ import SearchIcon from 'react-icons/lib/go/search' ;
34import { Highlight } from 'react-instantsearch/dom' ;
45import styled from 'styled-components' ;
56
67import Select from 'app/components/Select' ;
8+ import UserWithAvatar from 'app/components/user/UserWithAvatar' ;
79import Tooltip from 'common/components/Tooltip' ;
810
911import GitHubLogo from '../Git/modals/GitHubLogo' ;
@@ -12,12 +14,18 @@ import formatDownloads from './formatDownloads';
1214const Container = styled . div `
1315 display: flex;
1416 background: ${ props =>
15- props . highlighted ? props . theme . background3 : props . theme . background2 } ;
17+ props . highlighted
18+ ? props . theme . background2 . darken ( 0.3 )
19+ : props . theme . background2 } ;
1620 color: ${ props => props . theme . white } ;
1721 cursor: pointer;
1822 &:not(:last-child) {
1923 border-bottom: 1px solid ${ props => props . theme . background3 } ;
2024 }
25+
26+ &:hover {
27+ background-color: ${ props => props . theme . background2 . darken ( 0.2 ) } ;
28+ }
2129` ;
2230
2331const Left = styled . div `
@@ -36,16 +44,22 @@ const Row = styled.div`
3644 }
3745` ;
3846
47+ const Description = Row . extend `
48+ font-size: 0.875rem;
49+ color: rgba(255, 255, 255, 0.6);
50+ ` ;
51+
3952const Downloads = styled . span `
4053 color: ${ props => props . theme . gray } ;
54+ font-weight: 500;
4155 font-size: 12px;
4256` ;
4357
4458const License = styled . span `
45- border: 1px solid ${ props => props . theme . gray } ;
59+ border: 1px solid rgba(255, 255, 255, 0.4) ;
4660 border-radius: 3px;
4761 padding: 1px 3px;
48- color: ${ props => props . theme . gray } ;
62+ color: rgba(255, 255, 255, 0.6) ;
4963 font-size: 12px;
5064` ;
5165
@@ -54,6 +68,15 @@ const IconLink = styled.a`
5468 color: rgba(255, 255, 255, 0.8);
5569` ;
5670
71+ const StyledSelect = Select . extend `
72+ font-size: 0.875rem;
73+ ` ;
74+
75+ const StyledUserWithAvatar = styled ( UserWithAvatar ) `
76+ font-size: 0.75rem;
77+ font-weight: 500;
78+ ` ;
79+
5780type Props = {
5881 highlighted : boolean ,
5982 hit : Object ,
@@ -77,6 +100,12 @@ export default class DependencyHit extends React.PureComponent {
77100 return `https://github.com/${ repo . user } /${ repo . project } ` ;
78101 }
79102
103+ makeSearchUrl ( hitName : string ) {
104+ return `https://codesandbox.io/search?refinementList%5Bnpm_dependencies.dependency%5D%5B0%5D=${
105+ hitName
106+ } &page=1`;
107+ }
108+
80109 stopPropagation ( e ) {
81110 e . stopPropagation ( ) ;
82111 }
@@ -91,6 +120,7 @@ export default class DependencyHit extends React.PureComponent {
91120 const { highlighted, hit, onClick } = this . props ;
92121 const versions = Object . keys ( hit . versions ) ;
93122 versions . reverse ( ) ;
123+
94124 return (
95125 < Container highlighted = { highlighted } onClick = { onClick } >
96126 < Left >
@@ -99,7 +129,13 @@ export default class DependencyHit extends React.PureComponent {
99129 < Downloads > { formatDownloads ( hit . downloadsLast30Days ) } </ Downloads >
100130 { hit . license && < License > { hit . license } </ License > }
101131 </ Row >
102- < Row > { hit . description } </ Row >
132+ < Description > { hit . description } </ Description >
133+ < Row >
134+ < StyledUserWithAvatar
135+ username = { hit . owner . name }
136+ avatarUrl = { hit . owner . avatar }
137+ />
138+ </ Row >
103139 </ Left >
104140 < Right >
105141 < Row >
@@ -127,13 +163,23 @@ export default class DependencyHit extends React.PureComponent {
127163 </ IconLink >
128164 </ Tooltip >
129165 ) }
130- < Select
166+ < Tooltip title = { `Search for sandboxes using ${ hit . name } ` } >
167+ < IconLink
168+ href = { this . makeSearchUrl ( hit . name ) }
169+ target = "_blank"
170+ rel = "noreferrer noopener"
171+ onClick = { this . stopPropagation }
172+ >
173+ < SearchIcon />
174+ </ IconLink >
175+ </ Tooltip >
176+ < StyledSelect
131177 onClick = { this . stopPropagation }
132178 onChange = { this . handleVersionChange }
133179 value = { this . state . selectedVersion }
134180 >
135181 { versions . map ( v => < option key = { v } > { v } </ option > ) }
136- </ Select >
182+ </ StyledSelect >
137183 </ Row >
138184 </ Right >
139185 </ Container >
0 commit comments