import {Link} from "react-router-dom"; import {Card, CardContent, Grid, Typography} from "@mui/material"; import React from "react"; import examples from "../examples"; import { withStyles } from "tss-react/mui"; import TextField from '@mui/material/TextField'; const styles = { container: { flexGrow: 1, justifyContent: 'center', alignItems: 'center', marginTop: 16, }, card: { '&:hover': { background: 'lightgrey', fontWeight: 500, } }, cardContent: { '&:last-child': { padding: 8, } }, link: { textDecoration: 'none', }, label: { fontWeight: 'inherit' } }; class ExamplesGrid extends React.Component { state = { searchVal: '' } setSearchVal = (val) => { this.setState({ searchVal: val }); } render() { const {classes} = this.props; // Sort Examples alphabetically const examplesSorted = {}; Object.keys(examples).sort().forEach(function (key) { examplesSorted[key] = examples[key]; }); const examplesSortedKeys = Object.keys(examplesSorted).filter((item) => { if (this.state.searchVal === '') return true; console.dir(item); return item.toLowerCase().indexOf( this.state.searchVal.toLowerCase() ) !== -1 ? true : false; }); return ( Choose an Example ({examplesSortedKeys.length}) Examples this.setSearchVal(e.target.value)} /> {examplesSortedKeys.map((label, index) => ( {label} ))} ); } } export default withStyles(ExamplesGrid, styles);