-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add filter example in the example repo
skill tree listens and collapses trees when treeid doesn't match filter query add memoization to functions for small performance iprovements update broken type
- Loading branch information
1 parent
84a16e5
commit f190abe
Showing
10 changed files
with
178 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
|
||
interface Props { | ||
handleFilter: (query: string) => void; | ||
} | ||
|
||
function FilterInput(props: Props) { | ||
const { handleFilter } = props; | ||
return ( | ||
<input | ||
style={{ height: '32px' }} | ||
onChange={e => handleFilter(e.target.value)} | ||
placeholder="Search for skill..." | ||
/> | ||
); | ||
} | ||
|
||
export default FilterInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useEffect, useContext } from 'react'; | ||
import FilterContext from '../../context/FilterContext'; | ||
|
||
interface Props { | ||
setVisibility: (isVisible: boolean) => void; | ||
isVisible: boolean; | ||
treeId: string; | ||
} | ||
|
||
function FilterListener({ setVisibility, isVisible, treeId }: Props) { | ||
const { filtersMatches } = useContext(FilterContext); | ||
|
||
useEffect(() => { | ||
if (!filtersMatches) { | ||
if (isVisible === true) return; | ||
|
||
return setVisibility(true); | ||
} | ||
|
||
if (!filtersMatches.has(treeId)) { | ||
if (isVisible === false) return; | ||
return setVisibility(false); | ||
} | ||
|
||
if (isVisible === true) return; | ||
return setVisibility(true); | ||
}, [filtersMatches]); | ||
|
||
return null; | ||
} | ||
|
||
export default FilterListener; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters