Skip to content

Commit bb7e808

Browse files
committed
ヘッダーに検索機能を再追加
1 parent 5f030c0 commit bb7e808

File tree

5 files changed

+82
-26
lines changed

5 files changed

+82
-26
lines changed

app/assets/stylesheets/custom.scss

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ img.emoji {
7070
border-radius: 0px;
7171
}
7272

73-
/* DocSearch by Algolia */
74-
.search {
75-
padding-top: 17px;
76-
padding-left: 15px;
77-
padding-right: 20px;
78-
padding-bottom: 10px;
79-
}
80-
8173
#searchbox {
8274
padding-left: 5px;
8375
font-size: 90%;

app/assets/stylesheets/extension/header.scss

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "color";
2+
13
body {
24
padding: 64px 0 0;
35
}
@@ -120,7 +122,7 @@ body {
120122
}
121123
}
122124

123-
@media only screen and (max-width:865px) {
125+
@media only screen and (max-width:900px) {
124126
.container-fluid {
125127
padding: 5px 10px;
126128
}
@@ -177,3 +179,57 @@ body {
177179
max-height: 540px;
178180
}
179181
}
182+
183+
/* DocSearch by Algolia */
184+
.search {
185+
padding-top: 17px;
186+
padding-left: 15px;
187+
padding-right: 20px;
188+
padding-bottom: 10px;
189+
position: absolute;
190+
right: 0;
191+
#searchbox {
192+
width: 0;
193+
transition: all .3s;
194+
padding: 4px 0;
195+
border: none;
196+
border-radius: 4px;
197+
}
198+
}
199+
.search-icon {
200+
width: 16px;
201+
border-radius: 0;
202+
}
203+
.collapse > .navbar-nav > li.search-li {
204+
position: static;
205+
&::before, &::after {
206+
display: none;
207+
}
208+
@media only screen and (max-width: 768px) {
209+
display: none;
210+
}
211+
}
212+
.search-label {
213+
margin: 0;
214+
padding: 15px 8px;
215+
color: #fff;
216+
font-size: 14px;
217+
line-height: 26px;
218+
cursor: pointer;
219+
}
220+
.search-checkbox {
221+
display: none;
222+
}
223+
.search-checkbox:checked + .search {
224+
#searchbox {
225+
width: 190px;
226+
transition: all .3s;
227+
padding: 4px;
228+
box-shadow: 0 0 6px 1px rgba(88, 88, 88, 41%);
229+
border: #fff solid 1px;
230+
&:focus{
231+
border: $main-blue solid 2px;
232+
outline: none;
233+
}
234+
}
235+
}

app/views/layouts/application.html.haml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
%meta{content: "#{meta_image(yield(:meta_image))}", property: "og:image"}/
2525
%meta{content: "image/png", property: "og:image:type"}/
2626
%meta{content: "CoderDojo Japan", property: "og:site_name"}/
27-
27+
2828
%meta{content: "summary_large_image", name: "twitter:card"}/
2929
%meta{content: "@CoderDojoJapan", name: "twitter:site"}/
3030
%meta{content: "@CoderDojoJapan", name: "twitter:creator"}/
@@ -68,9 +68,7 @@
6868
6969
7070
/ at the end of the HEAD
71-
/ TODO: Fix this later - https://github.com/coderdojo-japan/coderdojo.jp/issues/912
72-
/- if is_kata?
73-
/ %link{href: "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css", rel: "stylesheet"}
71+
%link{href: "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css", rel: "stylesheet"}
7472
7573
%body
7674
= render 'shared/header'
@@ -84,17 +82,16 @@
8482
:javascript
8583
twemoji.parse(document.body);
8684

87-
/ TODO: Fix this later - https://github.com/coderdojo-japan/coderdojo.jp/issues/912
88-
/- if is_kata?
89-
/ %script{:src => "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js",
90-
/ type: "text/javascript"}
91-
/ :javascript
92-
/ docsearch({
93-
/ apiKey: '315da3c406c3fa374a0696590f4821a3',
94-
/ indexName: 'coderdojo',
95-
/ inputSelector: '#searchbox',
96-
/ debug: false // Set debug to true if you want to inspect the dropdown
97-
/ });
85+
86+
%script{:src => "https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js", type: "text/javascript"}
87+
88+
:javascript
89+
docsearch({
90+
apiKey: '315da3c406c3fa374a0696590f4821a3',
91+
indexName: 'coderdojo',
92+
inputSelector: '#searchbox',
93+
debug: false // Set debug to true if you want to inspect the dropdown
94+
});
9895

9996
#fb-root
10097
:javascript

app/views/shared/_header.html.haml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
.navbar-header-logos
1111
= link_to image_tag('/img/header-logo.png', alt: 'CoderDojo logo'), '/', id: "header-logo"
1212
= link_to image_tag('/img/header-brand.png', alt: 'CoderDojo brand'), '/', id: "header-brand"
13-
.collapse#header-nav-toggle.navbar-collapse
13+
#bs-example-navbar-collapse-1.collapse#header-nav-toggle.navbar-collapse
1414
%ul.nav.navbar-nav.navbar-right
1515
%li= link_to '全国の道場', '/#dojos'
1616
%li= link_to '近日開催の道場', '/events'
@@ -27,5 +27,12 @@
2727
%li= link_to '立ち上げる', '/kata#startup'
2828
%li= link_to '支援', '/kata#support'
2929
%li= link_to 'FAQ', '/kata#faq'
30-
30+
/ DocSearch: https://github.com/algolia/docsearch-configs/blob/master/configs/coderdojo.json
31+
%li.search-li
32+
<label for="search" class="search-label"><img src="/img/search.svg" alt="検索" class="search-icon" /></label>
33+
= check_box_tag :search, "検索アイコン", false, class: 'search-checkbox'
34+
.search
35+
%input#searchbox{ :placeholder => "資料を検索", :type => "text" }
36+
#hits
37+
#pagination
3138
%li= link_to 'お問い合わせ', '/#contact'

public/img/search.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)