-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add search with autocomplete #27
Conversation
package.json
Outdated
}, | ||
"devDependencies": { | ||
"@next/eslint-plugin-next": "^12.1.6", | ||
"eslint": "^8.2.0", | ||
"json-server": "0.17.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix the formatting in this file
|
package.json
Outdated
"bootstrap": "5.1.3", | ||
"classnames": "2.3.1", | ||
"lodash": "4.17.21", | ||
"next": "12.1", | ||
"normalize.css": "8.0.1", | ||
"react": "17.0.2", | ||
"react-dom": "17.0.2", | ||
"react-responsive": "^9.0.0-beta.10", | ||
"sass": "^1.52.3", | ||
"react-responsive": "9.0.0-beta.10", | ||
"react-select": "^5.5.0", | ||
"sass": "1.52.3", | ||
"superagent": "7.1.1", | ||
"typograf": "^6.14.1" | ||
"typograf": "6.14.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why ^
symbols has been removed from this PR?
Please fix |
components/Search/Search.jsx
Outdated
@@ -0,0 +1,27 @@ | |||
import React from "react"; | |||
import Select from "react-select/base"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that react-select is redundant for this task. It's main feature is multiselect.
- a lot of unnecessary unused logic
- there is no modularity with 28 kb
(https://bundlephobia.com/package/[email protected])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic in our component is very different from react-search
For example, we have item groups with headings
export const SuggestionItem = ({ suggestion }) => ( | ||
<div> | ||
<h4> | ||
{suggestion.guide_name} / {suggestion.guide_section} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest adding the guide_name of the manual to the search
Cause: sections can be duplicated in different manuals
export const SearchInput = ({ isVisible }) => { | ||
const [suggestions, setSuggestions] = React.useState([]); | ||
const styleInputBlock = classNames(style.searchInput__container, { | ||
[style.hidden]: !isVisible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the hidden={!isVisible}
attribute. It will be great for accessibility
mock/search-data.mock.json
Outdated
"1": { | ||
"items": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE
It will have to return only an array. Key for simulating a user request
We have to ask the backend to limit the number of search results returned. If backend return 20 results — write |
TODO back-end We won't do it yet
|
import React from "react"; | ||
import { SuggestionItem } from "../SuggestionItem/SuggestionItem"; | ||
|
||
export const SearchSuggestionBlock = ({ suggestions }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SearchSuggestionBlock
-> SearchSuggestion
import React from "react"; | ||
import Link from "next/link"; | ||
|
||
export const SuggestionItem = ({ suggestion }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SuggestionItem
-> SearchSuggestionItem
components/ManualPage/ManualPage.jsx
Outdated
@@ -20,6 +22,8 @@ function ManualPage({ | |||
catalogIndex, | |||
children, | |||
}) { | |||
const [showSearchInput, setShowSearchInput] = React.useState(false); | |||
|
|||
const getLine = (columnList) => { | |||
if (!columnList.children.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columnList.children.length > 0
@@ -8,32 +8,37 @@ | |||
"lint:fix": "eslint --fix --ext .js,.jsx .", | |||
"prettier": "npx prettier --write .", | |||
"prepare": "husky install", | |||
"json-server": "json-server ./mock/search-data.mock.json --port 8088", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add to dev: "next dev & npm run json-server"
872e008
to
30631b2
Compare
left: calc(max(384px, 20%) + 15vw); | ||
opacity: 0; | ||
bottom: 0; | ||
transition: all .4s ease-in-out; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so slow)
animations more than 100-150ms seems very slow
border: 6px solid #EEEFF1; | ||
border-top: 6px solid #EEEFF1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
border-top
duplicates border
import styles from './SearchSuggestion.module.css' | ||
|
||
export function SearchSuggestion({ suggestions }) { | ||
if (suggestions.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the components less smart.
Let the parent component check whether the child component should be render.
ref={(input) => input?.focus()} | ||
className={style.input} | ||
onChange={debounce(async (e) => { | ||
const textInput = e.target.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this callback to separate function
Done in #47 |
json-server