Skip to content

Commit 8d4b835

Browse files
CopilotSoonIter
andauthored
feat!: update @rspress/plugin-algolia to docsearch v4.1.0 (#2620)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: SoonIter <[email protected]> Co-authored-by: SoonIter <[email protected]>
1 parent 430fa0c commit 8d4b835

File tree

7 files changed

+349
-177
lines changed

7 files changed

+349
-177
lines changed

packages/plugin-algolia/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"reset": "rimraf ./**/node_modules"
4040
},
4141
"dependencies": {
42-
"@docsearch/css": "^3.9.0",
43-
"@docsearch/react": "^3.9.0"
42+
"@docsearch/css": "^4.1.0",
43+
"@docsearch/react": "^4.1.0"
4444
},
4545
"devDependencies": {
4646
"@microsoft/api-extractor": "^7.52.13",

packages/plugin-algolia/src/runtime/Search.css

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,34 @@
22
align-self: center;
33
}
44

5-
html:not(.rp-dark) {
6-
[class*='DocSearch'] {
7-
--docsearch-searchbox-background: var(--rp-c-bg-mute);
8-
--docsearch-primary-color: var(--rp-c-brand);
9-
--docsearch-highlight-color: var(--docsearch-primary-color);
10-
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
11-
}
12-
}
13-
14-
html.rp-dark [class*='DocSearch'] {
15-
--docsearch-searchbox-background: var(--rp-c-bg-mute);
5+
[class*='DocSearch'] {
166
--docsearch-primary-color: var(--rp-c-brand);
17-
--docsearch-highlight-color: var(--docsearch-primary-color);
18-
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--docsearch-primary-color);
7+
--docsearch-text-color: var(--rp-c-text-1);
8+
--docsearch-secondary-text-color: var(--rp-c-text-2);
9+
--docsearch-muted-color: var(--rp-c-text-2);
10+
--docsearch-subtle-color: var(--rp-c-divider);
1911

20-
--docsearch-searchbox-focus-background: var(--rp-c-bg-mute);
21-
--docsearch-modal-shadow: none;
22-
--docsearch-footer-shadow: none;
23-
--docsearch-logo-color: var(--rp-c-text-2);
24-
--docsearch-hit-background: var(--rp-c-dark-light-1);
25-
--docsearch-hit-color: var(--rp-c-text-2);
26-
--docsearch-hit-shadow: none;
12+
--docsearch-container-background: rgba(60, 60, 60, 0.4);
2713
--docsearch-modal-background: var(--rp-c-bg);
28-
--docsearch-footer-background: var(--rp-c-bg);
2914

30-
--docsearch-key-gradient: var(--rp-c-bg);
31-
--docsearch-key-shadow: var(--rp-c-bg-mute);
32-
--docsearch-text-color: var(--rp-c-text-2);
33-
--docsearch-muted-color: var(--rp-c-text-2);
34-
--docsearch-key-pressed-shadow: none;
15+
--docsearch-searchbox-background: var(--rp-c-bg-soft);
16+
--docsearch-searchbox-focus-background: var(--rp-c-bg);
17+
--docsearch-hit-color: var(--rp-c-text-1);
18+
--docsearch-hit-active-color: var(--rp-c-text-1);
19+
--docsearch-hit-background: var(--rp-c-bg-soft);
20+
--docsearch-hit-shadow: var(--rp-shadow-2);
21+
--docsearch-footer-background: var(--rp-c-bg-soft);
22+
23+
--docsearch-key-background: var(--rp-c-bg-mute);
24+
--docsearch-key-color: var(--rp-c-text-2);
25+
--docsearch-logo-color: var(--rp-c-text-2);
26+
--docsearch-highlight-color: var(--rp-c-brand);
27+
--docsearch-icon-color: var(--rp-c-text-2);
28+
--docsearch-background-color: var(--rp-c-bg);
29+
}
30+
31+
html.rp-dark [class*='DocSearch'] {
32+
--docsearch-container-background: rgba(0, 0, 0, 0.8);
3533
}
3634

3735
@media (max-width: 768px) {

packages/plugin-algolia/src/runtime/locales.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const ZH_LOCALES: Locales = {
1515
},
1616
modal: {
1717
searchBox: {
18-
resetButtonTitle: '清除查询条件',
19-
resetButtonAriaLabel: '清除查询条件',
20-
cancelButtonText: '取消',
21-
cancelButtonAriaLabel: '取消',
18+
clearButtonTitle: '清除查询条件',
19+
clearButtonAriaLabel: '清除查询条件',
20+
closeButtonText: '取消',
21+
closeButtonAriaLabel: '取消',
2222
},
2323
startScreen: {
2424
recentSearchesTitle: '搜索历史',
@@ -36,7 +36,7 @@ export const ZH_LOCALES: Locales = {
3636
selectText: '选择',
3737
navigateText: '切换',
3838
closeText: '关闭',
39-
searchByText: '搜索提供者',
39+
poweredByText: '搜索提供者',
4040
},
4141
noResultsScreen: {
4242
noResultsText: '无法找到相关结果',
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { describe, expect, test } from 'vitest';
2+
import { ZH_LOCALES } from '../src/runtime/locales';
3+
4+
describe('Docsearch v4 Locales', () => {
5+
test('should have correct translation property names for v4', () => {
6+
const zhLocale = ZH_LOCALES.zh;
7+
8+
// Check if the new v4 property names are used
9+
expect(
10+
zhLocale.translations?.modal?.searchBox?.clearButtonTitle,
11+
).toBeDefined();
12+
expect(
13+
zhLocale.translations?.modal?.searchBox?.clearButtonAriaLabel,
14+
).toBeDefined();
15+
expect(
16+
zhLocale.translations?.modal?.searchBox?.closeButtonText,
17+
).toBeDefined();
18+
expect(
19+
zhLocale.translations?.modal?.searchBox?.closeButtonAriaLabel,
20+
).toBeDefined();
21+
expect(zhLocale.translations?.modal?.footer?.poweredByText).toBeDefined();
22+
23+
// Check the actual values
24+
expect(zhLocale.translations?.modal?.searchBox?.clearButtonTitle).toBe(
25+
'清除查询条件',
26+
);
27+
expect(zhLocale.translations?.modal?.footer?.poweredByText).toBe(
28+
'搜索提供者',
29+
);
30+
31+
// Ensure old v3 properties are not used
32+
expect(
33+
(zhLocale.translations?.modal?.searchBox as any)?.resetButtonTitle,
34+
).toBeUndefined();
35+
expect(
36+
(zhLocale.translations?.modal?.footer as any)?.searchByText,
37+
).toBeUndefined();
38+
});
39+
40+
test('should have placeholder text', () => {
41+
const zhLocale = ZH_LOCALES.zh;
42+
expect(zhLocale.placeholder).toBe('搜索文档');
43+
});
44+
});

0 commit comments

Comments
 (0)