react-emotion-face 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/index.d.ts +5 -3
- package/dist/react-emotion-face.es.js +359 -419
- package/dist/react-emotion-face.umd.cjs +2 -2
- package/package.json +13 -4
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# react-emotion-face
|
|
2
|
+
|
|
3
|
+
Animated cartoon emotion face React component library.
|
|
4
|
+
A cute, highly-customizable SVG character face that displays various emotions with fluid animations!
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i react-emotion-face
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
import { EmotionFace } from 'react-emotion-face';
|
|
17
|
+
|
|
18
|
+
function App() {
|
|
19
|
+
const [emotion, setEmotion] = useState('Happy');
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<EmotionFace
|
|
24
|
+
emotion={emotion}
|
|
25
|
+
size={250}
|
|
26
|
+
animated={true}
|
|
27
|
+
message="Hello world!"
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<button onClick={() => setEmotion('Sad')}>Make Sad</button>
|
|
31
|
+
<button onClick={() => setEmotion('Excited')}>Make Excited</button>
|
|
32
|
+
<button onClick={() => setEmotion('Angry')}>Make Angry</button>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Props
|
|
39
|
+
|
|
40
|
+
- `emotion` (string) - The emotion to display (e.g., 'Happy', 'Sad', 'Angry', 'Surprised', 'Love', 'Tired', etc.)
|
|
41
|
+
- `message` (string) - Optional text to display in a speech bubble above the face.
|
|
42
|
+
- `size` (number) - Width and height of the component (default: 200).
|
|
43
|
+
- `animated` (boolean) - Whether to play the idle animations matching each emotion (default: true).
|
|
44
|
+
- `color` (string) - Optional hex color code to override the default skin color for the face.
|
|
45
|
+
- `onEmotionChange` (function) - Callback `(emotion: string) => void` fired when the emotion state is applied inside the component.
|
|
46
|
+
|
|
47
|
+
## Emotion Types
|
|
48
|
+
This library includes over 20 pre-configured emotions: Happy, Sad, Angry, Mad, Surprised, Calm, Sleepy, Excited, Tired, Confused, Embarrassed, Nervous, Proud, Disgusted, Bored, Love, Silly, Sick, Scared, Furious, Shocked. Provide any corresponding key to switch the face seamlessly!
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
export declare type Emotion = 'happy' | 'sad' | 'angry' | 'mad' | 'surprised' | 'calm' | 'sleepy' | 'excited' | 'tired' | 'confused' | 'embarrassed' | 'nervous' | 'proud' | 'disgusted' | 'bored' | 'love' | 'silly' | 'determined' | 'shy' | 'anxious';
|
|
3
|
+
export declare type Emotion = 'happy' | 'sad' | 'angry' | 'mad' | 'surprised' | 'calm' | 'sleepy' | 'excited' | 'tired' | 'confused' | 'embarrassed' | 'nervous' | 'proud' | 'disgusted' | 'bored' | 'love' | 'silly' | 'determined' | 'shy' | 'anxious' | 'laughing';
|
|
4
4
|
|
|
5
|
-
export declare function EmotionFace({ emotion, message, size, animated,
|
|
5
|
+
export declare function EmotionFace({ emotion, message, size, animated, color, onEmotionChange, }: EmotionFaceProps): JSX_2.Element;
|
|
6
6
|
|
|
7
7
|
export declare interface EmotionFaceProps {
|
|
8
8
|
emotion: Emotion;
|
|
9
9
|
message?: string;
|
|
10
10
|
size?: number;
|
|
11
11
|
animated?: boolean;
|
|
12
|
-
showBody?: boolean;
|
|
13
12
|
color?: string;
|
|
14
13
|
onEmotionChange?: (emotion: Emotion) => void;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export declare const EMOTIONS: Emotion[];
|
|
18
17
|
|
|
18
|
+
/** Returns all available emotion strings. */
|
|
19
|
+
export declare function getEmotions(): Emotion[];
|
|
20
|
+
|
|
19
21
|
export { }
|