Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 724a6d2

Browse files
committed
add empty state
1 parent 7664bcb commit 724a6d2

File tree

2 files changed

+40
-28
lines changed

2 files changed

+40
-28
lines changed

src/client/app/modules/components/search-form.jsx

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -132,34 +132,35 @@ export class SearchForm extends React.Component {
132132
<input className="FormInput" type="text" value={location} onChange={this.handleLocationChange} placeholder="File Path (absolute)"/>
133133
</div>
134134
<div className="ResultsContainer">
135-
<div className="Summary">
136-
{
137-
(searchString === '' && location === '') ?
138-
<span> Type in the searchbox to get started! </span> :
135+
{
136+
(searchString !== '' || location !== '') ?
137+
<div className="Summary">
139138
<span>
140139
Search results for string <code>{searchString === '' ? '' : `'${searchString}'`}</code> at <code>{ location === '' ? 'any path' : `'${location}'`}</code>
141140
</span>
142-
}
143-
</div>
141+
</div> : null
142+
}
144143
<div className="Results" ref={(ref) => this.resultView = this.resultView || ref} >
145-
<ConnectedInfiniteScroll loadMore={() => this.loadMore(hashes)} hasMore={searchString || location}>
146-
{
147-
results.map((result, i) => {
148-
var {file, lno, above_lines, the_line, below_lines} = result;
149-
var code = above_lines.concat(the_line, below_lines);
150-
return (
151-
<ConnectedCodeView
152-
key={i}
153-
filePath={file}
154-
content={code.join('\n')+'\n'}
155-
length={code.length}
156-
start={lno-3}
157-
lno={lno}
158-
/>
159-
);
160-
})
161-
}
162-
</ConnectedInfiniteScroll>
144+
{ (results.length > 0) ?
145+
<ConnectedInfiniteScroll loadMore={() => this.loadMore(hashes)} hasMore={searchString || location}>
146+
{
147+
results.map((result, i) => {
148+
var {file, lno, above_lines, the_line, below_lines} = result;
149+
var code = above_lines.concat(the_line, below_lines);
150+
return (
151+
<ConnectedCodeView
152+
key={i}
153+
filePath={file}
154+
content={code.join('\n')+'\n'}
155+
length={code.length}
156+
start={lno-3}
157+
lno={lno}
158+
/>
159+
);
160+
})
161+
}
162+
</ConnectedInfiniteScroll> : <div className="Empty">Type something to get started!</div>
163+
}
163164
</div>
164165
</div>
165166
<div className="Footer">

src/client/sass/partials/_search.scss

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@
2727
}
2828

2929
.Slogan {
30-
margin-top: 4px;
30+
margin-top: 9px;
3131
margin-right: 16px;
32-
font-family: 'Lato', 'Open Sans';
33-
font-weight: 800;
34-
font-size: 24px;
32+
font-family: 'Inconsolata', monospace;
33+
font-size: 18px;
3534
}
3635

3736
.FormContainer {
@@ -95,6 +94,7 @@
9594
.Results {
9695
flex: 1;
9796
overflow: scroll;
97+
height: 100%;
9898
}
9999
}
100100

@@ -120,6 +120,17 @@
120120
}
121121
}
122122

123+
.Empty {
124+
height: 100%;
125+
padding-bottom: 50px;
126+
box-sizing: border-box;
127+
display: flex;
128+
justify-content: center;
129+
align-items: center;
130+
font-size: 34px;
131+
color: #3a424c;
132+
}
133+
123134
.Footer {
124135
display: flex;
125136
justify-content: space-between;

0 commit comments

Comments
 (0)