react-robot-vacuum 1.0.3 → 1.0.4
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 +4 -93
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
# 🤖 React Robot Vacuum
|
|
2
2
|
|
|
3
|
-
An animated React component featuring an autonomous robot vacuum that cleans your page by collecting dirt particles. Built with TypeScript, React
|
|
3
|
+
An animated React component featuring an autonomous robot vacuum that cleans your page by collecting dirt particles. Built with TypeScript, React and CSS
|
|
4
4
|
|
|
5
|
-

|
|
18
6
|
|
|
19
7
|
## 📦 Installation
|
|
20
8
|
|
|
@@ -87,86 +75,9 @@ function App() {
|
|
|
87
75
|
- **`startCleaning()`** - Manually start the cleaning process
|
|
88
76
|
- **`reset()`** - Reset robot to dock and generate new dirt
|
|
89
77
|
|
|
90
|
-
### Types
|
|
91
|
-
|
|
92
|
-
```tsx
|
|
93
|
-
export interface RobotVacuumRef {
|
|
94
|
-
startCleaning: () => void;
|
|
95
|
-
reset: () => void;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface RobotVacuumProps {
|
|
99
|
-
readonly numberOfDirtBits?: number;
|
|
100
|
-
readonly minSpeed?: number;
|
|
101
|
-
readonly speedFactor?: number;
|
|
102
|
-
readonly rotationDuration?: number;
|
|
103
|
-
readonly autoStart?: boolean;
|
|
104
|
-
readonly onCleaningStart?: () => void;
|
|
105
|
-
readonly onCleaningComplete?: () => void;
|
|
106
|
-
readonly onDirtCollected?: (collected: number, total: number) => void;
|
|
107
|
-
}
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## 🎨 Examples
|
|
111
|
-
|
|
112
|
-
### Manual Control with Callbacks
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
import { useRef, useState } from "react";
|
|
116
|
-
import { RobotVacuum, RobotVacuumRef } from "react-robot-vacuum";
|
|
117
|
-
|
|
118
|
-
function App() {
|
|
119
|
-
const robotRef = useRef<RobotVacuumRef>(null);
|
|
120
|
-
const [progress, setProgress] = useState("0/0");
|
|
121
|
-
const [status, setStatus] = useState("Ready");
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<div>
|
|
125
|
-
<RobotVacuum
|
|
126
|
-
ref={robotRef}
|
|
127
|
-
autoStart={false}
|
|
128
|
-
numberOfDirtBits={10}
|
|
129
|
-
onCleaningStart={() => setStatus("Cleaning...")}
|
|
130
|
-
onDirtCollected={(collected, total) => {
|
|
131
|
-
setProgress(`${collected}/${total}`);
|
|
132
|
-
}}
|
|
133
|
-
onCleaningComplete={() => setStatus("Complete!")}
|
|
134
|
-
/>
|
|
135
|
-
|
|
136
|
-
<div style={{ position: "fixed", top: 20, right: 20 }}>
|
|
137
|
-
<p>Status: {status}</p>
|
|
138
|
-
<p>Progress: {progress}</p>
|
|
139
|
-
<button onClick={() => robotRef.current?.startCleaning()}>
|
|
140
|
-
Start
|
|
141
|
-
</button>
|
|
142
|
-
<button onClick={() => robotRef.current?.reset()}>
|
|
143
|
-
Reset
|
|
144
|
-
</button>
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
### Slow and Methodical Cleaning
|
|
152
|
-
|
|
153
|
-
```tsx
|
|
154
|
-
import { RobotVacuum } from "react-robot-vacuum";
|
|
155
|
-
|
|
156
|
-
function App() {
|
|
157
|
-
return (
|
|
158
|
-
<RobotVacuum
|
|
159
|
-
minSpeed={1.5}
|
|
160
|
-
speedFactor={50}
|
|
161
|
-
rotationDuration={1.2}
|
|
162
|
-
/>
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
78
|
## 🎮 Live Demo
|
|
168
79
|
|
|
169
|
-
Try it on [CodeSandbox](https://codesandbox.io/
|
|
80
|
+
Try it on [CodeSandbox](https://codesandbox.io/p/sandbox/react-robot-vacuum-4xlm7j)
|
|
170
81
|
|
|
171
82
|
## 🛠️ Development
|
|
172
83
|
|
|
@@ -186,7 +97,7 @@ npm run lint
|
|
|
186
97
|
|
|
187
98
|
## 📄 License
|
|
188
99
|
|
|
189
|
-
MIT ©
|
|
100
|
+
MIT © ZhanmuTW
|
|
190
101
|
|
|
191
102
|
## 🤝 Contributing
|
|
192
103
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-robot-vacuum",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "An animated React component featuring a robot vacuum that autonomously cleans your page by collecting dirt particles",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|