Skip to content

Commit a1e01a8

Browse files
Merge pull request #5 from drinking-code/v0.5.0
V0.5.0
2 parents 8619d1f + 128c824 commit a1e01a8

8 files changed

Lines changed: 3494 additions & 749 deletions

File tree

.npmignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
.idea/
2-
.git/
3-
node_modules/
42
src/
53
lib/

README.md

Lines changed: 61 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Openmoji for React
2-
unofficial; bodged by drinking-code
3-
not optimized for production use
2+
3+
unofficial; bodged by drinking-code
44

55
1. [What is Openmoji for React?](#what-is-openmoji-for-react)
66
2. [Installation](#installation)
@@ -14,19 +14,26 @@ not optimized for production use
1414
3. [Attributes](#attributes)
1515

1616
#### 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.
1820

1921
> Please comply with the [Openmoji Attribution Requirements](https://github.com/hfg-gmuend/openmoji#attribution-requirements)
2022
2123
## Installation
24+
2225
```shell script
2326
npm i react-openmoji
2427
```
2528

2629
## Usage
30+
2731
### Automatically
32+
2833
#### `reactReplaceEmojis(jsx[, options])`
34+
2935
For easy and dynamic use you can replace emojis completely automatically:
36+
3037
```jsx
3138
import React from 'react';
3239
import reactReplaceEmojis from 'react-openmoji';
@@ -38,9 +45,12 @@ const App = () => {
3845
export default App;
3946
```
4047

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` |
4454

4555
```jsx
4656
import React from 'react';
@@ -57,7 +67,9 @@ export default App;
5767
```
5868

5969
#### `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+
6173
```jsx
6274
import React from 'react';
6375
import {replaceEmojis} from 'react-openmoji';
@@ -70,24 +82,33 @@ export default App;
7082
```
7183

7284
### Manually
85+
7386
#### Via icon name
87+
7488
```jsx
7589
import React from 'react';
76-
import { ManRaisingHand } from 'react-openmoji';
90+
import {ManRaisingHand} from 'react-openmoji';
7791

7892
const App = () => {
79-
return <p>Hello World! <ManRaisingHand/></p>
93+
return <p>Hello World! <ManRaisingHand/></p>
8094
};
8195

8296
export default App;
8397
```
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+
85102
##### Additions
86-
`:` are replaced with `_`.
103+
104+
`:` is replaced with `_`.
105+
87106
```
88-
waving hand: light skin tone -> WavingHand_LightSkinTone
107+
waving hand: light skin tone -> WavingHand_LightSkinTone
89108
```
109+
90110
`,`, `.`, ``, `!`, ``, and `&` are removed.
111+
91112
```
92113
person: light skin tone, blond hair -> Person_LightSkinToneBlondHair
93114
Mrs. Claus -> MrsClaus
@@ -96,56 +117,72 @@ ON! arrow -> ONArrow
96117
Japanese “here” button -> JapaneseHereButton
97118
flag: Bosnia & Herzegovina -> Flag_BosniaHerzegovina
98119
```
120+
99121
`#` is replaced with `NumberSign`, `*` is replaced with `Asterisk`.
122+
100123
```
101-
keycap: # -> Keycap_NumberSign
102-
keycap: * -> Keycap_Asterisk
124+
keycap: # -> Keycap_NumberSign
125+
keycap: * -> Keycap_Asterisk
103126
```
127+
104128
Everything in brackets is removed.
129+
105130
```
106131
A button (blood type) -> AButton
107132
```
133+
108134
If a name starts with a number, a `_` is added in front of the name.
135+
109136
```
110137
1st place medal -> _1stPlaceMedal
111138
```
112139

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+
113142
#### 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`.
146+
115147
```jsx
116148
import React from 'react';
117-
import {_1F64B_200D_2642_FE0F} from 'react-openmoji';
149+
import {U_1F64B_200D_2642_FE0F} from 'react-openmoji';
118150

119151
const App = () => {
120-
return <p>Hello World! <_1F64B_200D_2642_FE0F/></p>
152+
return <p>Hello World! <U_1F64B_200D_2642_FE0F/></p>
121153
};
122154

123155
export default App;
124156
```
125157

126-
You can also include all 3458 emojis:
158+
> **Fun fact:** Importing all 3914 emojis at once is actually just as fast as the other methods because all emojis are dynamically loaded:
159+
127160
```jsx
128161
import React from 'react';
129162
import * as Emoji from 'react-openmoji';
130163

131164
const App = () => {
132-
return <p>Hello <Emoji.ManRaisingHand/> World! <Emoji._1F30D/></p>
165+
return <p>Hello <Emoji.ManRaisingHand/> World! <Emoji._1F30D/></p>
133166
};
134167

135168
export default App;
136169
```
137170

138171
#### Attributes
139-
In all manual cases you can use two attributes:
140-
`size` — sets the size of the emojis; default `1.7em`
141-
`outline` — add if you want the colourless emojis
172+
173+
With all manual methods you can use two attributes:
174+
175+
|Field|Type|Description|Default|
176+
|---|---|---|---|
177+
|`size`| CSS length (string) | size of the emojis | `1.5em` |
178+
|`outline`| boolean attribute | add if you want the colourless emojis | `false` |
142179

143180
```jsx
144181
import React from 'react';
145-
import { ManRaisingHand } from 'react-openmoji';
182+
import {ManRaisingHand} from 'react-openmoji';
146183

147184
const App = () => {
148-
return <p>Hello World! <ManRaisingHand size={'1.2em'} outline/></p>
185+
return <p>Hello World! <ManRaisingHand size={'1.2em'} outline/></p>
149186
};
150187

151188
export default App;

0 commit comments

Comments
 (0)