Skip to content

Commit a609280

Browse files
committed
Updated search interaction
1 parent 1cc1122 commit a609280

File tree

5 files changed

+71
-6
lines changed

5 files changed

+71
-6
lines changed

docs/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
2727

2828
<div id="contentWrapper">
2929
<input placeholder="Search" type="text" id="filter" autocorrect="off" autocapitalize="off" spellcheck="false" />
30+
<div id="exitSearchButton"></div>
3031

3132
<select id="language">
3233
<option value="en">en</option>
@@ -91,6 +92,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
9192
var panel = document.getElementById( 'panel' );
9293
var content = document.getElementById( 'content' );
9394
var expandButton = document.getElementById( 'expandButton' );
95+
var exitSearchButton = document.getElementById( 'exitSearchButton' );
9496
var panelScrim = document.getElementById( 'panelScrim' );
9597
var filterInput = document.getElementById( 'filter' );
9698
var iframe = document.querySelector( 'iframe' );
@@ -120,6 +122,19 @@ <h1><a href="http://threejs.org">three.js</a></h1>
120122

121123

122124
// Functionality for search/filter input field
125+
filterInput.onfocus = function ( event ) {
126+
127+
panel.classList.add('searchFocused');
128+
129+
}
130+
131+
exitSearchButton.onclick = function( event ) {
132+
133+
filterInput.value = '';
134+
updateFilter();
135+
panel.classList.remove('searchFocused');
136+
137+
}
123138

124139
filterInput.oninput = function ( event ) {
125140

docs/page.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ strong {
161161

162162
#button {
163163
position: fixed;
164-
bottom: 16px;
165-
right: 16px;
164+
bottom: 12px;
165+
right: 12px;
166166

167167
padding: 8px;
168168
border-radius: 50%;
@@ -179,6 +179,7 @@ strong {
179179

180180
#button img {
181181
display: block;
182+
width: 20px;
182183
}
183184

184185
a.permalink {

examples/index.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
}
1313
#button {
1414
position: fixed;
15-
bottom: 16px;
16-
right: 16px;
15+
bottom: 12px;
16+
right: 12px;
1717

1818
padding: 8px;
1919
border-radius: 50%;
@@ -30,6 +30,7 @@
3030

3131
#button img {
3232
display: block;
33+
width: 20px;
3334
}
3435
</style>
3536
</head>
@@ -52,6 +53,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
5253

5354
<div id="contentWrapper">
5455
<input placeholder="Search" type="text" id="filter" autocorrect="off" autocapitalize="off" spellcheck="false" />
56+
<div id="exitSearchButton"></div>
5557

5658
<select id="language">
5759
<option value="en">en</option>
@@ -84,6 +86,7 @@ <h1><a href="http://threejs.org">three.js</a></h1>
8486
var viewer = document.getElementById( 'viewer' );
8587

8688
var filterInput = document.getElementById( 'filter' );
89+
var exitSearchButton = document.getElementById( 'exitSearchButton' );
8790

8891
var expandButton = document.getElementById( 'expandButton' );
8992
expandButton.addEventListener( 'click', function ( event ) {
@@ -193,6 +196,19 @@ <h1><a href="http://threejs.org">three.js</a></h1>
193196
}
194197

195198
// filter
199+
filterInput.onfocus = function ( event ) {
200+
201+
panel.classList.add('searchFocused');
202+
203+
}
204+
205+
exitSearchButton.onclick = function( event ) {
206+
207+
filterInput.value = '';
208+
updateFilter();
209+
panel.classList.remove('searchFocused');
210+
211+
}
196212

197213
filterInput.addEventListener( 'input', function( e ) {
198214

files/ic_close_black_24dp.svg

Lines changed: 4 additions & 0 deletions
Loading

files/main.css

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
--text-color: #444;
44
--border-style: 1px solid #EEE;
55
--header-height: 48px;
6+
--panel-padding: 16px;
67
}
78

89
@font-face {
@@ -83,6 +84,34 @@ h1 a {
8384
transition: 0s 0s height;
8485
}
8586

87+
#panel #exitSearchButton {
88+
position: absolute;
89+
width: 40px;
90+
height: 40px;
91+
top: 4px;
92+
right: calc(var(--panel-padding) - 12px);
93+
z-index: 1000;
94+
display: none;
95+
background-size: 20px 20px;
96+
background-position: 50% 50%;
97+
background-repeat: no-repeat;
98+
background-image: url(../files/ic_close_black_24dp.svg);
99+
cursor: pointer;
100+
}
101+
102+
#panel.searchFocused #exitSearchButton {
103+
display: block;
104+
}
105+
106+
#panel.searchFocused #language {
107+
display: none;
108+
}
109+
110+
#panel.searchFocused #filter {
111+
background-image: none;
112+
padding-left: var(--panel-padding);
113+
}
114+
86115
#panel #expandButton {
87116
margin-right: 14px;
88117
margin-left: 4px;
@@ -100,7 +129,7 @@ h1 a {
100129
}
101130

102131
#panel #sections * {
103-
padding: 0 16px;
132+
padding: 0 var(--panel-padding);
104133
height: 100%;
105134
position: relative;
106135
display: flex;
@@ -166,7 +195,7 @@ h1 a {
166195
#panel #content {
167196
flex: 1;
168197
overflow: scroll;
169-
padding: 0 16px 24px 16px;
198+
padding: 0 var(--panel-padding) 24px var(--panel-padding);
170199
}
171200

172201
#panel #content ul {

0 commit comments

Comments
 (0)