Skip to content

Commit b427433

Browse files
authored
ux: copy search term to AI widget (#23212)
Harmonize buttons in the nav and automatically copy the search term to the AI widget. Uses "cmd k" to open the AI widget instead of search. Touch up search results.
1 parent d86d4f7 commit b427433

File tree

12 files changed

+116
-114
lines changed

12 files changed

+116
-114
lines changed

assets/css/components.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
}
9696
}
9797
.button {
98-
@apply my-2 mr-2 inline-block rounded-sm bg-blue-500 p-1 px-3 text-blue-50 text-white hover:bg-blue-600 dark:bg-blue-500 hover:dark:bg-blue-400;
98+
@apply my-2 mr-2 inline-block rounded-sm bg-blue-500 p-1 px-3 text-white hover:bg-blue-600 dark:bg-blue-500 hover:dark:bg-blue-400;
9999
}
100100

101101
.summary-bar {

assets/css/global.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
}
2121

2222
mark {
23-
@apply bg-transparent font-bold text-blue-500 dark:text-blue-800;
23+
@apply bg-transparent font-bold text-blue-500 dark:text-blue-400;
2424
}
2525

2626
/* Hide the clear (X) button for search inputs */

assets/css/utilities.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,10 @@
249249
@utility breadcrumbs {
250250
font-size: 90%;
251251
}
252+
@utility topbar-button {
253+
@apply text-white font-semibold min-h-10 px-2 bg-blue-300/50 rounded-md border-1 border-blue-300 inline-flex justify-center items-center gap-1.5 hover:bg-blue-400/70 hover:border-blue-200 transition-colors;
254+
svg {
255+
font-size: 19px;
256+
}
257+
}
258+

assets/icons/search.svg

Lines changed: 8 additions & 0 deletions
Loading

assets/icons/sparkle.svg

Lines changed: 8 additions & 0 deletions
Loading

assets/images/ai-stars.svg

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

assets/images/search-ai.svg

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

hugo_stats.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"classes": [
55
"--mount",
66
"--tmpfs",
7-
"-mt-0.5",
87
"-mt-8",
98
"-top-10",
109
"-top-16",
1110
"-v",
1211
"-z-10",
1312
".NET",
13+
"2xl:flex",
1414
"AWS-Route-53",
1515
"Admin-Console",
1616
"After",
@@ -162,15 +162,15 @@
162162
"aspect-video",
163163
"bake-action",
164164
"bg-amber-500",
165-
"bg-background-light",
166165
"bg-background-toc",
167166
"bg-black/100",
168167
"bg-black/50",
169168
"bg-blue",
170169
"bg-blue-400",
170+
"bg-blue-400/95",
171171
"bg-blue-500",
172+
"bg-blue-600",
172173
"bg-gradient-to-br",
173-
"bg-gradient-to-r",
174174
"bg-gray-100",
175175
"bg-gray-400",
176176
"bg-gray-50",
@@ -182,24 +182,25 @@
182182
"bg-pattern-purple",
183183
"bg-pattern-verde",
184184
"bg-red-500",
185-
"bg-transparent",
186185
"bg-violet-500",
187186
"bg-white",
188-
"bg-white/10",
189187
"block",
190188
"border",
191189
"border-0",
190+
"border-1",
192191
"border-b",
193192
"border-b-4",
194193
"border-blue",
194+
"border-blue-300",
195195
"border-divider-light",
196+
"border-gray-100",
196197
"border-gray-200",
197198
"border-gray-400",
198199
"border-green-400",
199200
"border-l-2",
200201
"border-l-magenta-light",
202+
"border-none",
201203
"border-transparent",
202-
"border-white",
203204
"bottom-0",
204205
"breadcrumbs",
205206
"build-push-action",
@@ -246,13 +247,11 @@
246247
"dark:fill-blue-300",
247248
"dark:focus:ring-3-blue-dark",
248249
"dark:from-blue-300",
249-
"dark:from-blue-600",
250250
"dark:hidden",
251251
"dark:hover:bg-blue-400",
252252
"dark:hover:bg-blue-500",
253253
"dark:hover:bg-blue-700",
254254
"dark:hover:bg-gray-600",
255-
"dark:hover:bg-gray-800",
256255
"dark:hover:bg-gray-900",
257256
"dark:hover:text-blue",
258257
"dark:outline-gray-800",
@@ -271,7 +270,6 @@
271270
"dark:text-magenta-dark",
272271
"dark:text-white",
273272
"dark:to-blue-400",
274-
"dark:to-blue-500",
275273
"docker/bake-action",
276274
"docker/build-push-action",
277275
"download-links",
@@ -288,8 +286,11 @@
288286
"flex-col-reverse",
289287
"flex-grow",
290288
"flex-none",
289+
"flex-row",
291290
"flex-shrink",
291+
"flex-shrink-0",
292292
"flex-wrap",
293+
"focus:outline-none",
293294
"focus:ring-3-blue-light",
294295
"font-bold",
295296
"font-medium",
@@ -299,7 +300,6 @@
299300
"footnote-ref",
300301
"footnotes",
301302
"from-blue-400",
302-
"from-blue-600",
303303
"gap-0",
304304
"gap-1",
305305
"gap-10",
@@ -334,23 +334,23 @@
334334
"highlight",
335335
"hover:bg-blue",
336336
"hover:bg-blue-400",
337+
"hover:bg-blue-400/90",
337338
"hover:bg-blue-500",
338339
"hover:bg-gray-100",
339340
"hover:bg-gray-200",
340341
"hover:bg-gray-50",
341-
"hover:bg-white/20",
342342
"hover:border-white/20",
343343
"hover:dark:bg-blue-500",
344344
"hover:dark:bg-gray-800",
345345
"hover:dark:text-blue-400",
346346
"hover:dark:text-blue-700",
347347
"hover:opacity-90",
348348
"hover:text-blue",
349-
"hover:text-white",
350349
"hover:underline",
351350
"icon-lg",
352351
"icon-sm",
353352
"icon-svg",
353+
"icon-svg-stroke",
354354
"inline",
355355
"inline-block",
356356
"inline-flex",
@@ -400,6 +400,7 @@
400400
"mb-8",
401401
"md-dropdown",
402402
"md:block",
403+
"md:flex",
403404
"md:flex-nowrap",
404405
"md:flex-row",
405406
"md:grid-cols-2",
@@ -447,13 +448,16 @@
447448
"object-cover",
448449
"open-kapa-widget",
449450
"openSUSE-and-SLES",
451+
"order-1",
452+
"order-2",
450453
"origin-bottom-right",
451454
"origin-top-right",
452455
"ot-sdk-show-settings",
453456
"outline",
454457
"outline-1",
455458
"outline-gray-200",
456459
"outline-hidden",
460+
"outline-none",
457461
"outline-offset-[-1px]",
458462
"overflow-clip",
459463
"overflow-hidden",
@@ -478,7 +482,6 @@
478482
"pl-4",
479483
"pl-5",
480484
"place-items-center",
481-
"placeholder:text-white",
482485
"pr-2",
483486
"prose",
484487
"pt-10",
@@ -518,14 +521,11 @@
518521
"self-center",
519522
"self-start",
520523
"shadow",
521-
"shadow-lg",
522524
"shadow-md",
523525
"sm:block",
524-
"sm:flex",
525526
"sm:flex-row",
526527
"sm:hidden",
527528
"sm:items-center",
528-
"sm:w-full",
529529
"space-y-2",
530530
"space-y-4",
531531
"sticky",
@@ -558,41 +558,41 @@
558558
"text-white",
559559
"text-xl",
560560
"text-xs",
561-
"to-50%",
562561
"to-blue-200",
563-
"to-blue-500",
564562
"toc",
565563
"top-0",
566564
"top-1",
567565
"top-16",
568566
"top-6",
569-
"top-full",
567+
"topbar-button",
570568
"transition",
571569
"transition-colors",
572570
"transition-transform",
573571
"truncate",
574572
"underline-offset-2",
573+
"w-0",
575574
"w-2",
575+
"w-32",
576576
"w-5",
577577
"w-65",
578578
"w-8",
579579
"w-[1200px]",
580-
"w-fit",
580+
"w-[500px]",
581581
"w-full",
582-
"w-screen",
583582
"whitespace-nowrap",
583+
"xl:flex",
584584
"xl:flex-row",
585585
"xl:grid-cols-3",
586586
"xl:grid-cols-4",
587587
"xl:mb-0",
588588
"xl:w-[1200px]",
589-
"xl:w-[400px]",
590589
"youtube-video",
591590
"z-10",
592591
"z-20",
593592
"z-30",
594593
"z-40",
595-
"z-50"
594+
"z-50",
595+
"z-[999]"
596596
],
597597
"ids": null
598598
}

layouts/_default/search.html

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,16 @@ <h1 class="py-4">{{ .Title }}</h1>
88
{{ .Content }}
99
<div class="not-prose">
1010
<div class="flex flex-col justify-between gap-8 lg:flex-row">
11-
<input
12-
type="search"
13-
id="search-page-input"
11+
<input type="search" id="search-page-input"
1412
class="ring-3-gray-light-200 dark:ring-3-gray-dark-400 dark:bg-background-dark focus:ring-3-blue-light dark:focus:ring-3-blue-dark ring-3-[1.5px] w-full max-w-xl min-w-0 rounded-sm bg-white px-4 py-2 outline-hidden"
15-
placeholder="Search…"
16-
tabindex="0"
17-
/>
18-
<div class="flex min-w-fit flex-grow flex-col items-center">
19-
<p>Not finding what you're looking for?</p>
20-
<button
21-
class="open-kapa-widget flex w-fit items-center gap-2 rounded-sm px-2 py-1 font-semibold hover:bg-gray-200 dark:hover:bg-gray-800"
22-
>
23-
<span>Try Ask AI</span>
24-
<img
25-
height="24px"
26-
width="24px"
27-
src="{{ (resources.Get "images/ai-stars.svg").Permalink }}"
28-
alt="AI sparkles!"
29-
/>
13+
placeholder="Search…" tabindex="0" />
14+
<div class="admonition flex flex-row min-w-fit items-center w-0 gap-1">
15+
<p>Not finding what you're looking for? Try</p>
16+
<button onclick="askAI('search-page-input')" class="topbar-button bg-blue-400/95 border-blue-300 hover:bg-blue-400/90">
17+
<span>Ask&nbsp;AI</span>
18+
<span class="icon-svg">
19+
{{ partial "utils/svg.html" "/icons/sparkle.svg" }}
20+
</span>
3021
</button>
3122
</div>
3223
</div>

layouts/partials/head.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,36 @@
7474
data-user-analytics-fingerprint-enabled="true"
7575
data-bot-protection-mechanism="hcaptcha"
7676
data-website-id="{{ site.Params.kapa.id }}"
77+
data-modal-open-on-command-k="true"
78+
data-modal-border-radius="6px"
7779
></script>
80+
<script>
81+
// Define askAI function to work with search-page-input
82+
window.askAI = function(inputId = "search-page-input") {
83+
const searchInput = document.querySelector("#" + inputId);
84+
const query = searchInput ? searchInput.value.trim() : "";
85+
86+
if (query && window.Kapa) {
87+
window.Kapa.open({
88+
mode: "ai",
89+
query: query,
90+
submit: false
91+
});
92+
} else if (window.Kapa) {
93+
window.Kapa.open({
94+
mode: "ai"
95+
});
96+
}
97+
};
98+
99+
// Add event listener for the Ask AI button
100+
document.addEventListener('click', function(event) {
101+
if (event.target.closest('.open-kapa-widget')) {
102+
event.preventDefault();
103+
window.askAI("search-page-input");
104+
}
105+
});
106+
</script>
78107
{{/* preload Roboto Flex as it's a critical font: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/preload */}}
79108
<link
80109
href="/assets/fonts/RobotoFlex.woff2"

0 commit comments

Comments
 (0)