2.0.2 • Published 9 months ago

react-thermostat v2.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

React Thermostat

version

A react thermostat which can be easily plugged into any smart home application, I've used this with Home Assistant connecting to websockets for a standalone smart home application and it's working great.

Online Demo

npm.io

Help me out?

I've spent a lot of time on this, you're free to use it but would appreciate a small donation if you're feeling generous! Buy me a beer!

Buy me a beer!

Install

  npm i react-thermostat

Example

The size of the thermostat is relative to it's parent and automatically will adjust on resize, you can also set the size of the thermostat by setting the width of the parent container.

import React, { useState } from 'react';
import styled from '@emotion/styled';
import { Thermostat } from 'react-thermostat';
const Container = styled.div`
  width: 100%;
  max-width: 300px;
`;
const App = () => {
    const [value, setValue] = useState(50);
    return (
      <Container>
        <Thermostat
          value={value}
          onChange={ newValue => setValue(Number(newValue.toFixed(0))) }
        />
      </Container>
    )
};
export default App;

Main Props

proptyperequireddefaultdescription
valuenumberyesThe value for the thermostat
onChange(value: number) => voidyesCalled when a user interacts with the handle, you should update your value with this callback, this value is NOT rounded intentionally.
valueSuffixstringno°The suffix for the value, use '' if you don't want a suffix
minnumberno0The minimum value for the thermostat
maxnumberno100The maximum value for the thermostat
handleHandlePropsnoHandlePropsThe props for the dragging handle
disabledbooleannofalseIf the thermostat should be disabled
trackTrackPropsnoTrackPropsThe props for the track

Handle Props

proptyperequireddefaultdescription
sizenumbernosize / 15The size of the handle
colorsHandleColorsnoHandleColorsThe colours for the handle

Handle Colors

proptyperequireddefaultdescription
handlestringno#fffThe background color of the handle
iconstringno#111The color of the icon in the handle
pulsestringnorgba(0,0,0,0.3)The color of the pulse effect behind the handle

Track Props

proptyperequireddefaultdescription
colorsstring[]no'#cfac48', '#cd5401'The colours of the track gradient, from left to right, this can be one or many colours and will apply in a conical gradient effect
thicknessnumbernosize / 10The thickness of the main arc track, the inner thermometer will divide it's track size by 1.4
markersMarkersnoMarkersThe options for the markers on the arc track, this is really only for advanced control

Markers Props

proptyperequireddefaultdescription
enabledbooleannotrueIf the markers on the arc track should be enabled
everynumberno5Every 5 ticks will be the "main" mark
countno60The number of marks to include on the arc
main.colorstringnoblackThe colour of the main mark
main.lengthnumbernotrack.thickness / 4The length of the mark
main.thicknessnumberno2The thickness of the mark
sub.colorstringnorgba(0,0,0,0.8)The colour of the sub mark
sub.lengthnumbernotrack.thickness / 8The length of the sub mark
sub.thicknessnumberno1The thickness of the sub mark

Developer

Once the repository has been checked out, simply run npm run dev which will spawn a local webserver.

Any changes made in the src direction will appear in the demo page created.

Publishing

This is a very simple package setup, no tagging in place for now, increment the package version, npm run build and push all your changes then run npm publish

2.0.2

9 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago