@johnpaul97/pocket-calculator

1.0.2 • Public • Published

@johnpaul97/pocket-calculator

Simple calculator react component. Supports expressions using basic operations and paranthesis on big numbers. It is suitable for financial or mathemathical apps.

NPM JavaScript Style Guide

Install

npm install --save @johnpaul97/pocket-calculator

Usage

import React, { Component } from 'react'

import Calculator from '@johnpaul97/pocket-calculator'
import '@johnpaul97/pocket-calculator/dist/index.css'

class Example extends Component {
   state = {
    backgroundColor: '#7e7e7e',
    buttonColor: '#46403D',
    resultLabel: 'result',
    expressionLabel: 'expression'
  };

  render() {
    const {backgroundColor, buttonColor, resultLabel, expressionLabel} = this.state;

    return <Calculator 
              backgroundColor={backgroundColor} 
              buttonColor={buttonColor} 
              resultLabel={resultLabel} 
              expressionLabel={expressionLabel} 
             />
  }
}

Props

  • backgroundColor - define calculator's color (hexadecimal value)
  • buttonColor - define button's color (hexadecimal value)
  • resultLabel - text for result input (string)
  • expressionLabel - text for expression input (string)

Uncontrolable Props

  • isPlayingAudio - binded to switch element on interface that allows background click sound to play when a button is clicked

Default props

  • backgroundColor: '#7e7e7e',
  • buttonColor: '#46403D',
  • resultLabel: 'result',
  • expressionLabel: 'expression'

License

MIT © JohnPaul97

Readme

Keywords

none

Package Sidebar

Install

npm i @johnpaul97/pocket-calculator

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

39.7 kB

Total Files

7

Last publish

Collaborators

  • johnpaul97