diff --git a/README.md b/README.md index 134273f..32e4990 100644 --- a/README.md +++ b/README.md @@ -1,181 +1,241 @@ -# TSDX React w/ Storybook User Guide +# react-search-highlight -Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it. + -> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`. +react-search-highlight is a light weight react package to highlight static/dynamic search for auto completion -> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/) +
+ + + + +
-## Commands +## Installation -TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`. +install it using npm or yarn to include it in your own React project -The recommended workflow is to run TSDX in one terminal: +You will also need to import css modules in root your project before using it. `dist/react-search-highlight.cjs.development.css` ```bash -npm start # or yarn start +npm install react-search-highlight ``` -This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`. - -Then run either Storybook or the example playground: - -### Storybook - -Run inside another terminal: +or: ```bash -yarn storybook +yarn add react-search-highlight ``` -This loads the stories from `./stories`. - -> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper. - -### Example - -Then run the example inside another: - -```bash -cd example -npm i # or yarn to install dependencies -npm start # or yarn start +## Usage + +You can either use the hook: + +```tsx static +import { + PopOverList, + PopOverOption, + PopOverOptionText, + Props, + ReactSearchHighlightProvider, + SearchBar, + STRING_MATCHING, + useReactSearchHighlight, + Wrapper +} from 'react-search-highlight'; +import 'react-search-highlight/dist/react-search-highlight.cjs.development.css'; + +import TEST_DATA from '../data.json'; + +const Template = () => { + const {suggestions, isResultsEmpty} = useReactSearchHighlight(); + return ( + + + + {suggestions?.map((item, index) => ( + alert(index)} + > + ⚡️ + + + + ))} + {isResultsEmpty &&

No results found

} +
+
+ ); +}; + +export const Custom = () => { + return ( + +