File tree Expand file tree Collapse file tree 8 files changed +125
-26
lines changed
Expand file tree Collapse file tree 8 files changed +125
-26
lines changed Original file line number Diff line number Diff line change @@ -246,25 +246,94 @@ $darkgrey: #202020;
246246 }
247247
248248 /* Search box and results */
249- form #search-form {
250- margin : 1em 0 ;
251249
252- input {
250+ form .search , #search-overlay {
251+ input , button {
253252 border : 2px solid $normalgreen ;
254- margin : 4px 2px ;
253+ margin : 4px 0 2px ;
255254 padding : 10px 12px ;
256255 border-radius : 5px ;
257256 }
257+
258258 input [type = text ] {
259259 border-collapse : collapse ;
260- width : 300 px ;
260+ width : 400 px ;
261261 }
262- input [type = submit ] {
262+
263+ button {
263264 background-color : $lightgrey ;
264265 color : black ;
265266 cursor : pointer ;
266267 }
267268 }
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+
268337 ul #search-results {
269338 // entry height
270339 $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 11---
22title: Search on this site
3- menu_name: 🔍 Site search
4- menu_weight: -1
53---
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.*' %>
105< h2 id ="search-heading "> </ h2 >
116< ul id ="search-results "> </ ul >
127< 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"
2020 link rel =" stylesheet" href =" /css/easyrpg.css"
2121 link rel =" stylesheet" href =" /css/rouge-github-dark.css"
2222 script src =" /js/vendor/jquery-2.2.4.min.js"
23+ script src =" /js/search.js"
2324 body
2425 #header
2526 .maxwidth
Original file line number Diff line number Diff line change 44 < % navigation_for(@item).each do |index, target| %>
55 < li > < %= link_to_unless_current(target[:text], target[:link]) %> </ li >
66 < % end %>
7+ < % if @item.identifier.components[0] != "search" %>
8+ < li > < button title ="Search Site " id ="show-search "> 🔍</ button > </ li >
9+ < % end %>
710 </ 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 %>
819< % 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 11
2- # allow partial layouts (menu/submenu)
3- include Nanoc ::Helpers ::Rendering
4- # generate links to specific items
5- include Nanoc ::Helpers ::LinkTo
6-
72def link_to_upper_page ( attributes = { } )
83 p = @item_rep . path
94
@@ -45,7 +40,8 @@ def navigation_for(item)
4540 next if not it . identifier . to_s . end_with? ( ".html" , ".md" )
4641 next if it [ :is_hidden ] # e.g. 404
4742 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
4945
5046 # defaults
5147 subsection = it . identifier . components [ part ] . split ( "." ) [ 0 ]
@@ -55,14 +51,7 @@ def navigation_for(item)
5551
5652 # special case subsection index
5753 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"
6655 link = section
6756 menu_weight = 100
6857 end
Original file line number Diff line number Diff line change 11use_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