From fcba1d93eaf4da27298aed337c7d7b64c60a37f3 Mon Sep 17 00:00:00 2001 From: Rehane Date: Wed, 4 Jan 2023 22:39:04 +0530 Subject: [PATCH 1/2] fix: #15 Icon not appearing after import --- src/container/SearchBar/index.tsx | 4 ++-- src/icons/search.tsx | 10 ++++++++++ stories/custom.stories.tsx | 2 -- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 src/icons/search.tsx diff --git a/src/container/SearchBar/index.tsx b/src/container/SearchBar/index.tsx index c33a751..0572f8e 100644 --- a/src/container/SearchBar/index.tsx +++ b/src/container/SearchBar/index.tsx @@ -7,7 +7,7 @@ import { import { useReactSearchHighlight } from '../../context'; import { Stack } from '../../elements/flexBox'; import { useKeyDown, useRefComposition } from '../../hooks'; -import searchIcon from '../../icons/search.svg'; +import SearchIcon from '../../icons/search'; import { InternalContext } from '../main'; import { @@ -104,7 +104,7 @@ export const SearchBar = React.forwardRef(({ cursor={'text'} >
- {PrefixIcon ? : } + {PrefixIcon ? : }
{ + return ( + + + + ); +}; + +export default SearchIcon \ No newline at end of file diff --git a/stories/custom.stories.tsx b/stories/custom.stories.tsx index daa388c..153fdd3 100644 --- a/stories/custom.stories.tsx +++ b/stories/custom.stories.tsx @@ -34,8 +34,6 @@ const Template = args => { const {suggestions, isResultsEmpty} = useReactSearchHighlight(); const ref = useRef(); - console.log('ref :', ref); - return ( Date: Thu, 5 Jan 2023 00:07:57 +0530 Subject: [PATCH 2/2] dcos: added docs --- README.md | 336 ++++++++++++++++++------------ example/.npmignore | 3 - example/index.html | 14 -- example/index.tsx | 14 -- example/package.json | 24 --- example/tsconfig.json | 18 -- package.json | 2 +- resources/logo.svg | 3 + src/container/SearchBar/index.tsx | 38 ++++ src/container/main.tsx | 7 + test/blah.test.tsx | 11 - 11 files changed, 247 insertions(+), 223 deletions(-) delete mode 100644 example/.npmignore delete mode 100644 example/index.html delete mode 100644 example/index.tsx delete mode 100644 example/package.json delete mode 100644 example/tsconfig.json create mode 100644 resources/logo.svg delete mode 100644 test/blah.test.tsx 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 ( + +