Skip to content

Commit 7a0b48b

Browse files
committed
search in topbar
1 parent 0d93d80 commit 7a0b48b

File tree

8 files changed

+76
-40
lines changed

8 files changed

+76
-40
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="search-section" role="search" class="project-section initially-hidden">
1+
<dialog id="search-dialog" role="search" class="search-dialog initially-hidden">
22
<form action="#" method="get" accept-charset="utf-8">
33
<div id="search-field-wrapper">
44
<input id="search-field" role="combobox" aria-label="Search"
@@ -9,6 +9,7 @@
99

1010
<ul id="search-results" aria-label="Search Results"
1111
aria-busy="false" aria-expanded="false"
12-
aria-atomic="false" class="initially-hidden"></ul>
12+
aria-atomic="false" class="initially-hidden">
13+
</ul>
1314
</form>
14-
</div>
15+
</dialog>

lib/rdoc/generator/template/rorvswild/_navigation.rhtml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<nav id="navigation" role="navigation">
2-
<div id="project-navigation">
3-
<%= render '_sidebar_search.rhtml' %>
4-
</div>
52
<%= render '_sidebar_classes.rhtml' %>
63
<%= render '_sidebar_pages.rhtml' %>
74
<%= render '_footer.rhtml' %>
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<header class="topbar">
22
<%= render '_sidebar_toggle.rhtml' %>
33
<a href="<%= rel_prefix %>/index.html" rel="home"><%= @options.title %></a>
4-
</header>
4+
<button type="button" aria-label="Search" class="search-button">
5+
search
6+
</button>
7+
</header>
8+
9+
<%= render '_dialog_search.rhtml' %>

lib/rdoc/generator/template/rorvswild/css/rdoc.css

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,39 @@ nav.contextual {
449449
}
450450

451451
/* 9. Search */
452+
453+
.search-button {
454+
background-color: var(--color-background);
455+
border: none;
456+
border-radius: 4px;
457+
color:var(--color-text-light);
458+
box-shadow: none;
459+
}
460+
461+
.search-button:hover,
462+
.search-button:focus {
463+
color:var(--color-text);
464+
}
465+
466+
.search-dialog {
467+
background-color: var(--color-background);
468+
width: calc(100% - 4em);
469+
max-width: 1000px;
470+
max-height: calc(100svh - 80px);
471+
margin: 0 auto;
472+
top: 40px;
473+
border: 0;
474+
border-radius: 8px;
475+
box-shadow:
476+
0 0 0 1px var(--color-border),
477+
0 0 24px 8px oklch(0.02 0.05 269 /1);
478+
}
479+
480+
.search-dialog::backdrop {
481+
background-color: oklch(0.1 0.02 269 /0.9);
482+
backdrop-filter: blur(4px);
483+
}
484+
452485
#search-section {
453486
padding: 1em 1em 0;
454487
background-color: var(--color-background);
@@ -466,16 +499,14 @@ nav.contextual {
466499
padding: 0.5em 1em 0.5em 2em;
467500
border: 1px solid var(--color-border);
468501
color: var(--color-text);
469-
border-radius: 20px;
502+
border-radius: 4px;
470503
font-size: 14px;
471504
outline: none;
472505
transition: border-color 0.3s ease;
473506
background-color: var(--color-background);
474507
}
475508

476-
#search-field:focus {
477-
border-color: var(--color-primary);
478-
}
509+
#search-field:focus { border-color: var(--color-primary); }
479510

480511
#search-field::placeholder {
481512
color: var(--color-text);
@@ -493,7 +524,6 @@ nav.contextual {
493524
opacity: 0.6;
494525
}
495526

496-
/* 10. Utility Classes */
497527
.hide { display: none !important; }
498528
.initially-hidden { display: none; }
499529

@@ -586,9 +616,7 @@ em {
586616
font-weight: bold;
587617
}
588618

589-
.method-detail {
590-
margin: 1.5rem 0 0;
591-
}
619+
.method-detail { margin: 1.5rem 0 0; }
592620

593621
.method-detail + .method-detail {
594622
margin: 1.5rem 0 0;
@@ -650,7 +678,12 @@ em {
650678
}
651679

652680
/* @group search results */
653-
#search-results { font-weight: 300; }
681+
#search-results {
682+
margin: 0;
683+
color: var(--color-text);
684+
}
685+
686+
#search-results li:first-of-type { margin-top: 2rem; }
654687

655688
#search-results .search-match { font-weight: normal; }
656689

@@ -690,21 +723,12 @@ em {
690723
/* 11. Media Queries */
691724

692725
@media (max-width: 480px) {
693-
nav { width: 100%; }
694-
695726
main {
696727
margin: 1em auto;
697728
padding: 0 1em;
698729
max-width: 100%;
699730
}
700731

701-
#navigation-toggle {
702-
right: 10px;
703-
left: auto;
704-
}
705-
706-
#navigation-toggle[aria-expanded="true"] { left: auto; }
707-
708732
table {
709733
display: block;
710734
overflow-x: auto;
@@ -778,8 +802,7 @@ em {
778802

779803
--color-topbar: oklch(0.5 0.18 29);
780804
--color-topbar-text: oklch(0.99 0.001 269);
781-
782-
/* greys */
805+
783806
--color-text: oklch(0.84 0.02 269);
784807
--color-text-light: oklch(0.74 0.02 269);
785808
--color-title: oklch(0.91 0.02 269);
@@ -791,7 +814,6 @@ em {
791814

792815
pre,
793816
code {
794-
/* syntax highlighting */
795817
--color-constant: oklch(0.84 0.09 260); /* Bright blue for constants */
796818
--color-keyword: var(--color-primary); /* Red for keywords */
797819
--color-ivar: oklch(0.85 0.09 59); /* Orange for instance variables */

lib/rdoc/generator/template/rorvswild/js/darkfish.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,33 @@ function hookSourceViews() {
4040
};
4141

4242
function hookSearch() {
43+
44+
const searchButton = document.querySelector('button[aria-label="Search"]');
45+
const searchDialog = document.getElementById('search-dialog');
46+
47+
if (searchButton && searchDialog) {
48+
searchButton.addEventListener('click', function(event) {
49+
event.preventDefault();
50+
searchDialog.showModal();
51+
searchDialog.querySelector('input[name="q"]').focus();
52+
});
53+
}
54+
55+
// Close dialog when clicking on the backdrop
56+
searchDialog.addEventListener('click', function(event) {
57+
const rect = this.getBoundingClientRect();
58+
const isInDialog = (rect.top <= event.clientY && event.clientY <= rect.top + rect.height &&
59+
rect.left <= event.clientX && event.clientX <= rect.left + rect.width);
60+
if (!isInDialog) {
61+
this.close();
62+
}
63+
});
64+
4365
var input = document.querySelector('#search-field');
4466
var result = document.querySelector('#search-results');
4567
result.classList.remove("initially-hidden");
4668

47-
var search_section = document.querySelector('#search-section');
69+
var search_section = document.querySelector('#search-dialog');
4870
search_section.classList.remove("initially-hidden");
4971

5072
var search = new Search(search_data, input, result);

lib/rdoc/generator/template/rorvswild/servlet_not_found.rhtml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
<%= render '_sidebar_toggle.rhtml' %>
33

44
<nav id="navigation" role="navigation">
5-
<div id="project-navigation">
6-
<%= render '_sidebar_navigation.rhtml' %>
7-
<%= render '_sidebar_search.rhtml' %>
8-
</div>
9-
105
<%= render '_sidebar_pages.rhtml' %>
116
<%= render '_sidebar_classes.rhtml' %>
127

lib/rdoc/generator/template/rorvswild/servlet_root.rhtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
<a href="<%= rel_prefix %>/" rel="home">Home</a>
99
</h2>
1010
</div>
11-
12-
<%= render '_sidebar_search.rhtml' %>
1311
</div>
1412

1513
<%= render '_sidebar_installed.rhtml' %>

lib/rdoc/generator/template/rorvswild/table_of_contents.rhtml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<body id="top" class="table-of-contents">
22

33
<nav id="navigation" role="navigation">
4-
<div id="project-navigation">
5-
<%= render '_sidebar_search.rhtml' %>
6-
</div>
7-
84
<%= render '_footer.rhtml' %>
95
</nav>
106
<main role="main">

0 commit comments

Comments
 (0)