@kawapress/plugin-search 0.0.1 → 0.1.0

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.
package/README.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta version"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm version"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="documentation build"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT license"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 or newer">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.zh-CN.md">简体中文</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress is in beta. It is ready for testing and early projects, but APIs may change before 0.1.0. Please pin the version when adopting it today.
31
+ If you run into any problems while using KawaPress, please [open an issue](https://github.com/ShenQingchuan/kawapress/issues). Your feedback helps shape the project during its early development.
33
32
 
34
33
  ## Why KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress is an independent project. It is not a VitePress fork or a drop-in rep
47
46
 
48
47
  You need [Node.js](https://nodejs.org/) 22.12 or newer.
49
48
 
49
+ Create a new site with the scaffolder:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` and `yarn create kawapress my-kawapress-site` do the same thing. The scaffolder asks for a site title and a default language, and can install dependencies for you.
58
+
59
+ If you would rather see every file from the start, set the site up by hand:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/README.zh-CN.md CHANGED
@@ -16,7 +16,7 @@
16
16
  </p>
17
17
 
18
18
  <p align="center">
19
- <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress/beta?label=npm%20beta&color=42b883" alt="npm beta 版本"></a>
19
+ <a href="https://www.npmjs.com/package/kawapress"><img src="https://img.shields.io/npm/v/kawapress?label=npm&color=42b883" alt="npm 版本"></a>
20
20
  <a href="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml"><img src="https://github.com/ShenQingchuan/kawapress/actions/workflows/deploy-pages.yml/badge.svg" alt="文档构建状态"></a>
21
21
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ShenQingchuan/kawapress" alt="MIT 许可"></a>
22
22
  <img src="https://img.shields.io/badge/Node.js-%E2%89%A522.12-339933?logo=nodedotjs&logoColor=white" alt="Node.js 22.12 或更高版本">
@@ -28,8 +28,7 @@
28
28
  <a href="https://github.com/ShenQingchuan/kawapress/blob/main/README.md">English</a>
29
29
  </p>
30
30
 
31
- > [!IMPORTANT]
32
- > KawaPress 目前处于 beta 阶段,适合试用和早期项目。0.1.0 之前,公开 API 仍可能调整;现阶段使用时请固定具体版本。
31
+ 使用 KawaPress 时遇到任何问题,欢迎到 [提交 Issue](https://github.com/ShenQingchuan/kawapress/issues) 反馈,一起参与本项目的早期建设。
33
32
 
34
33
  ## 为什么选择 KawaPress?
35
34
 
@@ -47,6 +46,18 @@ KawaPress 是一个独立项目,不是 VitePress 的分支或配置兼容层
47
46
 
48
47
  请先准备 [Node.js](https://nodejs.org/) 22.12 或更高版本。
49
48
 
49
+ 用脚手架创建新站点:
50
+
51
+ ```sh
52
+ npm create kawapress@latest my-kawapress-site
53
+ cd my-kawapress-site
54
+ npm run dev
55
+ ```
56
+
57
+ `pnpm create kawapress my-kawapress-site` 和 `yarn create kawapress my-kawapress-site` 的作用完全一样。脚手架会询问站点标题和默认语言,也可以顺便帮你安装依赖。
58
+
59
+ 如果你更想从零看清每个文件,可以手动创建:
60
+
50
61
  ```sh
51
62
  mkdir my-kawapress-site
52
63
  cd my-kawapress-site
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kawapress/plugin-search",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.1.0",
5
5
  "description": "Lazy local full-text search plugin for KawaPress",
6
6
  "license": "MIT",
7
7
  "homepage": "https://shenqingchuan.github.io/kawapress/",
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "peerDependencies": {
45
45
  "vue": "^3.5.41",
46
- "kawapress": "0.0.1"
46
+ "kawapress": "0.1.0"
47
47
  },
48
48
  "dependencies": {
49
49
  "@mdit-vue/plugin-frontmatter": "^3.0.2",
@@ -59,6 +59,6 @@
59
59
  "typescript": "^6.0.3",
60
60
  "vite": "^8.2.2",
61
61
  "vue": "^3.5.41",
62
- "kawapress": "0.0.1"
62
+ "kawapress": "0.1.0"
63
63
  }
64
64
  }
@@ -5,6 +5,7 @@ import './search.css'
5
5
  export default defineRuntimePlugin({
6
6
  name: '@kawapress/plugin-search',
7
7
  setup(api) {
8
+ api.addToOutlet('header.actions', { id: 'trigger', component: Search })
8
9
  api.vueApp((app) => {
9
10
  app.component('KawaSearch', Search)
10
11
  })
@@ -12,6 +12,8 @@ import { container as containerPlugin } from '@mdit/plugin-container'
12
12
  import {
13
13
  markdownPagePathToRoutePath,
14
14
  normalizeFrontmatterSource,
15
+ resolveHeadingTitle,
16
+ resolveLocaleIndex,
15
17
  resolvePageMetadata,
16
18
  stringifyJson,
17
19
  useMarkdownItPlugin,
@@ -230,7 +232,7 @@ export async function loadSearchIndexes(
230
232
  for (const file of files) {
231
233
  const source = await readFile(file, 'utf8')
232
234
  const route = markdownPagePathToRoutePath(relative(sourceRoot, file))
233
- const locale = getLocaleIndex(route, locales)
235
+ const locale = resolveLocaleIndex(route, locales)
234
236
  const index = localeIndexes[locale]
235
237
  if (index) {
236
238
  index.addAll(createSearchDocuments(
@@ -307,7 +309,7 @@ export function createSearchDocuments(
307
309
  if (token.type === 'heading_open') {
308
310
  finishSection()
309
311
  const inline = tokens[index + 1]
310
- const title = inline ? getInlineText(inline) : ''
312
+ const title = inline ? resolveHeadingTitle(inline) : ''
311
313
  const level = Number.parseInt(token.tag.slice(1), 10)
312
314
  if (!title || !Number.isInteger(level)) {
313
315
  continue
@@ -357,7 +359,7 @@ function getSearchPageHeaders(tokens: Token[]): Array<{
357
359
  continue
358
360
  }
359
361
  const level = Number.parseInt(token.tag.slice(1), 10)
360
- const title = tokens[index + 1] ? getInlineText(tokens[index + 1]) : ''
362
+ const title = tokens[index + 1] ? resolveHeadingTitle(tokens[index + 1]) : ''
361
363
  if (title && Number.isInteger(level)) {
362
364
  headers.push({ level, title })
363
365
  }
@@ -365,10 +367,6 @@ function getSearchPageHeaders(tokens: Token[]): Array<{
365
367
  return headers
366
368
  }
367
369
 
368
- function getInlineText(token: Token): string {
369
- return normalizeText(getInlineRawText(token))
370
- }
371
-
372
370
  function getInlineRawText(token: Token): string {
373
371
  return (token.children ?? [])
374
372
  .filter(child => child.type === 'text'
@@ -412,7 +410,7 @@ function getInlineSourceText(
412
410
  const inline = markdown.parseInline(source, {
413
411
  references: env.references,
414
412
  })[0]
415
- return inline ? getInlineText(inline) : ''
413
+ return inline ? normalizeText(getInlineRawText(inline)) : ''
416
414
  }
417
415
 
418
416
  function resolveGitHubAlertLabels(
@@ -455,17 +453,6 @@ async function findMarkdownFiles(directory: string): Promise<string[]> {
455
453
  return files.flat()
456
454
  }
457
455
 
458
- function getLocaleIndex(route: string, locales: string[]): string {
459
- const locale = locales
460
- .filter(item => item !== 'root')
461
- .sort((left, right) => right.length - left.length)
462
- .find((item) => {
463
- const prefix = `/${item}`
464
- return route === prefix || route.startsWith(`${prefix}/`)
465
- })
466
- return locale ?? 'root'
467
- }
468
-
469
456
  function isMarkdownFile(file: string, sourceRoot: string): boolean {
470
457
  const relativePath = relative(sourceRoot, file)
471
458
  return file.endsWith('.md')
package/src/search.css CHANGED
@@ -1,476 +1,397 @@
1
- .kawa-search-button,
2
- .kawa-search,
3
- .kawa-search * {
4
- box-sizing: border-box;
5
- }
6
-
7
- .kawa-search-button {
8
- display: grid;
9
- flex: none;
10
- place-items: center;
11
- width: 2.25rem;
12
- height: 2.25rem;
13
- padding: 0;
14
- color: var(--kawa-search-c-text-2, light-dark(
15
- oklch(0.5 0.012 286),
16
- oklch(0.68 0.012 286)
17
- ));
18
- font: inherit;
19
- background: transparent;
20
- border: 0;
21
- border-radius: 0.5rem;
22
- cursor: pointer;
23
- transition:
24
- color 180ms cubic-bezier(0.22, 1, 0.36, 1),
25
- background-color 180ms cubic-bezier(0.22, 1, 0.36, 1);
26
- }
27
-
28
- .kawa-search-button:hover {
29
- color: var(--kawa-search-c-text-1, light-dark(
30
- oklch(0.32 0.012 286),
31
- oklch(0.9 0.01 286)
32
- ));
33
- background: var(--kawa-search-c-bg-soft, light-dark(
34
- oklch(0.965 0.005 286),
35
- oklch(0.26 0.01 286)
36
- ));
37
- }
38
-
39
- .kawa-search-button:focus-visible,
40
- .kawa-search :where(button, a):focus-visible {
41
- outline: 2px solid var(--kawa-search-c-brand, light-dark(
42
- oklch(0.48 0.18 275),
43
- oklch(0.78 0.13 275)
44
- ));
45
- outline-offset: 2px;
46
- }
47
-
48
- .kawa-search-button svg,
49
- .kawa-search__icon,
50
- .kawa-search__close svg {
51
- width: 1.125rem;
52
- height: 1.125rem;
53
- fill: none;
54
- stroke: currentcolor;
55
- stroke-linecap: round;
56
- stroke-linejoin: round;
57
- stroke-width: 1.75;
58
- }
59
-
60
- .kawa-search-button__text,
61
- .kawa-search-button__keys {
62
- display: none;
63
- }
64
-
65
- .kawa-search {
66
- position: fixed;
67
- inset: 8vh auto auto 50%;
68
- width: min(calc(100vw - 2rem), 42rem);
69
- max-width: none;
70
- max-height: none;
71
- margin: 0;
72
- padding: 0;
73
- color: var(--kawa-search-c-text-1, light-dark(
74
- oklch(0.32 0.012 286),
75
- oklch(0.9 0.01 286)
76
- ));
77
- font-family: var(--kawa-search-font-family, system-ui, sans-serif);
78
- background: transparent;
79
- border: 0;
80
- overflow: visible;
81
- transform: translateX(-50%);
82
- animation: kawa-search-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
83
- }
1
+ @layer kawa.plugin {
2
+ :root {
3
+ /* Private to this plugin: a modal scrim has no shared token. */
4
+ --kawa-search-backdrop: light-dark(
5
+ oklch(0.12 0.01 286 / 58%),
6
+ oklch(0.02 0 0 / 72%)
7
+ );
8
+ /* Private to this plugin: the panel never grows past a readable width. */
9
+ --kawa-search-panel-width: 42rem;
10
+ }
84
11
 
85
- .kawa-search::backdrop {
86
- background: var(--kawa-search-backdrop, oklch(0.12 0.01 286 / 58%));
87
- animation: kawa-search-backdrop-enter 150ms ease-out;
88
- }
12
+ .kawa-search-button,
13
+ .kawa-search,
14
+ .kawa-search * {
15
+ box-sizing: border-box;
16
+ }
89
17
 
90
- .kawa-search__panel {
91
- display: flex;
92
- flex-direction: column;
93
- max-height: min(84dvh, 42rem);
94
- overflow: hidden;
95
- background: var(--kawa-search-c-bg, light-dark(
96
- oklch(0.995 0.002 286),
97
- oklch(0.22 0.008 286)
98
- ));
99
- border: 1px solid var(--kawa-search-c-border, light-dark(
100
- oklch(0.8 0.008 286),
101
- oklch(0.36 0.012 286)
102
- ));
103
- border-radius: 0.875rem;
104
- box-shadow: var(--kawa-search-shadow, 0 1.5rem 4rem oklch(0.08 0.01 286 / 28%));
105
- }
18
+ .kawa-search-button {
19
+ display: grid;
20
+ flex: none;
21
+ place-items: center;
22
+ width: 2.25rem;
23
+ height: 2.25rem;
24
+ padding: 0;
25
+ color: var(--kawa-c-text-2);
26
+ font: inherit;
27
+ background: transparent;
28
+ border: 0;
29
+ border-radius: 0.5rem;
30
+ cursor: pointer;
31
+ transition:
32
+ color 180ms cubic-bezier(0.22, 1, 0.36, 1),
33
+ background-color 180ms cubic-bezier(0.22, 1, 0.36, 1);
34
+ }
106
35
 
107
- .kawa-search__form {
108
- display: flex;
109
- flex: none;
110
- align-items: center;
111
- gap: 0.75rem;
112
- min-height: 3.75rem;
113
- margin: 0.75rem;
114
- padding: 0 0.875rem;
115
- background: var(--kawa-search-c-bg-soft, light-dark(
116
- oklch(0.965 0.005 286),
117
- oklch(0.26 0.01 286)
118
- ));
119
- border: 1px solid var(--kawa-search-c-divider, light-dark(
120
- oklch(0.9 0.006 286),
121
- oklch(0.29 0.01 286)
122
- ));
123
- border-radius: 0.625rem;
124
- }
36
+ .kawa-search-button:hover {
37
+ color: var(--kawa-c-text-1);
38
+ background: var(--kawa-c-bg-soft);
39
+ }
125
40
 
126
- .kawa-search__form:focus-within {
127
- border-color: var(--kawa-search-c-border, light-dark(
128
- oklch(0.8 0.008 286),
129
- oklch(0.36 0.012 286)
130
- ));
131
- }
41
+ .kawa-search-button:focus-visible,
42
+ .kawa-search :where(button, a):focus-visible {
43
+ outline: 2px solid var(--kawa-c-brand);
44
+ outline-offset: 2px;
45
+ }
132
46
 
133
- .kawa-search__icon {
134
- flex: none;
135
- color: var(--kawa-search-c-brand, light-dark(
136
- oklch(0.48 0.18 275),
137
- oklch(0.78 0.13 275)
138
- ));
139
- }
47
+ .kawa-search-button svg,
48
+ .kawa-search__icon,
49
+ .kawa-search__close svg {
50
+ width: 1.125rem;
51
+ height: 1.125rem;
52
+ fill: none;
53
+ stroke: currentcolor;
54
+ stroke-linecap: round;
55
+ stroke-linejoin: round;
56
+ stroke-width: 1.75;
57
+ }
140
58
 
141
- .kawa-search__label {
142
- position: absolute;
143
- width: 1px;
144
- height: 1px;
145
- padding: 0;
146
- margin: -1px;
147
- overflow: hidden;
148
- clip: rect(0, 0, 0, 0);
149
- white-space: nowrap;
150
- }
59
+ .kawa-search-button__text,
60
+ .kawa-search-button__keys {
61
+ display: none;
62
+ }
151
63
 
152
- .kawa-search__input {
153
- min-width: 0;
154
- width: 100%;
155
- padding: 0.75rem 0;
156
- color: inherit;
157
- font: inherit;
158
- font-size: 1rem;
159
- background: transparent;
160
- border: 0;
161
- outline: none;
162
- }
64
+ .kawa-search {
65
+ position: fixed;
66
+ inset: 8vh auto auto 50%;
67
+ width: min(calc(100vw - 2rem), var(--kawa-search-panel-width));
68
+ max-width: none;
69
+ max-height: none;
70
+ margin: 0;
71
+ padding: 0;
72
+ color: var(--kawa-c-text-1);
73
+ font-family: var(--kawa-font-sans);
74
+ background: transparent;
75
+ border: 0;
76
+ overflow: visible;
77
+ transform: translateX(-50%);
78
+ animation: kawa-search-enter 180ms cubic-bezier(0.22, 1, 0.36, 1);
79
+ }
163
80
 
164
- .kawa-search__input::placeholder {
165
- color: var(--kawa-search-c-text-3, light-dark(
166
- oklch(0.64 0.01 286),
167
- oklch(0.52 0.012 286)
168
- ));
169
- }
81
+ .kawa-search::backdrop {
82
+ background: var(--kawa-search-backdrop);
83
+ animation: kawa-search-backdrop-enter 150ms ease-out;
84
+ }
170
85
 
171
- .kawa-search__input::-webkit-search-cancel-button {
172
- display: none;
173
- }
86
+ .kawa-search__panel {
87
+ display: flex;
88
+ flex-direction: column;
89
+ max-height: min(84dvh, 42rem);
90
+ overflow: hidden;
91
+ background: var(--kawa-c-bg-elv);
92
+ border: 1px solid var(--kawa-c-border);
93
+ border-radius: 0.875rem;
94
+ box-shadow: var(--kawa-shadow-overlay);
95
+ }
174
96
 
175
- .kawa-search__close {
176
- display: grid;
177
- flex: none;
178
- place-items: center;
179
- width: 2rem;
180
- height: 2rem;
181
- padding: 0;
182
- color: var(--kawa-search-c-text-2, light-dark(
183
- oklch(0.5 0.012 286),
184
- oklch(0.68 0.012 286)
185
- ));
186
- background: transparent;
187
- border: 0;
188
- border-radius: 0.375rem;
189
- cursor: pointer;
190
- }
97
+ .kawa-search__form {
98
+ display: flex;
99
+ flex: none;
100
+ align-items: center;
101
+ gap: 0.75rem;
102
+ min-height: 3.75rem;
103
+ margin: 0.75rem;
104
+ padding: 0 0.875rem;
105
+ background: var(--kawa-c-bg-soft);
106
+ border: 1px solid var(--kawa-c-divider);
107
+ border-radius: 0.625rem;
108
+ }
191
109
 
192
- .kawa-search__close:hover {
193
- color: var(--kawa-search-c-text-1, light-dark(
194
- oklch(0.32 0.012 286),
195
- oklch(0.9 0.01 286)
196
- ));
197
- background: color-mix(in oklab, currentcolor 8%, transparent);
198
- }
110
+ .kawa-search__form:focus-within {
111
+ border-color: var(--kawa-c-border);
112
+ }
199
113
 
200
- .kawa-search__body {
201
- display: flex;
202
- min-height: 12rem;
203
- min-width: 0;
204
- overflow: hidden;
205
- border-top: 1px solid var(--kawa-search-c-divider, light-dark(
206
- oklch(0.9 0.006 286),
207
- oklch(0.29 0.01 286)
208
- ));
209
- }
114
+ .kawa-search__icon {
115
+ flex: none;
116
+ color: var(--kawa-c-brand);
117
+ }
210
118
 
211
- .kawa-search__state {
212
- display: flex;
213
- flex: 1;
214
- align-items: center;
215
- justify-content: center;
216
- gap: 0.75rem;
217
- min-height: 12rem;
218
- padding: 2rem;
219
- color: var(--kawa-search-c-text-2, light-dark(
220
- oklch(0.5 0.012 286),
221
- oklch(0.68 0.012 286)
222
- ));
223
- font-size: 0.875rem;
224
- text-align: center;
225
- }
119
+ .kawa-search__label {
120
+ position: absolute;
121
+ width: 1px;
122
+ height: 1px;
123
+ padding: 0;
124
+ margin: -1px;
125
+ overflow: hidden;
126
+ clip: rect(0, 0, 0, 0);
127
+ white-space: nowrap;
128
+ }
226
129
 
227
- .kawa-search__loader {
228
- width: 1rem;
229
- height: 1rem;
230
- border: 2px solid var(--kawa-search-c-divider, light-dark(
231
- oklch(0.9 0.006 286),
232
- oklch(0.29 0.01 286)
233
- ));
234
- border-top-color: var(--kawa-search-c-brand, light-dark(
235
- oklch(0.48 0.18 275),
236
- oklch(0.78 0.13 275)
237
- ));
238
- border-radius: 50%;
239
- animation: kawa-search-spin 700ms linear infinite;
240
- }
130
+ .kawa-search__input {
131
+ min-width: 0;
132
+ width: 100%;
133
+ padding: 0.75rem 0;
134
+ color: inherit;
135
+ font: inherit;
136
+ font-size: 1rem;
137
+ background: transparent;
138
+ border: 0;
139
+ outline: none;
140
+ }
241
141
 
242
- .kawa-search__retry {
243
- padding: 0.375rem 0.75rem;
244
- color: var(--kawa-search-c-brand, light-dark(
245
- oklch(0.48 0.18 275),
246
- oklch(0.78 0.13 275)
247
- ));
248
- font: inherit;
249
- font-weight: 600;
250
- background: transparent;
251
- border: 1px solid currentcolor;
252
- border-radius: 0.375rem;
253
- cursor: pointer;
254
- }
142
+ .kawa-search__input::placeholder {
143
+ color: var(--kawa-c-text-3);
144
+ }
255
145
 
256
- .kawa-search__results-scroll {
257
- width: 100%;
258
- max-height: min(62dvh, 32rem);
259
- padding: 0.5rem;
260
- overflow: auto;
261
- overscroll-behavior: contain;
262
- }
146
+ .kawa-search__input::-webkit-search-cancel-button {
147
+ display: none;
148
+ }
263
149
 
264
- .kawa-search__results {
265
- display: flex;
266
- flex-direction: column;
267
- gap: 0.125rem;
268
- margin: 0;
269
- padding: 0;
270
- list-style: none;
271
- }
150
+ .kawa-search__close {
151
+ display: grid;
152
+ flex: none;
153
+ place-items: center;
154
+ width: 2rem;
155
+ height: 2rem;
156
+ padding: 0;
157
+ color: var(--kawa-c-text-2);
158
+ background: transparent;
159
+ border: 0;
160
+ border-radius: 0.375rem;
161
+ cursor: pointer;
162
+ }
272
163
 
273
- .kawa-search-result {
274
- display: flex;
275
- flex-direction: column;
276
- gap: 0.25rem;
277
- padding: 0.75rem 0.875rem;
278
- color: inherit;
279
- text-decoration: none;
280
- border-radius: 0.5rem;
281
- outline: none;
282
- }
164
+ .kawa-search__close:hover {
165
+ color: var(--kawa-c-text-1);
166
+ background: color-mix(in oklab, currentcolor 8%, transparent);
167
+ }
283
168
 
284
- .kawa-search-result:hover,
285
- .kawa-search-result.is-selected {
286
- background: var(--kawa-search-c-bg-soft, light-dark(
287
- oklch(0.965 0.005 286),
288
- oklch(0.26 0.01 286)
289
- ));
290
- }
169
+ .kawa-search__body {
170
+ display: flex;
171
+ min-height: 12rem;
172
+ min-width: 0;
173
+ overflow: hidden;
174
+ border-top: 1px solid var(--kawa-c-divider);
175
+ }
291
176
 
292
- .kawa-search-result.is-selected {
293
- box-shadow: inset 0 0 0 1px var(--kawa-search-c-divider, light-dark(
294
- oklch(0.9 0.006 286),
295
- oklch(0.29 0.01 286)
296
- ));
297
- }
177
+ .kawa-search__state {
178
+ display: flex;
179
+ flex: 1;
180
+ align-items: center;
181
+ justify-content: center;
182
+ gap: 0.75rem;
183
+ min-height: 12rem;
184
+ padding: 2rem;
185
+ color: var(--kawa-c-text-2);
186
+ font-size: 0.875rem;
187
+ text-align: center;
188
+ }
298
189
 
299
- .kawa-search-result__path {
300
- color: var(--kawa-search-c-text-3, light-dark(
301
- oklch(0.64 0.01 286),
302
- oklch(0.52 0.012 286)
303
- ));
304
- font-size: 0.75rem;
305
- line-height: 1.4;
306
- }
190
+ .kawa-search__loader {
191
+ width: 1rem;
192
+ height: 1rem;
193
+ border: 2px solid var(--kawa-c-divider);
194
+ border-top-color: var(--kawa-c-brand);
195
+ border-radius: 50%;
196
+ animation: kawa-search-spin 700ms linear infinite;
197
+ }
307
198
 
308
- .kawa-search-result__title {
309
- color: var(--kawa-search-c-text-1, light-dark(
310
- oklch(0.32 0.012 286),
311
- oklch(0.9 0.01 286)
312
- ));
313
- font-size: 0.9375rem;
314
- font-weight: 650;
315
- line-height: 1.5;
316
- }
199
+ .kawa-search__retry {
200
+ padding: 0.375rem 0.75rem;
201
+ color: var(--kawa-c-brand);
202
+ font: inherit;
203
+ font-weight: 600;
204
+ background: transparent;
205
+ border: 1px solid currentcolor;
206
+ border-radius: 0.375rem;
207
+ cursor: pointer;
208
+ }
317
209
 
318
- .kawa-search-result__excerpt {
319
- display: -webkit-box;
320
- overflow: hidden;
321
- color: var(--kawa-search-c-text-2, light-dark(
322
- oklch(0.5 0.012 286),
323
- oklch(0.68 0.012 286)
324
- ));
325
- font-size: 0.8125rem;
326
- line-height: 1.55;
327
- -webkit-box-orient: vertical;
328
- -webkit-line-clamp: 2;
329
- }
210
+ .kawa-search__results-scroll {
211
+ width: 100%;
212
+ max-height: min(62dvh, 32rem);
213
+ padding: 0.5rem;
214
+ overflow: auto;
215
+ overscroll-behavior: contain;
216
+ }
330
217
 
331
- .kawa-search-result mark {
332
- padding: 0 0.1em;
333
- color: inherit;
334
- background: color-mix(
335
- in oklab,
336
- var(--kawa-search-c-brand, oklch(0.58 0.17 275)) 20%,
337
- transparent
338
- );
339
- border-radius: 0.15rem;
340
- }
218
+ .kawa-search__results {
219
+ display: flex;
220
+ flex-direction: column;
221
+ gap: 0.125rem;
222
+ margin: 0;
223
+ padding: 0;
224
+ list-style: none;
225
+ }
341
226
 
342
- .kawa-search__shortcuts {
343
- display: flex;
344
- flex: none;
345
- align-items: center;
346
- gap: 1rem;
347
- min-height: 2.75rem;
348
- padding: 0 1rem;
349
- color: var(--kawa-search-c-text-3, light-dark(
350
- oklch(0.64 0.01 286),
351
- oklch(0.52 0.012 286)
352
- ));
353
- font-size: 0.75rem;
354
- border-top: 1px solid var(--kawa-search-c-divider, light-dark(
355
- oklch(0.9 0.006 286),
356
- oklch(0.29 0.01 286)
357
- ));
358
- }
227
+ .kawa-search-result {
228
+ display: flex;
229
+ flex-direction: column;
230
+ gap: 0.25rem;
231
+ padding: 0.75rem 0.875rem;
232
+ color: inherit;
233
+ text-decoration: none;
234
+ border-radius: 0.5rem;
235
+ outline: none;
236
+ }
359
237
 
360
- .kawa-search__shortcuts span {
361
- display: flex;
362
- align-items: center;
363
- gap: 0.25rem;
364
- }
238
+ .kawa-search-result:hover,
239
+ .kawa-search-result.is-selected {
240
+ background: var(--kawa-c-bg-soft);
241
+ }
365
242
 
366
- .kawa-search__shortcuts kbd,
367
- .kawa-search-button__keys kbd {
368
- display: inline-grid;
369
- min-width: 1.25rem;
370
- min-height: 1.25rem;
371
- place-items: center;
372
- padding: 0 0.25rem;
373
- color: inherit;
374
- font: inherit;
375
- line-height: 1;
376
- background: color-mix(in oklab, currentcolor 8%, transparent);
377
- border: 1px solid var(--kawa-search-c-divider, light-dark(
378
- oklch(0.9 0.006 286),
379
- oklch(0.29 0.01 286)
380
- ));
381
- border-radius: 0.25rem;
382
- }
243
+ .kawa-search-result.is-selected {
244
+ box-shadow: inset 0 0 0 1px var(--kawa-c-divider);
245
+ }
383
246
 
384
- .kawa-search-button__command {
385
- display: none;
386
- }
247
+ .kawa-search-result__path {
248
+ color: var(--kawa-c-text-3);
249
+ font-size: 0.75rem;
250
+ line-height: 1.4;
251
+ }
387
252
 
388
- :root[data-kawa-platform='apple'] .kawa-search-button__command {
389
- display: inline;
390
- }
253
+ .kawa-search-result__title {
254
+ color: var(--kawa-c-text-1);
255
+ font-size: 0.9375rem;
256
+ font-weight: 650;
257
+ line-height: 1.5;
258
+ }
391
259
 
392
- :root[data-kawa-platform='apple'] .kawa-search-button__control {
393
- display: none;
394
- }
260
+ .kawa-search-result__excerpt {
261
+ display: -webkit-box;
262
+ overflow: hidden;
263
+ color: var(--kawa-c-text-2);
264
+ font-size: 0.8125rem;
265
+ line-height: 1.55;
266
+ -webkit-box-orient: vertical;
267
+ -webkit-line-clamp: 2;
268
+ }
395
269
 
396
- @media (min-width: 48rem) {
397
- .kawa-search-button {
398
- display: flex;
399
- width: auto;
400
- gap: 0.625rem;
401
- padding: 0 0.625rem;
402
- background: var(--kawa-search-c-bg-soft, light-dark(
403
- oklch(0.965 0.005 286),
404
- oklch(0.26 0.01 286)
405
- ));
270
+ .kawa-search-result mark {
271
+ padding: 0 0.1em;
272
+ color: inherit;
273
+ background: color-mix(in oklab, var(--kawa-c-brand) 20%, transparent);
274
+ border-radius: 0.15rem;
406
275
  }
407
276
 
408
- .kawa-search-button__text {
409
- display: inline;
410
- font-size: 0.8125rem;
411
- font-weight: 500;
277
+ .kawa-search__shortcuts {
278
+ display: flex;
279
+ flex: none;
280
+ align-items: center;
281
+ gap: 1rem;
282
+ min-height: 2.75rem;
283
+ padding: 0 1rem;
284
+ color: var(--kawa-c-text-3);
285
+ font-size: 0.75rem;
286
+ border-top: 1px solid var(--kawa-c-divider);
412
287
  }
413
288
 
414
- .kawa-search-button__keys {
289
+ .kawa-search__shortcuts span {
415
290
  display: flex;
416
291
  align-items: center;
417
- gap: 0.125rem;
418
- color: var(--kawa-search-c-text-3, light-dark(
419
- oklch(0.64 0.01 286),
420
- oklch(0.52 0.012 286)
421
- ));
292
+ gap: 0.25rem;
422
293
  }
423
- }
424
294
 
425
- @media (max-width: 39.999rem) {
426
- .kawa-search {
427
- inset: 0;
428
- width: 100%;
429
- transform: none;
430
- height: 100dvh;
295
+ .kawa-search__shortcuts kbd,
296
+ .kawa-search-button__keys kbd {
297
+ display: inline-grid;
298
+ min-width: 1.25rem;
299
+ min-height: 1.25rem;
300
+ place-items: center;
301
+ padding: 0 0.25rem;
302
+ color: inherit;
303
+ font: inherit;
304
+ line-height: 1;
305
+ background: color-mix(in oklab, currentcolor 8%, transparent);
306
+ border: 1px solid var(--kawa-c-divider);
307
+ border-radius: 0.25rem;
431
308
  }
432
309
 
433
- .kawa-search__panel {
434
- height: 100dvh;
435
- max-height: none;
436
- border: 0;
437
- border-radius: 0;
310
+ .kawa-search-button__command {
311
+ display: none;
438
312
  }
439
313
 
440
- .kawa-search__body,
441
- .kawa-search__results-scroll {
442
- flex: 1;
443
- max-height: none;
314
+ :root[data-kawa-platform='apple'] .kawa-search-button__command {
315
+ display: inline;
444
316
  }
445
317
 
446
- .kawa-search__shortcuts {
318
+ :root[data-kawa-platform='apple'] .kawa-search-button__control {
447
319
  display: none;
448
320
  }
449
- }
450
321
 
451
- @media (prefers-reduced-motion: reduce) {
452
- .kawa-search,
453
- .kawa-search::backdrop,
454
- .kawa-search__loader {
455
- animation: none;
322
+ @media (min-width: 48rem) {
323
+ .kawa-search-button {
324
+ display: flex;
325
+ width: auto;
326
+ gap: 0.625rem;
327
+ padding: 0 0.625rem;
328
+ background: var(--kawa-c-bg-soft);
329
+ }
330
+
331
+ .kawa-search-button__text {
332
+ display: inline;
333
+ font-size: 0.8125rem;
334
+ font-weight: 500;
335
+ }
336
+
337
+ .kawa-search-button__keys {
338
+ display: flex;
339
+ align-items: center;
340
+ gap: 0.125rem;
341
+ color: var(--kawa-c-text-3);
342
+ }
456
343
  }
457
- }
458
344
 
459
- @keyframes kawa-search-enter {
460
- from {
461
- opacity: 0;
462
- transform: translateX(-50%) translateY(-0.5rem) scale(0.985);
345
+ @media (max-width: 39.999rem) {
346
+ .kawa-search {
347
+ inset: 0;
348
+ width: 100%;
349
+ transform: none;
350
+ height: 100dvh;
351
+ }
352
+
353
+ .kawa-search__panel {
354
+ height: 100dvh;
355
+ max-height: none;
356
+ border: 0;
357
+ border-radius: 0;
358
+ }
359
+
360
+ .kawa-search__body,
361
+ .kawa-search__results-scroll {
362
+ flex: 1;
363
+ max-height: none;
364
+ }
365
+
366
+ .kawa-search__shortcuts {
367
+ display: none;
368
+ }
463
369
  }
464
- }
465
370
 
466
- @keyframes kawa-search-backdrop-enter {
467
- from {
468
- opacity: 0;
371
+ @media (prefers-reduced-motion: reduce) {
372
+ .kawa-search,
373
+ .kawa-search::backdrop,
374
+ .kawa-search__loader {
375
+ animation: none;
376
+ }
377
+ }
378
+
379
+ @keyframes kawa-search-enter {
380
+ from {
381
+ opacity: 0;
382
+ transform: translateX(-50%) translateY(-0.5rem) scale(0.985);
383
+ }
384
+ }
385
+
386
+ @keyframes kawa-search-backdrop-enter {
387
+ from {
388
+ opacity: 0;
389
+ }
469
390
  }
470
- }
471
391
 
472
- @keyframes kawa-search-spin {
473
- to {
474
- transform: rotate(360deg);
392
+ @keyframes kawa-search-spin {
393
+ to {
394
+ transform: rotate(360deg);
395
+ }
475
396
  }
476
397
  }