diff --git a/README.md b/README.md
index c9daa42..6fa2fdf 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,8 @@
- [x] show also who knows this person
- [ ] login for different pod providers
- [x] faster (parallel) crawling
-- [ ] search people
+- [x] search people
+ - [ ] make it more accessible and easier to navigate
- [ ] highlight also people who know the person
- [ ] highlight people whose button is crawled in PersonList
- [ ] add custom starting point for crawling
diff --git a/src/components/PersonCard.tsx b/src/components/PersonCard.tsx
index 0e760ea..cc49352 100644
--- a/src/components/PersonCard.tsx
+++ b/src/components/PersonCard.tsx
@@ -10,70 +10,58 @@ interface Props {
const PersonCard = ({ person, knows, known, onSelectPerson }: Props) => {
return (
-
-
-
-
-
- {person.photo && (
-
-
-
-
-
- )}
-
- knows: {knows.length}
-
-
-
- {knows.map(friend => (
- onSelectPerson(friend.uri)}
- key={friend.uri}
- className="button is-link"
- >
- {friend.name}
-
- ))}
-
-
-
- known by: {known.length}
-
-
-
- {known.map(friend => (
- onSelectPerson(friend.uri)}
- key={friend.uri}
- className="button is-link"
- >
- {friend.name}
-
- ))}
-
-
-
+
+
+ {person.photo && (
+
+
+
+
-
+ )}
+
+ knows: {knows.length}
+
+
+
+ {knows.map(friend => (
+ onSelectPerson(friend.uri)}
+ key={friend.uri}
+ className="button is-link"
+ >
+ {friend.name}
+
+ ))}
+
+
+
+ known by: {known.length}
+
+
+
+ {known.map(friend => (
+ onSelectPerson(friend.uri)}
+ key={friend.uri}
+ className="button is-link"
+ >
+ {friend.name}
+
+ ))}
+
+
)
}
diff --git a/src/components/Search.tsx b/src/components/Search.tsx
new file mode 100644
index 0000000..c0b4755
--- /dev/null
+++ b/src/components/Search.tsx
@@ -0,0 +1,37 @@
+import React from 'react'
+
+interface Props {
+ onChange: (text: string) => void
+ onSelect: (text: string) => void
+ value: string
+ options: { value: string; label: string }[]
+}
+
+const Search: React.FC
= ({
+ onChange,
+ onSelect,
+ value,
+ options,
+ ...props
+}: Props) => (
+
+
onChange(e.target.value)}
+ />
+
+
+)
+
+export default Search
diff --git a/src/components/VisualizationContainer.tsx b/src/components/VisualizationContainer.tsx
index 1ed86f0..0c27347 100644
--- a/src/components/VisualizationContainer.tsx
+++ b/src/components/VisualizationContainer.tsx
@@ -6,6 +6,7 @@ import { Vector } from '../helpers/draw'
import { Grid } from '../helpers/draw'
import numeric from 'numeric'
import PersonCard from './PersonCard'
+import Search from './Search'
import { withRouter, RouteComponentProps } from 'react-router-dom'
import { PeopleContext, Person } from './DataContainer'
import { IriString } from '@inrupt/solid-client'
@@ -24,6 +25,31 @@ const transform = (matrix: number[][], vector: Vector): Vector => {
return [x, y]
}
+interface ICProps {
+ children: React.ReactNode
+}
+const InfoContainer = ({ children }: ICProps) => (
+
+)
+
type VisualizationNode = {
x: number
y: number
@@ -154,6 +180,8 @@ const VisualizationContainer: React.FC = ({
links: [],
})
+ const [search, setSearch] = useState('')
+
const [highlightedNode, setHighlightedNode] = useState()
const people = useContext(PeopleContext)
@@ -268,16 +296,41 @@ const VisualizationContainer: React.FC = ({
- {person && knows && known && (
-
- )}
+
+ {person && knows && known ? (
+
+ ) : (
+
+ )}
+
>
)
}
export default withRouter(VisualizationContainer)
+
+const selectSearchOptions = (
+ query: string,
+ people: PeopleGraph,
+): { value: string; label: string }[] => {
+ if (query.length < 2) return []
+ return Object.values(people)
+ .filter(
+ ({ name, uri }) =>
+ name.toLowerCase().includes(query.toLowerCase()) ||
+ uri.toLowerCase().includes(query.toLowerCase()),
+ )
+ .sort(({ known: a }, { known: b }) => (b?.size ?? 0) - (a?.size ?? 0))
+ .map(({ name, uri }) => ({ value: uri, label: name || uri }))
+ .slice(0, 10)
+}
diff --git a/src/index.scss b/src/index.scss
index a6489a1..1305564 100644
--- a/src/index.scss
+++ b/src/index.scss
@@ -4,6 +4,7 @@
@import '~bulma/sass/elements/button.sass';
@import '~bulma/sass/grid/columns.sass';
@import '~bulma/sass/components/card.sass';
+@import '~bulma/sass/components/menu.sass';
// You can use Bulma variables from here on