@netlify/spark-ui 1.11.0 → 1.12.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/assets/AskNetlify.css +1 -1
  2. package/dist/assets/SearchLink.css +1 -1
  3. package/dist/assets/SearchModal.css +1 -1
  4. package/dist/chunks/{ChatInterface.EQAPs01R.js → AskNetlify.lrswYyKn.js} +119 -110
  5. package/dist/components/preact/AskNetlify/AskNetlify.d.ts +3 -3
  6. package/dist/components/preact/AskNetlify/AskNetlify.js +8 -34
  7. package/dist/components/preact/AskNetlify/components/ChatMessages.d.ts +2 -1
  8. package/dist/components/preact/AskNetlify/components/ChatMessages.js +78 -70
  9. package/dist/components/preact/AskNetlify/components/SourcesList.d.ts +3 -0
  10. package/dist/components/preact/AskNetlify/components/SourcesList.js +23 -0
  11. package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.d.ts +23 -0
  12. package/dist/components/preact/AskNetlify/hooks/useAskAnalytics.js +22 -0
  13. package/dist/components/preact/Icon/index.js +6 -6
  14. package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.d.ts +1 -1
  15. package/dist/components/preact/SearchModal/components/SearchLink/SearchLink.js +23 -22
  16. package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.d.ts +1 -0
  17. package/dist/components/preact/SearchModal/components/SearchLinkThemeToggle.js +26 -0
  18. package/dist/components/preact/SearchModal/components/SearchModal/SearchModal.js +89 -84
  19. package/dist/components/preact/SearchModal/components/SearchWindow.d.ts +1 -1
  20. package/dist/components/preact/SearchModal/components/SearchWindow.js +55 -48
  21. package/dist/components/preact/SearchModal/hooks/index.d.ts +1 -1
  22. package/dist/components/preact/SearchModal/hooks/index.js +8 -8
  23. package/dist/components/preact/SearchModal/hooks/useKeyboardNav.d.ts +1 -1
  24. package/dist/components/preact/SearchModal/hooks/useKeyboardNav.js +11 -12
  25. package/dist/components/preact/SearchModal/hooks/useSearch.js +19 -19
  26. package/dist/components/preact/SearchModal/hooks/{useSearchLogger.d.ts → useSearchAnalytics.d.ts} +2 -2
  27. package/dist/components/preact/SearchModal/hooks/{useSearchLogger.js → useSearchAnalytics.js} +5 -5
  28. package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.d.ts +1 -1
  29. package/dist/components/preact/SearchModal/hooks/useSearchHotkeys.js +8 -9
  30. package/dist/components/preact/SearchModal/hooks/useSearchParams.d.ts +1 -1
  31. package/dist/components/preact/SearchModal/hooks/useSearchParams.js +14 -7
  32. package/dist/components/preact/SearchModal/hooks/useSearchToggles.d.ts +1 -1
  33. package/dist/components/preact/SearchModal/hooks/useSearchToggles.js +7 -8
  34. package/dist/components/preact/SearchModal/types/search.types.d.ts +11 -4
  35. package/dist/components/preact/index.js +3 -3
  36. package/package.json +2 -2
  37. package/packages/components/preact/AskNetlify/AskNetlify.css +54 -1
  38. package/packages/components/preact/AskNetlify/AskNetlify.tsx +98 -34
  39. package/packages/components/preact/AskNetlify/components/ChatMessages.tsx +10 -5
  40. package/packages/components/preact/AskNetlify/components/SourcesList.tsx +33 -0
  41. package/packages/components/preact/AskNetlify/hooks/useAskAnalytics.tsx +50 -0
  42. package/packages/components/preact/Icon/index.tsx +2 -2
  43. package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.css +5 -0
  44. package/packages/components/preact/SearchModal/components/SearchLink/SearchLink.tsx +6 -4
  45. package/packages/components/preact/SearchModal/components/SearchLinkThemeToggle.tsx +19 -0
  46. package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.css +22 -3
  47. package/packages/components/preact/SearchModal/components/SearchModal/SearchModal.tsx +73 -89
  48. package/packages/components/preact/SearchModal/components/SearchWindow.tsx +64 -46
  49. package/packages/components/preact/SearchModal/hooks/index.ts +1 -1
  50. package/packages/components/preact/SearchModal/hooks/useKeyboardNav.ts +1 -3
  51. package/packages/components/preact/SearchModal/hooks/useSearch.ts +20 -16
  52. package/packages/components/preact/SearchModal/hooks/{useSearchLogger.ts → useSearchAnalytics.ts} +9 -10
  53. package/packages/components/preact/SearchModal/hooks/useSearchHotkeys.ts +2 -4
  54. package/packages/components/preact/SearchModal/hooks/useSearchParams.ts +24 -2
  55. package/packages/components/preact/SearchModal/hooks/useSearchToggles.ts +1 -3
  56. package/packages/components/preact/SearchModal/types/search.types.tsx +7 -4
  57. package/packages/styles/loaders.css +18 -0
  58. package/packages/styles/tokens.css +4 -0
  59. package/dist/components/preact/AskNetlify/components/ChatInterface.d.ts +0 -7
  60. package/dist/components/preact/AskNetlify/components/ChatInterface.js +0 -10
  61. package/packages/components/preact/AskNetlify/components/ChatInterface.tsx +0 -94
@@ -2,9 +2,9 @@ import { default as t } from "./KeyboardKey/KeyboardKey.js";
2
2
  import { default as d } from "./Modal/Modal.js";
3
3
  import { default as m } from "./Icon/index.js";
4
4
  import { default as s } from "./SearchModal/components/SearchLink/SearchLink.js";
5
- import { default as x } from "./SearchModal/components/SearchHeading/SearchHeading.js";
5
+ import { default as u } from "./SearchModal/components/SearchHeading/SearchHeading.js";
6
6
  import { default as i } from "./SearchModal/components/SearchToggle/SearchToggle.js";
7
- import { default as S } from "./AskNetlify/AskNetlify.js";
7
+ import { A as S } from "../../chunks/AskNetlify.lrswYyKn.js";
8
8
  import "preact";
9
9
  import "../../chunks/hooks.module.DGkdD5n9.js";
10
10
  import { default as n } from "./SearchModal/components/SearchModal/SearchModal.js";
@@ -13,7 +13,7 @@ export {
13
13
  m as Icon,
14
14
  t as KeyboardKey,
15
15
  d as Modal,
16
- x as SearchHeading,
16
+ u as SearchHeading,
17
17
  s as SearchLink,
18
18
  n as SearchModal,
19
19
  i as SearchToggle
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@netlify/spark-ui",
3
3
  "description": "Assets, design tokens, components, and utilities",
4
- "version": "1.11.0",
4
+ "version": "1.12.0-alpha.1",
5
5
  "type": "module",
6
6
  "main": "dist/components/preact/index.js",
7
7
  "types": "dist/components/preact/index.d.ts",
@@ -68,4 +68,4 @@
68
68
  "prettier": "^3.5.3",
69
69
  "prettier-plugin-astro": "^0.14.1"
70
70
  }
71
- }
71
+ }
@@ -12,11 +12,12 @@
12
12
  .n-ask-conversation {
13
13
  display: grid;
14
14
  align-items: flex-end;
15
+ gap: var(--space-s);
15
16
  height: calc(var(--n-search-container-height) + var(--n-search-footer-height));
16
17
  padding: var(--n-search-padding-inline);
17
18
  overflow-y: auto;
18
19
  scroll-behavior: smooth;
19
- gap: var(--space-s);
20
+ grid-template-rows: 1fr;
20
21
  }
21
22
 
22
23
  .n-ask-form {
@@ -84,6 +85,9 @@
84
85
  display: grid;
85
86
  grid-template-columns: minmax(0, 1fr);
86
87
  gap: var(--space-s);
88
+ }
89
+
90
+ .n-ask-message:first-of-type {
87
91
  margin-block-start: var(--space-2xl);
88
92
  }
89
93
 
@@ -101,6 +105,54 @@
101
105
  background: var(--search-user-message-color);
102
106
  }
103
107
 
108
+ .n-ask-sources {
109
+ margin-block-start: var(--space-m);
110
+ }
111
+
112
+ .n-ask-sources-title {
113
+ font-size: var(--step-0);
114
+ font-weight: var(--font-weight-bold);
115
+ }
116
+
117
+ .n-ask-sources a {
118
+ font-size: var(--step--1);
119
+ }
120
+
121
+ .n-ask-sources details summary::marker {
122
+ display: none;
123
+ content: none;
124
+ }
125
+
126
+ .n-ask-sources details {
127
+ background: var(--search-source-list-color);
128
+ padding: var(--space-xs) var(--space-xs);
129
+ border-radius: var(--radius-l);
130
+ }
131
+
132
+ .n-ask-sources details summary {
133
+ display: flex;
134
+ align-items: center;
135
+ justify-content: space-between;
136
+ gap: var(--space-xs);
137
+ cursor: pointer;
138
+ }
139
+
140
+ .n-ask-sources details ul {
141
+ margin-block-start: var(--space-3xs);
142
+ }
143
+
144
+ .n-ask-sources [data-icon='caretRight'] {
145
+ width: 0.8em;
146
+ display: inline-block;
147
+ transform: rotate(90deg);
148
+ height: auto;
149
+ color: var(--color-text-weaker);
150
+ }
151
+
152
+ .n-ask-sources details[open] [data-icon='caretRight'] {
153
+ transform: rotate(270deg);
154
+ }
155
+
104
156
  /* ----------------------------- */
105
157
  /* Form UI */
106
158
  /* ----------------------------- */
@@ -235,6 +287,7 @@
235
287
  }
236
288
 
237
289
  .n-ask-message-loader :where(#ask-netlify-eyelid-left, #ask-netlify-eyelid-right) {
290
+ --n-ask-netlify-eyelid-color: var(--search-bg-color);
238
291
  transform-origin: top center;
239
292
  transform: scaleY(1.035);
240
293
  animation: askEyeBlink 4s infinite;
@@ -1,44 +1,108 @@
1
- import { useRef } from 'preact/hooks';
2
- import { KapaProvider } from '@kapaai/react-sdk';
3
- import Analytics from '../../../analytics/analytics';
4
- import ChatInterface from './components/ChatInterface';
1
+ import { useState, useRef, useEffect } from 'preact/hooks';
2
+ import { useChat } from '@kapaai/react-sdk';
3
+ import { questions } from './components/QuestionList/questions';
4
+ import { QuestionList } from './components/QuestionList/QuestionList';
5
+ import { BackButton } from './components/BackButton';
6
+ import { ChatMessages } from './components/ChatMessages';
7
+
5
8
  import './AskNetlify.css';
6
9
 
7
- interface AskNetlifyProps {
8
- kapaIntegrationId?: string;
10
+ interface Props {
9
11
  setModalState?: (e: { current: string }) => void;
12
+ initialQuery?: string;
10
13
  }
11
14
 
12
- export default function AskNetlify(props: AskNetlifyProps) {
13
- const analyticsRef = useRef<Analytics>(new Analytics());
15
+ export default function AskNetlify({ setModalState, initialQuery }: Props) {
16
+ const [message, setMessage] = useState('');
17
+ const [newMessageReady, setNewMessageReady] = useState(false);
18
+ const chatRef = useRef<HTMLDivElement>(null);
19
+ const menuRef = useRef<HTMLUListElement>(null);
20
+ const lastMessageRef = useRef<HTMLDivElement | null>(null);
21
+
22
+ const { conversation, submitQuery, isGeneratingAnswer, isPreparingAnswer, stopGeneration } =
23
+ useChat();
24
+
25
+ const handleSubmit = (e: Event | preact.JSX.TargetedMouseEvent<HTMLButtonElement>) => {
26
+ e.preventDefault();
27
+ const target = e.target as HTMLButtonElement;
28
+ const id = target?.getAttribute('data-question-id');
29
+ const text = id ? questions[id] : message;
30
+
31
+ if (text.trim()) {
32
+ submitQuery(text.trim());
33
+ }
34
+ if (!id) setMessage('');
14
35
 
15
- if (!props.kapaIntegrationId) return;
36
+ setNewMessageReady(true);
37
+ };
38
+
39
+ /*
40
+ * When a new user message is ready, scroll it into view and reset the flag.
41
+ * This ensures the most recent message is visible to the user immediately after rendering.
42
+ */
43
+ useEffect(() => {
44
+ if (newMessageReady && lastMessageRef.current) {
45
+ lastMessageRef.current.scrollIntoView({ behavior: 'smooth' });
46
+ setNewMessageReady(false);
47
+ }
48
+ }, [newMessageReady]);
49
+
50
+ useEffect(() => {
51
+ if (initialQuery) {
52
+ submitQuery(initialQuery.trim());
53
+ setNewMessageReady(true);
54
+ }
55
+ }, [initialQuery]);
16
56
 
17
57
  return (
18
- <KapaProvider
19
- integrationId={props.kapaIntegrationId}
20
- callbacks={{
21
- askAI: {
22
- onQuerySubmit: data => {
23
- if (!data.question || !data.threadId) return;
24
-
25
- analyticsRef?.current?.track('ask:new_query', {
26
- question: data.question,
27
- thread_id: data.threadId,
28
- });
29
- },
30
- onAnswerGenerationCompleted: data => {
31
- if (!data.questionAnswerId || !data.answer) return;
32
-
33
- analyticsRef?.current?.track('ask:answer_generated', {
34
- question_id: data.questionAnswerId,
35
- answer_length: data.answer.length,
36
- });
37
- },
38
- },
39
- }}
40
- >
41
- <ChatInterface setModalState={props.setModalState} />
42
- </KapaProvider>
58
+ <div className="n-ask-chat-container">
59
+ <BackButton onClick={() => setModalState?.({ current: 'search' })} />
60
+ <div ref={chatRef} className="n-ask-conversation n-search-window">
61
+ {!conversation.length ? (
62
+ <QuestionList onClick={handleSubmit} menuRef={menuRef} />
63
+ ) : (
64
+ <ChatMessages
65
+ isPreparingAnswer={isPreparingAnswer}
66
+ conversation={conversation}
67
+ lastMessageRef={lastMessageRef}
68
+ />
69
+ )}
70
+ </div>
71
+
72
+ <form onSubmit={handleSubmit} className="n-ask-form n-search-input-wrapper">
73
+ <input
74
+ className="n-ask-input n-search-input"
75
+ type="text"
76
+ value={message}
77
+ onInput={e => setMessage(e.currentTarget.value)}
78
+ placeholder="Ask a question..."
79
+ disabled={isPreparingAnswer || isGeneratingAnswer}
80
+ />
81
+
82
+ {isGeneratingAnswer ? (
83
+ <button
84
+ type="button"
85
+ className="n-ask-form-submit"
86
+ onClick={stopGeneration}
87
+ aria-label="Stop generation"
88
+ >
89
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="var(--neutral-100)">
90
+ <rect x="0" y="0" width="16" height="16" />
91
+ </svg>
92
+ </button>
93
+ ) : (
94
+ <button
95
+ type="submit"
96
+ className="n-ask-form-submit"
97
+ disabled={!message.trim() || isPreparingAnswer}
98
+ aria-label="Send message"
99
+ >
100
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" fill="var(--neutral-100)">
101
+ <path d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z" />
102
+ </svg>
103
+ </button>
104
+ )}
105
+ </form>
106
+ </div>
43
107
  );
44
108
  }
@@ -1,13 +1,16 @@
1
1
  import { marked } from 'marked';
2
2
  import Icon from '../../Icon';
3
3
  import { Ref } from 'preact';
4
+ import { SourcesList } from './SourcesList';
4
5
 
5
6
  export function ChatMessages({
6
7
  conversation,
7
8
  lastMessageRef,
9
+ isPreparingAnswer,
8
10
  }: {
9
11
  conversation: any[];
10
12
  lastMessageRef: Ref<HTMLDivElement>;
13
+ isPreparingAnswer: boolean;
11
14
  }) {
12
15
  return (
13
16
  <>
@@ -25,22 +28,24 @@ export function ChatMessages({
25
28
  </div>
26
29
 
27
30
  <div class="n-ask-message-left">
28
- {qa.answer ? (
31
+ {qa.answer && (
29
32
  <div class="n-ask-message-bubble n-ask-bot-message">
30
33
  <div
31
34
  class="n-ask-message-answer n-ask-prose prose flow"
32
35
  dangerouslySetInnerHTML={{ __html: marked.parse(qa.answer) }}
33
36
  />
34
- </div>
35
- ) : (
36
- <div class="n-ask-message-loader">
37
- <Icon name="askNetlify" />
37
+ {qa.id && <SourcesList sources={qa.sources} />}
38
38
  </div>
39
39
  )}
40
40
  </div>
41
41
  </div>
42
42
  );
43
43
  })}
44
+ {isPreparingAnswer && (
45
+ <div class="n-ask-message-loader">
46
+ <Icon name="askNetlify" />
47
+ </div>
48
+ )}
44
49
  </>
45
50
  );
46
51
  }
@@ -0,0 +1,33 @@
1
+ import Icon from '../../Icon';
2
+
3
+ export function SourcesList({ sources }) {
4
+ if (!sources?.length) return null;
5
+
6
+ return (
7
+ <div className="n-ask-sources">
8
+ <details>
9
+ <summary>
10
+ <h4 class="n-ask-sources-title">Sources:</h4>
11
+ <Icon name="caretRight" />
12
+ </summary>
13
+
14
+ <ul>
15
+ {sources.map((source, index) => {
16
+ if (!source.title) return;
17
+
18
+ return (
19
+ <li key={index}>
20
+ <a href={source.source_url} target="_blank" rel="noopener noreferrer">
21
+ {source.title}
22
+ {source.subtitle && source.subtitle !== source.title && (
23
+ <span> - {source.subtitle}</span>
24
+ )}
25
+ </a>
26
+ </li>
27
+ );
28
+ })}
29
+ </ul>
30
+ </details>
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1,50 @@
1
+ import type { QuerySubmitPayload, AnswerGenerationCompletedPayload } from '@kapaai/react-sdk';
2
+ import { useRef, useCallback } from 'preact/hooks';
3
+ import Analytics from '../../../../analytics/analytics';
4
+
5
+ /**
6
+ * Custom hook that tracks analytics events related to Ask Netlify and pushes them to the Google Analytics 4 (GA4) data layer.
7
+ *
8
+ * This hook captures two key interaction events and pushes their payloads to the `dataLayer`, enabling tracking in GA4:
9
+ * - `ask:new_query`: Triggered when a user submits a new question. The payload includes the question text and a thread ID.
10
+ * - `ask:answer_generated`: Triggered when a generated answer is completed. The payload includes the question ID and the length of the answer.
11
+ *
12
+ * Internally, the hook uses an instance of the `Analytics` class to structure and dispatch events. All event payloads are pushed to `window.dataLayer` to be consumed by Google Tag Manager and GA4.
13
+ *
14
+ * @returns {Object} - An object with the following functions:
15
+ * - `handleNewQuery`: Callback to be invoked when a user submits a new question. Sends a `ask:new_query` event with:
16
+ * - `question` (string): The user-submitted question.
17
+ * - `thread_id` (string): A unique identifier for the conversation thread.
18
+ * - `handleAnswer`: Callback to be invoked when a answer is returned. Sends a `ask:answer_generated` event with:
19
+ * - `question_id` (string): The ID linking the question to its answer.
20
+ * - `answer_length` (number): The character length of the generated answer.
21
+
22
+ */
23
+
24
+ export function useAskAnalytics() {
25
+ const ref = useRef<Analytics>(new Analytics());
26
+ const analytics = ref.current;
27
+
28
+ const handleNewQuery = useCallback((data: QuerySubmitPayload) => {
29
+ if (!data.question || !data.threadId) return;
30
+
31
+ analytics?.track('ask:new_query', {
32
+ question: data.question,
33
+ thread_id: data.threadId,
34
+ });
35
+ }, []);
36
+
37
+ const handleAnswer = useCallback((data: AnswerGenerationCompletedPayload) => {
38
+ if (!data.questionAnswerId || !data.answer) return;
39
+
40
+ analytics?.track('ask:answer_generated', {
41
+ question_id: data.questionAnswerId,
42
+ answer_length: data.answer.length,
43
+ });
44
+ }, []);
45
+
46
+ return {
47
+ handleNewQuery,
48
+ handleAnswer,
49
+ };
50
+ }
@@ -67,7 +67,7 @@ const AskNetlify: FunctionComponent = () => {
67
67
  y="7.3"
68
68
  width="3"
69
69
  height="2"
70
- fill="var(--search-bg-color, currentColor)"
70
+ fill="var(--n-ask-netlify-eyelid-color, currentColor)"
71
71
  />
72
72
  <rect
73
73
  id="ask-netlify-eyelid-right"
@@ -75,7 +75,7 @@ const AskNetlify: FunctionComponent = () => {
75
75
  y="7.3"
76
76
  width="3"
77
77
  height="2"
78
- fill="var(--search-bg-color, currentColor)"
78
+ fill="var(--n-ask-netlify-eyelid-color, currentColor)"
79
79
  />
80
80
  </>
81
81
  );
@@ -33,11 +33,16 @@
33
33
  }
34
34
 
35
35
  & .n-search-link-icon :where(#ask-netlify-eyelid-left, #ask-netlify-eyelid-right) {
36
+ --n-ask-netlify-eyelid-color: var(--n-search-color-bg-2);
36
37
  animation: askEyeBlink 4s infinite;
37
38
  animation-delay: 200ms;
38
39
  }
39
40
  }
40
41
 
42
+ .n-search-link-icon :where(#ask-netlify-eyelid-left, #ask-netlify-eyelid-right) {
43
+ --n-ask-netlify-eyelid-color: var(--search-bg-color);
44
+ }
45
+
41
46
  .n-search-link-title {
42
47
  font-weight: var(--font-weight-medium);
43
48
  color: var(--color-text-1);
@@ -1,5 +1,5 @@
1
1
  import type { SearchLinkProps } from '../../types/search.types';
2
- import { useSearchLogger } from '../../hooks';
2
+ import { useSearchAnalytics } from '../../hooks';
3
3
  import './SearchLink.css';
4
4
 
5
5
  import Icon from '../../../Icon';
@@ -12,8 +12,9 @@ const SearchLink = ({
12
12
  excerpt,
13
13
  resource,
14
14
  onClick,
15
+ children,
15
16
  }: SearchLinkProps) => {
16
- const { handleClick: log } = useSearchLogger();
17
+ const { handleClick: trackClick } = useSearchAnalytics();
17
18
 
18
19
  return (
19
20
  <Component
@@ -21,7 +22,7 @@ const SearchLink = ({
21
22
  href={url}
22
23
  onClick={(e: Event) => {
23
24
  onClick && onClick();
24
- log(e);
25
+ trackClick(e);
25
26
  }}
26
27
  >
27
28
  {icon && (
@@ -31,7 +32,8 @@ const SearchLink = ({
31
32
  )}
32
33
  <div className="n-search-link-body">
33
34
  <p className="n-search-link-title">
34
- <span className="n-search-link-label">{label}</span>{' '}
35
+ {label && <span className="n-search-link-label">{label}</span>}
36
+ {children && <span className="n-search-link-label">{children}</span>}
35
37
  {resource && (
36
38
  <span className="n-search-link-badge" data-resource={resource}>
37
39
  {resource}
@@ -0,0 +1,19 @@
1
+ import SearchLink from '../components/SearchLink/SearchLink';
2
+ import { THEMES } from '../../../../utils/types';
3
+ import { handleThemeChange, ThemeMap } from '../../../../utils/theme';
4
+
5
+ export default function SearchLinkThemeToggle() {
6
+ return (
7
+ <SearchLink
8
+ as="button"
9
+ icon="lightbulb"
10
+ label="Toggle theme"
11
+ onClick={() => {
12
+ const isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
13
+ const currentTheme = document.documentElement.getAttribute('data-theme');
14
+ const theme = isDarkTheme ? 'dark' : currentTheme ? currentTheme : 'light';
15
+ theme && handleThemeChange(ThemeMap[theme as THEMES]);
16
+ }}
17
+ />
18
+ );
19
+ }
@@ -1,6 +1,7 @@
1
1
  @import '../../../KeyboardKey/KeyboardKey.css';
2
2
  @import '../SearchHeading/SearchHeading.css';
3
3
  @import '../SearchLink/SearchLink.css';
4
+ @import '../../../../../styles/loaders.css';
4
5
 
5
6
  /* Root Variables */
6
7
  .n-search-modal {
@@ -26,9 +27,10 @@
26
27
  width: min(var(--n-search-max-w), 100%);
27
28
  margin: auto;
28
29
  background: var(--n-search-color-bg);
30
+ transition-delay: 200ms;
29
31
  }
30
32
 
31
- .n-search-modal-ask {
33
+ .n-search-modal[data-state='ask'] {
32
34
  --n-search-max-w: 800px;
33
35
  }
34
36
 
@@ -90,6 +92,7 @@
90
92
 
91
93
  .n-search-links {
92
94
  padding: var(--space-2xs);
95
+ height: 100%;
93
96
  }
94
97
 
95
98
  .n-search-label {
@@ -98,6 +101,16 @@
98
101
  align-items: center;
99
102
  }
100
103
 
104
+ .n-results-list {
105
+ padding-block-end: var(--space-2xs);
106
+ }
107
+
108
+ .n-results-info {
109
+ font-family: var(--font-family-display);
110
+ font-size: var(--step--1);
111
+ padding-inline: var(--space-xs);
112
+ }
113
+
101
114
  .n-search-label > * {
102
115
  display: inline-block;
103
116
  margin: 0;
@@ -111,8 +124,8 @@
111
124
  }
112
125
 
113
126
  .n-search-term {
114
- font-weight: var(--font-medium);
115
- font-size: 1.1em;
127
+ font-weight: var(--font-bold);
128
+ color: var(--n-search-color-text-secondary);
116
129
  }
117
130
 
118
131
  /* Search Results */
@@ -126,6 +139,12 @@
126
139
  background: var(--n-search-color-bg);
127
140
  }
128
141
 
142
+ .n-search-feedback {
143
+ height: calc(100% - 70px);
144
+ display: grid;
145
+ place-content: center;
146
+ }
147
+
129
148
  /* Footer */
130
149
  .n-search-footer {
131
150
  position: relative;