Skip to content

Commit 25a5bf0

Browse files
committed
Added a search box to the nav header for the mobile view.
1 parent 787df66 commit 25a5bf0

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

source/myscript.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
$(document).ready(function(){
22

33
$('header .links__icon').on('click', function (){
4-
$(this).next().slideToggle();
4+
$("header .header__searchbar").hide();
5+
$("header .header__links").slideToggle();
6+
});
7+
8+
$('header .search__icon').on('click', function (){
9+
$("header .header__links").hide();
10+
$("header .header__searchbar").slideToggle(400, function() {
11+
if($(this).is(':visible')) {
12+
$(this).find("input[type=text]").focus();
13+
}
14+
});
515
});
616

717
if($('.wy-menu-vertical li.current>a').length){

source/templates/header.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<header>
22
<div class="header__container">
3+
<div class="search__icon">
4+
<i class="fa fa-search"></i>
5+
</div>
36
<a href="http://docs.mattermost.com/" class="header__logo">
47
<img width="176" src="https://about.mattermost.com/wp-content/uploads/2016/01/logo.png">
58
</a>
@@ -14,5 +17,12 @@
1417
<li><a href="https://about.mattermost.com/contact/">Contact</a></li>
1518
<li><a href="https://www.mattermost.org/download/">Download</a></li>
1619
</ul>
20+
<div class="header__searchbar">
21+
<form id="rtd-search-form" class="wy-form" action="{{ pathto('search') }}" method="get">
22+
<input type="text" name="q" placeholder="Search by keyword" autofocus />
23+
<input type="hidden" name="check_keywords" value="yes" />
24+
<input type="hidden" name="area" value="default" />
25+
</form>
26+
</div>
1727
</div>
1828
</header>

source/theme.css

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,15 @@ header .links__icon {
201201
position: relative;
202202
}
203203

204+
header .search__icon {
205+
cursor: pointer;
206+
display: none;
207+
float: left;
208+
font-size: 20px;
209+
padding: 0 20px;
210+
position: relative;
211+
}
212+
204213
.wy-nav-top {
205214
background: #F5F5F5;
206215
padding: 0 10px;
@@ -270,13 +279,23 @@ header .header__links li a {
270279
border-top: 3px solid transparent;
271280
}
272281

282+
header .header__searchbar {
283+
display: none;
284+
float: left;
285+
padding: 0 5px 0 0;
286+
}
287+
273288
@media (max-width: 768px){
289+
<<<<<<< HEAD
274290
header .links__icon {
275291
display: block;
276292
}
277293
.wy-nav-top {
278294
display: none;
279295
}
296+
=======
297+
298+
>>>>>>> c8fd417... Added a search box to the nav header for the mobile view.
280299
.wy-side-nav-search {
281300
position: relative;
282301
}
@@ -290,9 +309,41 @@ header .header__links li a {
290309
.wy-nav-content-wrap.shift {
291310
top: 70px;
292311
}
312+
header .header__container {
313+
text-align:center;
314+
}
315+
header .links__icon {
316+
display: block;
317+
}
318+
header .search__icon {
319+
display: block;
320+
}
321+
header .header__logo {
322+
position: relative;
323+
margin-left: auto;
324+
margin-right: auto;
325+
float:none;
326+
}
293327
header .header__logo img {
294328
width: 176px;
295329
}
330+
header .header__searchbar {
331+
border-bottom: 1px solid #ccc;
332+
display: none;
333+
background: #fff;
334+
line-height: 40px;
335+
padding: 0 15px 5px;
336+
width: 100%;
337+
}
338+
header .header__searchbar input[type="text"] {
339+
width: 100%;
340+
border-radius: 50px;
341+
border: 1px solid #ddd;
342+
padding: 6px 12px;
343+
}
344+
header .header__searchbar input:focus {
345+
outline: none;
346+
}
296347
header .header__links {
297348
border-bottom: 1px solid #ccc;
298349
display: none;

0 commit comments

Comments
 (0)