You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-24Lines changed: 61 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Openmoji for React
2
-
unofficial; bodged by drinking-code
3
-
not optimized for production use
2
+
3
+
unofficial; bodged by drinking-code
4
4
5
5
1.[What is Openmoji for React?](#what-is-openmoji-for-react)
6
6
2.[Installation](#installation)
@@ -14,19 +14,26 @@ not optimized for production use
14
14
3.[Attributes](#attributes)
15
15
16
16
#### What is Openmoji for React?
17
-
[Openmoji](https://github.com/hfg-gmuend/openmoji) is a collection of open source emojis. This repository lets you use these emojis in a React app easily.
17
+
18
+
[Openmoji](https://github.com/hfg-gmuend/openmoji) is a collection of open source emojis. This repository lets you use
19
+
these emojis in a React app easily.
18
20
19
21
> Please comply with the [Openmoji Attribution Requirements](https://github.com/hfg-gmuend/openmoji#attribution-requirements)
20
22
21
23
## Installation
24
+
22
25
```shell script
23
26
npm i react-openmoji
24
27
```
25
28
26
29
## Usage
30
+
27
31
### Automatically
32
+
28
33
#### `reactReplaceEmojis(jsx[, options])`
34
+
29
35
For easy and dynamic use you can replace emojis completely automatically:
36
+
30
37
```jsx
31
38
importReactfrom'react';
32
39
importreactReplaceEmojisfrom'react-openmoji';
@@ -38,9 +45,12 @@ const App = () => {
38
45
exportdefaultApp;
39
46
```
40
47
41
-
You can also set options:
42
-
`size` — size of the emojis; default `1.7em`
43
-
`outline` — set to `true` if you want the colourless emojis; default `false`
48
+
You can also set options:
49
+
50
+
|Field|Type|Description|Default|
51
+
|---|---|---|---|
52
+
|`size`| CSS length (string) | size of the emojis |`1.5em`|
53
+
|`outline`| boolean | set to `true` if you want the colourless emojis |`false`|
44
54
45
55
```jsx
46
56
importReactfrom'react';
@@ -57,7 +67,9 @@ export default App;
57
67
```
58
68
59
69
#### `replaceEmojis(string[, options])`
60
-
Is the sting equivalent to `reactReplaceEmojis`. Use this if you only want to replace emojis within a string.
70
+
71
+
Is the string equivalent to `reactReplaceEmojis`. Use this if you just want to replace emojis within a string.
72
+
61
73
```jsx
62
74
importReactfrom'react';
63
75
import {replaceEmojis} from'react-openmoji';
@@ -70,24 +82,33 @@ export default App;
70
82
```
71
83
72
84
### Manually
85
+
73
86
#### Via icon name
87
+
74
88
```jsx
75
89
importReactfrom'react';
76
-
import {ManRaisingHand} from'react-openmoji';
90
+
import {ManRaisingHand} from'react-openmoji';
77
91
78
92
constApp= () => {
79
-
return<p>Hello World!<ManRaisingHand/></p>
93
+
return<p>Hello World!<ManRaisingHand/></p>
80
94
};
81
95
82
96
exportdefaultApp;
83
97
```
84
-
Icon names from the [Openmoji Library](https://openmoji.org/library/) are converted into camelCase, so `man raising hand` translates to `ManRaisingHand`.
98
+
99
+
Icon names from the [Openmoji Library](https://openmoji.org/library/) are converted into PascalCase,
100
+
so `man raising hand` translates to `ManRaisingHand`.
101
+
85
102
##### Additions
86
-
`:` are replaced with `_`.
103
+
104
+
`:` is replaced with `_`.
105
+
87
106
```
88
-
waving hand: light skin tone -> WavingHand_LightSkinTone
107
+
waving hand: light skin tone -> WavingHand_LightSkinTone
flag: Bosnia & Herzegovina -> Flag_BosniaHerzegovina
98
119
```
120
+
99
121
`#` is replaced with `NumberSign`, `*` is replaced with `Asterisk`.
122
+
100
123
```
101
-
keycap: # -> Keycap_NumberSign
102
-
keycap: * -> Keycap_Asterisk
124
+
keycap: # -> Keycap_NumberSign
125
+
keycap: * -> Keycap_Asterisk
103
126
```
127
+
104
128
Everything in brackets is removed.
129
+
105
130
```
106
131
A button (blood type) -> AButton
107
132
```
133
+
108
134
If a name starts with a number, a `_` is added in front of the name.
135
+
109
136
```
110
137
1st place medal -> _1stPlaceMedal
111
138
```
112
139
140
+
> **Note:** Some names may appear more than once in the Library (i.e. some emoji variations). Those duplicates are renamed to `DuplicatedName2`, `DuplicatedName3` etc.
141
+
113
142
#### Via unicode
114
-
You can use the unicode of the emoji to import it. Unicodes are listed also in the [Openmoji Library](https://openmoji.org/library/).
143
+
144
+
You can use the unicode of the emoji to import it. Unicodes are also listed in
145
+
the [Openmoji Library](https://openmoji.org/library/). All unicode names have the `U_` prefix in `react-openmoji`.
0 commit comments