Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 132475b

Browse files
authored
chore(dependencies): updated dependencies and removed some overrides (#2843)
1 parent a449b82 commit 132475b

15 files changed

Lines changed: 1650 additions & 1644 deletions

File tree

package-lock.json

Lines changed: 1508 additions & 1588 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"react-intl": "^6.1.1",
5858
"react-tabs": "5.1.0",
5959
"reading-time": "^1.5.0",
60+
"string-similarity": "^4.0.4",
6061
"typescript": "^4.8.3",
6162
"yaml": "^2.1.1"
6263
},
@@ -105,6 +106,7 @@
105106
"@types/react-click-outside-hook": "^1.0.0",
106107
"@types/react-dom": "^18.0.6",
107108
"@types/react-helmet": "^6.1.5",
109+
"@types/string-similarity": "^4.0.0",
108110
"@types/throttle-debounce": "^5.0.0",
109111
"@typescript-eslint/eslint-plugin": "^5.36.2",
110112
"@typescript-eslint/parser": "^5.36.2",
@@ -148,13 +150,6 @@
148150
"@mdx-js/react": {
149151
"react": "$react"
150152
},
151-
"react-element-to-jsx-string": {
152-
"react": "$react",
153-
"react-dom": "$react-dom"
154-
},
155-
"react-inspector": {
156-
"react": "$react"
157-
},
158153
"gatsby-theme-i18n": {
159154
"react": "$react",
160155
"react-dom": "$react-dom"

src/__fixtures__/hooks.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { ContributorApiResponse, Contributor } from '../hooks';
1+
import {
2+
ContributorApiResponse,
3+
Contributor,
4+
} from '../hooks/useNodeJsContributorsApi';
25

36
export const createRandomContributorApiData = (): ContributorApiResponse => ({
47
login: 'login_mock',

src/components/Codebox/index.module.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727

2828
.code {
2929
@extend %baseStyles;
30-
3130
font-weight: var(--font-weight-light);
3231
padding: 0 6px;
32+
33+
white-space: break-spaces;
3334
}
3435

3536
.pre {
@@ -108,8 +109,8 @@
108109
}
109110

110111
.code {
111-
background-color: var(--black2);
112-
color: var(--black9);
112+
background-color: var(--black9);
113+
color: var(--black2);
113114
}
114115

115116
a .code {

src/components/Codebox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const Codebox = ({ children: { props } }: Props): JSX.Element => {
6666
return (
6767
<pre className={classnames(styles.pre, replaceLanguages(className))}>
6868
<div className={styles.top}>
69-
<span>{replaceLanguages(language).toUpperCase()}</span>
69+
<span>{language.toUpperCase()}</span>
7070
<button type="button" onClick={handleCopyCode}>
7171
{copied ? 'copied' : 'copy'}
7272
</button>

src/components/DataTag/index.module.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
height: 2.4rem;
99
line-height: 2.4rem;
1010
margin-right: 0.8rem;
11+
min-width: 2.4rem;
1112
text-align: center;
1213
width: 2.4rem;
1314

src/components/Header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ReactComponent as LogoDark } from '../../images/logos/nodejs-logo-dark-
88
import SearchBar from '../SearchBar';
99
import DarkModeToggle from '../DarkModeToggle';
1010
import LanguageSelector from '../LanguageSelector';
11-
import { useFeatureToggles } from '../../hooks';
11+
import { useFeatureToggles } from '../../hooks/useFeatureToggles';
1212
import styles from './index.module.scss';
1313

1414
const Header = (): JSX.Element => {

src/components/RandomContributor/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { MutableRefObject, useRef } from 'react';
22
import { FormattedMessage } from 'react-intl';
33
import AnimatedPlaceholder from '../AnimatedPlaceholder';
4-
import { useNodeJsContributorsApi, useOnScreen } from '../../hooks';
4+
import { useOnScreen } from '../../hooks/useOnScreen';
5+
import { useNodeJsContributorsApi } from '../../hooks/useNodeJsContributorsApi';
56
import styles from './index.module.scss';
67

78
const RandomContributor = (): JSX.Element => {

src/components/SearchBar/index.module.scss

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
flex-direction: column;
66
height: fit-content;
77
max-height: 90vh;
8-
overflow-y: auto;
8+
overflow-y: hidden;
99

1010
&.expanded {
1111
padding-bottom: 10px;
@@ -58,6 +58,7 @@
5858
display: flex;
5959
flex-direction: column;
6060
height: 100%;
61+
overflow-y: scroll;
6162
width: 100%;
6263

6364
.loading-wrapper {
@@ -89,9 +90,32 @@
8990
> a {
9091
text-decoration: none;
9192
text-overflow: ellipsis;
92-
text-transform: capitalize;
93+
94+
span {
95+
text-transform: capitalize;
96+
}
97+
98+
code {
99+
border-radius: 0.3rem;
100+
font-weight: var(--font-weight-light);
101+
padding: 0 6px;
102+
}
93103
}
94104
}
95105
}
96106
}
97107
}
108+
109+
:global(.light) {
110+
.search-content ul li > a > code {
111+
background-color: var(--black2);
112+
color: var(--black9);
113+
}
114+
}
115+
116+
:global(.dark) {
117+
.search-content ul li > a > code {
118+
background-color: var(--black9);
119+
color: var(--black2);
120+
}
121+
}

src/components/SearchBar/index.tsx

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import React, { useMemo, useEffect, useState, createRef } from 'react';
2-
import { graphql, useStaticQuery } from 'gatsby';
32
import { FormattedMessage } from 'react-intl';
43
import { LocalizedLink as Link } from 'gatsby-theme-i18n';
54
import TravelExploreIcon from '@mui/icons-material/TravelExplore';
65
import CloseIcon from '@mui/icons-material/Close';
76
import classNames from 'classnames';
87
import { AnimatePresence, motion } from 'framer-motion';
98
import { useClickOutside } from 'react-click-outside-hook';
10-
import { Index, SerialisedIndexData } from 'elasticlunr';
119
import SectionTitle from '../SectionTitle';
1210
import { SearchResult } from '../../types';
13-
import styles from './index.module.scss';
1411
import useKeyPress from '../../hooks/useKeyPress';
12+
import { useSearchResults } from '../../hooks/useSearchResults';
13+
import styles from './index.module.scss';
1514

1615
const containerTransition = { type: 'spring', damping: 22, stiffness: 150 };
1716
const containerVariants = {
@@ -32,46 +31,22 @@ const containerVariants = {
3231
const MotionCloseIcon = motion(CloseIcon);
3332

3433
const SearchBar = (): JSX.Element => {
35-
const { siteSearchIndex } = useStaticQuery(graphql`
36-
query localSearchLearnPages {
37-
siteSearchIndex {
38-
index
39-
}
40-
}
41-
`);
42-
43-
const resultData = siteSearchIndex.index as SerialisedIndexData<SearchResult>;
44-
4534
const [query, setQuery] = useState('');
46-
const [results, setResults] = useState<SearchResult[]>([]);
4735
const searchInputRef = createRef<HTMLInputElement>();
4836

49-
const isEmpty = !results || results.length === 0;
5037
const [isExpanded, setExpanded] = useState(false);
5138
const [parentRef, isClickedOutside] = useClickOutside();
5239

53-
const storeIndex = useMemo(
54-
() => Index.load<SearchResult>(resultData),
55-
[resultData]
56-
);
40+
const search = useSearchResults();
5741

58-
const searchForResults = (currentQuery: string) => {
59-
const currentResults = storeIndex
60-
.search(currentQuery, { expand: true })
61-
.map(({ ref }) => storeIndex.documentStore.getDoc(ref) as SearchResult);
42+
const results = useMemo(() => search(query), [query, search]);
6243

63-
setResults(currentResults.slice(0, 20));
64-
};
44+
const isEmpty = !results || results.length === 0;
6545

6646
const changeHandler = (e: React.ChangeEvent<HTMLInputElement>) => {
6747
e.preventDefault();
6848

69-
if (e.target.value === '') {
70-
setResults([]);
71-
}
72-
7349
setQuery(e.target.value);
74-
searchForResults(e.target.value);
7550
};
7651

7752
const expandContainer = () => {
@@ -81,7 +56,6 @@ const SearchBar = (): JSX.Element => {
8156
const collapseContainer = () => {
8257
setExpanded(false);
8358
setQuery('');
84-
setResults([]);
8559
};
8660

8761
useEffect(() => {
@@ -179,14 +153,19 @@ const SearchBar = (): JSX.Element => {
179153
{!isEmpty && (
180154
<ul>
181155
{results.map((result: SearchResult) => {
182-
const sectionPath = result.displayTitle
183-
? ['home', result.category, result.title]
184-
: ['home', result.category];
156+
const sectionPath =
157+
result.category === 'api'
158+
? ['home', result.category, result.title]
159+
: ['home', result.category];
160+
161+
const displayTitle = result.displayTitle || result.title;
185162

186163
return (
187164
<li key={result.id}>
188165
<Link to={result.slug}>
189-
<span>{result.displayTitle || result.title}</span>
166+
{(result.wrapInCode && <code>{displayTitle}</code>) || (
167+
<span>{displayTitle}</span>
168+
)}
190169
</Link>
191170
<SectionTitle path={sectionPath} />
192171
</li>

0 commit comments

Comments
 (0)