@boomitra/carbon-calculator 0.2.13 → 0.2.15
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 +62 -2
- package/dist-embed/carbon-calculator-widget.iife.js +51 -35
- package/dist-embed/index.html +1 -2
- package/dist-package/index.cjs.js +1 -1
- package/dist-package/index.es.js +12 -9
- package/dist-package/index.html +1 -2
- package/package.json +14 -11
package/README.md
CHANGED
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# Carbon Calculator
|
|
2
|
+
|
|
3
|
+
A versatile Carbon Calculator available as a React package.
|
|
4
|
+
|
|
5
|
+
## 📦 Usage as a React Package
|
|
6
|
+
|
|
7
|
+
If you have an existing React application, you can install and use the component directly.
|
|
8
|
+
|
|
9
|
+
### 1. Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @boomitra/carbon-calculator
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 2. Integration
|
|
16
|
+
|
|
17
|
+
Import the component and its styles in your application.
|
|
18
|
+
**Note:** You must pass the `host` prop to specify the destination URL (e.g., your checkout page) where the user will be redirected when clicking the "Offset" button.
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
import React from "react";
|
|
22
|
+
import CarbonCalculator from "@boomitra/carbon-calculator";
|
|
23
|
+
import "@boomitra/carbon-calculator/style.css"; // Don't forget the styles!
|
|
24
|
+
|
|
25
|
+
function App() {
|
|
26
|
+
const host = "https://your-website.com/checkout"; // URL for redirection
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="App">
|
|
30
|
+
<h1>Carbon Footprint Calculator</h1>
|
|
31
|
+
<CarbonCalculator host={host} />
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default App;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## 🛠️ Development
|
|
42
|
+
|
|
43
|
+
### Setup
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm install
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Run Locally
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm start
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Runs the app in development mode at `http://localhost:5173`.
|
|
56
|
+
|
|
57
|
+
### Build Commands
|
|
58
|
+
|
|
59
|
+
- **Build Package**: `npm run build`
|
|
60
|
+
- Outputs to `dist-package/`
|
|
61
|
+
- Used for publishing to npm (ESM + CommonJS).
|
|
62
|
+
|