From d393b145152234031f800be891793504974779ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mime=20=C4=8Cuvalo?= Date: Fri, 26 Apr 2024 15:22:22 +0100 Subject: [PATCH] examples: add filter input --- apps/examples/src/ExamplePage.tsx | 15 ++++++++++++++- apps/examples/src/styles.css | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/examples/src/ExamplePage.tsx b/apps/examples/src/ExamplePage.tsx index 94b4fbcae..221f0d71f 100644 --- a/apps/examples/src/ExamplePage.tsx +++ b/apps/examples/src/ExamplePage.tsx @@ -28,6 +28,10 @@ export function ExamplePage({ children: React.ReactNode }) { const categories = examples.map((e) => e.id) + const [filterValue, setFilterValue] = useState('') + const handleFilterChange = (e: React.ChangeEvent) => { + setFilterValue(e.target.value) + } return ( @@ -69,6 +73,12 @@ export function ExamplePage({ Develop +
    {categories.map((currentCategory) => (
  • @@ -76,7 +86,10 @@ export function ExamplePage({
      {examples .find((category) => category.id === currentCategory) - ?.value.map((sidebarExample) => ( + ?.value.filter((example) => + example.title.toLowerCase().includes(filterValue.toLowerCase()) + ) + .map((sidebarExample) => ( ul > li) { + display: block; +} + ul.example__sidebar__category__items { list-style: none; padding: 0px 0px 0px 4px;