Skip to content

Commit 6bc3041

Browse files
committed
Add search powered by Algolia
1 parent e553a58 commit 6bc3041

File tree

7 files changed

+84
-6
lines changed

7 files changed

+84
-6
lines changed

sass/custom/_paulus.scss

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
@charset "UTF-8";
22

3+
$primary-color: #049cdb;
4+
5+
.site-header {
6+
position: relative;
7+
}
8+
9+
.search-container {
10+
position: absolute;
11+
top: 0;
12+
left: 0;
13+
right: 0;
14+
bottom: 0;
15+
background-color: white;
16+
padding-top: 19px;
17+
padding-right: 15%;
18+
19+
.search {
20+
max-width: 500px;
21+
width: 100%;
22+
border-bottom: 2px solid $primary-color;
23+
float: right;
24+
25+
.algolia-autocomplete {
26+
width: calc(100% - 58px);
27+
margin: 0 10px;
28+
}
29+
30+
input {
31+
border: 0;
32+
width: 100%;
33+
}
34+
}
35+
}
36+
37+
@media only screen and (max-width: $menu-collapse) {
38+
.search-container {
39+
z-index: 20;
40+
padding-right: 5px;
41+
padding-left: 5px;
42+
}
43+
}
44+
345
.hero {
446
background-color: #038FC7;
547
padding-bottom: 0;

sass/oscailte/base/_navigation.scss

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,23 @@ header .grid {
8181
font-weight: normal;
8282
font-size: 14px;
8383
line-height: 1;
84+
85+
&.show-search {
86+
padding-left: 0;
87+
padding-right: 0;
88+
}
8489
}
8590

8691
.menu > li > a:hover, .menu > li > a:focus{
8792
background: $site-background;
8893
box-shadow: inset 0px 5px $navigation-color;
8994
color: $navigation-color;
90-
padding: 40px 12px 24px;
95+
padding-top: 40px;
96+
padding-bottom: 24px;
9197
}
9298

93-
.toggle{
94-
z-index: 20;
99+
.toggle{
100+
z-index: 20;
95101
}
96102

97103
@media only screen and (max-width: $menu-collapse){

source/_includes/custom/header.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@
99
<nav>
1010
{% include site/navigation.html %}
1111
</nav>
12+
13+
<div class='search-container' style='display: none'>
14+
<div class='search'>
15+
<i class="icon-search"></i>
16+
<input id='search' placeholder='Search the docs…'>
17+
<a href='#' class='close'><i class="icon-remove-sign"></i></a>
18+
</div>
19+
</div>
1220
</div>

source/_includes/custom/navigation.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
<li><a href="/developers/">Developers</a></li>
1717
<li><a href="/blog/">Blog</a></li>
1818
<li><a href="/help/">Need help?</a></li>
19+
<li><a href='#' class='show-search'><i class="icon-search"></i></a></li>
1920
</ul>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" />
2+
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
3+
<script type="text/javascript">
4+
docsearch({
5+
apiKey: 'ae96d94b201c5444c8a443093edf3efb',
6+
indexName: 'home-assistant',
7+
inputSelector: '#search',
8+
debug: false // Set debug to true if you want to inspect the dropdown
9+
});
10+
document.querySelector('.search .close').addEventListener('click', function(ev) {
11+
ev.preventDefault();
12+
document.querySelector('.search-container').style.display = 'none';
13+
});
14+
document.querySelector('.show-search').addEventListener('click', function(ev) {
15+
ev.preventDefault();
16+
document.querySelector('.search-container').style.display = 'block';
17+
document.getElementById('toggle').checked = false;
18+
document.querySelector('.search-container input').focus();
19+
});
20+
</script>

source/_includes/javascripts/scripts.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55

66
{% include javascripts/google_analytics.html %}
77
{% include javascripts/disqus.html %}
8+
{% include javascripts/algolia.html %}
89

910
{% if page.sidebar != false %}
1011
{% include javascripts/github.html %}
1112
{% include javascripts/delicious.html %}
12-
{% endif %}
13+
{% endif %}

source/_layouts/default.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<body {% if page.body_id %} id="{{ page.body_id }}"{% endif %}>
88

9-
<header>
9+
<header class='site-header'>
1010
{% include site/header.html %}
1111
</header>
1212

@@ -42,4 +42,4 @@
4242

4343
{% include javascripts/scripts.html %}
4444
</body>
45-
</html>
45+
</html>

0 commit comments

Comments
 (0)