diff --git a/index.html b/index.html index 7b59572..621c6f3 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ html, body { font-family: "Calibri", "Arial", "Helvetica Neue", sans-serif; } -select { +select, input[type="text"] { padding: 8px; } diff --git a/lib/pages/vocabulary-page.tsx b/lib/pages/vocabulary-page.tsx index 5ca9a47..e625d85 100644 --- a/lib/pages/vocabulary-page.tsx +++ b/lib/pages/vocabulary-page.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useMemo, useState } from "react"; import { dilateBoundingBox, getBoundingBoxSize } from "../bounding-box"; import { createSvgSymbolContext, @@ -38,13 +38,31 @@ const SvgSymbol: React.FC = (props) => { export const VocabularyPage: React.FC<{}> = () => { const [ctx, setCtx] = useState(createSvgSymbolContext()); + const [filter, setFilter] = useState(""); + const finalFilter = filter.toLowerCase().replace(/ /g, "_"); + const items = useMemo( + () => + SvgVocabulary.items.filter((item) => + item.name.toLowerCase().includes(finalFilter) + ), + [finalFilter] + ); return ( <>

Mystic Symbolic Vocabulary

+
+ + setFilter(e.target.value)} + /> +
- {SvgVocabulary.items.map((symbolData) => ( + {items.map((symbolData) => (