Add a search field in vocabulary page.
rodzic
a917f40da9
commit
9aa0c6118f
|
@ -6,7 +6,7 @@ html, body {
|
||||||
font-family: "Calibri", "Arial", "Helvetica Neue", sans-serif;
|
font-family: "Calibri", "Arial", "Helvetica Neue", sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select, input[type="text"] {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { useState } from "react";
|
import React, { useMemo, useState } from "react";
|
||||||
import { dilateBoundingBox, getBoundingBoxSize } from "../bounding-box";
|
import { dilateBoundingBox, getBoundingBoxSize } from "../bounding-box";
|
||||||
import {
|
import {
|
||||||
createSvgSymbolContext,
|
createSvgSymbolContext,
|
||||||
|
@ -38,13 +38,31 @@ const SvgSymbol: React.FC<SvgSymbolProps> = (props) => {
|
||||||
|
|
||||||
export const VocabularyPage: React.FC<{}> = () => {
|
export const VocabularyPage: React.FC<{}> = () => {
|
||||||
const [ctx, setCtx] = useState(createSvgSymbolContext());
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Mystic Symbolic Vocabulary</h1>
|
<h1>Mystic Symbolic Vocabulary</h1>
|
||||||
|
<div className="thingy">
|
||||||
|
<label htmlFor="filter">Search: </label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
id="filter"
|
||||||
|
value={filter}
|
||||||
|
onChange={(e) => setFilter(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<SymbolContextWidget ctx={ctx} onChange={setCtx} />
|
<SymbolContextWidget ctx={ctx} onChange={setCtx} />
|
||||||
<HoverDebugHelper>
|
<HoverDebugHelper>
|
||||||
{SvgVocabulary.items.map((symbolData) => (
|
{items.map((symbolData) => (
|
||||||
<div
|
<div
|
||||||
key={symbolData.name}
|
key={symbolData.name}
|
||||||
style={{
|
style={{
|
||||||
|
|
Ładowanie…
Reference in New Issue