1.0.26 • Published 3 months ago

carbon-footprint-widget v1.0.26

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

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:

npm install carbon-footprint-widget

Usage

In index.js or index.tsx

Import the necessary components in your JavaScript or TypeScript file:

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:

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.

1.0.26

3 months ago

1.0.22

3 months ago

1.0.25

3 months ago

1.0.24

3 months ago

1.0.23

3 months ago

1.0.19

4 months ago

1.0.18

4 months ago

1.0.21

4 months ago

1.0.20

4 months ago

1.0.17

4 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

5 months ago

1.0.12

5 months ago

1.0.11

5 months ago

1.0.10

5 months ago

1.0.9

5 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago