react-native-ai-animations 0.8.0 → 0.8.1
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 +124 -72
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
1
|
# React Native AI Animations
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/react-native-ai-animations)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
3
6
|
Animated React Native and Expo components for AI chat apps: streaming text,
|
|
4
7
|
shimmer loading text, thinking and status indicators, voice orbs and
|
|
5
8
|
waveforms, image and video generation loaders, question cards and reasoning
|
|
6
9
|
effort bars. Built on Reanimated and Skia, themeable, and reduce motion aware.
|
|
7
10
|
|
|
11
|
+
**Docs and live demos:** [nami-motion-web.vercel.app](https://nami-motion-web.vercel.app/)
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
8
15
|
```bash
|
|
9
16
|
npx expo install react-native-ai-animations react-native-reanimated react-native-worklets
|
|
10
17
|
```
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
The orbs, waveforms and media loaders in `react-native-ai-animations/skia` also need Skia:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx expo install @shopify/react-native-skia
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
| Peer | Version |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `react` | 19.2 or newer |
|
|
28
|
+
| `react-native` | 0.83 or newer |
|
|
29
|
+
| `react-native-reanimated` | 4.2 or newer |
|
|
30
|
+
| `react-native-worklets` | 0.7 or newer |
|
|
31
|
+
| `@shopify/react-native-skia` | 2.4 or newer, optional |
|
|
32
|
+
|
|
33
|
+
> Formerly published as `nami-motion`. Replace `nami-motion` with
|
|
34
|
+
> `react-native-ai-animations` in your imports.
|
|
14
35
|
|
|
15
36
|
## Components
|
|
16
37
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/spinning-mark.gif" width="200" alt="Spinning Mark recording" /><br /><b>Spinning Mark</b><br /><code>react-native-ai-animations/brand</code></td>
|
|
20
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/shimmer-text.gif" width="200" alt="Shimmer Text recording" /><br /><b>Shimmer Text</b><br /><code>react-native-ai-animations/text</code></td>
|
|
21
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/streaming-text.gif" width="200" alt="Streaming Text recording" /><br /><b>Streaming Text</b><br /><code>react-native-ai-animations/text</code></td>
|
|
22
|
-
</tr>
|
|
23
|
-
<tr>
|
|
24
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/status-row.gif" width="200" alt="Status Row recording" /><br /><b>Status Row</b><br /><code>react-native-ai-animations/chat</code></td>
|
|
25
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/thinking-block.gif" width="200" alt="Thinking Block recording" /><br /><b>Thinking Block</b><br /><code>react-native-ai-animations/chat</code></td>
|
|
26
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/question-card.gif" width="200" alt="Question Card recording" /><br /><b>Question Card</b><br /><code>react-native-ai-animations/chat</code></td>
|
|
27
|
-
</tr>
|
|
28
|
-
<tr>
|
|
29
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/effort-bar.gif" width="200" alt="Effort Bar recording" /><br /><b>Effort Bar</b><br /><code>react-native-ai-animations/chat</code></td>
|
|
30
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/media-generating.gif" width="200" alt="Media Generating recording" /><br /><b>Media Generating</b><br /><code>react-native-ai-animations/skia</code></td>
|
|
31
|
-
<td align="center" valign="top" width="33%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/voice-wave.gif" width="200" alt="Voice Wave recording" /><br /><b>Voice Wave</b><br /><code>react-native-ai-animations/skia</code></td>
|
|
32
|
-
</tr>
|
|
33
|
-
</table>
|
|
34
|
-
|
|
35
|
-
<table>
|
|
36
|
-
<tr>
|
|
37
|
-
<td align="center" valign="top" width="50%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/shimmer-text.gif" width="160" alt="Shimmer Text recording" /><br /><b>Shimmer Text</b><br /><code>react-native-ai-animations/text</code><br /><a href="https://github.com/AhmeetKaar/nami-motion/raw/main/media/shimmer-text.mp4">10s video</a></td>
|
|
38
|
-
<td align="center" valign="top" width="50%"><img src="https://raw.githubusercontent.com/AhmeetKaar/nami-motion/main/media/voice-wave.gif" width="160" alt="Voice Wave recording" /><br /><b>Voice Wave</b><br /><code>react-native-ai-animations/skia</code><br /><a href="https://github.com/AhmeetKaar/nami-motion/raw/main/media/voice-wave.mp4">10s video</a></td>
|
|
39
|
-
</tr>
|
|
40
|
-
</table>
|
|
38
|
+
Every component and style is shown in motion, with copyable code and agent
|
|
39
|
+
prompts, on the [website](https://nami-motion-web.vercel.app/).
|
|
41
40
|
|
|
42
41
|
| Component | Entry | What it does |
|
|
43
42
|
| --- | --- | --- |
|
|
44
|
-
| Shimmer Text |
|
|
45
|
-
| Streaming Text |
|
|
46
|
-
| Spoken Text |
|
|
47
|
-
| Spinning Mark |
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
43
|
+
| Shimmer Text | `/text` | A light band sweeping across text while a response is being generated. |
|
|
44
|
+
| Streaming Text | `/text` | Words of a streaming answer fade and rise in, with a blinking caret. |
|
|
45
|
+
| Spoken Text | `/text` | Highlights the word being spoken and dims the words already read aloud, for voice replies. |
|
|
46
|
+
| Spinning Mark | `/brand` | Spins any icon you pass (your logo) with optional breathing and entrance. |
|
|
47
|
+
| Status Row | `/chat` | Pulsing icon, shimmering label and elapsed timer for agent status. |
|
|
48
|
+
| Thinking Block | `/chat` | "Thought for Ns" header that springs open into a step timeline. |
|
|
49
|
+
| Question Card | `/chat` | Paged questions with numbered options and a custom answer, as a card or a sheet. |
|
|
50
|
+
| Effort Bar | `/chat` | Reasoning effort control wired to `reasoning.effort` (low, medium, high) in four styles: bars, track, segmented and slider. |
|
|
51
|
+
| Media Generating | `/skia` | One loading state for image and video generation in six variants: blobs, matrix, orbit, scan, constellation and helix. |
|
|
52
|
+
| Dot Orb | `/skia` | The dot sphere behind the media variants, also usable on its own. |
|
|
53
|
+
| Matrix Orb | `/skia` | Dot matrix orb with idle, listening and thinking states and per state colors. |
|
|
54
|
+
| Liquid Orb | `/skia` | Voice orb in metal, water, iridescent or ring material that reacts to idle, listening, thinking and speaking and a live level. |
|
|
55
|
+
| Voice Wave | `/skia` | Live microphone waveform in four styles: lines, bars, dots and pulse. |
|
|
56
|
+
|
|
57
|
+
Entries are subpaths of `react-native-ai-animations`. The root export holds
|
|
58
|
+
`/theme` and `/text`; nothing that needs Skia is imported from the root.
|
|
56
59
|
|
|
57
60
|
Every style is also its own component with the same props minus `variant`:
|
|
58
|
-
`VoiceWaveLines`, `VoiceWaveBars`, `VoiceWaveDots` and `VoiceWavePulse`;
|
|
59
|
-
`EffortBars`, `EffortTrack`, `EffortSegmented` and
|
|
60
|
-
`EffortSlider`; `MediaGeneratingBlobs`, `MediaGeneratingMatrix`,
|
|
61
|
-
`MediaGeneratingOrbit`, `MediaGeneratingScan`, `MediaGeneratingConstellation`
|
|
62
|
-
and `MediaGeneratingHelix`; and `QuestionSheet`.
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
`
|
|
62
|
+
- `VoiceWaveLines`, `VoiceWaveBars`, `VoiceWaveDots`, `VoiceWavePulse`
|
|
63
|
+
- `EffortBars`, `EffortTrack`, `EffortSegmented`, `EffortSlider`
|
|
64
|
+
- `MediaGeneratingBlobs`, `MediaGeneratingMatrix`, `MediaGeneratingOrbit`,
|
|
65
|
+
`MediaGeneratingScan`, `MediaGeneratingConstellation`, `MediaGeneratingHelix`
|
|
66
|
+
- `QuestionSheet`
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
## Usage
|
|
70
69
|
|
|
71
70
|
### Shimmer Text
|
|
72
71
|
|
|
@@ -76,16 +75,6 @@ import { ShimmerText } from "react-native-ai-animations/text";
|
|
|
76
75
|
<ShimmerText text="Generating a response" activeColor={colors.text} mutedColor={colors.textTertiary} />;
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
### Spinning Mark
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { SpinningMark } from "react-native-ai-animations/brand";
|
|
83
|
-
|
|
84
|
-
<SpinningMark size={160} duration={3600} breathe entrance>
|
|
85
|
-
<Image source={require("./logo.png")} style={{ width: 160, height: 160 }} />
|
|
86
|
-
</SpinningMark>;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
78
|
### Streaming Text, Status Row, Thinking Block
|
|
90
79
|
|
|
91
80
|
```tsx
|
|
@@ -97,20 +86,33 @@ import { StatusRow, ThinkingBlock } from "react-native-ai-animations/chat";
|
|
|
97
86
|
<StreamingText text={answer} streaming={streaming} textStyle={{ fontFamily: "Inter" }} />;
|
|
98
87
|
```
|
|
99
88
|
|
|
100
|
-
###
|
|
89
|
+
### Spinning Mark
|
|
101
90
|
|
|
102
91
|
```tsx
|
|
103
|
-
import {
|
|
92
|
+
import { SpinningMark } from "react-native-ai-animations/brand";
|
|
104
93
|
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
<VideoGenerating status="queued" variant="orbit" />;
|
|
94
|
+
<SpinningMark size={160} duration={3600} breathe entrance>
|
|
95
|
+
<Image source={require("./logo.png")} style={{ width: 160, height: 160 }} />
|
|
96
|
+
</SpinningMark>;
|
|
109
97
|
```
|
|
110
98
|
|
|
99
|
+
### Question Card
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { QuestionCard } from "react-native-ai-animations/chat";
|
|
103
|
+
|
|
104
|
+
<QuestionCard questions={questions} variant="sheet" onSubmit={(answers) => send(answers)} />;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
`QuestionCard` and `QuestionSheet` take a `ref` with `select(index)`,
|
|
108
|
+
`goTo(page)` and `submit()`, so a demo, a voice flow or a test can drive the
|
|
109
|
+
questions without touches.
|
|
110
|
+
|
|
111
111
|
### Effort Bar
|
|
112
112
|
|
|
113
|
-
`REASONING_EFFORTS` matches the `reasoning.effort` values OpenRouter and most
|
|
113
|
+
`REASONING_EFFORTS` matches the `reasoning.effort` values OpenRouter and most
|
|
114
|
+
reasoning APIs take (`low`, `medium`, `high`), with each level's share of
|
|
115
|
+
`max_tokens`. `reasoningRequest(effort)` builds the request fields.
|
|
114
116
|
|
|
115
117
|
```tsx
|
|
116
118
|
import { EffortBar, REASONING_EFFORTS, reasoningRequest } from "react-native-ai-animations/chat";
|
|
@@ -123,15 +125,29 @@ import { EffortBar, REASONING_EFFORTS, reasoningRequest } from "react-native-ai-
|
|
|
123
125
|
const body = { model, messages, max_tokens: 16000, ...reasoningRequest(effort) };
|
|
124
126
|
```
|
|
125
127
|
|
|
126
|
-
|
|
128
|
+
| Prop | Does |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `variant` | `bars` (default), `track`, `segmented` or `slider` |
|
|
131
|
+
| `size="compact"` | Small inline form for model rows |
|
|
132
|
+
| `fillColors` | Tints the fill of any style |
|
|
133
|
+
| `tabLabel` | Your model name in the slider's tab |
|
|
134
|
+
| `levelIcon` | Replaces every level name with your own icon |
|
|
135
|
+
|
|
136
|
+
EffortBar is only the control: put your own title, level label or description
|
|
137
|
+
around it.
|
|
138
|
+
|
|
139
|
+
### Media Generating
|
|
127
140
|
|
|
128
141
|
```tsx
|
|
129
|
-
import {
|
|
142
|
+
import { ImageGenerating, MediaGenerating, VideoGenerating } from "react-native-ai-animations/skia";
|
|
130
143
|
|
|
131
|
-
<
|
|
144
|
+
<MediaGenerating variant="constellation" label="Creating image" startedAt={startedAt} />;
|
|
145
|
+
<MediaGenerating variant="scan" chrome="overlay" status="generating" progress={0.42} meta="720p · 6s" aspectRatio={16 / 9} />;
|
|
146
|
+
<ImageGenerating variant="helix" startedAt={startedAt} />;
|
|
147
|
+
<VideoGenerating status="queued" variant="orbit" />;
|
|
132
148
|
```
|
|
133
149
|
|
|
134
|
-
|
|
150
|
+
`ImageGenerating` and `VideoGenerating` are presets of `MediaGenerating`.
|
|
135
151
|
|
|
136
152
|
### Voice Wave
|
|
137
153
|
|
|
@@ -144,9 +160,13 @@ const level = useSharedValue(0);
|
|
|
144
160
|
<VoiceWave level={level} variant="bars" colors={["#1F8A70", "#88C9F7", "#5FC7B0"]} />;
|
|
145
161
|
```
|
|
146
162
|
|
|
147
|
-
### Liquid Orb and Spoken Text
|
|
163
|
+
### Liquid Orb and Spoken Text
|
|
148
164
|
|
|
149
|
-
`LiquidOrb`
|
|
165
|
+
`LiquidOrb` comes in `metal`, `water` or `iridescent`, or three glowing loops
|
|
166
|
+
with `ring` (color them with `colors`). `state` switches between `idle`,
|
|
167
|
+
`listening`, `thinking` and `speaking`, and `level` (0 to 1) makes it swell
|
|
168
|
+
while listening or speaking. `SpokenText` highlights the word being read aloud:
|
|
169
|
+
pass the index of the current word as `spoken`.
|
|
150
170
|
|
|
151
171
|
```tsx
|
|
152
172
|
import { useSharedValue } from "react-native-reanimated";
|
|
@@ -160,6 +180,38 @@ const level = useSharedValue(0);
|
|
|
160
180
|
<SpokenText text={reply} spoken={wordIndex} textStyle={{ fontFamily: "Inter", fontSize: 20, lineHeight: 28 }} />;
|
|
161
181
|
```
|
|
162
182
|
|
|
183
|
+
## Theming
|
|
184
|
+
|
|
185
|
+
Components use the built-in Moodstone palette until you wrap your app in
|
|
186
|
+
`MotionThemeProvider`. Pass one palette, or a `light` and `dark` pair with a
|
|
187
|
+
`colorScheme`. Components that read the palette also take `colors` to override
|
|
188
|
+
a single instance; Shimmer Text, Voice Wave, Dot Orb and Matrix Orb take their
|
|
189
|
+
colors directly (`activeColor`, `colors`, `color`).
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { useColorScheme } from "react-native";
|
|
193
|
+
import { MotionThemeProvider } from "react-native-ai-animations/theme";
|
|
194
|
+
|
|
195
|
+
<MotionThemeProvider
|
|
196
|
+
colorScheme={useColorScheme() ?? "light"}
|
|
197
|
+
palette={{ light: { accent: "#2F7BF5" }, dark: { accent: "#5AA2FF" } }}
|
|
198
|
+
>
|
|
199
|
+
<App />
|
|
200
|
+
</MotionThemeProvider>;
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Palette keys: `background`, `card`, `surface`, `raised`, `text`,
|
|
204
|
+
`textSecondary`, `textTertiary`, `accent`, `accentContrast`, `success`,
|
|
205
|
+
`danger`. Read the active palette in your own components with
|
|
206
|
+
`useMotionPalette()`.
|
|
207
|
+
|
|
208
|
+
## Customization and accessibility
|
|
209
|
+
|
|
210
|
+
- Icons, fonts, colors and timing are props on every component; nothing is
|
|
211
|
+
tied to a brand or an icon set.
|
|
212
|
+
- When the system's reduce motion setting is on, every component settles to a
|
|
213
|
+
static final state.
|
|
214
|
+
|
|
163
215
|
## Development
|
|
164
216
|
|
|
165
217
|
```bash
|
|
@@ -172,4 +224,4 @@ Changes that affect the package need a changeset: `npm run changeset`.
|
|
|
172
224
|
|
|
173
225
|
## License
|
|
174
226
|
|
|
175
|
-
MIT
|
|
227
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-ai-animations",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Animated React Native and Expo components for AI chat apps: streaming text, shimmer loading text, thinking and status indicators, voice orbs and waveforms, image and video generation loaders, question cards and reasoning effort bars. Built on Reanimated and Skia.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ahmet Kar",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/AhmeetKaar/nami-motion.git"
|
|
10
10
|
},
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://nami-motion-web.vercel.app/",
|
|
12
12
|
"keywords": [
|
|
13
13
|
"react-native",
|
|
14
14
|
"expo",
|