File tree 8 files changed +125
-26
lines changed
8 files changed +125
-26
lines changed Original file line number Diff line number Diff line change @@ -246,25 +246,94 @@ $darkgrey: #202020;
246
246
}
247
247
248
248
/* Search box and results */
249
- form #search-form {
250
- margin : 1em 0 ;
251
249
252
- input {
250
+ form .search , #search-overlay {
251
+ input , button {
253
252
border : 2px solid $normalgreen ;
254
- margin : 4px 2px ;
253
+ margin : 4px 0 2px ;
255
254
padding : 10px 12px ;
256
255
border-radius : 5px ;
257
256
}
257
+
258
258
input [type = text ] {
259
259
border-collapse : collapse ;
260
- width : 300 px ;
260
+ width : 400 px ;
261
261
}
262
- input [type = submit ] {
262
+
263
+ button {
263
264
background-color : $lightgrey ;
264
265
color : black ;
265
266
cursor : pointer ;
266
267
}
267
268
}
269
+
270
+ form .search {
271
+ margin : 1em 0 ;
272
+ }
273
+
274
+ #show-search {
275
+ display : inline-block ;
276
+ background-color : $darkgrey ;
277
+ color : $lightgrey ;
278
+ border : none ;
279
+ height : 40px ;
280
+ padding : 0 1em ;
281
+ font-size : 1em ;
282
+ cursor : pointer ;
283
+ opacity : 0.8 ;
284
+ & :hover {
285
+ opacity : 1 ;
286
+ }
287
+ }
288
+
289
+ #search-overlay {
290
+ height : 100% ;
291
+ width : 100% ;
292
+ position : fixed ;
293
+ z-index : 2 ;
294
+ top : 0 ;
295
+ left : 0 ;
296
+ background-color : rgba (40 , 40 , 40 , 0.8 );
297
+ transition : opacity 0.5s ease-in-out ;
298
+
299
+ & .visible {
300
+ visibility : visible ;
301
+ opacity : 1 ;
302
+ }
303
+
304
+ & .hidden {
305
+ position : absolute ;
306
+ visibility : hidden ;
307
+ opacity : 0 ;
308
+ }
309
+
310
+ & .transitioning {
311
+ visibility : visible ;
312
+ }
313
+
314
+ #search-bar {
315
+ position : relative ;
316
+ top : 46% ;
317
+ width : 80% ;
318
+ text-align : center ;
319
+ margin : auto ;
320
+ }
321
+
322
+ #hide-search {
323
+ position : absolute ;
324
+ top : 20px ;
325
+ right : 20px ;
326
+ opacity : 0.8 ;
327
+ & :hover {
328
+ opacity : 1 ;
329
+ }
330
+ }
331
+
332
+ input , button {
333
+ font-size : 2em ;
334
+ }
335
+ }
336
+
268
337
ul #search-results {
269
338
// entry height
270
339
$eheight : 32px ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Adds a toggle-able search overlay
3
+ */
4
+ document . addEventListener ( "DOMContentLoaded" , function ( event ) {
5
+ // ignore on search page
6
+ if ( window . location . href . indexOf ( "/search/" ) === - 1 ) {
7
+ var overlay = document . getElementById ( 'search-overlay' )
8
+ var input = document . getElementById ( "search-input" )
9
+
10
+ function searchBox ( e ) {
11
+ if ( e . target . id === "show-search" ) {
12
+ overlay . className = "visible transitioning"
13
+ input . focus ( ) ;
14
+ } else {
15
+ overlay . className = "hidden transitioning"
16
+ }
17
+ }
18
+
19
+ document . getElementById ( 'show-search' ) . addEventListener ( 'click' , searchBox )
20
+ document . getElementById ( 'hide-search' ) . addEventListener ( 'click' , searchBox )
21
+ input . addEventListener ( 'keyup' , function ( e ) {
22
+ if ( e . keyCode == 27 ) searchBox ( e )
23
+ } )
24
+ overlay . addEventListener ( 'transitionend' , function ( ) {
25
+ overlay . classList . remove ( "transitioning" )
26
+ } )
27
+ }
28
+ } )
Original file line number Diff line number Diff line change 1
1
---
2
2
title: Search on this site
3
- menu_name: 🔍 Site search
4
- menu_weight: -1
5
3
---
6
- < form action ="/search/ " id ="search-form " class ="search " method ="get " >
7
- < input name ="q " type ="text " id ="search-input " placeholder ="enter search term... " autofocus required >
8
- < input type ="submit " value ="Search ">
9
- </ form >
4
+ < %= render '/searchform.*' %>
10
5
< h2 id ="search-heading "> </ h2 >
11
6
< ul id ="search-results "> </ ul >
12
7
< script src ="/js/vendor/lunr.min.js "> </ script >
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ html lang="en"
20
20
link rel =" stylesheet" href =" /css/easyrpg.css"
21
21
link rel =" stylesheet" href =" /css/rouge-github-dark.css"
22
22
script src =" /js/vendor/jquery-2.2.4.min.js"
23
+ script src =" /js/search.js"
23
24
body
24
25
# header
25
26
. maxwidth
Original file line number Diff line number Diff line change 4
4
< % navigation_for(@item).each do |index, target| %>
5
5
< li > < %= link_to_unless_current(target[:text], target[:link]) %> </ li >
6
6
< % end %>
7
+ < % if @item.identifier.components[0] != "search" %>
8
+ < li > < button title ="Search Site " id ="show-search "> 🔍</ button > </ li >
9
+ < % end %>
7
10
</ ul >
11
+ < % if @item.identifier.components[0] != "search" %>
12
+ < div id ="search-overlay " class ="hidden ">
13
+ < button id ="hide-search "> ×</ button >
14
+ < div id ="search-bar ">
15
+ < %= render '/searchform.*' %>
16
+ </ div >
17
+ </ div >
18
+ < % end %>
8
19
< % end %>
Original file line number Diff line number Diff line change
1
+ < form action ="/search/ " id ="search-form " class ="search " method ="get ">
2
+ < input name ="q " type ="search " id ="search-input " placeholder ="enter search term... " autofocus required >
3
+ < button type ="submit "> 🔍</ button >
4
+ </ form >
Original file line number Diff line number Diff line change 1
1
2
- # allow partial layouts (menu/submenu)
3
- include Nanoc ::Helpers ::Rendering
4
- # generate links to specific items
5
- include Nanoc ::Helpers ::LinkTo
6
-
7
2
def link_to_upper_page ( attributes = { } )
8
3
p = @item_rep . path
9
4
@@ -45,7 +40,8 @@ def navigation_for(item)
45
40
next if not it . identifier . to_s . end_with? ( ".html" , ".md" )
46
41
next if it [ :is_hidden ] # e.g. 404
47
42
next if it [ :no_menu ] # e.g. contact
48
- next if it . identifier . to_s == "/index.html" # homepage
43
+ next if it . identifier =~ "/index.*" # homepage
44
+ next if it . identifier =~ '/search/*' # search
49
45
50
46
# defaults
51
47
subsection = it . identifier . components [ part ] . split ( "." ) [ 0 ]
@@ -55,14 +51,7 @@ def navigation_for(item)
55
51
56
52
# special case subsection index
57
53
if subsection == "index"
58
- case section
59
- when "/search/"
60
- menu_name = "🔍 Site search"
61
- when "/contribute/"
62
- menu_name = "Introduction"
63
- else
64
- menu_name = "Overview"
65
- end
54
+ menu_name = it [ :title ] . include? ( ":" ) ? it [ :title ] . split ( ":" ) [ 1 ] . strip : "Start"
66
55
link = section
67
56
menu_weight = 100
68
57
end
Original file line number Diff line number Diff line change 1
1
use_helper CreateSearchIndex
2
+ use_helper Nanoc ::Helpers ::Rendering
3
+ use_helper Nanoc ::Helpers ::LinkTo
You can’t perform that action at this time.
0 commit comments