1.1.91 • Published 1 year ago

@mahesh005/temp_conversion v1.1.91

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Temperature Converter React Component

A React component for converting temperatures between Celsius and Fahrenheit.

Table of Contents

Introduction

This package provides a TemperatureConverter React component and a custom hook useTemperatureConverter for handling temperature conversions.

Installation

You can install the package via npm:

npm install @mahesh005/temp_conversion

Usage

Import the TemperatureConverter component and use it in your React application:

Temperature Converter with UI

import React from 'react';
import TemperatureConverter from '@mahesh005/temp_conversion';

const App = () => {
  return (
    <div>
      <TemperatureConverter initialCelsius={25} size={2} showRange={true} />
    </div>
  );
};

export default App;

Hooks

useTemperatureConverter: Custom hook for managing temperature state and conversion logic.

Parameters

initialCelsius (number): Initial temperature in Celsius (default: 0).

Returns

celsius (number): Current temperature in Celsius. fahrenheit (number): Current temperature in Fahrenheit. setCelsius (function): Function to set the temperature in Celsius. setFahrenheit (function): Function to set the temperature in Fahrenheit.

Example

import React, { useState } from 'react';
import { useTemperatureConverter } from '@mahesh005/temp_conversion';

const CustomComponent = () => {
  const { celsius, fahrenheit, setCelsius, setFahrenheit } = useTemperatureConverter(0);
  console.log("Celsius :" + celsius,"Fahrenheit: " + fahrenheit)
  return (
    <div>
      <div>
        <label>
          Celsius:
          <input
            type="number"
            value={celsius}
            onChange={(e) => setCelsius(parseFloat(e.target.value))}
          />
        </label>
      </div>
      <div>
        <label>
          Fahrenheit:
          <input
            type="number"
            value={fahrenheit}
            onChange={(e) => setFahrenheit(parseFloat(e.target.value))}
          />
        </label>
      </div>
    </div>
  );
};

export default CustomComponent;

Components

TemperatureConverter: React component for temperature conversion UI. useTemperatureConverter: Custom hook for managing temperature state and conversion logic.

Features

Converts temperatures between Celsius and Fahrenheit. Adjustable size and optional temperature range display.

Props

initialCelsius: Initial temperature in Celsius (default: 0). size: Size multiplier for adjusting visual components (default: 1). showRange: Boolean to show/hide temperature range inputs (default: true).

Example Usage

<TemperatureConverter initialCelsius={0} size={1.5} showRange={false} />

Scripts

start: Starts the development server. build: Builds the production-ready bundle. test: Runs tests. lint: Lints the codebase.

Dependencies

React React DOM

DevDependencies

Babel ESLint Jest

Conclusion

This package provides an easy-to-use component for temperature conversion in React applications. It includes adjustable visual components and straightforward temperature input controls.

1.1.91

1 year ago

1.1.83

1 year ago

1.1.82

1 year ago

1.1.81

1 year ago

1.1.80

1 year ago

1.1.79

1 year ago

1.1.78

1 year ago

1.1.77

1 year ago

1.1.76

1 year ago

1.1.75

1 year ago

1.1.74

1 year ago

1.1.73

1 year ago

1.1.72

1 year ago

1.1.71

1 year ago

1.1.69

1 year ago

1.1.68

1 year ago

1.1.67

1 year ago

1.1.66

1 year ago

1.1.65

1 year ago

1.1.64

1 year ago

1.1.63

1 year ago

1.1.62

1 year ago

1.1.61

1 year ago

1.1.60

1 year ago

1.1.59

1 year ago

1.1.58

1 year ago

1.1.57

1 year ago

1.1.56

1 year ago

1.1.55

1 year ago

1.1.54

1 year ago

1.1.53

1 year ago

1.1.52

1 year ago

1.1.51

1 year ago

1.1.50

1 year ago

1.1.49

1 year ago

1.1.48

1 year ago

1.1.47

1 year ago

1.1.46

1 year ago

1.1.44

1 year ago

1.1.43

1 year ago

1.1.42

1 year ago

1.1.41

1 year ago

1.1.40

1 year ago

1.1.39

1 year ago

1.1.38

1 year ago

1.1.37

1 year ago

1.1.35

1 year ago

1.1.34

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.1.31

1 year ago

1.1.30

1 year ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.22

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago