npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mahesh005/temp_conversion

v1.1.91

Published

A React component for converting temperatures between Celsius and Fahrenheit.

Downloads

19

Readme

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.