Skip to content

Commit 0eb4ec3

Browse files
committed
All: Enable Typesense in prod and fix appearance on sites without it
E.g.: - https://blog.jquery.com/ - https://learn.jquery.com/ - https://jquery.org/team/ These now use the typesense-minibar HTML appearance but without the data attributes and JS payload to hydrate them, keeping the same no-js behaviour as before, based on WordPress search. Also: * Remove `input:focus` override to improve accessibility. It didn't look very good on the previous design but seems fine with typesense-minibar and matches how typesense-minibar is used in its own demo. * Fix order of stylesheets and simplify selectors accordingly. Previously I was fighting specificity because our overrides applies *before* typesense-minibar.css was applied. This allows various selectors to be simplified. Ref jquery/infrastructure-puppet#33
1 parent 28542b5 commit 0eb4ec3

File tree

7 files changed

+33
-180
lines changed

7 files changed

+33
-180
lines changed

sites.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ function jquery_sites() {
1818
),
1919
'jquery_body_class' => 'jquery',
2020
'jquery_xfn_rel_me' => 'https://social.lfx.dev/@jquery',
21-
'jquery_docsearch_api_key' => '3cfde9aca378c8aab554d5bf1b23489b',
22-
'jquery_docsearch_index_name' => 'jquery',
2321
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
2422
'jquery_typesense_collection' => 'jquery_com',
2523
),
@@ -45,8 +43,6 @@ function jquery_sites() {
4543
),
4644
'jquery_body_class' => 'jquery',
4745
'jquery_logo_link'=> 'https://jquery.com/',
48-
'jquery_docsearch_api_key' => '3cfde9aca378c8aab554d5bf1b23489b',
49-
'jquery_docsearch_index_name' => 'jquery',
5046
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
5147
'jquery_typesense_collection' => 'jquery_com',
5248
),
@@ -86,8 +82,6 @@ function jquery_sites() {
8682
'jquery-static-index.php',
8783
),
8884
'jquery_body_class' => 'jquery-ui',
89-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
90-
'jquery_docsearch_index_name' => 'jqueryui',
9185
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
9286
'jquery_typesense_collection' => 'jqueryui_com',
9387
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -115,8 +109,6 @@ function jquery_sites() {
115109
),
116110
'jquery_body_class' => 'jquery-ui',
117111
'jquery_logo_link'=> 'https://jqueryui.com/',
118-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
119-
'jquery_docsearch_index_name' => 'jqueryui',
120112
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
121113
'jquery_typesense_collection' => 'jqueryui_com',
122114
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -134,8 +126,6 @@ function jquery_sites() {
134126
),
135127
'jquery_body_class' => 'jquery-ui',
136128
'jquery_logo_link'=> 'https://jqueryui.com/',
137-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
138-
'jquery_docsearch_index_name' => 'jqueryui',
139129
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
140130
'jquery_typesense_collection' => 'jqueryui_com',
141131
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -153,8 +143,6 @@ function jquery_sites() {
153143
),
154144
'jquery_body_class' => 'jquery-ui',
155145
'jquery_logo_link'=> 'https://jqueryui.com/',
156-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
157-
'jquery_docsearch_index_name' => 'jqueryui',
158146
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
159147
'jquery_typesense_collection' => 'jqueryui_com',
160148
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -184,8 +172,6 @@ function jquery_sites() {
184172
'jquery-static-index.php',
185173
),
186174
'jquery_body_class' => 'jquery-mobile',
187-
'jquery_docsearch_api_key' => '207328b0f1c18555c9021d05157dd651',
188-
'jquery_docsearch_index_name' => 'jquerymobile',
189175
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
190176
'jquery_typesense_collection' => 'jquerymobile_com',
191177
'jquery_twitter_link' => 'https://twitter.com/jquerymobile',
@@ -203,8 +189,6 @@ function jquery_sites() {
203189
),
204190
'jquery_body_class' => 'jquery-mobile',
205191
'jquery_logo_link'=> 'https://jquerymobile.com/',
206-
'jquery_docsearch_api_key' => '207328b0f1c18555c9021d05157dd651',
207-
'jquery_docsearch_index_name' => 'jquerymobile',
208192
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
209193
'jquery_typesense_collection' => 'jquerymobile_com',
210194
'jquery_twitter_link' => 'https://twitter.com/jquerymobile',
@@ -263,8 +247,6 @@ function jquery_sites() {
263247
),
264248
'jquery_body_class' => 'jquery-mobile',
265249
'jquery_logo_link'=> 'https://jquerymobile.com/',
266-
'jquery_docsearch_api_key' => '207328b0f1c18555c9021d05157dd651',
267-
'jquery_docsearch_index_name' => 'jquerymobile',
268250
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
269251
'jquery_typesense_collection' => 'jquerymobile_com',
270252
'jquery_twitter_link' => 'https://twitter.com/jquerymobile',
@@ -282,8 +264,6 @@ function jquery_sites() {
282264
),
283265
'jquery_body_class' => 'jquery-ui',
284266
'jquery_logo_link'=> 'https://jqueryui.com/',
285-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
286-
'jquery_docsearch_index_name' => 'jqueryui',
287267
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
288268
'jquery_typesense_collection' => 'jqueryui_com',
289269
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -301,8 +281,6 @@ function jquery_sites() {
301281
),
302282
'jquery_body_class' => 'jquery-ui',
303283
'jquery_logo_link'=> 'https://jqueryui.com/',
304-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
305-
'jquery_docsearch_index_name' => 'jqueryui',
306284
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
307285
'jquery_typesense_collection' => 'jqueryui_com',
308286
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -320,8 +298,6 @@ function jquery_sites() {
320298
),
321299
'jquery_body_class' => 'jquery-ui',
322300
'jquery_logo_link'=> 'https://jqueryui.com/',
323-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
324-
'jquery_docsearch_index_name' => 'jqueryui',
325301
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
326302
'jquery_typesense_collection' => 'jqueryui_com',
327303
'jquery_twitter_link' => 'https://twitter.com/jqueryui',
@@ -339,8 +315,6 @@ function jquery_sites() {
339315
),
340316
'jquery_body_class' => 'jquery-mobile',
341317
'jquery_logo_link'=> 'https://jquerymobile.com/',
342-
'jquery_docsearch_api_key' => '207328b0f1c18555c9021d05157dd651',
343-
'jquery_docsearch_index_name' => 'jquerymobile',
344318
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
345319
'jquery_typesense_collection' => 'jquerymobile_com',
346320
'jquery_twitter_link' => 'https://twitter.com/jquerymobile',
@@ -371,8 +345,6 @@ function jquery_sites() {
371345
),
372346
'jquery_body_class' => 'jquery-ui',
373347
'jquery_logo_link'=> 'https://jqueryui.com/',
374-
'jquery_docsearch_api_key' => '2fce35e56784bbb48c78d105739190c2',
375-
'jquery_docsearch_index_name' => 'jqueryui',
376348
'jquery_typesense_key' => 'Zh8mMgohXECel9wjPwqT7lekLSG3OCgz',
377349
'jquery_typesense_collection' => 'jqueryui_com',
378350
'jquery_twitter_link' => 'https://twitter.com/jqueryui',

themes/jquery.org/style.css

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ a.icon-search::before {
492492

493493
/*Adjust widths for longer navigation*/
494494

495-
nav#main .searchform {
495+
.searchform {
496496
width: 20%;
497497
}
498498

@@ -504,30 +504,6 @@ nav#main ul {
504504
padding-bottom: 15px;
505505
}
506506

507-
@media only screen and (max-width: 767px) {
508-
.sponsors-page ul.block-grid li img {
509-
float: none;
510-
width: 80%;
511-
max-width: 80%;
512-
display: block;
513-
margin-left: auto;
514-
margin-right: auto;
515-
margin-bottom: 20px;
516-
margin-top: 0;
517-
}
518-
519-
.sponsors-page ul.block-grid li p {
520-
float: none;
521-
width: 100%;
522-
text-align: center;
523-
}
524-
525-
nav#main .searchform,
526-
nav#main ul {
527-
width: 100%;
528-
}
529-
}
530-
531507

532508
/*iPad Portrait*/
533509

themes/jquery/css/base.css

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,6 @@ nav#main {
16141614
background-color: rgba(0, 0, 0, 0.4);
16151615
}
16161616

1617-
.jquery-foundation nav#main {
1618-
background-color: rgba(102, 102, 102, 0.1);
1619-
}
1620-
16211617
nav#main ul {
16221618
margin: 0;
16231619
float: left;
@@ -1653,16 +1649,14 @@ nav#main li.current a {
16531649

16541650
.searchform {
16551651
float: right;
1656-
width: 28%;
1652+
margin: 6px 0;
1653+
width: 30%;
16571654
}
16581655
.searchform input {
16591656
font-family: "Lucida Grande", Lucida, Verdana, sans-serif;
16601657
}
1661-
.searchform input:focus {
1662-
outline: none;
1663-
}
16641658

1665-
.searchform.tsmb-form {
1659+
.tsmb-form {
16661660
--tsmb-size-radius: 5px;
16671661
--tsmb-size-base: 12px;
16681662
--tsmb-size-sm: 0.8rem;
@@ -1676,27 +1670,33 @@ nav#main li.current a {
16761670
--tsmb-color-primary30: #333; /* jQuery Black */
16771671
--tsmb-color-primary50: #0769ad; /* jQuery Primary Blue */
16781672
--tsmb-color-primary90: #b4efff; /* oklch(0.92 0.07 228) hue=228 of #7ACEF4 (jQuery Secondary Blue) */
1679-
margin: 6px 0;
1680-
width: 30%;
16811673
}
1682-
.jquery-ui .searchform.tsmb-form {
1674+
.jquery-ui .tsmb-form {
16831675
--tsmb-color-primary50: #b24926; /* jQuery UI Secondary Orange */
16841676
--tsmb-color-primary90: #ffddb2; /* = #b4efff + oklch(hue=70) of #FAA523 (jQuery UI Primary Orange) */
16851677
}
1686-
.jquery-mobile .searchform.tsmb-form {
1678+
.jquery-mobile .tsmb-form {
16871679
--tsmb-color-primary50: #108040; /* jQuery Mobile Secondary Green */
16881680
--tsmb-color-primary90: #c9f2c8; /* = #b4efff + oklch(hue=144) of #3EB249 (jQuery UI Primary Orange) */
16891681
}
1690-
.searchform.tsmb-form:not(:focus-within)::before {
1682+
.jquery-foundation .tsmb-form {
1683+
--tsmb-color-primary50: #333; /* jQuery Black */
1684+
--tsmb-color-primary90: #ccc;
1685+
}
1686+
.jquery-learn .tsmb-form {
1687+
--tsmb-color-primary50: #222;
1688+
--tsmb-color-primary90: #ccc;
1689+
}
1690+
.tsmb-form:not(:focus-within)::before {
16911691
filter: invert();
16921692
}
1693-
.searchform.tsmb-form input[type=search] {
1693+
.tsmb-form input[type=search] {
16941694
border-width: 0;
16951695
}
1696-
.searchform.tsmb-form [role="listbox"] {
1696+
.tsmb-form [role="listbox"] {
16971697
right: 0;
16981698
}
1699-
.searchform.tsmb-form [role="option"] mark {
1699+
.tsmb-form [role="option"] mark {
17001700
border-bottom: 2px solid var(--tsmb-color-primary90);
17011701
}
17021702

@@ -2845,7 +2845,7 @@ footer .books li a cite {
28452845
margin: 15px auto;
28462846
clear:both;
28472847
}
2848-
.searchform.tsmb-form input[type=search] {
2848+
.searchform input[type=search] {
28492849
border-width: 1px;
28502850
}
28512851

themes/jquery/css/docsearch.css

Lines changed: 0 additions & 62 deletions
This file was deleted.

themes/jquery/functions.jquery.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,9 @@ function jq_posts_per_page($limits) {
178178
function jq_search_get_provider() {
179179
$typesenseKey = get_option( 'jquery_typesense_key' );
180180
$typesenseCollection = get_option( 'jquery_typesense_collection' );
181-
if ( JQUERY_STAGING && $typesenseKey && $typesenseCollection ) {
181+
if ( $typesenseKey && $typesenseCollection ) {
182182
return 'typesense';
183183
}
184-
$algoliaKey = get_option( 'jquery_docsearch_api_key' );
185-
$algoliaIndex = get_option( 'jquery_docsearch_index_name' );
186-
if ( $algoliaKey && $algoliaIndex ) {
187-
return 'algolia';
188-
}
189184
return '';
190185
}
191186

@@ -194,17 +189,5 @@ function jq_search_the_footer() {
194189
?>
195190
<script defer src="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.js"></script>
196191
<?php
197-
else:
198-
$algoliaKey = get_option( 'jquery_docsearch_api_key' );
199-
$algoliaIndex = get_option( 'jquery_docsearch_index_name' );
200-
if ( $algoliaKey && $algoliaIndex ) :
201-
?>
202-
<script async src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" onload='document.querySelector("input[name=\"s\"]") && docsearch({apiKey: <?php print json_encode($algoliaKey); ?>,
203-
indexName: <?php print json_encode($algoliaIndex); ?>,
204-
inputSelector: "input[name=\"s\"]",
205-
debug: true
206-
})'></script>
207-
<?php
208-
endif;
209192
endif;
210193
}

themes/jquery/header.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<meta name="viewport" content="width=device-width">
1919

2020
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/i/favicon.ico">
21+
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.css">
2122
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/base.css?v=6">
2223
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>?v=3">
2324

@@ -27,15 +28,6 @@
2728
<script src="https://use.typekit.net/wde1aof.js"></script>
2829
<script>try{Typekit.load();}catch(e){}</script>
2930
<?php
30-
if ( jq_search_get_provider() === 'typesense' ) {
31-
?><link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/lib/typesense-minibar/typesense-minibar.css">
32-
<?php
33-
} elseif ( jq_search_get_provider() === 'algolia' ) {
34-
?>
35-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
36-
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/docsearch.css">
37-
<?php
38-
}
3931
if ( get_option( 'thread_comments' ) && comments_open() ) {
4032
wp_enqueue_script( 'comment-reply' );
4133
}

0 commit comments

Comments
 (0)