# carbon-footprint-widget

> A library for carbon value

Latest version **1.0.26** (published 2024-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install carbon-footprint-widget
pnpm add carbon-footprint-widget
yarn add carbon-footprint-widget
bun add carbon-footprint-widget
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.26 |
| Published | 2024-02-05 |
| First published | 2023-09-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 153.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Abhishek |
| Maintainers | programmer_abby |
| Keywords | carbon-footprint, carbon, co2, carbon-index |

## Links

- npm: https://www.npmjs.com/package/carbon-footprint-widget
- Repository: https://github.com/Abbyrathore/carbon-footprint-widget
- Homepage: https://github.com/Abbyrathore/carbon-footprint-widget#readme
- Issues: https://github.com/Abbyrathore/carbon-footprint-widget/issues
- npm.io page: https://npm.io/package/carbon-footprint-widget

## Dependencies (1)

- [axios](https://npm.io/package/axios.md) ^1.6.2

## Recent versions

- 1.0.26 (latest) — 2024-02-05
- 1.0.25 — 2024-02-01
- 1.0.24 — 2024-02-01
- 1.0.23 — 2024-02-01
- 1.0.22 — 2024-02-01
- 1.0.21 — 2024-01-23
- 1.0.20 — 2024-01-23
- 1.0.19 — 2024-01-23
- 1.0.18 — 2024-01-23
- 1.0.17 — 2024-01-22
- 1.0.16 — 2023-12-18
- 1.0.15 — 2023-12-11
- 1.0.14 — 2023-12-08
- 1.0.13 — 2023-12-08
- 1.0.12 — 2023-12-08
- … 12 more at https://npm.io/package/carbon-footprint-widget/versions

## README

# carbon-footprint-widget

A JavaScript library for calculating carbon footprint values.

## Installation

You can install the `carbon-footprint-widget` library using npm. Open your terminal or command prompt and run the following command:

```bash
npm install carbon-footprint-widget
```

## Usage

### In `index.js` or `index.tsx`

Import the necessary components in your JavaScript or TypeScript file:

```jsx
import React from "react";
import ReactDOM from "react-dom";
import { CarbonWidgetProvider } from "carbon-footprint-widget";
import App from "./App/App";
import { WIDGET_API_KEY } from "./generated/from-web/constants";

ReactDOM.render(
  <React.StrictMode>
    <CarbonWidgetProvider apiKey={WIDGET_API_KEY}>
      <App />
    </CarbonWidgetProvider>
  </React.StrictMode>,
  document.getElementById("root")
);
```

Make sure to replace `WIDGET_API_KEY` with your actual API key.

### Add Hooks and Component

Import the required components and hooks into your React component:

```jsx
import React from "react";
import { Widget, useOffsetDeduction } from "carbon-footprint-widget";

const Cart: React.FC = () => {
  // Use the useOffsetDeduction hook to get relevant information
  const {
    isWidgetToggleOn,
    deductionAmount,
  } = useOffsetDeduction();

  return (
    <div>
      {/* Render the Widget component with the desired amount */}
      <Widget amount={Number(totalPrice)} />
    </div>
  );
};
```

Ensure that you have the necessary dependencies installed, and replace `totalPrice` with the actual value you want to calculate the carbon footprint for TAP.

Feel free to include any additional information, configuration options, or explanations as needed.

---
_Source: https://npm.io/package/carbon-footprint-widget · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
