Skip to content

Commit e5b6cea

Browse files
authored
Merge branch 'main' into patch-2
2 parents 3b4030e + b7f0f7f commit e5b6cea

1,467 files changed

Lines changed: 11753 additions & 1061492 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ When using the GitHub logos, be sure to follow the [GitHub logo guidelines](http
6060

6161
## Thanks :purple_heart:
6262

63-
Thanks for all your contributions and efforts towards improving the GitHub documentation. We thank you being part of our :sparkles: community :sparkles:!
63+
Thanks for all your contributions and efforts towards improving the GitHub documentation. We thank you for being part of our :sparkles: community :sparkles:!
39.8 KB
Loading
1.38 KB
Loading
66.4 KB
Loading
148 KB
Loading
2.66 KB
Loading
3.73 KB
Loading
24.2 KB
Loading
3.57 KB
Loading

components/Search.tsx

Lines changed: 77 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React, { useState, useEffect, useRef, ReactNode, RefObject } from 'react'
22
import { useRouter } from 'next/router'
33
import useSWR from 'swr'
44
import cx from 'classnames'
5-
import { ActionList, DropdownMenu, Flash, Label } from '@primer/react'
6-
import { ItemInput } from '@primer/react/lib/ActionList/List'
5+
import { Flash, Label, ActionList, ActionMenu } from '@primer/react'
6+
import { ItemInput } from '@primer/react/lib/deprecated/ActionList/List'
77

88
import { useTranslation } from 'components/hooks/useTranslation'
99
import { sendEvent, EventType } from 'components/lib/events'
@@ -397,12 +397,25 @@ function ShowSearchResults({
397397
>
398398
Select version:
399399
</p>
400-
<DropdownMenu
401-
placeholder={searchVersion}
402-
items={searchVersions}
403-
selectedItem={selectedVersion}
404-
onChange={setSelectedVersion}
405-
/>
400+
<ActionMenu>
401+
<ActionMenu.Button sx={{ display: 'inline-block' }}>
402+
{selectedVersion ? selectedVersion.text : searchVersion}
403+
</ActionMenu.Button>
404+
<ActionMenu.Overlay>
405+
<ActionList selectionVariant="single">
406+
{searchVersions.map((searchVersion) => {
407+
return (
408+
<ActionList.Item
409+
onSelect={() => setSelectedVersion(searchVersion)}
410+
key={searchVersion.key}
411+
>
412+
{searchVersion.text}
413+
</ActionList.Item>
414+
)
415+
})}
416+
</ActionList>
417+
</ActionMenu.Overlay>
418+
</ActionMenu>
406419
</div>
407420
</div>
408421
{/* We might have results AND isLoading. For example, the user typed
@@ -419,67 +432,63 @@ function ShowSearchResults({
419432
{t('matches_displayed')}: {results.length === 0 ? t('no_results') : results.length}
420433
</p>
421434

422-
<ActionList
423-
items={results.map(({ url, breadcrumbs, title, content, score, popularity }) => {
424-
return {
425-
key: url,
426-
text: title,
427-
renderItem: () => (
428-
<ActionList.Item as="div">
429-
<Link href={url} className="no-underline color-fg-default">
430-
<li
431-
data-testid="search-result"
432-
className={cx('list-style-none', styles.resultsContainer)}
433-
>
434-
<div className={cx('py-2 px-3')}>
435-
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
436-
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>
437-
{breadcrumbs.length === 0
438-
? title.replace(/<\/?[^>]+(>|$)|(\/)/g, '')
439-
: breadcrumbs
440-
.split(' / ')
441-
.slice(0, 1)
442-
.join(' ')
443-
.replace(/<\/?[^>]+(>|$)|(\/)/g, '')}
444-
</Label>
445-
{debug && (
446-
<small className="float-right">
447-
score: {score.toFixed(4)} popularity: {popularity.toFixed(4)}
448-
</small>
449-
)}
450-
<h2
451-
className={cx('mt-2 text-normal f3 d-block')}
452-
dangerouslySetInnerHTML={{
453-
__html: title,
454-
}}
455-
/>
456-
<div
457-
className={cx(styles.searchResultContent, 'mt-1 d-block overflow-hidden')}
458-
style={{ maxHeight: '2.5rem' }}
459-
dangerouslySetInnerHTML={{ __html: content }}
460-
/>
461-
<div
462-
className={'d-block mt-2 opacity-70 text-small'}
463-
dangerouslySetInnerHTML={
464-
breadcrumbs.length === 0
465-
? { __html: `${title}`.replace(/<\/?[^>]+(>|$)|(\/)/g, '') }
466-
: {
467-
__html: breadcrumbs
468-
.split(' / ')
469-
.slice(0, breadcrumbs.length - 1)
470-
.join(' / ')
471-
.replace(/<\/?[^>]+(>|$)/g, ''),
472-
}
473-
}
474-
/>
475-
</div>
476-
</li>
477-
</Link>
478-
</ActionList.Item>
479-
),
480-
}
435+
<ActionList as="div" variant="full">
436+
{results.map(({ url, breadcrumbs, title, content, score, popularity }) => {
437+
return (
438+
<ActionList.Item className="width-full" key={url} as="div">
439+
<Link href={url} className="no-underline color-fg-default">
440+
<li
441+
data-testid="search-result"
442+
className={cx('list-style-none', styles.resultsContainer)}
443+
>
444+
<div className={cx('py-2 px-3')}>
445+
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
446+
<Label size="small" variant="accent">
447+
{breadcrumbs.length === 0
448+
? title.replace(/<\/?[^>]+(>|$)|(\/)/g, '')
449+
: breadcrumbs
450+
.split(' / ')
451+
.slice(0, 1)
452+
.join(' ')
453+
.replace(/<\/?[^>]+(>|$)|(\/)/g, '')}
454+
</Label>
455+
{debug && (
456+
<small className="float-right">
457+
score: {score.toFixed(4)} popularity: {popularity.toFixed(4)}
458+
</small>
459+
)}
460+
<h2
461+
className={cx('mt-2 text-normal f3 d-block')}
462+
dangerouslySetInnerHTML={{
463+
__html: title,
464+
}}
465+
/>
466+
<div
467+
className={cx(styles.searchResultContent, 'mt-1 d-block overflow-hidden')}
468+
style={{ maxHeight: '2.5rem' }}
469+
dangerouslySetInnerHTML={{ __html: content }}
470+
/>
471+
<div
472+
className={'d-block mt-2 opacity-70 text-small'}
473+
dangerouslySetInnerHTML={
474+
breadcrumbs.length === 0
475+
? { __html: `${title}`.replace(/<\/?[^>]+(>|$)|(\/)/g, '') }
476+
: {
477+
__html: breadcrumbs
478+
.split(' / ')
479+
.slice(0, breadcrumbs.length - 1)
480+
.join(' / ')
481+
.replace(/<\/?[^>]+(>|$)/g, ''),
482+
}
483+
}
484+
/>
485+
</div>
486+
</li>
487+
</Link>
488+
</ActionList.Item>
489+
)
481490
})}
482-
/>
491+
</ActionList>
483492
</div>
484493
)
485494
return <div>{ActionListResults}</div>

0 commit comments

Comments
 (0)