Skip to content

Commit 5ac9d72

Browse files
authored
styling updates and get all results (#22809)
1 parent 8e46442 commit 5ac9d72

2 files changed

Lines changed: 66 additions & 68 deletions

File tree

components/Search.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
top: 0;
2424
right: 0;
2525
width: 0;
26-
border-radius: 3px;
26+
border-radius: 0 0 0 3px;
2727
background: var(--color-canvas-default);
2828
box-shadow: 0 1px 15px rgba(0, 0, 0, 0.15);
2929
transition: width 0.3s ease-in-out;

components/Search.tsx

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -265,74 +265,72 @@ function ShowSearchResults({
265265
>
266266
<div data-testid="search-results" className="mt-n2 mb-n2">
267267
<ActionList
268-
items={results
269-
.slice(0, results.length - 1)
270-
.map(({ url, breadcrumbs, title, content, score, popularity }) => {
271-
return {
272-
key: url,
273-
text: title,
274-
renderItem: () => (
275-
<ActionList.Item as="div">
276-
<Link href={url} className="no-underline color-fg-default">
277-
<li
278-
key={url}
279-
data-testid="search-result"
280-
className={cx('list-style-none')}
281-
>
282-
<div className={cx('py-2 px-3')}>
283-
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
284-
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>
285-
{breadcrumbs.length === 0
286-
? title.replace(/<\/?[^>]+(>|$)|(\/)/g, '')
287-
: breadcrumbs
288-
.split(' / ')
289-
.slice(0, 1)
290-
.join(' ')
291-
.replace(/<\/?[^>]+(>|$)|(\/)/g, '')}
292-
</Label>
293-
{debug && (
294-
<small className="float-right">
295-
score: {score.toFixed(4)} popularity: {popularity.toFixed(4)}
296-
</small>
268+
items={results.map(({ url, breadcrumbs, title, content, score, popularity }) => {
269+
return {
270+
key: url,
271+
text: title,
272+
renderItem: () => (
273+
<ActionList.Item as="div">
274+
<Link href={url} className="no-underline color-fg-default">
275+
<li
276+
key={url}
277+
data-testid="search-result"
278+
className={cx('list-style-none')}
279+
>
280+
<div className={cx('py-2 px-3')}>
281+
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
282+
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>
283+
{breadcrumbs.length === 0
284+
? title.replace(/<\/?[^>]+(>|$)|(\/)/g, '')
285+
: breadcrumbs
286+
.split(' / ')
287+
.slice(0, 1)
288+
.join(' ')
289+
.replace(/<\/?[^>]+(>|$)|(\/)/g, '')}
290+
</Label>
291+
{debug && (
292+
<small className="float-right">
293+
score: {score.toFixed(4)} popularity: {popularity.toFixed(4)}
294+
</small>
295+
)}
296+
<div
297+
className={cx(
298+
styles.searchResultTitle,
299+
'mt-2 d-block f4 text-semibold'
297300
)}
298-
<div
299-
className={cx(
300-
styles.searchResultTitle,
301-
'mt-2 d-block f4 text-semibold'
302-
)}
303-
dangerouslySetInnerHTML={{
304-
__html: title,
305-
}}
306-
/>
307-
<div
308-
className={cx(
309-
styles.searchResultContent,
310-
'mt-1 d-block overflow-hidden'
311-
)}
312-
style={{ maxHeight: '2.5rem' }}
313-
dangerouslySetInnerHTML={{ __html: content }}
314-
/>
315-
<div
316-
className={'d-block mt-2 opacity-60 text-small'}
317-
dangerouslySetInnerHTML={
318-
breadcrumbs.length === 0
319-
? { __html: `${title}`.replace(/<\/?[^>]+(>|$)|(\/)/g, '') }
320-
: {
321-
__html: breadcrumbs
322-
.split(' / ')
323-
.slice(0, breadcrumbs.length - 1)
324-
.join(' / ')
325-
.replace(/<\/?[^>]+(>|$)/g, ''),
326-
}
327-
}
328-
/>
329-
</div>
330-
</li>
331-
</Link>
332-
</ActionList.Item>
333-
),
334-
}
335-
})}
301+
dangerouslySetInnerHTML={{
302+
__html: title,
303+
}}
304+
/>
305+
<div
306+
className={cx(
307+
styles.searchResultContent,
308+
'mt-1 d-block overflow-hidden'
309+
)}
310+
style={{ maxHeight: '2.5rem' }}
311+
dangerouslySetInnerHTML={{ __html: content }}
312+
/>
313+
<div
314+
className={'d-block mt-2 opacity-60 text-small'}
315+
dangerouslySetInnerHTML={
316+
breadcrumbs.length === 0
317+
? { __html: `${title}`.replace(/<\/?[^>]+(>|$)|(\/)/g, '') }
318+
: {
319+
__html: breadcrumbs
320+
.split(' / ')
321+
.slice(0, breadcrumbs.length - 1)
322+
.join(' / ')
323+
.replace(/<\/?[^>]+(>|$)/g, ''),
324+
}
325+
}
326+
/>
327+
</div>
328+
</li>
329+
</Link>
330+
</ActionList.Item>
331+
),
332+
}
333+
})}
336334
/>
337335
</div>
338336
</Overlay>

0 commit comments

Comments
 (0)