Skip to content

Commit 6a6ad41

Browse files
authored
Merge pull request #12803 from github/repo-sync
repo sync
2 parents 6626cf4 + 078fdc9 commit 6a6ad41

77 files changed

Lines changed: 228 additions & 179 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.

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package.json @github/docs-engineering
1919
/.github/workflows/create-translation-batch-pr.yml @github/docs-localization
2020
/.github/workflows/crowdin.yml @github/docs-localization
2121
/crowdin*.yml @github/docs-engineering @github/docs-localization
22-
/translations/ @github/docs-engineering @github/docs-localization @github-actions
23-
/translations/log/ @github/docs-localization @github-actions
22+
/translations/ @github/docs-engineering @github/docs-localization @github-actions[bot]
23+
/translations/log/ @github/docs-localization @github-actions[bot]
2424

2525
# Site Policy
2626
/content/github/site-policy/ @github/site-policy-admins

components/Search.module.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@
4343
.headerSearchResults {
4444
max-height: 80vh;
4545
}
46+
47+
.searchWording {
48+
margin: 0.6rem 0 0.5rem 0.5rem;
49+
}
50+
51+
.selectWording {
52+
margin: 0.64rem 0.5rem 0 0;
53+
}

components/Search.tsx

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ 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, Label, Overlay } from '@primer/components'
5+
import { ActionList, DropdownMenu, Label, Overlay } from '@primer/components'
6+
import { ItemInput } from '@primer/components/lib/ActionList/List'
67

78
import { useTranslation } from 'components/hooks/useTranslation'
89
import { sendEvent, EventType } from 'components/lib/events'
910
import { useMainContext } from './context/MainContext'
10-
import { useVersion } from 'components/hooks/useVersion'
11+
import { DEFAULT_VERSION, useVersion } from 'components/hooks/useVersion'
1112
import { useQuery } from 'components/hooks/useQuery'
1213
import { Link } from 'components/Link'
1314
import { useLanguages } from './context/LanguagesContext'
@@ -294,6 +295,8 @@ function ShowSearchResults({
294295
const { currentVersion } = useVersion()
295296
const { allVersions } = useMainContext()
296297
const searchVersion = allVersions[currentVersion].versionTitle
298+
const [selectedVersion, setSelectedVersion] = useState<ItemInput | undefined>()
299+
297300
const latestVersions = new Set(
298301
Object.keys(allVersions)
299302
.map((version) => allVersions[version].latestVersion)
@@ -307,13 +310,39 @@ function ShowSearchResults({
307310
}
308311
})
309312

313+
const searchVersions: ItemInput[] = versions.map(({ title, version }) => {
314+
return {
315+
text: title,
316+
key: version,
317+
}
318+
})
319+
310320
const redirectParams: {
311321
query: string
312322
debug?: string
313323
} = { query }
324+
314325
if (debug) redirectParams.debug = JSON.stringify(debug)
326+
315327
const redirectQuery = `?${new URLSearchParams(redirectParams).toString()}`
316328

329+
useEffect(() => {
330+
if (selectedVersion) {
331+
const params = new URLSearchParams(redirectParams)
332+
let asPath = `/${router.locale}`
333+
334+
if (params.toString()) {
335+
asPath += `?${params.toString()}`
336+
}
337+
338+
if (selectedVersion.key === DEFAULT_VERSION) {
339+
router.push(`/?${params.toString()}`, asPath)
340+
} else {
341+
router.push(`/${router.locale}/${selectedVersion.key}${redirectQuery}`)
342+
}
343+
}
344+
}, [selectedVersion])
345+
317346
if (results) {
318347
if (results.length === 0) {
319348
// When there results, but exactly 0, it matters if this is the overlay or not.
@@ -341,22 +370,23 @@ function ShowSearchResults({
341370
isHeaderSearch && 'overflow-auto'
342371
)}
343372
>
344-
<div className="my-4">
345-
<p className="mx-4">
346-
You're searching the <span className="color-fg-attention">{searchVersion}</span>{' '}
347-
version. Didn't find what you're looking for? Click a different version to try again.
373+
<div className="mt-4 pb-6 width-full border-bottom">
374+
<p className={cx(styles.searchWording, 'f6 ml-4 d-inline-block')}>
375+
You're searching the <strong>{searchVersion}</strong> version.
348376
</p>
349-
{versions.map(({ title, version }) => {
350-
return (
351-
<button key={version} className="btn mr-2 mt-4 ml-4" type="button">
352-
<a href={`/${router.locale}/${version}${redirectQuery}`}>{title}</a>
353-
</button>
354-
)
355-
})}
377+
<div className="float-right mr-4">
378+
<p className={cx(styles.selectWording, 'f6 d-inline-block')}>Select version:</p>
379+
<DropdownMenu
380+
placeholder={searchVersion}
381+
items={searchVersions}
382+
selectedItem={selectedVersion}
383+
onChange={setSelectedVersion}
384+
/>
385+
</div>
356386
</div>
357387
{/* We might have results AND isLoading. For example, the user typed
358388
a first word, and is now typing more. */}
359-
<p className="d-block mt-4">
389+
<p className="d-block ml-4 mt-4">
360390
{isLoading ? <span>{t('loading')}...</span> : <span>&nbsp;</span>}
361391
</p>
362392

@@ -368,7 +398,10 @@ function ShowSearchResults({
368398
renderItem: () => (
369399
<ActionList.Item as="div">
370400
<Link href={url} className="no-underline color-fg-default">
371-
<li data-testid="search-result" className={cx('list-style-none')}>
401+
<li
402+
data-testid="search-result"
403+
className={cx('list-style-none', styles.resultsContainer)}
404+
>
372405
<div className={cx('py-2 px-3')}>
373406
{/* Breadcrumbs in search records don't include the page title. These fields may contain <mark> elements that we need to render */}
374407
<Label variant="small" sx={{ bg: 'accent.emphasis' }}>
@@ -425,9 +458,6 @@ function ShowSearchResults({
425458
<div>
426459
{!isHeaderSearch && !isMobileSearch ? (
427460
<>
428-
{/* Only if you're going to use an <Overlay> do you need
429-
to specify a portal div tag. */}
430-
<div id="__primerPortalRoot__" />
431461
<Overlay
432462
initialFocusRef={anchorRef}
433463
returnFocusRef={anchorRef}
@@ -436,17 +466,26 @@ function ShowSearchResults({
436466
onClickOutside={() => closeSearch()}
437467
aria-labelledby="title"
438468
sx={
439-
(isHeaderSearch && {
440-
background: 'none',
441-
boxShadow: 'none',
442-
position: 'static',
443-
overflowY: 'auto',
444-
maxHeight: '80vh',
445-
maxWidth: '96%',
446-
margin: '1.5em 2em 0 0.5em',
447-
scrollbarWidth: 'none',
448-
}) ||
449-
{}
469+
isHeaderSearch
470+
? {
471+
background: 'none',
472+
boxShadow: 'none',
473+
position: 'static',
474+
overflowY: 'auto',
475+
maxHeight: '80vh',
476+
maxWidth: '96%',
477+
margin: '1.5em 2em 0 0.5em',
478+
scrollbarWidth: 'none',
479+
}
480+
: window.innerWidth < 1012
481+
? {
482+
marginTop: '28rem',
483+
marginLeft: '5rem',
484+
}
485+
: {
486+
marginTop: '15rem',
487+
marginLeft: '5rem',
488+
}
450489
}
451490
>
452491
{ActionListResults}

components/hooks/useVersion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type VersionInfo = {
55
isEnterprise: boolean
66
isEnterpriseServer: boolean
77
}
8-
const DEFAULT_VERSION = 'free-pro-team@latest'
8+
export const DEFAULT_VERSION = 'free-pro-team@latest'
99
export const useVersion = (): VersionInfo => {
1010
const router = useRouter()
1111
const currentVersion = (router.query.versionId as string) || DEFAULT_VERSION
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
.header {
22
display: unset;
33
}
4+
5+
// Need children of portal root to be higher z-index to show dropdown
6+
.portalRoot * {
7+
z-index: 3 !important;
8+
}

components/page-header/Header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ export const Header = () => {
128128
</div>
129129
</div>
130130
</header>
131+
{/* Adding Portal Root here for DropdownMenu and ActionList Search Results */}
132+
<div id="__primerPortalRoot__" className={cx(styles.portalRoot)} />
131133
</div>
132134
)
133135
}

components/ui/BumpLink/BumpLink.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,11 @@ export type BumpLinkPropsT = {
1414
export const BumpLink = ({ as, children, href, title, className }: BumpLinkPropsT) => {
1515
const Component = as || 'a'
1616

17-
const symbol = <span className={styles.symbol}></span>
1817
let extendedTitle: ReactNode
1918
if (typeof title === 'string') {
20-
extendedTitle = (
21-
<span className="h4">
22-
{title} {symbol}
23-
</span>
24-
)
19+
extendedTitle = <span className="h4">{title}</span>
2520
} else {
26-
extendedTitle = cloneElement(title, title.props, title.props.children, symbol)
21+
extendedTitle = cloneElement(title, title.props, title.props.children)
2722
}
2823

2924
return (
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:4d7f912c32acbacc820bb0c417fa1df7de41b67f072d9237f3c913f332711e1a
3-
size 609489
2+
oid sha256:2d856fefcea1754920a6e4348a08888a378039af01ebd13d4fabc9cc6be6e7af
3+
size 609559
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:26b189615d8143df14319df1fba5d441280320cea0e0316a87682d6e6aedaf09
3-
size 1457922
2+
oid sha256:1e88ae8b315eef8d099366dd6af933cddf3abdfce1fabdb19eb1cbd02a9b7c89
3+
size 1458052
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:e8cb7b425945298089e833a4c1f2a6c5cca5b021ec2bde8cce0cedaeb6b596d7
3-
size 947205
2+
oid sha256:f3023a6b4fd1329485dc64f364e254cf265fa222dd6987d8629b363d72fd18b4
3+
size 947319

0 commit comments

Comments
 (0)