Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhood Shapouran committed Mar 27, 2023
1 parent 634226e commit 9858bb7
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
![react-native-highlighter](https://user-images.githubusercontent.com/7857656/227882432-2d18c750-5c96-4838-8dfd-62bd44cfa18f.jpg)


# react-native-highlighter

A library for highlight what you want and interact with them
Expand All @@ -11,13 +10,63 @@ A library for highlight what you want and interact with them
npm install react-native-highlighter
```

OR

```sh
yarn add react-native-highlighter
```

## Usage

```js
import Highlighter from 'react-native-highlighter';
import HighlightedText, { Highlight } from 'react-native-highlighter';

// ...
export default function App() {
const text = `React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces.
Use a little—or a lot. You can use React Native today in your existing Android and iOS projects or you can create a whole new app from scratch.
For more please visit https://reactnative.dev or read latest posts from @reactnative.
#react #reactnative #javascript`;

const mainKeywords = new Highlight({
keywords: ['react native', 'javascript'],
style: { color: '#6C00FF', fontWeight: 'bold' },
onPress: (keyword) => Alert.alert(keyword),
});

const extraMarkers = new Highlight({
keywords: ['user interface', 'highlight'],
style: { backgroundColor: '#F7DB6A' },
onPress: () => {},
});

return (
<HighlightedText
highlights={[mainKeywords, extraMarkers]}
hashtags={true}
hashtagStyle={styles.hashtagStyle}
mentions={true}
mentionStyle={styles.mentionStyle}
emails={true}
emailStyle={styles.emailStyle}
links={true}
onMentionPress={(mention) =>
Alert.alert(`https://twitter.com/${mention.replace('@', '')}`)
}
>
{text}
</HighlightedText>
);
}

const styles = StyleSheet.create({
hashtagStyle: {
color: '#F54291',
},
mentionStyle: { color: '#379237', fontWeight: 'bold' },
emailStyle: { color: '#FF6D28', fontWeight: 'bold' },
});
// ...
```

## Contributing
Expand Down

0 comments on commit 9858bb7

Please sign in to comment.