Skip to content

Commit f20a531

Browse files
committed
Improve page search.
1 parent 556fcfb commit f20a531

34 files changed

Lines changed: 713 additions & 285 deletions

File tree

‎frontend/purestack.studio/components/site/search-box/search-box.mdx‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ The live field above searches the real documentation index. Try a matching term,
8686
<div class="component-appearance-cell">
8787
<code>Empty query</code>
8888
<p class="m-0">
89-
The search field is visible; the results region stays hidden until a
90-
query is entered.
89+
Focus the search field to see a search prompt. Enter at least two
90+
characters to search the site.
9191
</p>
9292
</div>
9393
<div class="component-appearance-cell">
@@ -114,7 +114,7 @@ The live field above searches the real documentation index. Try a matching term,
114114
</div>
115115
</ComponentExample>
116116

117-
The current implementation derives its placeholder from site.siteTitle, even when a placeholder prop is supplied. Use the site title to configure the visible default; the API below describes the accepted prop separately.
117+
The default placeholder uses site.siteTitle. Supply a placeholder prop to customize the field for its context.
118118

119119
## Feature map
120120

@@ -130,6 +130,8 @@ This component exposes tone and variant, but no variantMode.
130130

131131
Pagefind indexes the built HTML, so new content appears after a successful indexed build. SearchBox does not fetch application records or replace autocomplete. Keyboard behavior and results are provided by the standard Pagefind search runtime.
132132

133+
Press `/` outside an editable field to focus the first visible search box. Use the up and down arrow keys to move between results, Enter to open the focused link, and Escape to dismiss the panel. Tab follows the normal link order. Result counts and search errors are announced to screen readers.
134+
133135
## API reference
134136

135137
<div class="api-overview">
@@ -179,8 +181,8 @@ Pagefind indexes the built HTML, so new content appears after a successful index
179181
defaultValue="Search + site title"
180182
>
181183
<p>
182-
The current component derives its placeholder from site.siteTitle. The
183-
registered placeholder prop is not read by the resolver.
184+
Custom field placeholder. When omitted, the component uses site.siteTitle,
185+
or simply Search when the site has no title.
184186
</p>
185187
</ApiProperty>
186188

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "purestack-repo",
4-
"version": "1.1.29",
4+
"version": "1.1.30",
55
"packageManager": "yarn@4.18.1",
66
"type": "module",
77
"sideEffects": false,

‎packages/purestack/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "purestack",
3-
"version": "1.1.29",
3+
"version": "1.1.30",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/purestack.mjs",
66
"types": "./dist/purestack.d.mts",

‎packages/purestack/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const version: string = '1.1.29'
1+
export const version: string = '1.1.30'
22

33
export * from '@purestack/ts-ssg'

‎packages/purestack/src/init/init.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ describe('project generation', () => {
782782
await readFile(path.join(unpacked, 'template', file), 'utf8'),
783783
)
784784
}
785-
})
785+
}, 20_000)
786786

787787
it('applies selected settings while preserving template configuration', async () => {
788788
const archive = await archiveFixture()

‎packages/ts-common/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@purestack/ts-common",
3-
"version": "1.1.29",
3+
"version": "1.1.30",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/ts-common.mjs",
66
"types": "./dist/ts-common.d.mts",

‎packages/ts-components/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@purestack/ts-components",
3-
"version": "1.1.29",
3+
"version": "1.1.30",
44
"packageManager": "yarn@4.9.2",
55
"module": "./dist/ts-components.mjs",
66
"types": "./dist/ts-components.d.mts",

‎packages/ts-components/src/standard/searchBox/searchBox.ts‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,26 @@ export interface SearchBox {
1212
}
1313

1414
const searchBoxTemplate = html`<div class="site-search" data-pagefind-search>
15-
<FormInputField
16-
icon="tabler:search"
17-
:tone="tone"
18-
:variant="variant"
19-
type="search"
20-
name="q"
21-
:placeholder="placeholder"
22-
autocomplete="off"
23-
spellcheck="false"
24-
data-pagefind-input
25-
aria-label="Search site content"/>
15+
<div class="site-search__control">
16+
<FormInputField
17+
icon="tabler:search"
18+
:tone="tone"
19+
:variant="variant"
20+
type="search"
21+
name="q"
22+
:placeholder="placeholder"
23+
autocomplete="off"
24+
spellcheck="false"
25+
data-pagefind-input
26+
aria-label="Search site content"/>
27+
<kbd class="site-search__shortcut" aria-hidden="true">/</kbd>
28+
</div>
29+
<span class="site-search__sr-only" data-pagefind-status role="status"></span>
2630
<div
27-
class="site-search__results doc-content"
31+
class="site-search__results"
2832
data-pagefind-results
33+
role="region"
34+
aria-label="Site search"
2935
hidden
3036
></div>
3137
</div>`
@@ -36,7 +42,9 @@ function defineSearchBoxComponent() {
3642
context: (head) => ({
3743
tone: head.props.tone,
3844
variant: head.props.variant,
39-
placeholder: resolveSearchPlaceholder(resolvePageContext(head)),
45+
placeholder:
46+
head.props.placeholder ??
47+
resolveSearchPlaceholder(resolvePageContext(head)),
4048
}),
4149
})
4250
}

0 commit comments

Comments
 (0)